-
Notifications
You must be signed in to change notification settings - Fork 10
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
R1CS poseidon impl #49
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
redshiftzero
force-pushed
the
opt-poseidon-impl
branch
from
June 8, 2023 17:17
2c3ee96
to
524faf7
Compare
From Section 6.2.1 of the Poseidon paper: "we do not need more constraints [than that from the SBoxes] as the linear layers and round constants can be incorporated into these ones" This means that the optimized matmul is only useful out of circuit, where we currently use it.
redshiftzero
force-pushed
the
opt-poseidon-impl
branch
from
June 8, 2023 19:14
524faf7
to
dd6d38b
Compare
redshiftzero
added a commit
that referenced
this pull request
Jul 5, 2023
redshiftzero
added a commit
that referenced
this pull request
Jul 5, 2023
redshiftzero
added a commit
that referenced
this pull request
Jul 6, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #30
This PR:
poseidon-permutation
crate whichposeidon377
now usesExpected number of constraints
Looking at the paper, Table 1, we see various instantiations of Poseidon and the number of R1CS constraints per permutation:
For example in the first row we see that POSEIDON-80 has the following:
2:1
The arity means that the length of the state word row vector$\vec{w}$ is 3 (arity is rate:capacity, so 2 (rate) + 1 (capacity) = 3). The number of constraints added in the full rounds is:
Partial rounds:
This gets us to the reported 171 from Table 1.
Poseidon377
For Poseidon377 using the same arity as the above case, but with our numbers of$\alpha=17, R_F = 8, R_P = 31$ for a test circuit doing a 2:1 hash, we have the R1CS constraint cost in the full rounds as:
In the partial rounds:
So we expect 275, but currently have 270 in a test circuit doing the 2:1 hash exposed in the
poseidon377
crate. The difference comes from the first full round, wherein we only add 10 constraints. This happens because the very first sbox is operating on a state words row vector where the first element is a constant, and the subsequent elements are the (witnessed) input words. If you modify the first element to also be a witness input word, you get 275 constraints as expected.