0.4.0 • Published 1 year ago

pedersen-fast v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Usage

npm i pedersen-fast

Package exposes two functions, one for calculations from HEX strings, the other from decimal strings:

import { pedersen_from_hex, pedersen_from_dec } from "pedersen-fast";

// returns a hex string starting with 0x
pedersen_from_hex(
  "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcde",
  "0x11223344556677889900aabbccddeeff11223344556677889900aabbccddeef",
);

Current state

According to our benchmarks, the fastest implementation would be the native module (via NEON). The problem with native modules is a need to compile them on the client or precompile them before. None of these solutions is trivial, that's why we use WASM for now.

napi-rs seems to be great at simplifying shipping native modules for nodejs. but its performance is much worse than neons. This needs further research.

Benchmarks

For 10 000 hash calculations from hex strings:

ImplementationTimeHash/s
Starknet JS23,493 ms425.659 hash/s
starknet_crypto (WASM)241 ms41,493.776 hash/s
starknet_crypto (native module)90 ms111,111.111 hash/s

Acknowledgments

Thanks goes to:

  • starknet-rs team for the fastest implementation our there :)

Development

To compile every package and run benchmarks do:

./scripts/benchmark.sh

License

MIT

0.4.0

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago