diff --git a/CUSTOM_FIELD_T.md b/CUSTOM_FIELD_T.md index e148df8..8e43b86 100644 --- a/CUSTOM_FIELD_T.md +++ b/CUSTOM_FIELD_T.md @@ -1,9 +1,11 @@ # How to use with other prime fields/t values + 1. First lookup the constants for your desired prime field and t value (state size) here https://github.com/HorizenLabs/poseidon2/tree/main/plain_implementations/src/poseidon2. -2. If the constants for your prime field/t have not already been precomputed, compute them using (this sage script)[https://github.com/HorizenLabs/poseidon2/blob/main/poseidon2_rust_params.sage] +2. If the constants for your prime field/t have not already been precomputed, compute them using (this sage script)[https://github.com/HorizenLabs/poseidon2/blob/main/poseidon2_rust_params.sage] 3. Use the proper constants to generate `Poseidon2Params` and create a new `Poseidon2` class instance using your desired prime + ```typescript -import {Poseidon2, F1Field, Poseidon2Params} from 'poseidon2'; +import { Poseidon2, F1Field, Poseidon2Params } from "poseidon2"; // call this function with your parameters from sage/horizen labs' precomputed constants function getPoseidon2Params( diff --git a/LICENSE.md b/LICENSE.md index 7224c17..b01bdd8 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/README.md b/README.md index 9981063..40d565f 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,6 @@ [![Stargazers][stars-shield]][stars-url] [![Issues][issues-shield]][issues-url] - - -
@@ -17,38 +14,58 @@ The permutation function exposed by the Poseidon2 class is one-to-one compatible

- # Install + ```bash npm install poseidon2 ``` ## Usage For Goldilocks Field, T = 12 + ### Permute + ```javascript -import {permute} from 'poseidon2/goldilocks-12'; -const result = permute([1337n, 123456n, 100n, 15n, 1n, 2n, 3n, 4n, 22n, 23n, 24n, 25n]); +import { permute } from "poseidon2/goldilocks-12"; +const result = permute([ + 1337n, + 123456n, + 100n, + 15n, + 1n, + 2n, + 3n, + 4n, + 22n, + 23n, + 24n, + 25n, +]); ``` ### Two to One (Hash two 4-element-wide values) + ```javascript -import {twoToOne} from 'poseidon2/goldilocks-12'; +import { twoToOne } from "poseidon2/goldilocks-12"; const result = twoToOne([1337n, 123456n, 100n, 15n], [1n, 2n, 3n, 4n]); ``` ### Sponge Hash with Pad (Hash n elements with padding) + ```javascript -import {hashPad} from 'poseidon2/goldilocks-12'; +import { hashPad } from "poseidon2/goldilocks-12"; const result = hashPad([1n, 2n, 3n, 1337n, 9999n, 123n]); ``` ## How to use with other prime fields/t values + See [Working with other prime fields and t values](./CUSTOM_FIELD_T.md). ## Credits + Original implementation of poseidon2 by https://github.com/HorizenLabs # License + MIT License Copyright (c) 2023 Zero Knowledge Labs Limited @@ -71,10 +88,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - + [contributors-shield]: https://img.shields.io/github/contributors/OpenAssetStandards/poseidon2.svg?style=for-the-badge [contributors-url]: https://github.com/OpenAssetStandards/poseidon2/graphs/contributors [forks-shield]: https://img.shields.io/github/forks/OpenAssetStandards/poseidon2.svg?style=for-the-badge @@ -82,4 +98,4 @@ SOFTWARE. [stars-shield]: https://img.shields.io/github/stars/OpenAssetStandards/poseidon2.svg?style=for-the-badge [stars-url]: https://github.com/OpenAssetStandards/poseidon2/stargazers [issues-shield]: https://img.shields.io/github/issues/OpenAssetStandards/poseidon2.svg?style=for-the-badge -[issues-url]: https://github.com/OpenAssetStandards/poseidon2/issues \ No newline at end of file +[issues-url]: https://github.com/OpenAssetStandards/poseidon2/issues diff --git a/package.json b/package.json index 62786ec..770dd15 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "poseidon2", "license": "MIT", "author": "Open Asset Standards", - "version": "0.1.0", + "version": "0.1.1", "description": "A zero dependency TypeScript implementation of the Poseidon2 Hash Function", "main": "./dist/poseidon2.cjs", "module": "./dist/poseidon2.mjs",