Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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')
})
})
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')
})
})
}, 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)
}
})