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
🗼 Tower Extensions (Fq2
, Fq6
, and Fq12
) and Torus Compression for BN254 precompiles
#38
base: dl-precompiles
Are you sure you want to change the base?
🗼 Tower Extensions (Fq2
, Fq6
, and Fq12
) and Torus Compression for BN254 precompiles
#38
Conversation
…or usage under the curve
…-trait-impls` 🗼 Tower Extension Implementation
…igin' into feature/modexp
Hey, @jules, I have added fixes for the above notes from you, though since we moved BN254-specific functionality to era-zkevm_circuits, you can check the changes in conjugated PR |
…veFieldOverU16Params and NonNativeFieldOverU16
…onNativeFieldOverU16
Modexp Implementation
🔬 Torus Compression Implementation
Fq2
, Fq6
, and Fq12
) and Torus Compression for BN254 precompiles
Since we moved the BN254-specific implementations outside this repo (namely, we moved them |
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.
looking great guys, just a few final notes :)
// We need this to ensure no conflicting implementations without negative impls | ||
|
||
#[derive(Derivative)] | ||
#[derivative(Clone, Copy, Debug, Hash)] | ||
#[derive(Derivative, Serialize, PartialEq)] |
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.
what was the reason for adding serialize functionality to this type?
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.
In circuits for ec_pairing
we use internal FSM state with Fq12
as intermediate value element, thus it was needed to add it here because otherwise it wouldn't get compiled
for i in BitIterator::new(exponent) { | ||
if found_one { | ||
result = result.square::<CS, SAFE>(cs); | ||
} else { | ||
found_one = i; | ||
} | ||
|
||
if i { | ||
result = result.mul::<CS, SAFE>(cs, self); | ||
} |
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 non-homogenous and needs to be updated to use conditional selection gates
src/gadgets/tower_extension/fq2.rs
Outdated
if power % 2 == 0 { | ||
return self.clone(); | ||
} |
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.
also non-homogenous in case the power can variate between circuits
for i in BitIterator::new(exponent) { | ||
if found_one { | ||
result = result.square(cs); | ||
} else { | ||
found_one = i; | ||
} | ||
|
||
if i { | ||
result = result.mul(cs, self); | ||
} |
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.
same thing here, seems like this will cause divergent circuits based on input
What ❔
This pull request primarily focuses on helper gadgets for EC pairing implementation under the constraint system.
To implement pairing, we introduce the following new functionality:
NonNativeField<F, T>
trait overWhy ❔
Checklist
zk fmt
andzk lint
.