Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setWorkersParams () {
// Generate a random seed for convenience
// In a prod network, this code will be in the principal node, not in a script like this
const seed = Math.floor (Math.random () * 100000);
const hash = web3Utils.soliditySha3 ({ t: 'uint256', v: seed });
const sig = engUtils.sign (this.params[4], hash);
const signer = EthCrypto.recoverPublicKey (sig, hash);
if (engUtils.toAddress (signer) !== this.params[0]) throw 'invalid principal signature';
console.log ('updating workers parameters with seed', seed);
return this.contract.setWorkersParams (seed, sig, {
from: this.custodian,
gas: 4712388,
gasPrice: web3Utils.toWei (GAS_PRICE_GWEI, 'gwei')
});
}
}
static recover_signer_public_key(signature, hash) {
return EthCrypto.recoverPublicKey(signature, hash);
}