Skip to content

Commit

Permalink
chore: apply clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
enricobottazzi committed Nov 28, 2023
1 parent a734d94 commit 76d4b5e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion zk_prover/src/chips/merkle_sum_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct MerkleSumTreeConfig {
/// Chip that performs various constraints related to a Merkle Sum Tree data structure such as:
///
/// * `s * swap_bit * (1 - swap_bit) = 0` (if `bool_and_swap_selector` is toggled). It basically enforces that swap_bit is either a 0 or 1.
/// * `s * (swap_bit * 2 * (elelment_r_cur - elelment_l_cur) - (elelment_l_next - elelment_l_cur) - (elelment_r_cur - elelment_r_next)) = 0`. Enforces that if the swap_bit is equal to 1, the values will be swapped on the next row (if `bool_and_swap_selector` is toggled).
/// * `s * (swap_bit * 2 * (element_r_cur - element_l_cur) - (element_l_next - element_l_cur) - (element_r_cur - element_r_next)) = 0`. Enforces that if the swap_bit is equal to 1, the values will be swapped on the next row (if `bool_and_swap_selector` is toggled).
/// If the swap_bit is equal to 0, the values will remain the same on the next row (if `bool_and_swap_selector` is toggled).
/// * `s * (left_balance + right_balance - computed_sum)`. It constraints the computed sum to be equal to the sum of the left and right balances (if `sum_selector` is toggled).
#[derive(Debug, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions zk_prover/src/chips/range/range_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct RangeCheckConfig<const N_BYTES: usize> {
lookup_enable_selector: Selector,
}

/// Helper chip that verfiies that the value witnessed in a given cell lies within a given range defined by N_BYTES.
/// Helper chip that verifies that the value witnessed in a given cell lies within a given range defined by N_BYTES.
/// For example, Let's say we want to constraint 0x1f2f3f4f to be within the range N_BYTES=4.
///
/// `z(0) = 0x1f2f3f4f`
Expand All @@ -47,7 +47,7 @@ pub struct RangeCheckConfig<const N_BYTES: usize> {
///
/// The column z contains the witnessed value to be checked at offset 0
/// At offset i, the column z contains the value z(i+1) = (z(i) - k(i)) / 2^8 (shift right by 8 bits) where k(i) is the i-th decomposition big-endian of `value`
/// The contraints that are enforced are:
/// The constraints that are enforced are:
/// - z(i) - 2^8⋅z(i+1) ∈ lookup_u8 (enabled by lookup_enable_selector at offset [0, N_BYTES - 1])
/// - z(N_BYTES) == 0
#[derive(Debug, Clone)]
Expand Down
4 changes: 2 additions & 2 deletions zk_prover/src/circuits/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fn fix_verifier_sol(yul_code_path: PathBuf) -> Result<String, Box<dyn std::error
if let Some(m) = m {
let mstore = m.get(1).unwrap().as_str();
let addr = m.get(2).unwrap().as_str();
let addr_as_num = u32::from_str_radix(addr, 10)?;
let addr_as_num = addr.parse::<u32>()?;
let transcript_addr = format!("{:#x}", addr_as_num);
transcript_addrs.push(addr_as_num);
line = line.replace(
Expand All @@ -238,7 +238,7 @@ fn fix_verifier_sol(yul_code_path: PathBuf) -> Result<String, Box<dyn std::error
if let Some(m) = m {
let mstore = m.get(1).unwrap().as_str();
let addr = m.get(2).unwrap().as_str();
let addr_as_num = u32::from_str_radix(addr, 10)?;
let addr_as_num = addr.parse::<u32>()?;
let transcript_addr = format!("{:#x}", addr_as_num);
transcript_addrs.push(addr_as_num);
line = line.replace(
Expand Down
4 changes: 2 additions & 2 deletions zk_prover/src/merkle_sum_tree/utils/csv_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn parse_csv_to_entries<P: AsRef<Path>, const N_ASSETS: usize, const N_BYTES
}

let mut entries = Vec::new();
let mut balances_acc: Vec<BigUint> = vec![BigUint::from(0 as usize); N_ASSETS];
let mut balances_acc: Vec<BigUint> = vec![BigUint::from(0_usize); N_ASSETS];

for result in rdr.deserialize() {
let record: HashMap<String, String> = result?;
Expand Down Expand Up @@ -63,7 +63,7 @@ pub fn parse_csv_to_entries<P: AsRef<Path>, const N_ASSETS: usize, const N_BYTES

// Iterate through the balance accumulator and throw error if any balance is not in range 0, 2 ^ (8 * N_BYTES):
for balance in balances_acc {
if balance >= BigUint::from(2 as usize).pow(8 * N_BYTES as u32) {
if balance >= BigUint::from(2_usize).pow(8 * N_BYTES as u32) {
return Err(
"Accumulated balance is not in the expected range, proof generation will fail!"
.into(),
Expand Down

0 comments on commit 76d4b5e

Please sign in to comment.