You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Lacks support for sponge hash
- Lacks support for t>4 cases for large fields (>4B)
Co-authored-by: danny-shterman <[email protected]>
Co-authored-by: Leon Hibnik <[email protected]>
Co-authored-by: LeonHibnik <[email protected]>
Co-authored-by: Yuval Shekel <[email protected]>
Copy file name to clipboardexpand all lines: docs/docs/icicle/golang-bindings/hash.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Using the Hash package requires `go` version 1.22
16
16
17
17
The ICICLE library provides Golang bindings for hashing using a variety of cryptographic hash functions. These hash functions are optimized for both general-purpose data and cryptographic operations such as multi-scalar multiplication, commitment generation, and Merkle tree construction.
18
18
19
-
This guide will show you how to use the ICICLE hashing API in Golang with examples for common hash algorithms, such as Keccak-256, Keccak-512, SHA3-256, SHA3-512, Blake2s, and Poseidon.
19
+
This guide will show you how to use the ICICLE hashing API in Golang with examples for common hash algorithms, such as Keccak-256, Keccak-512, SHA3-256, SHA3-512, Blake2s, Poseidon.
Copy file name to clipboardexpand all lines: docs/docs/icicle/primitives/hash.md
+26-3
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
ICICLE’s hashing system is designed to be flexible, efficient, and optimized for both general-purpose and cryptographic operations. Hash functions are essential in operations such as generating commitments, constructing Merkle trees, executing the Sumcheck protocol, and more.
6
6
7
-
ICICLE provides an easy-to-use interface for hashing on both CPU and GPU, with transparent backend selection. You can choose between several hash algorithms such as Keccak-256, Keccak-512, SHA3-256, SHA3-512, Blake2s, Poseidon and more, which are optimized for processing both general data and cryptographic field elements or elliptic curve points.
7
+
ICICLE provides an easy-to-use interface for hashing on both CPU and GPU, with transparent backend selection. You can choose between several hash algorithms such as Keccak-256, Keccak-512, SHA3-256, SHA3-512, Blake2s, Poseidon, Poseidon2 and more, which are optimized for processing both general data and cryptographic field elements or elliptic curve points.
8
8
9
9
## Hashing Logic
10
10
@@ -24,6 +24,7 @@ ICICLE supports the following hash functions:
24
24
4. **SHA3-512**
25
25
5. **Blake2s**
26
26
6. **Poseidon**
27
+
7. **Poseidon2**
27
28
28
29
:::info
29
30
Additional hash functions might be added in the future. Stay tuned!
@@ -50,6 +51,15 @@ Currently the Poseidon implementation is the Optimized Poseidon (https://hackmd.
50
51
51
52
The optional `domain_tag` pointer parameter enables domain separation, allowing isolation of hash outputs across different contexts or applications.
52
53
54
+
55
+
### Poseidon2
56
+
57
+
[Poseidon2](https://eprint.iacr.org/2023/323.pdf) is a cryptographic hash function designed specifically for field elements.
58
+
It is an improved version of the original [Poseidon](https://eprint.iacr.org/2019/458) hash, offering better performance on modern hardware. Poseidon2 is optimized for use with elliptic curve cryptography and finite fields, making it ideal for decentralized systems like blockchain. Its main advantage is balancing strong security with efficient computation, which is crucial for applications that require fast, reliable hashing.
59
+
60
+
The optional `domain_tag` pointer parameter enables domain separation, allowing isolation of hash outputs across different contexts or applications.
61
+
62
+
53
63
## Using Hash API
54
64
55
65
### 1. Creating a Hasher Object
@@ -60,6 +70,7 @@ First, you need to create a hasher object for the specific hash function you wan
60
70
#include"icicle/hash/keccak.h"
61
71
#include"icicle/hash/blake2s.h"
62
72
#include"icicle/hash/poseidon.h"
73
+
#include"icicle/hash/poseidon2.h"
63
74
64
75
// Create hasher instances for different algorithms
65
76
auto keccak256 = Keccak256::create();
@@ -74,6 +85,14 @@ auto poseidon = Poseidon::create<scalar_t>(t);
74
85
scalar_t domain_tag = scalar_t::zero(); // Example using zero; this can be set to any valid field element.
75
86
auto poseidon_with_domain_tag = Poseidon::create<scalar_t>(t, &domain_tag);
76
87
// This version of the hasher with a domain tag expects t-1 additional inputs for hashing.
88
+
// Poseidon2 requires specifying the field-type and t parameter (supported 2, 3, 4, 8, 12, 16, 20, 24) as defined by
89
+
// the Poseidon2 paper. For large fields (field width >= 254) the supported values of t are 2, 3, 4.
90
+
auto poseidon2 = Poseidon2::create<scalar_t>(t);
91
+
// Optionally, Poseidon2 can accept a domain-tag, which is a field element used to separate applications or contexts.
92
+
// The domain tag acts as the first input to the hash function, with the remaining t-1 inputs following it.
93
+
scalar_t domain_tag = scalar_t::zero(); // Example using zero; this can be set to any valid field element.
94
+
auto poseidon2_with_domain_tag = Poseidon2::create<scalar_t>(t, &domain_tag);
95
+
// This version of the hasher with a domain tag expects t-1 additional inputs for hashing.
Currently the poseidon sponge function (sponge function description could be found in Sec 2.1 of https://eprint.iacr.org/2019/458.pdf ) isn't implemented.
164
+
165
+
### 5. Poseidon2 sponge function
143
166
144
-
Currently the poseidon sponge function (Sec 2.1 of https://eprint.iacr.org/2019/458.pdf ) isn't implemented.
167
+
Currently the poseidon2 sponge function (sponge function description could be found in Sec 2.1 of https://eprint.iacr.org/2019/458.pdf ) isn't implemented.
Copy file name to clipboardexpand all lines: docs/docs/icicle/primitives/poseidon.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -62,9 +62,9 @@ So for Poseidon of arity 2 and input of size 1024 * 2, we would expect 1024 elem
62
62
63
63
Poseidon is extremely customizable and using different constants will produce different hashes, security levels and performance results.
64
64
65
-
We support pre-calculated and optimized constants for each of the [supported curves](../libraries#supported-curves-and-operations).The constants can be found [here](https://github.com/ingonyama-zk/icicle/tree/main/icicle/include/icicle/hash/poseidon_constants) and are labeled clearly per curve `<curve_name>_poseidon.h`.
65
+
We support pre-calculated and optimized constants for each of the [supported curves](../libraries#supported-curves-and-operations).The constants can be found [here](https://github.com/ingonyama-zk/icicle/tree/main/icicle/include/poseidon/constants) and are labeled clearly per curve `<curve_name>_poseidon.h`.
66
66
67
-
If you wish to generate your own constants you can use our python script which can be found [here](https://github.com/ingonyama-zk/icicle/tree/main/icicle/include/icicle/hash/poseidon_constants/generate_parameters.py).
67
+
If you wish to generate your own constants you can use our python script which can be found [here](https://github.com/ingonyama-zk/icicle/tree/main/icicle/include/poseidon/constants/generate_parameters.py).
0 commit comments