Blazing fast Pedersen hash implementation for Node.JS

Overview

ts-essentials

pedersen-fast

Blazing fast Pedersen hash implementation for Node.JS

Exposes starknet-crypto's implementation written in Rust as WASM package.

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:

Implementation Time Hash/s
Starknet JS 23,493 ms 425.659 hash/s
starknet_crypto (WASM) 241 ms 41,493.776 hash/s
starknet_crypto (native module) 90 ms 111,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

You might also like...
🥷🩸 Madara is a ⚡ blazing fast ⚡ Starknet sequencer, based on substrate, powered by Rust 🦀
🥷🩸 Madara is a ⚡ blazing fast ⚡ Starknet sequencer, based on substrate, powered by Rust 🦀

Report a Bug - Request a Feature - Ask a Question ⚡ Madara: Starknet Sequencer on Substrate 🦀 Welcome to Madara, a blazing fast ⚡ Starknet sequencer

Blazing fast toolkit for developing Starknet contracts.
Blazing fast toolkit for developing Starknet contracts.

Starknet Foundry Blazingly fast toolkit for developing Starknet contracts designed & developed by ex Protostar team from Software Mansion based on nat

Open sourcing a profitable MEV Arbitrage Bot written in blazing fast Rust.

Dex Arbitrage - MEV Bot Open sourcing a profitable MEV Arbitrage Bot written in blazing fast Rust. Before Starting I am a self-taught programmer, a co

Highly modular & configurable hash & crypto library
Highly modular & configurable hash & crypto library

Octavo Highly modular & configurable hash & crypto library written in pure Rust. Installation [dependencies] octavo = { git = "https://github.com/libO

Collection of cryptographic hash functions written in pure Rust

RustCrypto: hashes Collection of cryptographic hash functions written in pure Rust. All algorithms reside in the separate crates and implemented using

A rust binding for nodejs to generate md5 hash value

Hasher A rust binding for creating node module to generate md5 hash value This project was bootstrapped by create-neon. Installing hasher Installing h

the official Rust and C implementations of the BLAKE3 cryptographic hash function

BLAKE3 is a cryptographic hash function that is: Much faster than MD5, SHA-1, SHA-2, SHA-3, and BLAKE2. Secure, unlike MD5 and SHA-1. And secure again

paq files to hash.

paq paq files to hash. Hash a single file or all files in directory recursively. Installation Requires cargo. Run cargo install paq. Usage Run paq [sr

computed data's hash by webAssembly

wasm-hasher computed data's hash by webAssembly support md5,sha1,sha2-224,sha2-356,sha2-384,sha2-512,sha3-224,sha3-256,sha3-384,sha3-512,china-sm3 typ

Owner
L2BEAT
L2BEAT
ZKP fork for rust-secp256k1, adds wrappers for range proofs, pedersen commitments, etc

rust-secp256k1 rust-secp256k1 is a wrapper around libsecp256k1, a C library by Peter Wuille for producing ECDSA signatures using the SECG curve secp25

null 53 Dec 19, 2022
Fastmurmur3 - Fast non-cryptographic hash, with the benchmarks to prove it.

Fastmurmur3 Murmur3 is a fast, non-cryptographic hash function. fastmurmur3 is, in my testing, the fastest implementation of Murmur3. Usage let bytes:

Kurt Wolf 13 Dec 2, 2022
Reference implementation for the Poseidon Snark-friendly Hash algorithm.

Dusk-Poseidon Reference implementation for the Poseidon Hashing algorithm. Reference Starkad and Poseidon: New Hash Functions for Zero Knowledge Proof

Dusk Network 96 Jan 2, 2023
An implementation of Jakobsson's Fractal Hash Sequence Traversal algorithm

fractal-hash-traversal An implementation of Jakobsson's Fractal Hash Sequence Traversal algorithm. There is at least one hash traversal algorithm that

Dan Cline 1 Jan 12, 2022
A node and runtime configuration for polkadot node.

MANTA NODE This repo is a fresh FRAME-based Substrate node, forked from substrate-developer-hub/substrate-node-templte ?? It links to pallet-manta-dap

Manta Network 14 Apr 25, 2021
Simple node and rust script to achieve an easy to use bridge between rust and node.js

Node-Rust Bridge Simple rust and node.js script to achieve a bridge between them. Only 1 bridge can be initialized per rust program. But node.js can h

Pure 5 Apr 30, 2023
Sample lightning node command-line app built on top of Ldk Node (similar to ldk-sample).

ldk-node-sample Sample lightning node command-line app built on top of Ldk Node (similar to ldk-sample ). Installation git clone https://github.com/op

optout 3 Nov 21, 2023
A blazing fast, type-safe template engine for Rust.

markup.rs A blazing fast, type-safe template engine for Rust. markup.rs is a template engine for Rust powered by procedural macros which parses the te

Utkarsh Kukreti 209 Dec 24, 2022
Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.

foundry Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust. Foundry consists of: Forge: Ethe

Georgios Konstantopoulos 5.1k Jan 9, 2023
A low-level assembly language for the Ethereum Virtual Machine built in blazing-fast pure rust.

huff-rs • huff-rs is a Huff compiler built in rust. What is a Huff? Huff is a low-level programming language designed for developing highly optimized

Huff 276 Dec 31, 2022