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)
}
verify(signature: Uint8Array, message: Uint8Array): boolean {
return sodium.crypto_sign_verify_detached(signature, message, this.pub_edward);
}
verify(signature: Uint8Array, message: Uint8Array | string): boolean {
return sodium.crypto_sign_verify_detached(signature, message, this.pub_edward);
}
cb = ispk;
ispk = false;
}
const done = ret(cb);
if (!pk) { return done(new Error('Cannot verify without a key')); }
let payload, received, ipk;
[ payload ] = iparse(message);
[ pk, received ] = cparse(pk, signature);
ipk = (ispk) ? pk : sodium.crypto_sign_seed_keypair(pk).publicKey;
let verified;
try {
verified = sodium.crypto_sign_verify_detached(received, payload, ipk);
} catch(ex) {
return done(new Error('Libsodium error: ' + ex));
}
if (!verified) { return done(new Error('Invalid signature')); }
return done();
}