How to use the eth-sig-util.recoverTypedSignatureLegacy function in eth-sig-util

To help you get started, we’ve selected a few eth-sig-util 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 MetaMask / eth-hd-keyring / test / index.js View on Github external
it('signs in a compliant and recoverable way', async () => {
      await keyring.addAccounts(1)
      const addresses = await keyring.getAccounts()
      const address = addresses[0]
      const sig = await keyring.signTypedData_v1(address, typedData)
      const signedParams = Object.create(msgParams)
      signedParams.sig = sig;
      const restored = sigUtil.recoverTypedSignatureLegacy(signedParams)
      assert.equal(restored, address, 'recovered address')
    })
  })
github MetaMask / eth-simple-keyring / test / index.js View on Github external
it('returns the expected value', async () => {
      await keyring.deserialize([privKeyHex])
      const sig = await keyring.signTypedData(address, typedData)
      const signedParams = Object.create(msgParams)
      signedParams.sig = sig;
      assert.equal(sig, expectedSig, 'produced correct signature.')
      const restored = sigUtil.recoverTypedSignatureLegacy(signedParams)
      assert.equal(restored, address, 'recovered address')
    })
  })
github danfinlay / js-eth-personal-sign-examples / index.js View on Github external
}, function (err, result) {
    if (err) return console.dir(err)
    if (result.error) {
      alert(result.error.message)
    }
    if (result.error) return console.error(result)
    console.log('PERSONAL SIGNED:' + JSON.stringify(result.result))

    const recovered = sigUtil.recoverTypedSignatureLegacy({ data: msgParams, sig: result.result })

    if (ethUtil.toChecksumAddress(recovered) === ethUtil.toChecksumAddress(from)) {
      alert('Successfully ecRecovered signer as ' + from)
    } else {
      alert('Failed to verify signer when comparing ' + result + ' to ' + from)
    }

  })