-
Notifications
You must be signed in to change notification settings - Fork 310
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
feat: (bb) 128-bit challenges #8406
Changes from 22 commits
e058901
17cefae
d108856
528878a
4e68692
b821bcb
71246b0
3517079
cba9f09
7484dc1
f8e2e70
e1c0899
cc81b9a
a4827d5
394afa4
380cee6
e580af6
03bee42
4845e5f
39dfbd8
83ddb07
000bf51
20e8cf2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,8 @@ | |
#include "barretenberg/crypto/poseidon2/poseidon2.hpp" | ||
#include "barretenberg/stdlib/hash/poseidon2/poseidon2.hpp" | ||
#include "barretenberg/stdlib/primitives/field/field_conversion.hpp" | ||
#include "barretenberg/stdlib/primitives/group/cycle_group.hpp" | ||
#include "barretenberg/transcript/transcript.hpp" | ||
|
||
namespace bb::stdlib::recursion::honk { | ||
|
||
template <typename Builder> struct StdlibTranscriptParams { | ||
|
@@ -19,7 +19,23 @@ template <typename Builder> struct StdlibTranscriptParams { | |
Builder* builder = data[0].get_context(); | ||
return stdlib::poseidon2<Builder>::hash(*builder, data); | ||
} | ||
|
||
/** | ||
* @brief Split a challenge field element into two half-width challenges | ||
* @details `lo` is 128 bits and `hi` is 126 bits. | ||
* This should provide significantly more than our security parameter bound: 100 bits | ||
* | ||
* @param challenge | ||
* @return std::array<Fr, 2> | ||
*/ | ||
static inline std::array<Fr, 2> split_challenge(const Fr& challenge) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not too familiar with cycle_scalar... why are we using it instead of normal field_ts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cycle_scalar has an existing method to split a stdlib::field_t element into two half-width scalars. It's nontrivial to do efficiently so I wanted to reuse existing code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's a little unfortunate we have to bring in cycle group (which shouldn't have anything to do with this) but alright. I guess I don't have a better solution beyond copy paste... or some bigger refactoring |
||
{ | ||
// use existing field-splitting code in cycle_scalar | ||
using cycle_scalar = typename stdlib::cycle_group<Builder>::cycle_scalar; | ||
const cycle_scalar scalar = cycle_scalar(challenge); | ||
scalar.lo.create_range_constraint(cycle_scalar::LO_BITS); | ||
scalar.hi.create_range_constraint(cycle_scalar::HI_BITS); | ||
return std::array<Fr, 2>{ scalar.lo, scalar.hi }; | ||
} | ||
template <typename T> static inline T convert_challenge(const Fr& challenge) | ||
{ | ||
Builder* builder = challenge.get_context(); | ||
|
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.
publicInputsSize doesn't seem needed here as an input
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.
but maybe this was needed to maintain the same interface as Transcript.sol? unsure, didn't want to test it so I'll leave it