Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ed.sign = function (hash, keyPair) {
const sig = Buffer.alloc(sodium.crypto_sign_BYTES);
sodium.crypto_sign_detached(sig, hash, keyPair.privateKey);
return sig;
};
Block.prototype.sign = function (block, keyPair) {
const blockHash = this.getHash(block);
const sig = Buffer.alloc(sodium.crypto_sign_BYTES);
sodium.crypto_sign_detached(sig, blockHash, keyPair.privateKey);
return sig.toString('hex');
};
Transaction.prototype.sign = (keyPair, trs) => {
const sig = Buffer.alloc(sodium.crypto_sign_BYTES);
sodium.crypto_sign_detached(sig, self.getHash(trs), keyPair.privateKey);
return sig.toString('hex');
};
private sign(block, keyPair): Response {
const blockHash = this.getHash(block);
if (!blockHash.success) {
return new Response({ errors: [...blockHash.errors, 'sign'] });
}
const sig = Buffer.alloc(sodium.crypto_sign_BYTES);
sodium.crypto_sign_detached(sig, blockHash.data, keyPair.privateKey);
return new Response({ data: sig.toString('hex') });
}
Transaction.prototype.sign = function (keyPair, trs) {
const sig = Buffer.alloc(sodium.crypto_sign_BYTES);
sodium.crypto_sign_detached(sig, this.getHash(trs), keyPair.privateKey);
return sig.toString('hex');
};