How to use the eth-crypto.recoverPublicKey function in eth-crypto

To help you get started, we’ve selected a few eth-crypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github enigmampc / secret-contracts / enigma-lib / test-utils.js View on Github external
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')
        });
    }
}
github ShipChain / engine / src / entity / Wallet.ts View on Github external
static recover_signer_public_key(signature, hash) {
        return EthCrypto.recoverPublicKey(signature, hash);
    }