The function is exported by the library but it is not implemented. This is very confusing since the error is thrown when calling that function (even though it's exported)....
Might be a good idea to either not export it, or actually implement it.
I found a workaround, that can be used in the meantime:
function privateKeyToCurve25519Fallback(
ed25519PrivateKey: Uint8Array
): Uint8Array {
if (ed25519PrivateKey.length < 32) {
throw new Error('Invalid Ed25519 private key length')
}
const hash = sha512(ed25519PrivateKey.subarray(0, 32))
const curve25519PrivateKey = new Uint8Array(hash.subarray(0, 32))
curve25519PrivateKey[0] &= 248
curve25519PrivateKey[31] &= 127
curve25519PrivateKey[31] |= 64
return curve25519PrivateKey
}
The same is true for from_string functions.
again the workaround might simply be:
sodium.from_string(message) // THIS DOES NOT WORK
Buffer.from(message, 'utf-8') // THIS WORKS