From db5bee8a496e6927c950d1fe9e64fc6e0d81a551 Mon Sep 17 00:00:00 2001 From: Timofey Luin Date: Mon, 28 Aug 2023 22:07:26 +0300 Subject: [PATCH] clean up --- .../src/gadget/crypto/hash2curve.rs | 3 +-- .../src/gadget/crypto/sha256.rs | 10 ++++----- .../src/gadget/crypto/sha256_wide.rs | 6 ++--- ligthclient-circuits/src/lib.rs | 2 +- ligthclient-circuits/src/sync_step_circuit.rs | 2 +- ligthclient-circuits/src/util.rs | 15 ++++++------- prover/src/args.rs | 22 ++++++++++++------- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/ligthclient-circuits/src/gadget/crypto/hash2curve.rs b/ligthclient-circuits/src/gadget/crypto/hash2curve.rs index 9f62f988..9b142b4b 100644 --- a/ligthclient-circuits/src/gadget/crypto/hash2curve.rs +++ b/ligthclient-circuits/src/gadget/crypto/hash2curve.rs @@ -245,7 +245,6 @@ impl<'a, S: Spec, F: Field, HC: HashChip + 'a> HashToCurveChip<'a, S, F, HC> .digest::<192>(msg_prime.into(), ctx, region)? .output_bytes; - b_vals.insert( 0, hash_chip @@ -623,8 +622,8 @@ mod test { use std::vec; use std::{cell::RefCell, marker::PhantomData}; - use crate::gadget::crypto::Sha256Chip; use crate::gadget::crypto::sha256::SpreadConfig; + use crate::gadget::crypto::Sha256Chip; use crate::sha256_circuit::Sha256CircuitConfig; use crate::table::Sha256Table; use crate::util::{print_fq2_dev, Challenges, IntoWitness}; diff --git a/ligthclient-circuits/src/gadget/crypto/sha256.rs b/ligthclient-circuits/src/gadget/crypto/sha256.rs index 3b0d749a..cd581de4 100644 --- a/ligthclient-circuits/src/gadget/crypto/sha256.rs +++ b/ligthclient-circuits/src/gadget/crypto/sha256.rs @@ -121,10 +121,7 @@ impl<'a, F: Field> HashChip for Sha256Chip<'a, F> { // for _ in 0..remaining_byte_size { // assigned_input_bytes.push(assign_byte(0u8)); // } - assert_eq!( - assigned_input_bytes.len(), - MAX_INPUT_SIZE - ); + assert_eq!(assigned_input_bytes.len(), MAX_INPUT_SIZE); // todo: only check for no already assigned // for &assigned in assigned_input_bytes.iter() { // range.range_check(ctx, assigned, 8); @@ -374,9 +371,10 @@ mod test { let ctx = builder.main(0); - let mut result = sha256.digest::<64>(self.test_input.clone(), ctx, &mut region)?; + let mut result = + sha256.digest::<64>(self.test_input.clone(), ctx, &mut region)?; - for _ in 0..512*2 { + for _ in 0..512 * 2 { result = sha256.digest::<64>( HashInput::TwoToOne( result.output_bytes.into(), diff --git a/ligthclient-circuits/src/gadget/crypto/sha256_wide.rs b/ligthclient-circuits/src/gadget/crypto/sha256_wide.rs index 399eeac0..c761519b 100644 --- a/ligthclient-circuits/src/gadget/crypto/sha256_wide.rs +++ b/ligthclient-circuits/src/gadget/crypto/sha256_wide.rs @@ -24,7 +24,7 @@ use halo2_proofs::{ plonk::{Assigned, Error}, }; -use super::{HashChip, AssignedHashResult}; +use super::{AssignedHashResult, HashChip}; const SHA256_CONTEXT_ID: usize = usize::MAX; @@ -261,9 +261,7 @@ mod test { use std::{cell::RefCell, marker::PhantomData}; use crate::table::Sha256Table; - use crate::util::{ - full_prover, full_verifier, gen_pkey, Challenges, IntoWitness, - }; + use crate::util::{full_prover, full_verifier, gen_pkey, Challenges, IntoWitness}; use super::*; use ark_std::{end_timer, start_timer}; diff --git a/ligthclient-circuits/src/lib.rs b/ligthclient-circuits/src/lib.rs index 3f2ed8b7..79c14feb 100644 --- a/ligthclient-circuits/src/lib.rs +++ b/ligthclient-circuits/src/lib.rs @@ -14,8 +14,8 @@ pub mod util; pub mod witness; pub mod committee_update_circuit; -pub mod sync_step_circuit; mod sha256_circuit; +pub mod sync_step_circuit; mod poseidon; mod ssz_merkle; diff --git a/ligthclient-circuits/src/sync_step_circuit.rs b/ligthclient-circuits/src/sync_step_circuit.rs index 2a219dc3..cbd91b8e 100644 --- a/ligthclient-circuits/src/sync_step_circuit.rs +++ b/ligthclient-circuits/src/sync_step_circuit.rs @@ -465,7 +465,7 @@ mod tests { use rayon::iter::ParallelIterator; use rayon::prelude::{IndexedParallelIterator, IntoParallelIterator}; use snark_verifier_sdk::{ - evm::{evm_verify, gen_evm_proof_shplonk, encode_calldata}, + evm::{encode_calldata, evm_verify, gen_evm_proof_shplonk}, halo2::{aggregation::AggregationCircuit, gen_proof_shplonk, gen_snark_shplonk}, CircuitExt, SHPLONK, }; diff --git a/ligthclient-circuits/src/util.rs b/ligthclient-circuits/src/util.rs index 1f0c686d..9ccdd6e7 100644 --- a/ligthclient-circuits/src/util.rs +++ b/ligthclient-circuits/src/util.rs @@ -1,7 +1,7 @@ //! Common utility traits and functions. mod common; -use std::{cell::RefCell, rc::Rc, path::Path}; +use std::{cell::RefCell, path::Path, rc::Rc}; pub use common::*; @@ -16,7 +16,7 @@ use halo2curves::bn256; pub use proof::*; use halo2_base::{ - gates::builder::{GateThreadBuilder, FlexGateConfigParams}, + gates::builder::{FlexGateConfigParams, GateThreadBuilder}, safe_types::{GateInstructions, RangeChip, RangeInstructions}, utils::ScalarField, AssignedValue, Context, QuantumCell, @@ -42,8 +42,10 @@ use eth_types::*; use halo2_proofs::{ circuit::{Layouter, Region, Value}, plonk::{ - Challenge, ConstraintSystem, Error, Expression, FirstPhase, SecondPhase, VirtualCells, ProvingKey, - }, poly::kzg::commitment::ParamsKZG, + Challenge, ConstraintSystem, Error, Expression, FirstPhase, ProvingKey, SecondPhase, + VirtualCells, + }, + poly::kzg::commitment::ParamsKZG, }; /// Helper trait that implements functionality to represent a generic type as @@ -76,10 +78,7 @@ pub trait AppCircuitExt: CircuitExt + Default { fn setup( config: &FlexGateConfigParams, out: Option<&Path>, - ) -> ( - ParamsKZG, - ProvingKey, - ); + ) -> (ParamsKZG, ProvingKey); } /// Randomness used in circuits. diff --git a/prover/src/args.rs b/prover/src/args.rs index 4855e533..1205c7e3 100644 --- a/prover/src/args.rs +++ b/prover/src/args.rs @@ -19,7 +19,11 @@ pub struct SyncStepArgs { #[clap(long, short, default_value = "proof")] pub out: Out, - #[clap(long, short, default_value = "./ligthclient-circuits/config/sync_step.json")] + #[clap( + long, + short, + default_value = "./ligthclient-circuits/config/sync_step.json" + )] pub config_path: PathBuf, #[clap(long, short, default_value = "./build")] @@ -27,18 +31,21 @@ pub struct SyncStepArgs { #[clap(long, short, default_value = "./sync_state.json")] pub input_path: PathBuf, - + #[clap(index = 1, help = "path to output", default_value = ".")] - pub path_out: PathBuf, + pub path_out: PathBuf, } - #[derive(Clone, clap::Args)] pub struct CommitteeUpdateArgs { #[clap(long, short, default_value = "proof")] pub out: Out, - #[clap(long, short, default_value = "./ligthclient-circuits/config/committee_update.json")] + #[clap( + long, + short, + default_value = "./ligthclient-circuits/config/committee_update.json" + )] pub config_path: PathBuf, #[clap(long, short, default_value = "./build")] @@ -46,12 +53,11 @@ pub struct CommitteeUpdateArgs { #[clap(long, short, default_value = "./sync_state.json")] pub input_path: PathBuf, - + #[clap(index = 1, help = "path to output", default_value = ".")] - pub path_out: PathBuf, + pub path_out: PathBuf, } - #[derive(Clone, Debug, PartialEq, EnumString)] pub enum Out { #[strum(serialize = "proof")]