Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/herumi/ecdsa-wasm
ECDSA/secp256k1 + SHA-256
https://github.com/herumi/ecdsa-wasm
Last synced: about 1 month ago
JSON representation
ECDSA/secp256k1 + SHA-256
- Host: GitHub
- URL: https://github.com/herumi/ecdsa-wasm
- Owner: herumi
- Created: 2018-05-06T06:16:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-08-17T05:09:46.000Z (about 1 year ago)
- Last Synced: 2024-09-21T06:24:16.231Z (about 2 months ago)
- Language: JavaScript
- Size: 908 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
[![Build Status](https://github.com/herumi/ecdsa-wasm/actions/workflows/main.yml/badge.svg)](https://github.com/herumi/ecdsa-wasm/actions/workflows/main.yml)
# ECSSA/secp256k1 + SHA-256
# Abstract
This is a wasm version of [mcl/ecdsa.h](https://github.com/herumi/mcl/blob/master/include/mcl/ecdsa.h)
## News
- The performance is improved.
- `serialize()` supports the format defined at [BitCoin](https://www.oreilly.com/library/view/programming-bitcoin/9781492031482/ch04.html)## for Node.js
```
npm test
```## how to use
```
const ecdsa = require('ecdsa-wasm')// create secret key
const sec = new ecdsa.SecretKey()// initialize sec
sec.setByCSPRNG()// get public key
const pub = sec.getPublicKey()// make signature
const sig = sec.sign("abc")// verify signatpure by pub
> pub.verify(sig, "abc")
true
> pub.verify(sig, "abcd")
false// create precomputed public key(faster than pub)
const ppub = new ecdsa.PrecomputedPublicKey()
// initialize ppub
ppub.init(pub)// verify signature by ppub
> ppub.verify(sig, "abc")
true
> ppub.verify(sig, "abcd")
false// destroy ppub if unnecessary
ppub.destroy()
```### serialization
- `SecretKey.serialize()` return 32-bytes Uint8Array as big-endian
- `PublicKey.serialize()` return 65-bytes Uint8Array as 0x04 + `x` + `y`
- `PublicKey.serializeCompressed()` return 33-bytes Uint8Array as 0x02 (y is even) or 0x03 (y is odd) + `x`
- `Signature.serialize()` return DER-format
- `SecretKey.deserialize(a)`
- `PublicKey.deserialize(a)`
- `Signature.deserialize(a)`
- take `Uint8Array` of `a` and constract the object## how to build ecdsa_c.js
Install emscripten.
```
git clone --recurse-submodules [email protected]:herumi/ecdsa-wasm
cd ecdsa-wasm
make -C src wasm
```# License
modified new BSD License
http://opensource.org/licenses/BSD-3-Clause# Author
光成滋生 MITSUNARI Shigeo([email protected])