-
Notifications
You must be signed in to change notification settings - Fork 137
rp/poseidon arrays #3386
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
rp/poseidon arrays #3386
Conversation
|
Next steps:
Probably as a follow-up:
|
5472365 to
c846516
Compare
richardpringle
left a comment
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.
Some of these comments are for myself, others are for the reviewer
| state | ||
| .iter_mut() | ||
| .zip(params.round_constants[0].iter()) | ||
| .for_each(|(s, x)| { | ||
| s.add_assign(x); | ||
| }); |
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.
To get the exact same behaviour as before, these should actually be reversed:
| state | |
| .iter_mut() | |
| .zip(params.round_constants[0].iter()) | |
| .for_each(|(s, x)| { | |
| s.add_assign(x); | |
| }); | |
| params | |
| .round_constants[0] | |
| .iter() | |
| .zip(state.iter_mut()) | |
| .for_each(|(x, s)| { | |
| s.add_assign(x); | |
| }); |
In practice though, the round_constants[0] and state are always the same length.
@dannywillems, thoughts? Should I change this.
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, they must be the same length.
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.
@dannywillems, should we add an issue to add an assertion here? Could mark it with "good first issue" and hope someone else does it
c846516 to
44409d0
Compare
|
Running CI on github.com/mina |
bbc4fe8 to
a79887f
Compare
|
78eaadc to
0bba29c
Compare
| params: &ArithmeticSpongeParams<F, FULL_ROUNDS>, | ||
| state: &mut [F], | ||
| ) { | ||
| for r in 0..SC::PERM_HALF_ROUNDS_FULL { |
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 guess later we can remove PERM_HALF_ROUNDS_FULL from the params.
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.
@dannywillems, is there an issue for doing the partial round stuff? We can reference this comment in there
|
Added a bunch of follow up issues from the comments (mine and @dannywillems's) |
The main change of this PR is the
ArithmeticSpongeParamstype (found here).What used to be a
Vec<Vec<F>>is now[[F; FULL_ROUNDS]]whereFULL_ROUNDSis a const generic of typeusize. This means the data can now sit on either the stack or the heap, and is contiguous rather than spread across the heap.Making this change had wide spread affects to the all the dependent functions, types and traits. Now many of them are generic over a
usize. There's really only one file that had logical changes and that'sposeidon/src/permutation.rs. Extra allocations were removed and the code was cleaned up a little to now handle the arrays instead ofVecs.I benchmarked locally and there is small consistent speed up (though that was not the goal).