Skip to content
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

Refactory #39

Merged
merged 34 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8da011c
Remove redundant hiding state value
davxy Aug 10, 2024
d159e59
Test vectors feature
davxy Aug 11, 2024
35b1b66
Merge branch 'test-vectors' into extended
davxy Aug 11, 2024
74d9d85
Remove blake2_simd
davxy Aug 21, 2024
cd59d49
Simplify
davxy Aug 21, 2024
1080a5d
Minimize diff
davxy Aug 21, 2024
39a4b09
Set custom padding point
davxy Sep 12, 2024
7870dda
Expose padding point
davxy Sep 13, 2024
70a0289
Switch to ark-transcript
davxy Sep 21, 2024
01d2673
Use ArkTranscript by default
davxy Sep 21, 2024
3b9f20b
Merge pull request #4 from davxy/ark-transcript
davxy Sep 21, 2024
d3e37f9
Merge branch 'master' into extended
davxy Sep 21, 2024
86e3ce0
Merge branch 'master' into extended
davxy Sep 27, 2024
5192cdd
Apply @davxy suggestions from code review
drskalman Oct 23, 2024
8a8af80
Merge branch 'skalman--allow-ec-in-te' of https://github.com/w3f/ring…
drskalman Oct 23, 2024
c6d42b2
- feature-control time consuming benchmarking tests.
drskalman Oct 23, 2024
bd362e2
- move `find_random_point` to test helpers.
drskalman Oct 23, 2024
f6ec1d8
VrfAffineT → P because @davxy said so
drskalman Oct 23, 2024
7f77102
Merge branch 'skalman--allow-ec-in-te' into extendend-with-te
davxy Nov 1, 2024
681041c
Fix
davxy Nov 1, 2024
24e5d80
Default to ArkTranscript
davxy Nov 1, 2024
e9d31c4
Refactory
davxy Nov 2, 2024
43cd73d
Expose AffineCondAdd
davxy Nov 2, 2024
db0ef42
Further cleanup
davxy Nov 2, 2024
ccd9bcb
Docs
davxy Nov 2, 2024
cc68185
Remove unused gadget
davxy Nov 2, 2024
6e45942
Allow user to specify the padding point
davxy Nov 2, 2024
5e9ba2d
Merge pull request #6 from davxy/extendend-with-te
davxy Nov 2, 2024
7e416c8
Restore powers of two multiples gadget
davxy Nov 2, 2024
08d93ed
FieldFor -> BaseFieldOf
davxy Nov 7, 2024
a4462e8
Refine
davxy Nov 7, 2024
545e6e2
Clippy
davxy Nov 8, 2024
ad86f9d
Clippy
davxy Nov 8, 2024
708611e
Docs about PoP
davxy Nov 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ ark-serialize.workspace = true
fflonk.workspace = true
rayon = { workspace = true, optional = true }
getrandom_or_panic = { version = "0.0.3", default-features = false }
rand_core = "0.6"

