Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
TransactionHelper.prototype.signShielded = function (signatureHashFn) {
// Empty output script
var scriptCode = Buffer.alloc(0)
var dataToBeSigned = signatureHashFn(NOT_AN_INPUT, scriptCode, SIGHASH_ALL)
// Add the signature
this.joinSplitSig = Buffer.from(sodium.crypto_sign_detached(dataToBeSigned, this._joinSplitPrivKey))
// Sanity check
sodium.crypto_sign_verify_detached(this.joinSplitSig, dataToBeSigned, this.joinSplitPubKey)
}
sign(message: Uint8Array | string): Uint8Array {
return sodium.crypto_sign_detached(message, this.sec_edward);
}
sign(message: Uint8Array): Uint8Array {
return sodium.crypto_sign_detached(message, this.sec_edward);
}
const sign = async (message, key) => {
await sodiumsumo.ready;
return sodiumsumo.crypto_sign_detached(message, key);
}
switch (sk && Buffer.byteLength(sk)) {
case sodium.crypto_sign_SECRETKEYBYTES:
isk = sk;
break;
case sodium.crypto_sign_SEEDBYTES:
isk = sodium.crypto_sign_seed_keypair(sk).privateKey;
break;
default:
isk = sodium.crypto_sign_keypair().privateKey;
sk = sodium.crypto_sign_ed25519_sk_to_seed(isk);
}
let signature;
try {
signature = sodium.crypto_sign_detached(payload, isk);
} catch(ex) {
return done(new Error('Libsodium error: ' + ex));
}
return done(null, convert({
alg: 'ed25519',
sk: sk,
payload: payload,
signature: signature
}));
}