New host functions and Poseidon hash support #1780
Replies: 6 comments 20 replies
-
|
+1. Thanks for initiating the discussion @ymcrcat , we also have a tracking issue here: stellar/rs-soroban-env#1586 |
Beta Was this translation helpful? Give feedback.
-
|
I'm just sharing some thoughts: You are right that Poseidon is a family of hashes rather than a specific instantiation. Careful selection of the parameters must be studied to ensure security levels and comparable results with other systems. For Poseidon parameter selection, I recommend checking Table 2 (page 8) of the original paper and the referenced scripts for round and matrices configurations. For Poseidon2, there's the official repository with a Sage script to generate the parameters under different fields and configurations. Regarding the internal configuration, most implementations let you define the input size, then adaptively select the proper state size t, and correct parameters generated using previous scripts. (See, for example, https://github.com/iden3/circomlib/blob/master/circuits/poseidon.circom#L76-L79, https://github.com/ax0/noir/blob/master/noir_stdlib/src/hash/poseidon/bn254.nr#L107-L242). This provides a nice balance between flexibility of using different configurations, but prevents the user from instantiating an insecure hash function. However, I have seen other implementations that only present a more structured and optimized version for a specific configuration: https://github.com/risc0/risc0/blob/main/risc0/zkp/src/core/hash/poseidon2/consts.rs. Just to let you know, some details might still differ between different implementations (although they can produce the identical hashes), as is the case for the absorption in Noir and Circom (https://research.aragon.org/poseidon-noir.html). |
Beta Was this translation helpful? Give feedback.
-
|
Regarding Antonion's comment on Poseidon in Circom... |
Beta Was this translation helpful? Give feedback.
-
|
Based on inputs above and some of my initial research, here are a few approaches to supporting these as host functions (in decreasing preference) 1. As hash functions.This will introduce four new host functions As a starting point only support a few fixed arities (e.g. 1, 2, 4 which corresponds to a Merkle tree with arity=4). The main advantage of this is simplicity, based on a given curve and arity, the internal parameters can be fixed. We will pick the reference parameters but need to ensure its compatibility with major protocols (e.g. circom). The new metering cost types will likely be permutation of (version, curve, arity), each case being a new const costtype. The arity could be treated as a linear input, so it would just be (version, curve), each case being a linear costtype. We will decide based on calibration. 2. Expose the internal Poseidon building blocks (
|
Beta Was this translation helpful? Give feedback.
-
4. Provide host functions for
|
Beta Was this translation helpful? Give feedback.
-
|
CAP-75 has been created for this. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Starting a discussion here about new host functions.
Note that there are other threads that discuss support for specific curves or use-cases (BN254 host functions, cryptographic primitives for proof-verification).
Poseidon is a ZK-friendly hash that works directly on field elements and has some existing Rust implementations as well as implementations for the Circom compiler.
However, Poseidon is actually a hash-family that can result in different concrete instantiations based on parameters (round constants, MDS matrix). Hence it's important to pick the right parameters for host support of Poseidon bearing in mind what we expect it to be compatible with (perhaps the Circom library, poseidon-lite JS implementation, etc?)
Beta Was this translation helpful? Give feedback.
All reactions