Skip to content

Commit

Permalink
remove comments, style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dvush committed Jun 1, 2020
1 parent 50d2660 commit 305f2e5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ Cargo.lock

emergency_output_*

go_to_env.sh
go_to_env.sh
2 changes: 1 addition & 1 deletion bin/circuit-tests-debug
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
USAGE="Usage: zksync ciruit-tests [test_name,def all] [threads,def=1] [other_features(e.g) --nocapture]"
USAGE="Usage: zksync ciruit-tests-debug [test_name,def all] [threads,def=1] [other_features(e.g) --nocapture]"

if [ "$1" == "-h" ]; then
echo "$USAGE"
Expand Down
50 changes: 20 additions & 30 deletions core/circuit/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ impl<'a, E: RescueEngine + JubjubEngine> Circuit<E> for FranklinCircuit<'a, E> {

let old_root = rolling_root.clone();

// let old_root =
// CircuitElement::from_number(cs.namespace(|| "old_root"), rolling_root.clone())?;

// first chunk of block should always have number 0
let mut next_chunk_number = zero;

Expand Down Expand Up @@ -317,11 +314,6 @@ impl<'a, E: RescueEngine + JubjubEngine> Circuit<E> for FranklinCircuit<'a, E> {

let final_root = root_from_operator_after_fees;

// let final_root = CircuitElement::from_number(
// cs.namespace(|| "final_root"),
// root_from_operator_after_fees,
// )?;

{
// Now it's time to pack the initial SHA256 hash due to Ethereum BE encoding
// and start rolling the hash
Expand Down Expand Up @@ -350,15 +342,17 @@ impl<'a, E: RescueEngine + JubjubEngine> Circuit<E> for FranklinCircuit<'a, E> {

// Perform bit decomposition with an explicit in-field check
// and change to MSB first bit order
let mut old_root_le_bits = old_root
.into_bits_le_strict(cs.namespace(|| "old root hash into LE bits strict"))?;
assert_eq!(old_root_le_bits.len(), E::Fr::NUM_BITS as usize);
resize_grow_only(&mut old_root_le_bits, 256, Boolean::constant(false));
let mut old_root_be_bits = old_root_le_bits;
old_root_be_bits.reverse();
assert_eq!(old_root_be_bits.len(), 256);
let old_root_be_bits = {
let mut old_root_le_bits = old_root
.into_bits_le_strict(cs.namespace(|| "old root hash into LE bits strict"))?;
assert_eq!(old_root_le_bits.len(), E::Fr::NUM_BITS as usize);
resize_grow_only(&mut old_root_le_bits, 256, Boolean::constant(false));
let mut old_root_be_bits = old_root_le_bits;
old_root_be_bits.reverse();
assert_eq!(old_root_be_bits.len(), 256);
old_root_be_bits
};
pack_bits.extend(old_root_be_bits);
// pack_bits.extend(old_root.into_padded_be_bits(256));

hash_block = sha256::sha256(cs.namespace(|| "hash old_root"), &pack_bits)?;

Expand All @@ -367,15 +361,17 @@ impl<'a, E: RescueEngine + JubjubEngine> Circuit<E> for FranklinCircuit<'a, E> {

// Perform bit decomposition with an explicit in-field check
// and change to MSB first bit order
let mut final_root_le_bits = final_root
.into_bits_le_strict(cs.namespace(|| "final root hash into LE bits strict"))?;
assert_eq!(final_root_le_bits.len(), E::Fr::NUM_BITS as usize);
resize_grow_only(&mut final_root_le_bits, 256, Boolean::constant(false));
let mut final_root_be_bits = final_root_le_bits;
final_root_be_bits.reverse();
assert_eq!(final_root_be_bits.len(), 256);
let final_root_be_bits = {
let mut final_root_le_bits = final_root
.into_bits_le_strict(cs.namespace(|| "final root hash into LE bits strict"))?;
assert_eq!(final_root_le_bits.len(), E::Fr::NUM_BITS as usize);
resize_grow_only(&mut final_root_le_bits, 256, Boolean::constant(false));
let mut final_root_be_bits = final_root_le_bits;
final_root_be_bits.reverse();
assert_eq!(final_root_be_bits.len(), 256);
final_root_be_bits
};
pack_bits.extend(final_root_be_bits);
// pack_bits.extend(final_root.into_padded_be_bits(256));

hash_block = sha256::sha256(cs.namespace(|| "hash with new_root"), &pack_bits)?;

Expand Down Expand Up @@ -1160,12 +1156,6 @@ impl<'a, E: RescueEngine + JubjubEngine> FranklinCircuit<'a, E> {
&is_account_empty,
)?;

// let is_pubkey_correct = Boolean::and(
// cs.namespace(|| "acc not empty and keys are not the same"),
// &is_pub_equal_to_previous.not(),
// &is_account_empty.not(),
// )?
// .not();
is_valid_flags.push(is_pubkey_correct);

//verify correct amounts
Expand Down
2 changes: 0 additions & 2 deletions core/circuit/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ pub fn is_rescue_signature_verified<E: RescueEngine + JubjubEngine, CS: Constrai
.pk
.get_x()
.into_bits_le_strict(cs.namespace(|| "pk_x_bits into bits strict"))?;
// .into_bits_le_fixed(cs.namespace(|| "pk_x_bits"), FR_BIT_WIDTH)?;

assert_eq!(pk_x_serialized.len(), FR_BIT_WIDTH);

Expand All @@ -310,7 +309,6 @@ pub fn is_rescue_signature_verified<E: RescueEngine + JubjubEngine, CS: Constrai
.r
.get_x()
.into_bits_le_strict(cs.namespace(|| "r_x_bits into bits strict"))?;
// .into_bits_le_fixed(cs.namespace(|| "r_x_bits"), FR_BIT_WIDTH)?;

assert_eq!(r_x_serialized.len(), FR_BIT_WIDTH);

Expand Down

0 comments on commit 305f2e5

Please sign in to comment.