Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
nulltea committed Aug 28, 2023
1 parent 6921a5c commit db5bee8
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
3 changes: 1 addition & 2 deletions ligthclient-circuits/src/gadget/crypto/hash2curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ impl<'a, S: Spec, F: Field, HC: HashChip<F> + 'a> HashToCurveChip<'a, S, F, HC>
.digest::<192>(msg_prime.into(), ctx, region)?
.output_bytes;


b_vals.insert(
0,
hash_chip
Expand Down Expand Up @@ -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};
Expand Down
10 changes: 4 additions & 6 deletions ligthclient-circuits/src/gadget/crypto/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ impl<'a, F: Field> HashChip<F> 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);
Expand Down Expand Up @@ -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(),
Expand Down
6 changes: 2 additions & 4 deletions ligthclient-circuits/src/gadget/crypto/sha256_wide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion ligthclient-circuits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ligthclient-circuits/src/sync_step_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
15 changes: 7 additions & 8 deletions ligthclient-circuits/src/util.rs
Original file line number Diff line number Diff line change
@@ -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::*;

Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -76,10 +78,7 @@ pub trait AppCircuitExt<F: Field>: CircuitExt<F> + Default {
fn setup(
config: &FlexGateConfigParams,
out: Option<&Path>,
) -> (
ParamsKZG<bn256::Bn256>,
ProvingKey<bn256::G1Affine>,
);
) -> (ParamsKZG<bn256::Bn256>, ProvingKey<bn256::G1Affine>);
}

/// Randomness used in circuits.
Expand Down
22 changes: 14 additions & 8 deletions prover/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,45 @@ 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")]
pub build_dir: PathBuf,

#[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")]
pub build_dir: PathBuf,

#[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")]
Expand Down

0 comments on commit db5bee8

Please sign in to comment.