Skip to content

Commit 1f94fc3

Browse files
committed
Update README.md
1 parent b27fe9f commit 1f94fc3

File tree

1 file changed

+45
-20
lines changed

1 file changed

+45
-20
lines changed

README.md

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![NPM](https://img.shields.io/npm/v/tiny-secp256k1.svg)](https://www.npmjs.org/package/tiny-secp256k1)
44

5-
This library is under development, and, like the [secp256k1](https://github.com/bitcoin-core/secp256k1) C library it depends on, this is a research effort to determine an optimal API for end-users of the bitcoinjs ecosystem.
5+
This library is under development, and, like the [secp256k1](https://github.com/bitcoin-core/secp256k1) C library (through [secp256k1-sys](https://github.com/rust-bitcoin/rust-secp256k1/) Rust crate) it depends on, this is a research effort to determine an optimal API for end-users of the bitcoinjs ecosystem.
66

77
## Installation
88

@@ -18,6 +18,50 @@ npm install tiny-secp256k1
1818
yarn add tiny-secp256k1
1919
```
2020

21+
## WebAssembly and Node.js version
22+
23+
Previous version of `tiny-secp256k1` implement [C++ addon](https://nodejs.org/api/addons.html) through [NAN (Native Abstractions for Node.js)](https://github.com/nodejs/nan) and [elliptic](https://github.com/indutny/elliptic) as fallback when addon can not be built or in browser-like environement.
24+
25+
Current version use Rust crate (which use C library) compiled to [WebAssembly](https://developer.mozilla.org/en-US/docs/WebAssembly). With Wasm same code executed in any environment. Wasm is faster than `elliptic` but slower than node bindings ([results in PR](https://github.com/bitcoinjs/tiny-secp256k1/pull/53#issuecomment-801844450) or you can run own benchmark in `benches` directory).
26+
27+
## Building
28+
29+
For building locally you need Rust nightly version and C/C++ toolchain.
30+
31+
[rustup](https://rustup.rs/) is a recommended way to install `Rust`. You also will need `wasm32-unknown-unknown` target.
32+
33+
```
34+
rustup toolchain install nightly --target wasm32-unknown-unknown --component clippy --component rustfmt
35+
```
36+
37+
After installing development dependencies with `npm` you can build Wasm:
38+
39+
```
40+
make build-wasm
41+
```
42+
43+
or run tests:
44+
45+
```
46+
make test
47+
```
48+
49+
Alternative way is to use [Docker](https://www.docker.com/):
50+
51+
```
52+
% docker build -t tiny-secp256k1 .
53+
% docker run -it --rm -v `pwd`:/tiny-secp256k1 -w /tiny-secp256k1 tiny-secp256k1
54+
# npm install --unsafe-perm
55+
# make test
56+
# make clean
57+
```
58+
59+
## Examples
60+
61+
`tiny-secp256k1` includes two examples. First is [simple script for Node.js](examples/random-in-node) which generate random data and print arguments and methods results. Second is [React app](examples/react-app).
62+
63+
React app is builded in GitHub Actions on each commit to master branch and uploaded to [gh-pages](https://github.com/bitcoinjs/tiny-secp256k1/tree/gh-pages) branch, which is always available online: https://bitcoinjs.github.io/tiny-secp256k1/
64+
2165
## Documentation
2266

2367
### isPoint (A)
@@ -170,25 +214,6 @@ If `strict` is `true`, valid signatures with any of (r, s) values greater than `
170214
- `Expected Signature` if `signature` has any (r, s) values not in range `[0...order - 1]`
171215
- `Expected Scalar` if `h` is not 256-bit
172216

173-
---
174-
175-
## Docker Build / Development Environment
176-
177-
#### Build Docker image
178-
179-
```
180-
docker build -t tiny-secp256k1 .
181-
```
182-
183-
#### Run Docker container
184-
185-
```
186-
docker run -it --rm -v `pwd`:/tiny-secp256k1 -w /tiny-secp256k1 tiny-secp256k1
187-
# npm install --unsafe-perm
188-
# make test
189-
# make clean
190-
```
191-
192217
## Credit
193218

194219
This library uses the native library [secp256k1](https://github.com/bitcoin-core/secp256k1) by the bitcoin-core developers through Rust crate [secp256k1-sys](https://crates.io/crates/secp256k1-sys), including derivatives of its tests and test vectors.

0 commit comments

Comments
 (0)