Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the rust portion more modular #66

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a7c6df4
Make the rust portion more modular
junderw Nov 28, 2021
d84876c
Add simple command to test for variance between ECMult for certain sc…
junderw Nov 28, 2021
dbc9556
Refactor, add validation in Rust
junderw Nov 28, 2021
97a358e
Add default rand feature to library to get random context
junderw Nov 28, 2021
37a29ad
Update interface, start adding docs
junderw Nov 30, 2021
aeb0d32
Refactor
junderw Nov 30, 2021
0934e0d
Use crates.io for secp256k1-sys
junderw Nov 30, 2021
7b676c2
Update github actions
junderw Nov 30, 2021
0256ac0
Fix glob
junderw Nov 30, 2021
dbd7ee7
Add prng for no-rand context
junderw Dec 2, 2021
29278cf
WIP: use higher level
junderw Dec 4, 2021
78a06da
WIP: better context
junderw Dec 4, 2021
55c5cfd
WIP: Fix context
junderw Dec 14, 2021
2425afb
WIP: moving away from _sys, less unsafe
junderw Dec 17, 2021
7fc6331
Merge branch 'master' into wip/modular
junderw Mar 19, 2022
722e9fc
Update tiny-secp256k1 to not use sys package
junderw Mar 19, 2022
dc23167
Fix clippy rules and add Errors docs
junderw Mar 19, 2022
a259358
Add WASM funcs for new API
junderw Mar 19, 2022
ddb8f95
Add extra_data (waiting on upstream)
junderw Mar 19, 2022
eefcfc9
Fix clippy
junderw Mar 19, 2022
25038ef
Fix clippy again
junderw Mar 19, 2022
a644218
Upgrade to 0.22.1 with WASM fix patch
junderw Apr 2, 2022
9a01a31
Merge branch 'master' into wip/modular
junderw Jun 2, 2023
d7c01cf
Merge branch 'master' into wip/modular
junderw Jun 2, 2023
dabd937
Merge remote-tracking branch 'master' into wip/modular
junderw Jul 12, 2023
cbe73e5
WIP: Fix merge errors
junderw Jul 12, 2023
9187bee
Fix clippy and fmt
junderw Jul 12, 2023
bc9eca0
Update lint commands
junderw Jul 12, 2023
c9cebdb
Refactor
junderw Nov 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target = "wasm32-unknown-unknown"
11 changes: 8 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ jobs:
tar zxvf binaryen-version_100-x86_64-linux.tar.gz binaryen-version_100/bin/wasm-opt

- name: Build wasm
run: export PATH=$PATH:./binaryen-version_100/bin/ && make build-wasm
run: |
export PATH=$PATH:./binaryen-version_100/bin/
make build-wasm
shasum -a 256 lib/secp256k1.wasm
rustc --version --verbose

- name: Build JS
run: make build-js
Expand Down Expand Up @@ -123,18 +127,19 @@ jobs:
path: lib

- name: Create package
run: npm pack
run: npm pack && shasum -a 256 tiny-secp256k1-*.tgz

- name: Upload package
uses: actions/upload-artifact@v2
with:
name: package
path: tiny-secp256k1-*
path: tiny-secp256k1-*.tgz

benchmark:
name: Benchmark
needs: [test]
continue-on-error: true
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Fetch code
Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rust-analyzer.check.targets": [
"wasm32-unknown-unknown",
],
"rust-analyzer.check.command": "clippy"
}
214 changes: 209 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 6 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
[package]
name = "secp256k1-wasm"
version = "0.0.0"
authors = ["Kirill Fomichev <[email protected]>"]
edition = "2021"
description = "A Rust library for building tiny-secp256k1 WASM."
license = "MIT"
publish = false

[lib]
crate-type = ["cdylib"]

[dependencies.secp256k1-sys]
version = "=0.8.1"
default-features = false
features=[
"recovery",
"lowmemory"
[workspace]
resolver = "2"
members = [
"tiny-secp256k1",
"tiny-secp256k1-wasm",
]

[profile.release]
opt-level = "z"
lto = true
panic = "abort"
codegen-units = 1
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ build-js:

.PHONY: build-wasm
build-wasm:
RUSTFLAGS="-C link-args=-zstack-size=655360" cargo build --target wasm32-unknown-unknown --release
mkdir -p lib && cp -f target/wasm32-unknown-unknown/release/secp256k1_wasm.wasm lib/secp256k1.wasm
RUSTFLAGS="-C link-args=-zstack-size=655360" cargo build --target wasm32-unknown-unknown -p tiny-secp256k1-wasm --release
mkdir -p lib && cp -f target/wasm32-unknown-unknown/release/tiny_secp256k1_wasm.wasm lib/secp256k1.wasm
wasm-opt -O4 --strip-debug --strip-producers --output lib/secp256k1.wasm lib/secp256k1.wasm

.PHONY: build-wasm-debug
build-wasm-debug:
RUSTFLAGS="-C link-args=-zstack-size=655360" cargo build --target wasm32-unknown-unknown
mkdir -p lib && cp -f target/wasm32-unknown-unknown/debug/secp256k1_wasm.wasm lib/secp256k1.wasm
RUSTFLAGS="-C link-args=-zstack-size=655360" cargo build --target wasm32-unknown-unknown -p tiny-secp256k1-wasm
mkdir -p lib && cp -f target/wasm32-unknown-unknown/debug/tiny_secp256k1_wasm.wasm lib/secp256k1.wasm

.PHONY: clean
clean: clean-deps clean-built
Expand Down Expand Up @@ -68,7 +68,8 @@ install-js-deps:
.PHONY: lint
lint:
cargo fmt -- --check
cargo clippy --target wasm32-unknown-unknown
cargo clippy -p tiny-secp256k1-wasm --target wasm32-unknown-unknown --no-default-features
cargo clippy -p tiny-secp256k1 --target x86_64-unknown-linux-gnu --no-default-features
npx eslint $(eslint_files)

.PHONY: test
Expand Down
46 changes: 26 additions & 20 deletions benches/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
fschnorrTweak,
} from "./fixtures.js";

const WASM_ONLY = !!process.env.WASM_ONLY;

// import { loadAddon as _loadAddon } from "../lib/addon.js";
// function loadAddon(location) {
// const path = new URL(location, import.meta.url).pathname;
Expand All @@ -27,26 +29,30 @@ const modules = [
name: "tiny-secp256k1 (WASM)",
secp256k1: tiny_secp256k1,
},
{
name: "[email protected] (C++ addon, NAN/V8)",
secp256k1: tiny_secp256k1_prev_native,
},
{
name: "[email protected] (elliptic)",
secp256k1: tiny_secp256k1_prev_js,
},
{
name: "[email protected] (C++ addon, N-API)",
secp256k1: cryptocoinjs_secp256k1.native,
},
{
name: "[email protected] (elliptic)",
secp256k1: cryptocoinjs_secp256k1.js,
},
{
name: "[email protected] (BigInt)",
secp256k1: noble_secp256k1,
},
...(WASM_ONLY
? []
: [
{
name: "[email protected] (C++ addon, NAN/V8)",
secp256k1: tiny_secp256k1_prev_native,
},
{
name: "[email protected] (elliptic)",
secp256k1: tiny_secp256k1_prev_js,
},
{
name: "[email protected] (C++ addon, N-API)",
secp256k1: cryptocoinjs_secp256k1.native,
},
{
name: "[email protected] (elliptic)",
secp256k1: cryptocoinjs_secp256k1.js,
},
{
name: "[email protected] (BigInt)",
secp256k1: noble_secp256k1,
},
]),
];

const benchmarks = [
Expand Down
Loading