-
Notifications
You must be signed in to change notification settings - Fork 4
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
Cycle of curves #184
Cycle of curves #184
Conversation
pub struct RelaxedR1cs<C: CircuitDriver> { | ||
// 1. Structure S | ||
// a, b and c matrices and matrix size | ||
pub struct R1csShape<C: CircuitDriver> { |
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.
Extracted from the zkstd R1cs
structure.
The 1 instance is not counted, because we use u
value for verification.
|
||
let instance = RelaxedR1csInstance::new(x); | ||
let witness = RelaxedR1csWitness::new(w, m); | ||
pub(crate) fn r1cs_instance_and_witness<C: CircuitDriver>( |
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.
Get instance/witness values from R1cs that should match the provided shape.
R1csWitness and R1csInstance can be relaxed after if necessary.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #184 +/- ##
==========================================
+ Coverage 76.32% 77.69% +1.36%
==========================================
Files 66 68 +2
Lines 4381 4488 +107
==========================================
+ Hits 3344 3487 +143
+ Misses 1037 1001 -36 ☔ View full report in Codecov by Sentry. |
} | ||
} | ||
|
||
pub struct PublicParams<E1, E2, FC1, FC2> |
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.
Shapes for primary and secondary augmented circuits. Doesn't change the form and can be used on any iteration.
Commitment keys (passed to provers, used for r1cs verification)
@@ -137,28 +110,62 @@ impl<C: CircuitDriver> RelaxedR1cs<C> { | |||
.all(|(left, right)| left == right) | |||
} | |||
|
|||
pub(crate) fn absorb_by_transcript<const ROUNDS: usize>( | |||
/// check (A · Z) ◦ (B · Z) = (C · Z) | |||
pub fn is_sat( |
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.
Basic R1cs verification and additional commit_w
verification
@@ -5,6 +5,7 @@ use crate::common::{BNAffine, Deserialize, PrimeField, Serialize}; | |||
use core::fmt::Debug; | |||
|
|||
pub trait CircuitDriver: Clone + Debug + Default { | |||
const ORDER_STR: &'static str; |
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.
Used for module arithmetic in NifsCircuit depending on the driver
x: FieldAssignment<C>, | ||
y: FieldAssignment<C>, | ||
z: FieldAssignment<C>, | ||
pub struct PointAssignment<F: PrimeField> { |
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.
Defined this way, so we can use R1cs
on the opposite driver.
}, | ||
); | ||
|
||
Self { x, y, z } | ||
} | ||
|
||
pub fn witness(cs: &mut R1cs<C>, x: C::Scalar, y: C::Scalar, is_infinity: bool) -> Self { | ||
pub fn descale<C: CircuitDriver<Scalar = F>>(&self, cs: &mut R1cs<C>) -> 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.
Called before using the hash function to get same values with native hash computation.
Return (x/z, y/z, 1)
or the point if it is an identity.
let wire = cs.private_wire(); | ||
cs.w.push(witness); | ||
|
||
Self(SparseRow::from(wire)) | ||
} | ||
|
||
pub fn constant(constant: &C::Scalar) -> Self { | ||
pub fn inputize<C: CircuitDriver<Scalar = F>>(cs: &mut R1cs<C>, witness: Self) -> 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.
Make the computations accessible from outside of the circuit.
No description provided.