Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/miguelmota/sol-ecverify
A solidity library for verifying elliptic curve signatures in Ethereum (ecrecover)
https://github.com/miguelmota/sol-ecverify
cryptography ecdsa ecrecover ecverify ethereum signature smart-contracts solidity truffle verification web3
Last synced: 16 days ago
JSON representation
A solidity library for verifying elliptic curve signatures in Ethereum (ecrecover)
- Host: GitHub
- URL: https://github.com/miguelmota/sol-ecverify
- Owner: miguelmota
- License: mit
- Archived: true
- Created: 2017-11-08T23:57:07.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-20T05:17:52.000Z (almost 6 years ago)
- Last Synced: 2024-08-01T20:37:27.510Z (4 months ago)
- Topics: cryptography, ecdsa, ecrecover, ecverify, ethereum, signature, smart-contracts, solidity, truffle, verification, web3
- Language: JavaScript
- Homepage: https://github.com/miguelmota/sol-ecverify
- Size: 8.79 KB
- Stars: 7
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sol-ecverify
> A [solidity](https://github.com/ethereum/solidity) library for verifying elliptic curve signatures in Ethereum (wrapper around `ecrecover`).
## API
- **ecrecovery**(hash, sig) -> `address`
- {bytes32} hash - 32 byte sha3 (keccak256) hash of original message data
- {bytes} sig - 65 byte signature string
- **ecverify**(hash, sig, account) -> `bool`
- {bytes32} hash - 32 byte sha3 (keccak256) hash of original message data
- {bytes} sig - 65 byte signature string
- {address} signer - 20 byte address of proposed signer
## Getting started
```javascript
const {sha3} = require('ethereumjs-util')
const account = '0xa462d983B4b8C855e1876e8c24889CBa466A67EB'const msg = Buffer.from('some data')
const sig = web3.eth.sign(account, `0x${msg.toString('hex')}`)// https://github.com/ethereum/go-ethereum/issues/3731
const prefix = Buffer.from('\x19Ethereum Signed Message:\n');
const pmsg = `0x${sha3(Buffer.concat([prefix, Buffer.from(String(msg.length)), msg])).toString('hex')}`var signer = await ECVerify.ecrecovery(pmsg, sig)
console.log(signer) // "0xa462d983B4b8C855e1876e8c24889CBa466A67EB"var verified = await ECVerify.ecverify(pmsg, sig, account)
console.log(verified) // true
```## Test
```bash
truffle test
```## Credit
Thanks to [@axic](https://github.com/axic) for providing this [gist](https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d) ([#79](https://github.com/ethereum/EIPs/issues/79#issuecomment-205051630))
## License
[MIT](LICENSE)