mirror of
https://github.com/arnaucube/hash-chain-sonobe.git
synced 2026-01-19 20:21:32 +01:00
update to latest Sonobe version & arkworks v0.5.0
This commit is contained in:
38
Cargo.toml
38
Cargo.toml
@@ -6,23 +6,23 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
ark-groth16 = { version = "^0.4.0" }
|
||||
ark-pallas = {version="0.4.0", features=["r1cs"]}
|
||||
ark-vesta = {version="0.4.0", features=["r1cs"]}
|
||||
ark-bn254 = { version = "0.4.0", features = ["r1cs"] }
|
||||
ark-grumpkin = {version="0.4.0", features=["r1cs"]}
|
||||
ark-ec = "0.4.1"
|
||||
ark-ff = "0.4.1"
|
||||
ark-r1cs-std = { version = "0.4.0", default-features = false }
|
||||
ark-relations = { version = "0.4.0", default-features = false }
|
||||
ark-snark = { version = "^0.4.0", default-features = false }
|
||||
ark-poly-commit = "^0.4.0"
|
||||
ark-crypto-primitives = { version = "^0.4.0", default-features = false, features = [
|
||||
ark-groth16 = { version = "^0.5.0" }
|
||||
ark-pallas = {version="0.5.0", features=["r1cs"]}
|
||||
ark-vesta = {version="0.5.0", features=["r1cs"]}
|
||||
ark-bn254 = { version = "0.5.0", features = ["r1cs"] }
|
||||
ark-grumpkin = {version="0.5.0", features=["r1cs"]}
|
||||
ark-ec = "0.5.0"
|
||||
ark-ff = "0.5.0"
|
||||
ark-r1cs-std = { version = "0.5.0", default-features = false }
|
||||
ark-relations = { version = "0.5.0", default-features = false }
|
||||
ark-snark = { version = "^0.5.0", default-features = false }
|
||||
ark-poly-commit = "^0.5.0"
|
||||
ark-crypto-primitives = { version = "^0.5.0", default-features = false, features = [
|
||||
"r1cs",
|
||||
"sponge",
|
||||
"crh",
|
||||
] }
|
||||
ark-std = "0.4.0"
|
||||
ark-std = "0.5.0"
|
||||
color-eyre = "0.6.2"
|
||||
num-bigint = "0.4.3"
|
||||
# Note: for testing purposes we use the 'light-test' feature when importing
|
||||
@@ -30,7 +30,7 @@ num-bigint = "0.4.3"
|
||||
# this feature (but then the DeciderETH circuit is bigger and takes more time
|
||||
# to compute).
|
||||
folding-schemes = { git = "https://github.com/privacy-scaling-explorations/sonobe", package = "folding-schemes", features=["light-test"]}
|
||||
folding-schemes-circom = { git = "https://github.com/privacy-scaling-explorations/sonobe", package = "frontends", optional=true}
|
||||
folding-schemes-circom = { git = "https://github.com/privacy-scaling-explorations/sonobe", package = "experimental-frontends", optional=true}
|
||||
solidity-verifiers = { git = "https://github.com/privacy-scaling-explorations/sonobe", package = "solidity-verifiers"}
|
||||
serde = "1.0.198"
|
||||
serde_json = "1.0.116"
|
||||
@@ -45,13 +45,3 @@ rand = "0.8.5"
|
||||
[features]
|
||||
default = []
|
||||
experimental-frontends = ["dep:folding-schemes-circom"]
|
||||
|
||||
|
||||
[patch.crates-io]
|
||||
# patch ark_curves to use a cherry-picked version which contains
|
||||
# bn254::constraints & grumpkin for v0.4.0 (once arkworks v0.5.0 is released
|
||||
# this will no longer be needed)
|
||||
ark-bn254 = { git = "https://github.com/arnaucube/ark-curves-cherry-picked", branch="cherry-pick"}
|
||||
ark-grumpkin = { git = "https://github.com/arnaucube/ark-curves-cherry-picked", branch="cherry-pick"}
|
||||
ark-circom = { git = "https://github.com/arnaucube/circom-compat" }
|
||||
ark-r1cs-std = { git = "https://github.com/winderica/r1cs-std", branch="cherry-pick" }
|
||||
|
||||
@@ -15,19 +15,16 @@ mod tests {
|
||||
use ark_crypto_primitives::sponge::{
|
||||
constraints::CryptographicSpongeVar,
|
||||
poseidon::{constraints::PoseidonSpongeVar, PoseidonConfig, PoseidonSponge},
|
||||
Absorb, CryptographicSponge,
|
||||
CryptographicSponge,
|
||||
};
|
||||
use ark_r1cs_std::fields::fp::FpVar;
|
||||
use ark_r1cs_std::{alloc::AllocVar, eq::EqGadget};
|
||||
use ark_r1cs_std::{bits::uint8::UInt8, boolean::Boolean, ToBitsGadget, ToBytesGadget};
|
||||
use ark_relations::r1cs::{
|
||||
ConstraintSynthesizer, ConstraintSystem, ConstraintSystemRef, SynthesisError,
|
||||
};
|
||||
|
||||
use folding_schemes::transcript::poseidon::poseidon_canonical_config;
|
||||
|
||||
use crate::utils::tests::*;
|
||||
|
||||
/// Test circuit to be folded
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PoseidonChainCircuit<F: PrimeField, const N: usize, const HASHES_PER_STEP: usize> {
|
||||
@@ -66,9 +63,8 @@ mod tests {
|
||||
hashes_per_step: usize,
|
||||
) -> Vec<Fr> {
|
||||
let mut z_i: Vec<Fr> = z_0.clone();
|
||||
let mut sponge = PoseidonSponge::<Fr>::new(&poseidon_config);
|
||||
for _ in 0..n_steps {
|
||||
let mut sponge = PoseidonSponge::<Fr>::new(&poseidon_config);
|
||||
|
||||
for _ in 0..hashes_per_step {
|
||||
sponge.absorb(&z_i);
|
||||
z_i = sponge.squeeze_field_elements(1);
|
||||
|
||||
@@ -15,7 +15,11 @@ mod tests {
|
||||
use ark_crypto_primitives::crh::sha256::{constraints::Sha256Gadget, digest::Digest, Sha256};
|
||||
use ark_r1cs_std::fields::fp::FpVar;
|
||||
use ark_r1cs_std::{alloc::AllocVar, eq::EqGadget};
|
||||
use ark_r1cs_std::{bits::uint8::UInt8, boolean::Boolean, ToBitsGadget, ToBytesGadget};
|
||||
use ark_r1cs_std::{
|
||||
boolean::Boolean,
|
||||
convert::{ToBitsGadget, ToBytesGadget},
|
||||
uint8::UInt8,
|
||||
};
|
||||
use ark_relations::r1cs::{
|
||||
ConstraintSynthesizer, ConstraintSystem, ConstraintSystemRef, SynthesisError,
|
||||
};
|
||||
@@ -47,7 +51,7 @@ mod tests {
|
||||
for _ in 0..HASHES_PER_STEP {
|
||||
let mut sha256_var = Sha256Gadget::default();
|
||||
sha256_var.update(&b).unwrap();
|
||||
b = sha256_var.finalize()?.to_bytes()?;
|
||||
b = sha256_var.finalize()?.to_bytes_le()?;
|
||||
}
|
||||
|
||||
// update z_i = z_{i+1}
|
||||
@@ -55,7 +59,7 @@ mod tests {
|
||||
.iter()
|
||||
.map(|e| {
|
||||
let bits = e.to_bits_le().unwrap();
|
||||
Boolean::<F>::le_bits_to_fp_var(&bits).unwrap()
|
||||
Boolean::<F>::le_bits_to_fp(&bits).unwrap()
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,11 @@ mod tests {
|
||||
use ark_crypto_primitives::crh::sha256::{constraints::Sha256Gadget, digest::Digest, Sha256};
|
||||
use ark_ff::PrimeField;
|
||||
use ark_r1cs_std::fields::fp::FpVar;
|
||||
use ark_r1cs_std::{bits::uint8::UInt8, boolean::Boolean, ToBitsGadget, ToBytesGadget};
|
||||
use ark_r1cs_std::{
|
||||
boolean::Boolean,
|
||||
convert::{ToBitsGadget, ToBytesGadget},
|
||||
uint8::UInt8,
|
||||
};
|
||||
use ark_relations::r1cs::{ConstraintSystemRef, SynthesisError};
|
||||
use std::marker::PhantomData;
|
||||
use std::time::Instant;
|
||||
@@ -77,14 +81,14 @@ mod tests {
|
||||
for _ in 0..HASHES_PER_STEP {
|
||||
let mut sha256_var = Sha256Gadget::default();
|
||||
sha256_var.update(&b).unwrap();
|
||||
b = sha256_var.finalize()?.to_bytes()?;
|
||||
b = sha256_var.finalize()?.to_bytes_le()?;
|
||||
}
|
||||
|
||||
let z_i1: Vec<FpVar<F>> = b
|
||||
.iter()
|
||||
.map(|e| {
|
||||
let bits = e.to_bits_le().unwrap();
|
||||
Boolean::<F>::le_bits_to_fp_var(&bits).unwrap()
|
||||
Boolean::<F>::le_bits_to_fp(&bits).unwrap()
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
@@ -21,7 +21,11 @@ mod tests {
|
||||
|
||||
use ark_crypto_primitives::crh::sha256::{constraints::Sha256Gadget, digest::Digest, Sha256};
|
||||
use ark_r1cs_std::fields::fp::FpVar;
|
||||
use ark_r1cs_std::{bits::uint8::UInt8, boolean::Boolean, ToBitsGadget, ToBytesGadget};
|
||||
use ark_r1cs_std::{
|
||||
boolean::Boolean,
|
||||
convert::{ToBitsGadget, ToBytesGadget},
|
||||
uint8::UInt8,
|
||||
};
|
||||
use ark_relations::r1cs::{ConstraintSystemRef, SynthesisError};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
@@ -95,14 +99,14 @@ mod tests {
|
||||
for _ in 0..HASHES_PER_STEP {
|
||||
let mut sha256_var = Sha256Gadget::default();
|
||||
sha256_var.update(&b).unwrap();
|
||||
b = sha256_var.finalize()?.to_bytes()?;
|
||||
b = sha256_var.finalize()?.to_bytes_le()?;
|
||||
}
|
||||
|
||||
let z_i1: Vec<FpVar<F>> = b
|
||||
.iter()
|
||||
.map(|e| {
|
||||
let bits = e.to_bits_le().unwrap();
|
||||
Boolean::<F>::le_bits_to_fp_var(&bits).unwrap()
|
||||
Boolean::<F>::le_bits_to_fp(&bits).unwrap()
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user