-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example and docs for hash API #624
Conversation
cf30d22
to
c0e57c2
Compare
c0e57c2
to
cfd44e7
Compare
88bafb4
to
4d2ae12
Compare
4d2ae12
to
8ffa24e
Compare
docs/docs/icicle/primitives/hash.md
Outdated
|
||
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. | ||
|
||
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, and Poseidon, which are optimized for processing both general data and cryptographic field elements or elliptic curve points. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add:
(additional hash function might be added in the future. Stay tuned)
docs/docs/icicle/primitives/hash.md
Outdated
|
||
### Blake2s | ||
|
||
Blake2s is an optimized cryptographic hash function that provides high performance while ensuring strong security. Blake2s is ideal for hashing small data (such as field elements), especially when speed is crucial. It produces a 256-bit (32-byte) output and is often used in cryptographic protocols. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reference from the litriture for what is blake - like you did in sha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added for blake2s and poseidon too
docs/docs/icicle/primitives/hash.md
Outdated
|
||
### Poseidon | ||
|
||
Poseidon is a hash function designed specifically for cryptographic field elements and elliptic curve points. It is optimized for zero-knowledge proofs (ZKPs) and is often used in ZK-SNARK systems. Poseidon’s strength lies in its efficiency when working with cryptographic data, making it ideal for scenarios like Merkle tree construction and proof generation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why it is ideal for merkle tree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't know. chatgpt wrote this part. I will refine it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
docs/docs/icicle/primitives/hash.md
Outdated
auto sha3_256 = Sha3_256::create(); | ||
auto sha3_512 = Sha3_512::create(); | ||
auto blake2s = Blake2s::create(); | ||
auto poseidon = Poseidon::create<scalar_t>(arity); // Poseidon requires specifying the field type and arity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supported arity are {3,5,9,12}
|
||
The ICICLE library provides Rust 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. | ||
|
||
This guide will show you how to use the ICICLE hashing API in Rust with examples for common hash algorithms, such as Keccak-256, Keccak-512, SHA3-256, SHA3-512, Blake2s, and Poseidon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a pointer to primitives::hash.md
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
// Execute the Keccak hashing example | ||
keccak_hash_example(); | ||
|
||
// TODO: Implement a Merkle tree example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do it in the next PR. I can write it but not sure if it would work until we merge the implementation
2. String Hashing: Demonstrates hashing of basic strings using Keccak-256. | ||
3. Field Element Hashing: Hash Babybear field elements. | ||
4. Batch Hashing: Hash a large batch of field elements and measure the performance. | ||
5. (TODO merkle tree) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we have the api for that, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes we do. I will update the example in another PR for merkle tree but for 3.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work
This PR adds:
(1) documentation for hash apis
(2) rust example for hash api