-
Notifications
You must be signed in to change notification settings - Fork 2
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
Poseidon 2 #28
Poseidon 2 #28
Conversation
|
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.
Comments about Air
- It's common for the
eval
function to define all the flags and bools at the start, so it's clear when later constraints are being used. - The
is_internal
andis_external
can be derived from the sum of therounds
flags. - The application of the constants to the rounds cannot have an
if
. Instead, you need to conditionally select the constants usinglocal.rounds
, and use another selector to conditionally add the constants (is_external, is_init, is_internal
)
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.
Great work 🎉
Left some higher level comments related to maintenance
Updates: I applied the suggests in the comments, and fixed a small error in the internal matrix action to fix the tests. The only couple outstanding issues to address before I think this is ready to approve:
|
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.
Swooping in to block on the personal fork branch.
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.
This is great! I have a tiny suggestion below (feel free to ignore). Regarding the other two points mentioned, here's my two cents:
- I think the
.sage
script would not necessarily be out of place in this repo in some additional folder in the repo (assets/
orscripts/
or evendocs/
) and would vote for that, but I think the public-gist solution is also perfectly acceptable. - We definitely want the changes of
mp/poseidon_fix
to at least be merged into our fork, they are very minor and are unlikely to be a maintenance burden. I think upstream would be open to them as well, but we can do that later.
427a506
to
e206c61
Compare
Cargo.toml
Outdated
@@ -51,9 +69,11 @@ p3-maybe-rayon = { workspace = true } | |||
p3-poseidon2 = { workspace = true } | |||
p3-symmetric = { workspace = true } | |||
p3-util = { workspace = true } | |||
hybrid-array = "0.2.0-rc" |
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.
Please use workspace dependencies. To do this, you can use the cargo autoinherit tool.
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.
Leaving some comments to be converted to issues
mod util; | ||
|
||
/// A chip that implements addition for the Poseidon2 permutation | ||
pub struct Poseidon2Chip<C> |
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.
![derive(Default)]
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.
Because C: PoseidonConfig
doesn't have a blanket Default
implementation (and it shouldn't, because the round constants need to be provided by hand) this doesn't work and I had to do it by hand.
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.
Good for me!
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.
Looks good! Needs a final rebase/conflict resolve before merge
- Optimize chunk by 4 in Air - Move column generation logic to Poseidon2Cols - Make field generic in config
Rebased! |
Poseidon 2 chip for Loam.
Generic in width using
hybrid-array
The structure of the API around the chip is in a good spot I think.
The tests don't currently pass, I'm debugging!
Please take a look to make sure everything is as one would expect from the precompile
Note 1:
In order for this to work I had to fork Plonky3 and make a couple small changes
Permutation
trait so I could implement a new version to support fixed round constants, and not those generated by the rng in Plonky3.Note 2:
I added the
AlignedBorrow
inloam-macros
pretty early on in the process. I don't think it's strictly necessary anymore but it could help in other spots...Note 3:
I'm not sure what to do about the sage script... It doesn't make much sense to include it in the repository, but I also don't know if it's good practice for people to take us on our word that we generated the constants correctly.