Skip to content

Commit

Permalink
Update documentation Poseidon docs (#640)
Browse files Browse the repository at this point in the history
Co-authored-by: danny-shterman <[email protected]>
Co-authored-by: krakhit <[email protected]>
  • Loading branch information
3 people authored Nov 4, 2024
1 parent 6a879df commit a915a9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion docs/docs/icicle/primitives/hash.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ Keccak can take input messages of any length and produce a fixed-size hash. It u

Traditional hash functions, such as SHA-2, are difficult to represent within ZK circuits because they involve complex bitwise operations that don’t translate efficiently into arithmetic operations. Poseidon, however, is specifically designed to minimize the number of constraints required in these circuits, making it significantly more efficient for use in ZK-SNARKs and other cryptographic protocols that require hashing over field elements.

Currently the Poseidon implementation is the Optimized Poseidon (https://hackmd.io/@jake/poseidon-spec#Optimized-Poseidon). Optimized Poseidon significantly decreases the calculation time of the hash.

The optional `domain_tag` pointer parameter enables domain separation, allowing isolation of hash outputs across different contexts or applications.

## Using Hash API

Expand Down Expand Up @@ -94,7 +97,7 @@ eIcicleError hash(const std::byte* input, uint64_t size, const HashConfig& confi
* @tparam PREIMAGE The type of the input data.
* @tparam IMAGE The type of the output data.
* @param input Pointer to the input data.
* @param size The number of elements of type `PREIMAGE` to hash.
* @param size The number of elements of type `PREIMAGE` to a single hasher.
* @param config Configuration options for the hash operation.
* @param output Pointer to the output data.
* @return An error code of type eIcicleError indicating success or failure.
Expand Down Expand Up @@ -131,6 +134,10 @@ auto output = std::make_unique<std::byte[]>(32 * config.batch); // Allocate outp
eIcicleErr err = keccak256.hash(input.data(), input.size() / config.batch, config, output.get());
```

### 4. Posidon sponge function

Currently the poseidon sponge function (Sec 2.1 of https://eprint.iacr.org/2019/458.pdf ) isn't implemented.

### Supported Bindings

- [Rust](../rust-bindings/hash)
Expand Down
3 changes: 2 additions & 1 deletion icicle/include/icicle/hash/poseidon.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ namespace icicle {
*
* This function generates a Poseidon hash with customizable parameters to suit various cryptographic
* contexts and use cases. The width parameter (`t`) determines the number of elements in the state,
* influencing the security level and output structure of the hash. The optional `domain_tag` parameter
* influencing the security level and output structure of the hash. The optional `domain_tag` pointer parameter
* enables domain separation, allowing isolation of hash outputs across different contexts or applications.
* (See here for a detailed explanation: https://hackmd.io/@7dpNYqjKQGeYC7wMlPxHtQ/ByIbpfX9c#SAFE-Sponge-API-for-Field-Elements-–-A-Toolbox-for-ZK-Hash-Applications)
*
* @param S Represents the type of the field element used by the hash (e.g., a field element class).
*
Expand Down

0 comments on commit a915a9e

Please sign in to comment.