Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const signBytes = bytes => sign.detached(bytes, privateKey());
PrivateKey.addSigner(getOID('Ed25519'), function (this: PrivateKey, data: Buffer): Buffer {
const key = this.keyRaw
if (key.length !== 64) {
throw new Error('Invalid signing key.')
}
return Buffer.from(ed25519.detached(data, key))
})
const signBytes = bytes => sign.detached(bytes, key.secretKey);
sign(message, sk, encoding = 'hex') {
const skBytes = toUint8Array(sk);
const messageBytes = toUint8Array(message);
const signature = ed25519.detached(messageBytes, skBytes);
return encode(signature, encoding);
}