[dev-dependencies]
ark-ed-on-bls12-381-bandersnatch = { version = "0.4", default-features = false }
Expand All @@ -31,7 +30,6 @@ std = [
"ark-serialize/std",
"fflonk/std",
"getrandom_or_panic/std",
"rand_core/std"
]
parallel = [
"std",
Expand All @@ -44,3 +42,4 @@ parallel = [
]
print-trace = ["ark-std/print-trace"]
asm = ["fflonk/asm"]
test-vectors = []
6 changes: 3 additions & 3 deletions common/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<F: FftField> Domain<F> {
pub(crate) fn column(&self, mut evals: Vec<F>, hidden: bool) -> FieldColumn<F> {
let len = evals.len();
assert!(len <= self.capacity);
if self.hiding && hidden {
if self.hiding && hidden && !cfg!(feature = "test-vectors") {
evals.resize(self.capacity, F::zero());
evals.resize_with(self.domains.x1.size(), || {
F::rand(&mut getrandom_or_panic::getrandom_or_panic())
Expand Down Expand Up @@ -153,7 +153,7 @@ fn vanishes_on_row<F: FftField>(
) -> DensePolynomial<F> {
assert!(i < domain.size());
let w = domain.group_gen();
let wi = w.pow(&[i as u64]);
let wi = w.pow([i as u64]);
let wi = DensePolynomial::from_coefficients_slice(&[wi]);
let x = DensePolynomial::from_coefficients_slice(&[F::zero(), F::one()]);
&x - &wi
Expand All @@ -163,7 +163,7 @@ fn vanishes_on_row<F: FftField>(
fn vanishes_on_last_3_rows<F: FftField>(domain: GeneralEvaluationDomain<F>) -> DensePolynomial<F> {
let w = domain.group_gen();
let n3 = (domain.size() - ZK_ROWS) as u64;
let w3 = w.pow(&[n3]);
let w3 = w.pow([n3]);
let w2 = w3 * w;
let w1 = w2 * w;
assert_eq!(w1, domain.group_gen_inv());
Expand Down
2 changes: 1 addition & 1 deletion common/src/gadgets/booleanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct Booleanity<F: FftField> {
bits: BitColumn<F>,
}

impl<'a, F: FftField> Booleanity<F> {
impl<F: FftField> Booleanity<F> {
pub fn init(bits: BitColumn<F>) -> Self {
Self { bits }
}
Expand Down
72 changes: 57 additions & 15 deletions common/src/gadgets/cond_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,74 @@ use ark_ff::{FftField, Field};

use crate::domain::Domain;
use crate::gadgets::booleanity::BitColumn;
use crate::AffineColumn;
use crate::{AffineColumn, FieldColumn};

pub trait CondAdd<F, AffinePoint>
use super::{ProverGadget, VerifierGadget};

/// Affine point with conditional add implementation.
///
/// Currently supported for Arkworks Short Weierstrass and Twisted Edwards affine points.
pub trait AffineCondAdd: AffineRepr
drskalman marked this conversation as resolved.
Show resolved Hide resolved
where
BaseFieldOf<Self>: FftField,
{
/// Conditional addition operation
type CondAddT: CondAdd<BaseFieldOf<Self>, Self>;
}

// Conditional affine addition.
//
// If the bit is set for a point, add the point to the acc and store,
// otherwise copy the acc value
pub trait CondAdd<F, P>: ProverGadget<F>
where
F: FftField,
AffinePoint: AffineRepr<BaseField = F>,
P: AffineRepr<BaseField = F>,
{
type CondAddValT: CondAddValues<F>;
fn init(
bitmask: BitColumn<F>,
points: AffineColumn<F, AffinePoint>,
seed: AffinePoint,
domain: &Domain<F>,
) -> Self;

fn evaluate_assignment(&self, z: &F) -> Self::CondAddValT;
fn get_acc(&self) -> AffineColumn<F, AffinePoint>;
fn get_result(&self) -> AffinePoint;
type Values: CondAddValues<F>;

fn init(bitmask: BitColumn<F>, points: AffineColumn<F, P>, seed: P, domain: &Domain<F>)
-> Self;

fn evaluate_assignment(&self, z: &F) -> Self::Values;

fn get_acc(&self) -> AffineColumn<F, P>;

fn get_result(&self) -> P;
}

pub trait CondAddValues<F>
pub trait CondAddValues<F>: VerifierGadget<F>
where
F: Field,
{
fn acc_coeffs_1(&self) -> (F, F);

fn acc_coeffs_2(&self) -> (F, F);

fn init(bitmask: F, points: (F, F), not_last: F, acc: (F, F)) -> Self;
}

pub struct CondAddGen<P>
where
P: AffineRepr,
<P as AffineRepr>::BaseField: FftField,
{
pub(super) bitmask: BitColumn<BaseFieldOf<P>>,
pub(super) points: AffineColumn<BaseFieldOf<P>, P>,
pub(super) not_last: FieldColumn<BaseFieldOf<P>>,
pub acc: AffineColumn<BaseFieldOf<P>, P>,
pub result: P,
}

pub struct CondAddValuesGen<P: AffineRepr> {
pub bitmask: BaseFieldOf<P>,
pub points: (BaseFieldOf<P>, BaseFieldOf<P>),
pub not_last: BaseFieldOf<P>,
pub acc: (BaseFieldOf<P>, BaseFieldOf<P>),
}

pub type BaseFieldOf<P> = <P as AffineRepr>::BaseField;

pub type CondAddFor<P> = <P as AffineCondAdd>::CondAddT;

pub type CondAddValuesFor<P> = <CondAddFor<P> as CondAdd<BaseFieldOf<P>, P>>::Values;
1 change: 0 additions & 1 deletion common/src/gadgets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use ark_poly::{Evaluations, GeneralEvaluationDomain};
use ark_std::vec::Vec;

pub mod booleanity;
// pub mod inner_prod_pub;
pub mod cond_add;
pub mod fixed_cells;
pub mod inner_prod;
Expand Down
2 changes: 1 addition & 1 deletion common/src/gadgets/powers_of_two_multiples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ mod tests {
domain.divide_by_vanishing_poly(&c1);
domain.divide_by_vanishing_poly(&c2);

return (domain, gadget, cs);
(domain, gadget, cs)
}

#[test]
Expand Down
Loading
Loading