mirror of
https://github.com/dmpierre/plasma-fold.git
synced 2026-01-09 15:28:04 -05:00
chore: update deps and imports
This commit is contained in:
33
Cargo.toml
33
Cargo.toml
@@ -3,18 +3,29 @@ resolver = "2"
|
|||||||
members = [ "aggregator","plasma-fold", "client", "mock-contract" ]
|
members = [ "aggregator","plasma-fold", "client", "mock-contract" ]
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
folding-schemes = { git = "https://github.com/privacy-scaling-explorations/sonobe", rev = "fc91430" }
|
folding-schemes = { git = "https://github.com/privacy-scaling-explorations/sonobe", rev = "9b7dd34" }
|
||||||
ark-ff = { version = "0.5.0" }
|
ark-ff = { version = "^0.5.0"}
|
||||||
ark-bn254 = { version = "0.5.0" }
|
ark-bn254 = { version = "^0.5.0"}
|
||||||
ark-grumpkin = { version = "0.5.0" }
|
ark-grumpkin = { version = "^0.5.0"}
|
||||||
ark-r1cs-std = { version = "0.5.0" }
|
ark-r1cs-std = { version = "^0.5.0" }
|
||||||
ark-relations = { version = "0.5.0" }
|
ark-relations = { version = "^0.5.0"}
|
||||||
ark-crypto-primitives = { version = "0.5.0" }
|
ark-crypto-primitives = { version = "^0.5.0" }
|
||||||
ark-std = "0.5.0"
|
ark-std = { version = "^0.5.0"}
|
||||||
ark-serialize = "0.5.0"
|
ark-serialize = { version = "^0.5.0"}
|
||||||
ark-ec = "0.5.0"
|
ark-ec = { version = "^0.5.0" }
|
||||||
num = "0.4.0"
|
num = "0.4.0"
|
||||||
thiserror = "2.0.12"
|
thiserror = "2.0.12"
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
ark-r1cs-std = { git = "https://github.com/yelhousni/r1cs-std", rev = "440ca3" }
|
ark-ff = { git = "https://github.com/arkworks-rs/algebra" }
|
||||||
|
ark-bn254 = { git = "https://github.com/arkworks-rs/algebra" }
|
||||||
|
ark-grumpkin = { git = "https://github.com/arkworks-rs/algebra" }
|
||||||
|
ark-r1cs-std = { git = "https://github.com/flyingnobita/r1cs-std_yelhousni", rev = "b4bab0c" } # "perf/sw-updated" branch
|
||||||
|
ark-relations = { git = "https://github.com/arkworks-rs/snark" }
|
||||||
|
ark-crypto-primitives = { git = "https://github.com/flyingnobita/crypto-primitives", rev = "f559264" }
|
||||||
|
ark-std = { git = "https://github.com/arkworks-rs/std" }
|
||||||
|
ark-serialize = { git = "https://github.com/arkworks-rs/algebra" }
|
||||||
|
ark-ec = { git = "https://github.com/arkworks-rs/algebra" }
|
||||||
|
ark-snark = { git = "https://github.com/arkworks-rs/snark" }
|
||||||
|
ark-groth16 = { git = "https://github.com/arkworks-rs/groth16", rev = "b3b4a15" }
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ folding-schemes = { workspace = true }
|
|||||||
ark-r1cs-std = { workspace = true }
|
ark-r1cs-std = { workspace = true }
|
||||||
ark-ff = { workspace = true }
|
ark-ff = { workspace = true }
|
||||||
ark-relations = { workspace = true }
|
ark-relations = { workspace = true }
|
||||||
ark-crypto-primitives = { workspace = true, features = ["r1cs", "crh", "sponge"] }
|
ark-crypto-primitives = { workspace = true, features = ["constraints", "crh", "sponge"] }
|
||||||
ark-bn254 = { workspace = true, features = ["r1cs"] }
|
ark-bn254 = { workspace = true, features = ["r1cs"] }
|
||||||
ark-grumpkin = { workspace = true, features = ["r1cs"] }
|
ark-grumpkin = { workspace = true, features = ["r1cs"] }
|
||||||
ark-std = { workspace = true }
|
ark-std = { workspace = true }
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ use ark_r1cs_std::{
|
|||||||
groups::CurveVar,
|
groups::CurveVar,
|
||||||
prelude::Boolean,
|
prelude::Boolean,
|
||||||
uint8::UInt8,
|
uint8::UInt8,
|
||||||
R1CSVar,
|
GR1CSVar,
|
||||||
};
|
};
|
||||||
use ark_relations::r1cs::{ConstraintSystemRef, Namespace, SynthesisError};
|
use ark_relations::gr1cs::{ConstraintSystemRef, Namespace, SynthesisError};
|
||||||
use folding_schemes::frontend::FCircuit;
|
use folding_schemes::frontend::FCircuit;
|
||||||
use plasma_fold::{
|
use plasma_fold::{
|
||||||
datastructures::{
|
datastructures::{
|
||||||
@@ -443,7 +443,7 @@ mod tests {
|
|||||||
use ark_bn254::{Fr, G1Projective as Projective};
|
use ark_bn254::{Fr, G1Projective as Projective};
|
||||||
use ark_ff::UniformRand;
|
use ark_ff::UniformRand;
|
||||||
use ark_grumpkin::{constraints::GVar, Projective as Projective2};
|
use ark_grumpkin::{constraints::GVar, Projective as Projective2};
|
||||||
use ark_relations::r1cs::ConstraintSystem;
|
use ark_relations::gr1cs::ConstraintSystem;
|
||||||
use ark_serialize::CanonicalSerialize;
|
use ark_serialize::CanonicalSerialize;
|
||||||
use ark_std::rand::thread_rng;
|
use ark_std::rand::thread_rng;
|
||||||
use folding_schemes::{
|
use folding_schemes::{
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ plasma-fold = { path = "../plasma-fold/" }
|
|||||||
ark-ec = { workspace = true }
|
ark-ec = { workspace = true }
|
||||||
ark-ff = { workspace = true }
|
ark-ff = { workspace = true }
|
||||||
ark-std = { workspace = true }
|
ark-std = { workspace = true }
|
||||||
ark-crypto-primitives = { workspace = true, features = ["r1cs", "crh", "sponge"] }
|
ark-crypto-primitives = { workspace = true, features = ["constraints", "crh", "sponge"] }
|
||||||
ark-bn254 = { workspace = true }
|
ark-bn254 = { workspace = true }
|
||||||
console_error_panic_hook = { version = "0.1.7", optional = true }
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
ark-grumpkin = { workspace = true }
|
ark-grumpkin = { workspace = true }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use ark_crypto_primitives::{
|
|||||||
};
|
};
|
||||||
use ark_ec::CurveGroup;
|
use ark_ec::CurveGroup;
|
||||||
use ark_r1cs_std::{alloc::AllocVar, prelude::Boolean, select::CondSelectGadget};
|
use ark_r1cs_std::{alloc::AllocVar, prelude::Boolean, select::CondSelectGadget};
|
||||||
use ark_relations::r1cs::{ConstraintSystemRef, SynthesisError};
|
use ark_relations::gr1cs::{ConstraintSystemRef, SynthesisError};
|
||||||
use core::cmp::Ordering;
|
use core::cmp::Ordering;
|
||||||
use folding_schemes::folding::traits::Dummy;
|
use folding_schemes::folding::traits::Dummy;
|
||||||
use plasma_fold::{
|
use plasma_fold::{
|
||||||
@@ -142,7 +142,7 @@ impl<
|
|||||||
> AllocVar<UserAux<F, C, N_TX_PER_FOLD_STEP>, F> for UserAuxVar<F, C, CVar>
|
> AllocVar<UserAux<F, C, N_TX_PER_FOLD_STEP>, F> for UserAuxVar<F, C, CVar>
|
||||||
{
|
{
|
||||||
fn new_variable<T: std::borrow::Borrow<UserAux<F, C, N_TX_PER_FOLD_STEP>>>(
|
fn new_variable<T: std::borrow::Borrow<UserAux<F, C, N_TX_PER_FOLD_STEP>>>(
|
||||||
cs: impl Into<ark_relations::r1cs::Namespace<F>>,
|
cs: impl Into<ark_relations::gr1cs::Namespace<F>>,
|
||||||
f: impl FnOnce() -> Result<T, SynthesisError>,
|
f: impl FnOnce() -> Result<T, SynthesisError>,
|
||||||
mode: ark_r1cs_std::prelude::AllocationMode,
|
mode: ark_r1cs_std::prelude::AllocationMode,
|
||||||
) -> Result<Self, SynthesisError> {
|
) -> Result<Self, SynthesisError> {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use ark_crypto_primitives::{
|
|||||||
use ark_ec::CurveGroup;
|
use ark_ec::CurveGroup;
|
||||||
use ark_ff::PrimeField;
|
use ark_ff::PrimeField;
|
||||||
use ark_r1cs_std::{alloc::AllocVar, fields::fp::FpVar, groups::CurveVar};
|
use ark_r1cs_std::{alloc::AllocVar, fields::fp::FpVar, groups::CurveVar};
|
||||||
use ark_relations::r1cs::{ConstraintSystemRef, SynthesisError};
|
use ark_relations::gr1cs::{ConstraintSystemRef, SynthesisError};
|
||||||
use circuits::{UserAux, UserAuxVar, UserCircuit};
|
use circuits::{UserAux, UserAuxVar, UserCircuit};
|
||||||
use folding_schemes::{frontend::FCircuit, Error};
|
use folding_schemes::{frontend::FCircuit, Error};
|
||||||
use plasma_fold::primitives::accumulator::constraints::{
|
use plasma_fold::primitives::accumulator::constraints::{
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ use ark_crypto_primitives::{
|
|||||||
};
|
};
|
||||||
use ark_ff::{AdditiveGroup, Field};
|
use ark_ff::{AdditiveGroup, Field};
|
||||||
use ark_grumpkin::{constraints::GVar, Projective};
|
use ark_grumpkin::{constraints::GVar, Projective};
|
||||||
use ark_r1cs_std::{alloc::AllocVar, fields::fp::FpVar, R1CSVar};
|
use ark_r1cs_std::{alloc::AllocVar, fields::fp::FpVar, GR1CSVar};
|
||||||
use ark_relations::r1cs::{ConstraintSystem, ConstraintSystemRef};
|
use ark_relations::gr1cs::{ConstraintSystem, ConstraintSystemRef};
|
||||||
use ark_std::rand::thread_rng;
|
use ark_std::rand::thread_rng;
|
||||||
use client::ClientCircuitSha;
|
use client::ClientCircuitSha;
|
||||||
use client::{
|
use client::{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ folding-schemes = { workspace = true }
|
|||||||
ark-r1cs-std = { workspace = true }
|
ark-r1cs-std = { workspace = true }
|
||||||
ark-ff = { workspace = true }
|
ark-ff = { workspace = true }
|
||||||
ark-relations = { workspace = true }
|
ark-relations = { workspace = true }
|
||||||
ark-crypto-primitives = { workspace = true, features = ["r1cs", "crh", "sponge"] }
|
ark-crypto-primitives = { workspace = true, features = ["constraints", "crh", "sponge"] }
|
||||||
ark-bn254 = { workspace = true, features = ["r1cs"] }
|
ark-bn254 = { workspace = true, features = ["r1cs"] }
|
||||||
ark-grumpkin = { workspace = true, features = ["r1cs"] }
|
ark-grumpkin = { workspace = true, features = ["r1cs"] }
|
||||||
ark-std = { workspace = true }
|
ark-std = { workspace = true }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ folding-schemes = { workspace = true }
|
|||||||
ark-r1cs-std = { workspace = true }
|
ark-r1cs-std = { workspace = true }
|
||||||
ark-ff = { workspace = true }
|
ark-ff = { workspace = true }
|
||||||
ark-relations = { workspace = true }
|
ark-relations = { workspace = true }
|
||||||
ark-crypto-primitives = { workspace = true, features = ["r1cs", "crh", "sponge"] }
|
ark-crypto-primitives = { workspace = true, features = ["constraints", "crh", "sponge"] }
|
||||||
ark-bn254 = { workspace = true, features = ["r1cs"] }
|
ark-bn254 = { workspace = true, features = ["r1cs"] }
|
||||||
ark-grumpkin = { workspace = true, features = ["r1cs"] }
|
ark-grumpkin = { workspace = true, features = ["r1cs"] }
|
||||||
ark-std = { workspace = true }
|
ark-std = { workspace = true }
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use ark_r1cs_std::alloc::AllocVar;
|
|||||||
use ark_r1cs_std::eq::EqGadget;
|
use ark_r1cs_std::eq::EqGadget;
|
||||||
use ark_r1cs_std::fields::fp::FpVar;
|
use ark_r1cs_std::fields::fp::FpVar;
|
||||||
use ark_r1cs_std::prelude::Boolean;
|
use ark_r1cs_std::prelude::Boolean;
|
||||||
use ark_relations::r1cs::SynthesisError;
|
use ark_relations::gr1cs::SynthesisError;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use ark_crypto_primitives::merkle_tree::Config;
|
use ark_crypto_primitives::merkle_tree::Config;
|
||||||
@@ -56,7 +56,7 @@ impl<
|
|||||||
> AllocVar<TreeUpdateProof<P>, F> for TreeUpdateProofVar<P, F, PG>
|
> AllocVar<TreeUpdateProof<P>, F> for TreeUpdateProofVar<P, F, PG>
|
||||||
{
|
{
|
||||||
fn new_variable<T: std::borrow::Borrow<TreeUpdateProof<P>>>(
|
fn new_variable<T: std::borrow::Borrow<TreeUpdateProof<P>>>(
|
||||||
cs: impl Into<ark_relations::r1cs::Namespace<F>>,
|
cs: impl Into<ark_relations::gr1cs::Namespace<F>>,
|
||||||
f: impl FnOnce() -> Result<T, SynthesisError>,
|
f: impl FnOnce() -> Result<T, SynthesisError>,
|
||||||
mode: ark_r1cs_std::prelude::AllocationMode,
|
mode: ark_r1cs_std::prelude::AllocationMode,
|
||||||
) -> Result<Self, SynthesisError> {
|
) -> Result<Self, SynthesisError> {
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ pub struct BlockVar<F: PrimeField> {
|
|||||||
|
|
||||||
impl<F: PrimeField> AllocVar<Block<F>, F> for BlockVar<F> {
|
impl<F: PrimeField> AllocVar<Block<F>, F> for BlockVar<F> {
|
||||||
fn new_variable<T: std::borrow::Borrow<Block<F>>>(
|
fn new_variable<T: std::borrow::Borrow<Block<F>>>(
|
||||||
cs: impl Into<ark_relations::r1cs::Namespace<F>>,
|
cs: impl Into<ark_relations::gr1cs::Namespace<F>>,
|
||||||
f: impl FnOnce() -> Result<T, ark_relations::r1cs::SynthesisError>,
|
f: impl FnOnce() -> Result<T, ark_relations::gr1cs::SynthesisError>,
|
||||||
mode: ark_r1cs_std::prelude::AllocationMode,
|
mode: ark_r1cs_std::prelude::AllocationMode,
|
||||||
) -> Result<Self, ark_relations::r1cs::SynthesisError> {
|
) -> Result<Self, ark_relations::gr1cs::SynthesisError> {
|
||||||
let cs = cs.into().cs();
|
let cs = cs.into().cs();
|
||||||
let res = f()?;
|
let res = f()?;
|
||||||
let block = res.borrow();
|
let block = res.borrow();
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ use ark_r1cs_std::alloc::AllocVar;
|
|||||||
use ark_r1cs_std::alloc::AllocationMode;
|
use ark_r1cs_std::alloc::AllocationMode;
|
||||||
use ark_r1cs_std::select::CondSelectGadget;
|
use ark_r1cs_std::select::CondSelectGadget;
|
||||||
use ark_r1cs_std::{fields::fp::FpVar, groups::CurveVar, prelude::Boolean};
|
use ark_r1cs_std::{fields::fp::FpVar, groups::CurveVar, prelude::Boolean};
|
||||||
use ark_relations::r1cs::Namespace;
|
use ark_relations::gr1cs::Namespace;
|
||||||
use ark_relations::r1cs::SynthesisError;
|
use ark_relations::gr1cs::SynthesisError;
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ pub mod tests {
|
|||||||
use ark_crypto_primitives::crh::poseidon::constraints::CRHParametersVar;
|
use ark_crypto_primitives::crh::poseidon::constraints::CRHParametersVar;
|
||||||
|
|
||||||
use ark_r1cs_std::{alloc::AllocVar, fields::fp::FpVar, uint64::UInt64};
|
use ark_r1cs_std::{alloc::AllocVar, fields::fp::FpVar, uint64::UInt64};
|
||||||
use ark_relations::r1cs::ConstraintSystem;
|
use ark_relations::gr1cs::ConstraintSystem;
|
||||||
use ark_std::rand::{thread_rng, Rng};
|
use ark_std::rand::{thread_rng, Rng};
|
||||||
use folding_schemes::transcript::poseidon::poseidon_canonical_config;
|
use folding_schemes::transcript::poseidon::poseidon_canonical_config;
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ pub mod tests {
|
|||||||
use ark_ff::UniformRand;
|
use ark_ff::UniformRand;
|
||||||
use ark_grumpkin::{constraints::GVar, Projective};
|
use ark_grumpkin::{constraints::GVar, Projective};
|
||||||
use ark_r1cs_std::{alloc::AllocVar, fields::fp::FpVar};
|
use ark_r1cs_std::{alloc::AllocVar, fields::fp::FpVar};
|
||||||
use ark_relations::r1cs::ConstraintSystem;
|
use ark_relations::gr1cs::ConstraintSystem;
|
||||||
use ark_std::rand::{thread_rng, Rng};
|
use ark_std::rand::{thread_rng, Rng};
|
||||||
use folding_schemes::transcript::poseidon::poseidon_canonical_config;
|
use folding_schemes::transcript::poseidon::poseidon_canonical_config;
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use ark_r1cs_std::{
|
|||||||
fields::{fp::FpVar, FieldVar},
|
fields::{fp::FpVar, FieldVar},
|
||||||
groups::CurveVar,
|
groups::CurveVar,
|
||||||
};
|
};
|
||||||
use ark_relations::r1cs::{ConstraintSystemRef, Namespace, SynthesisError};
|
use ark_relations::gr1cs::{ConstraintSystemRef, Namespace, SynthesisError};
|
||||||
use ark_std::borrow::Borrow;
|
use ark_std::borrow::Borrow;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -66,10 +66,7 @@ impl<F: PrimeField + Absorb, C: CurveGroup<BaseField = F>, CVar: CurveVar<C, F>>
|
|||||||
) -> Result<Self, SynthesisError> {
|
) -> Result<Self, SynthesisError> {
|
||||||
let cs = cs.into().cs();
|
let cs = cs.into().cs();
|
||||||
let f = f()?;
|
let f = f()?;
|
||||||
let Transaction {
|
let Transaction { inputs, outputs } = f.borrow();
|
||||||
inputs,
|
|
||||||
outputs,
|
|
||||||
} = f.borrow();
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
inputs: Vec::new_variable(cs.clone(), || Ok(&inputs[..]), mode)?
|
inputs: Vec::new_variable(cs.clone(), || Ok(&inputs[..]), mode)?
|
||||||
.try_into()
|
.try_into()
|
||||||
@@ -108,10 +105,7 @@ impl<F: PrimeField + Absorb, C: CurveGroup<BaseField = F>, CVar: CurveVar<C, F>>
|
|||||||
impl<F: PrimeField + Absorb, C: CurveGroup<BaseField = F>, CVar: CurveVar<C, F>>
|
impl<F: PrimeField + Absorb, C: CurveGroup<BaseField = F>, CVar: CurveVar<C, F>>
|
||||||
TransactionVar<F, C, CVar>
|
TransactionVar<F, C, CVar>
|
||||||
{
|
{
|
||||||
pub fn enforce_valid(
|
pub fn enforce_valid(&self, sender: &PublicKeyVar<C, CVar>) -> Result<(), SynthesisError> {
|
||||||
&self,
|
|
||||||
sender: &PublicKeyVar<C, CVar>,
|
|
||||||
) -> Result<(), SynthesisError> {
|
|
||||||
for i in &self.inputs {
|
for i in &self.inputs {
|
||||||
i.pk.key
|
i.pk.key
|
||||||
.conditional_enforce_equal(&sender.key, &!&i.is_dummy)?;
|
.conditional_enforce_equal(&sender.key, &!&i.is_dummy)?;
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ pub mod tests {
|
|||||||
alloc::AllocVar,
|
alloc::AllocVar,
|
||||||
fields::{fp::FpVar, FieldVar},
|
fields::{fp::FpVar, FieldVar},
|
||||||
};
|
};
|
||||||
use ark_relations::r1cs::ConstraintSystem;
|
use ark_relations::gr1cs::ConstraintSystem;
|
||||||
use ark_std::rand::thread_rng;
|
use ark_std::rand::thread_rng;
|
||||||
use folding_schemes::transcript::poseidon::poseidon_canonical_config;
|
use folding_schemes::transcript::poseidon::poseidon_canonical_config;
|
||||||
const W: usize = 32;
|
const W: usize = 32;
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ pub struct UserVar<C: CurveGroup> {
|
|||||||
// z_i is a vec of FpVar<F> in sonobe
|
// z_i is a vec of FpVar<F> in sonobe
|
||||||
impl<C: CurveGroup> AllocVar<User<C>, C::ScalarField> for UserVar<C> {
|
impl<C: CurveGroup> AllocVar<User<C>, C::ScalarField> for UserVar<C> {
|
||||||
fn new_variable<T: std::borrow::Borrow<User<C>>>(
|
fn new_variable<T: std::borrow::Borrow<User<C>>>(
|
||||||
cs: impl Into<ark_relations::r1cs::Namespace<C::ScalarField>>,
|
cs: impl Into<ark_relations::gr1cs::Namespace<C::ScalarField>>,
|
||||||
f: impl FnOnce() -> Result<T, ark_relations::r1cs::SynthesisError>,
|
f: impl FnOnce() -> Result<T, ark_relations::gr1cs::SynthesisError>,
|
||||||
mode: ark_r1cs_std::prelude::AllocationMode,
|
mode: ark_r1cs_std::prelude::AllocationMode,
|
||||||
) -> Result<Self, ark_relations::r1cs::SynthesisError> {
|
) -> Result<Self, ark_relations::gr1cs::SynthesisError> {
|
||||||
let res = f()?;
|
let res = f()?;
|
||||||
let user = res.borrow();
|
let user = res.borrow();
|
||||||
let cs = cs.into().cs();
|
let cs = cs.into().cs();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use ark_r1cs_std::{
|
|||||||
groups::CurveVar,
|
groups::CurveVar,
|
||||||
prelude::Boolean,
|
prelude::Boolean,
|
||||||
};
|
};
|
||||||
use ark_relations::r1cs::{Namespace, SynthesisError};
|
use ark_relations::gr1cs::{Namespace, SynthesisError};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
datastructures::keypair::constraints::PublicKeyVar,
|
datastructures::keypair::constraints::PublicKeyVar,
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ use std::marker::PhantomData;
|
|||||||
|
|
||||||
use ark_crypto_primitives::{
|
use ark_crypto_primitives::{
|
||||||
crh::{
|
crh::{
|
||||||
poseidon::{constraints::{CRHParametersVar, TwoToOneCRHGadget}, TwoToOneCRH},
|
poseidon::{
|
||||||
|
constraints::{CRHParametersVar, TwoToOneCRHGadget},
|
||||||
|
TwoToOneCRH,
|
||||||
|
},
|
||||||
sha256::{
|
sha256::{
|
||||||
constraints::{Sha256Gadget, UnitVar},
|
constraints::{Sha256Gadget, UnitVar},
|
||||||
Sha256,
|
Sha256,
|
||||||
@@ -13,7 +16,7 @@ use ark_crypto_primitives::{
|
|||||||
};
|
};
|
||||||
use ark_ff::PrimeField;
|
use ark_ff::PrimeField;
|
||||||
use ark_r1cs_std::{convert::ToConstraintFieldGadget, fields::fp::FpVar, prelude::ToBytesGadget};
|
use ark_r1cs_std::{convert::ToConstraintFieldGadget, fields::fp::FpVar, prelude::ToBytesGadget};
|
||||||
use ark_relations::r1cs::SynthesisError;
|
use ark_relations::gr1cs::SynthesisError;
|
||||||
|
|
||||||
pub trait Accumulator<F: PrimeField, H: TwoToOneCRHScheme, T: TwoToOneCRHSchemeGadget<H, F>> {
|
pub trait Accumulator<F: PrimeField, H: TwoToOneCRHScheme, T: TwoToOneCRHSchemeGadget<H, F>> {
|
||||||
fn update(
|
fn update(
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ impl<F: PrimeField + Absorb, C: CurveGroup<BaseField = F>, CVar: CurveVar<C, F>>
|
|||||||
fn evaluate(
|
fn evaluate(
|
||||||
parameters: &Self::ParametersVar,
|
parameters: &Self::ParametersVar,
|
||||||
input: &Self::InputVar,
|
input: &Self::InputVar,
|
||||||
) -> Result<Self::OutputVar, ark_relations::r1cs::SynthesisError> {
|
) -> Result<Self::OutputVar, ark_relations::gr1cs::SynthesisError> {
|
||||||
let elements: Vec<FpVar<F>> = input.try_into()?;
|
let elements: Vec<FpVar<F>> = input.try_into()?;
|
||||||
CRHGadget::evaluate(parameters, &elements)
|
CRHGadget::evaluate(parameters, &elements)
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ impl<F: PrimeField + Absorb> CRHSchemeGadget<NonceCRH<F>, F> for NonceVarCRH<F>
|
|||||||
fn evaluate(
|
fn evaluate(
|
||||||
parameters: &Self::ParametersVar,
|
parameters: &Self::ParametersVar,
|
||||||
input: &Self::InputVar,
|
input: &Self::InputVar,
|
||||||
) -> Result<Self::OutputVar, ark_relations::r1cs::SynthesisError> {
|
) -> Result<Self::OutputVar, ark_relations::gr1cs::SynthesisError> {
|
||||||
CRHGadget::evaluate(parameters, [input.to_fp()?].as_slice())
|
CRHGadget::evaluate(parameters, [input.to_fp()?].as_slice())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ impl<C: CurveGroup<BaseField: PrimeField + Absorb>, CVar: CurveVar<C, C::BaseFie
|
|||||||
fn evaluate(
|
fn evaluate(
|
||||||
parameters: &Self::ParametersVar,
|
parameters: &Self::ParametersVar,
|
||||||
input: &Self::InputVar,
|
input: &Self::InputVar,
|
||||||
) -> Result<Self::OutputVar, ark_relations::r1cs::SynthesisError> {
|
) -> Result<Self::OutputVar, ark_relations::gr1cs::SynthesisError> {
|
||||||
let key = input.key.to_constraint_field()?;
|
let key = input.key.to_constraint_field()?;
|
||||||
CRHGadget::evaluate(parameters, &key)
|
CRHGadget::evaluate(parameters, &key)
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ impl<F: PrimeField + Absorb, C: CurveGroup<BaseField = F>, CVar: CurveVar<C, F>>
|
|||||||
fn evaluate(
|
fn evaluate(
|
||||||
parameters: &Self::ParametersVar,
|
parameters: &Self::ParametersVar,
|
||||||
input: &Self::InputVar,
|
input: &Self::InputVar,
|
||||||
) -> Result<Self::OutputVar, ark_relations::r1cs::SynthesisError> {
|
) -> Result<Self::OutputVar, ark_relations::gr1cs::SynthesisError> {
|
||||||
let bool_as_fp: FpVar<F> = input.is_dummy.clone().into();
|
let bool_as_fp: FpVar<F> = input.is_dummy.clone().into();
|
||||||
let pk_point = input.pk.key.to_constraint_field()?;
|
let pk_point = input.pk.key.to_constraint_field()?;
|
||||||
let mut input = Vec::from([input.amount.clone(), bool_as_fp]);
|
let mut input = Vec::from([input.amount.clone(), bool_as_fp]);
|
||||||
@@ -137,7 +137,7 @@ impl<F: PrimeField + Absorb> CRHSchemeGadget<BlockCRH<F>, F> for BlockVarCRH<F>
|
|||||||
fn evaluate(
|
fn evaluate(
|
||||||
parameters: &Self::ParametersVar,
|
parameters: &Self::ParametersVar,
|
||||||
input: &Self::InputVar,
|
input: &Self::InputVar,
|
||||||
) -> Result<Self::OutputVar, ark_relations::r1cs::SynthesisError> {
|
) -> Result<Self::OutputVar, ark_relations::gr1cs::SynthesisError> {
|
||||||
CRHGadget::evaluate(
|
CRHGadget::evaluate(
|
||||||
parameters,
|
parameters,
|
||||||
&[
|
&[
|
||||||
|
|||||||
@@ -181,8 +181,8 @@ pub mod tests {
|
|||||||
};
|
};
|
||||||
use ark_ff::UniformRand;
|
use ark_ff::UniformRand;
|
||||||
use ark_grumpkin::{constraints::GVar, Projective};
|
use ark_grumpkin::{constraints::GVar, Projective};
|
||||||
use ark_r1cs_std::{alloc::AllocVar, R1CSVar};
|
use ark_r1cs_std::{alloc::AllocVar, GR1CSVar};
|
||||||
use ark_relations::r1cs::ConstraintSystem;
|
use ark_relations::gr1cs::ConstraintSystem;
|
||||||
use ark_std::rand::thread_rng;
|
use ark_std::rand::thread_rng;
|
||||||
use folding_schemes::transcript::poseidon::poseidon_canonical_config;
|
use folding_schemes::transcript::poseidon::poseidon_canonical_config;
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ use ark_r1cs_std::{
|
|||||||
convert::ToBitsGadget,
|
convert::ToBitsGadget,
|
||||||
fields::fp::FpVar,
|
fields::fp::FpVar,
|
||||||
prelude::{Boolean, CurveVar, EqGadget, FieldVar},
|
prelude::{Boolean, CurveVar, EqGadget, FieldVar},
|
||||||
R1CSVar,
|
GR1CSVar,
|
||||||
};
|
};
|
||||||
use ark_relations::r1cs::SynthesisError;
|
use ark_relations::gr1cs::SynthesisError;
|
||||||
use ark_std::{cmp::max, rand::Rng, UniformRand};
|
use ark_std::{cmp::max, rand::Rng, UniformRand};
|
||||||
|
|
||||||
pub struct Schnorr {}
|
pub struct Schnorr {}
|
||||||
@@ -208,7 +208,7 @@ mod tests {
|
|||||||
use ark_ff::{BigInteger, UniformRand};
|
use ark_ff::{BigInteger, UniformRand};
|
||||||
use ark_grumpkin::{constraints::GVar, Projective};
|
use ark_grumpkin::{constraints::GVar, Projective};
|
||||||
use ark_r1cs_std::prelude::AllocVar;
|
use ark_r1cs_std::prelude::AllocVar;
|
||||||
use ark_relations::r1cs::ConstraintSystem;
|
use ark_relations::gr1cs::ConstraintSystem;
|
||||||
use ark_std::rand::thread_rng;
|
use ark_std::rand::thread_rng;
|
||||||
use num::{BigUint, Zero};
|
use num::{BigUint, Zero};
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ use ark_r1cs_std::{
|
|||||||
eq::EqGadget,
|
eq::EqGadget,
|
||||||
fields::fp::FpVar,
|
fields::fp::FpVar,
|
||||||
prelude::Boolean,
|
prelude::Boolean,
|
||||||
R1CSVar,
|
GR1CSVar,
|
||||||
};
|
};
|
||||||
use ark_r1cs_std::{prelude::ToBitsGadget, select::CondSelectGadget};
|
use ark_r1cs_std::{prelude::ToBitsGadget, select::CondSelectGadget};
|
||||||
use ark_relations::r1cs::{ConstraintSystemRef, Namespace, SynthesisError};
|
use ark_relations::gr1cs::{ConstraintSystemRef, Namespace, SynthesisError};
|
||||||
use std::{borrow::Borrow, ops::Not};
|
use std::{borrow::Borrow, ops::Not};
|
||||||
|
|
||||||
use super::{MerkleSparseTreePath, MerkleSparseTreeTwoPaths, SparseConfig};
|
use super::{MerkleSparseTreePath, MerkleSparseTreeTwoPaths, SparseConfig};
|
||||||
@@ -400,7 +400,7 @@ mod test {
|
|||||||
use ark_crypto_primitives::crh::CRHScheme;
|
use ark_crypto_primitives::crh::CRHScheme;
|
||||||
use ark_grumpkin::constraints::GVar;
|
use ark_grumpkin::constraints::GVar;
|
||||||
use ark_grumpkin::Projective;
|
use ark_grumpkin::Projective;
|
||||||
use ark_relations::r1cs::ConstraintSystem;
|
use ark_relations::gr1cs::ConstraintSystem;
|
||||||
use folding_schemes::transcript::poseidon::poseidon_canonical_config;
|
use folding_schemes::transcript::poseidon::poseidon_canonical_config;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
Reference in New Issue
Block a user