diff --git a/README.md b/README.md index 68e1c36..65dbcf1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,9 @@ Minimal, auditable JS implementation of elliptic curve cryptography. - ECDSA, EdDSA, Schnorr, BLS signature schemes, ECDH key agreement - [hash to curve](https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve/) for encoding or hashing an arbitrary string to a point on an elliptic curve -- Auditable, [fast](#speed) +- [Poseidon](https://www.poseidon-hash.info) ZK-friendly hash +- Auditable +- 🏎 [Ultra-fast](#speed), hand-optimized for caveats of JS engines - 🔍 Unique tests ensure correctness. Wycheproof vectors included - 🔻 Tree-shaking-friendly: there is no entry point, which ensures small size of your app @@ -24,7 +26,6 @@ Curves incorporate work from previous noble packages [ed25519](https://github.com/paulmillr/noble-ed25519), [bls12-381](https://github.com/paulmillr/noble-bls12-381)), which had security audits and were developed from 2019 to 2022. -The goal is to replace them with lean UMD builds based on single-codebase noble-curves. ### This library belongs to _noble_ crypto @@ -88,6 +89,7 @@ To define a custom curve, check out API below. - [abstract/montgomery: Montgomery curve](#abstractmontgomery-montgomery-curve) - [abstract/weierstrass: Short Weierstrass curve](#abstractweierstrass-short-weierstrass-curve) - [abstract/hash-to-curve: Hashing strings to curve points](#abstracthash-to-curve-hashing-strings-to-curve-points) +- [abstract/poseidon: Poseidon hash](#abstractposeidon-poseidon-hash) - [abstract/modular](#abstractmodular) - [abstract/utils](#abstractutils) @@ -369,6 +371,30 @@ hashes arbitrary-length byte strings to a list of one or more elements of a fini }; ``` +### abstract/poseidon: Poseidon hash + +Implements [Poseidon](https://www.poseidon-hash.info) ZK-friendly hash. + +There are many poseidon instances with different constants. We don't provide them, +but we provide ability to specify them manually. For actual usage, check out +stark curve source code. + +```ts +import { poseidon } from '@noble/curves/abstract/poseidon'; + +type PoseidonOpts = { + Fp: Field; + t: number; + roundsFull: number; + roundsPartial: number; + sboxPower?: number; + reversePartialPowIdx?: boolean; // Hack for stark + mds: bigint[][]; + roundConstants: bigint[][]; +}; +const instance = poseidon(opts: PoseidonOpts); +``` + ### abstract/modular Modular arithmetics utilities. diff --git a/package.json b/package.json index 0a914a6..f34c08f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@noble/curves", - "version": "0.5.2", + "version": "0.6.0", "description": "Minimal, auditable JS implementation of elliptic curve cryptography", "files": [ "lib"