-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add RecursiveChallenger for in-circuit FS challenge sampling
#143
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
Conversation
bfdde19 to
b3b5eae
Compare
hratoanina
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.
Looks good, thanks!
You don't have to address the code comments, if I need it I'll just change it in the Poseidon sponge table PR.
| fn test_hash_absorb_squeeze_sequence() { | ||
| let mut circuit = CircuitBuilder::<BabyBear>::new(); | ||
| circuit.enable_op( | ||
| NonPrimitiveOpType::HashAbsorb { reset: true }, |
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.
Does it need you would need to potentially separately allow with reset = true and reset = false?
| } | ||
|
|
||
| /// Flush the absorb buffer, performing the actual hash absorb operation. | ||
| fn flush_absorb<F: Field>(&mut self, circuit: &mut CircuitBuilder<F>) { |
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'm trying to think of a case where you would need to absorb outside of for sampling, or if we can just put the logic directly into sample.
| self.buffer_flushed = false; | ||
| } | ||
|
|
||
| fn sample(&mut self, circuit: &mut CircuitBuilder<F>) -> Target { |
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.
For easier compatibility with the table, it would be better if add_hash_squeeze were called only with vecs of RATE elements.
It could be done either by maintaining an output vector, or by always returning RATE elements when calling sample. I'd prefer the former.
|
@hratoanina should I just merge as is then? |
|
@Nashtare Yeah, I'm fine with merging it right now. |
builds on top of #141
Part of some more global refactoring around
PublicInputlogic andChallengesgeneration.Attempt at proposing a
RecursiveChallengertrait along with a concrete impl throughCircuitChallengerto observe values and sample challenges. There remains to actually have hashing constraints (via fixed Poseidon2 or generic).There are a couple tweaks / cleanups / lighter refactoring that I'd still like to do but decoupling the 3 PRs got a bit messy so I may hold it off for now (dropped some TODOs inline)