Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryardley/ecdsa-ethereum-example
An example of how ECDSA works in Ethereum
https://github.com/ryardley/ecdsa-ethereum-example
Last synced: 21 days ago
JSON representation
An example of how ECDSA works in Ethereum
- Host: GitHub
- URL: https://github.com/ryardley/ecdsa-ethereum-example
- Owner: ryardley
- Created: 2023-08-03T06:56:18.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-08-04T01:36:43.000Z (over 1 year ago)
- Last Synced: 2024-10-11T04:03:29.499Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ECDSA in Ethereum
An example of how ECDSA works in Ethereum in TypeScript
```ts
const sk = toHexString(crypto.randomBytes(32));
const kp = await keypair(sk);const msg = "Hello World!";
const msgh = hash(msg);const { r, s, v } = ecsign(msgh, kp.privateKey);
const pk = ecrecover(msgh, v, r, s);assert(toHexString(kp.publicKey) == toHexString(pk)); // true
```## References
- https://github.com/MetaMask/eth-simple-keyring/blob/main/src/simple-keyring.ts
- https://github.com/ethereum/js-ethereum-cryptography#readme
- https://github.com/paulmillr/noble-curves