Skip to content

Commit

Permalink
Trim blanks
Browse files Browse the repository at this point in the history
  • Loading branch information
osuketh committed Apr 17, 2019
1 parent 13760ee commit 4fc2d06
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 114 deletions.
2 changes: 1 addition & 1 deletion core/crypto/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub const PLAINTEXT_SIZE: usize = 16;
pub const CIPHERTEXT_SIZE: usize = 16;
// BLAKE2s invocation personalizations
/// BLAKE2s Personalization for CRH^ivk = BLAKE2s(ak | nk)
pub const KDF_PERSONALIZATION: &'static [u8; 8] = b"zech_KDF";
pub const KDF_PERSONALIZATION: &'static [u8; 8] = b"zech_KDF";
pub const MIMC_PERSONALIZATION: &'static [u8; 8] = b"zechMIMC";
pub const DEFAULT_MIMC_SEED: &[u8] = b"mimc";
pub const DEFAULT_MIMC_ROUND: usize = 97;
Expand Down
28 changes: 14 additions & 14 deletions core/crypto/src/mimc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// use pairing::{
// PrimeField,
// PrimeFieldRepr,
// Field,
// bls12_381::{Bls12},
// Field,
// bls12_381::{Bls12},
// };

// use blake2_rfc::blake2s::Blake2s;
Expand All @@ -20,33 +20,33 @@
// pub fn mimc_constants<'a, E>(
// seed: &'a[u8],
// scalar_field: E::Fs,
// rounds: u64
// rounds: u64
// ) -> Vec<E::Fs>
// where E: JubjubEngine
// {
// let mut res = Vec::with_capacity(DEFAULT_MIMC_ROUND);
// let mut preimage = seed;
// let mut preimage = seed;

// // let mut h = Blake2s::with_params(32, &[], &[], MIMC_PERSONALIZATION);
// // h.update(&preimage);
// // let mut tmp = &mut *(h.finalize().as_bytes());
// // res.push(tmp);

// for _ in 0..rounds {
// let mut h = Blake2s::with_params(32, &[], &[], MIMC_PERSONALIZATION);
// let mut h = Blake2s::with_params(32, &[], &[], MIMC_PERSONALIZATION);
// // tmp = &mut *tmp;
// h.update(preimage);
// preimage = h.finalize();
// res.push(E::Fs::to_uniform(preimage.as_ref()));
// h.update(preimage);
// preimage = h.finalize();

// res.push(E::Fs::to_uniform(preimage.as_ref()));
// }

// assert_eq!(res.len(), 91);
// res
// }

// This is an implementation of MiMC.
// See http://eprint.iacr.org/2016/492 for more
// See http://eprint.iacr.org/2016/492 for more
// information about this construction.
// pub fn mimc<E: JubjubEngine>(
// mut x: E::Fs,
Expand All @@ -59,13 +59,13 @@
// for i in 0..DEFAULT_MIMC_ROUND {
// let mut tmp1 = x;
// tmp1.add_assign(&k);
// tmp1.add_assign(&constants[i]);
// tmp1.add_assign(&constants[i]);
// let tmp2 = tmp1;
// tmp1.square();
// tmp1.square();
// tmp1.square();
// tmp1.mul_assign(&tmp2);

// tmp1.mul_assign(&tmp2);
// x = tmp1;
// }
// x.add_assign(&k);
Expand Down
2 changes: 1 addition & 1 deletion core/jubjub/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub const PROOF_GENERATION_KEY_BASE_GENERATOR_PERSONALIZATION: &'static [u8; 8]
pub const VALUE_COMMITMENT_GENERATOR_PERSONALIZATION: &'static [u8; 8]
= b"Zcash_cv";

/// BLAKE2s Personalization for the value encryption generator
/// BLAKE2s Personalization for the value encryption generator
pub const NULLIFIER_POSITION_IN_TREE_GENERATOR_PERSONALIZATION: &'static [u8; 8]
= b"Zcash_J_";

Expand Down
14 changes: 7 additions & 7 deletions core/jubjub/src/curve/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use ::std::fmt::Debug;
#[cfg(not(feature = "std"))]
use crate::std::fmt::Debug;

pub fn test_suite<E: JubjubEngine>(params: &E::Params)
pub fn test_suite<E: JubjubEngine>(params: &E::Params)
where <E as pairing::Engine>::Fr: Debug
{
test_back_and_forth::<E>(params);
Expand All @@ -32,8 +32,8 @@ pub fn test_suite<E: JubjubEngine>(params: &E::Params)
test_addition_associativity::<E>(params);
test_order::<E>(params);
test_mul_associativity::<E>(params);
test_loworder::<E>(params);
test_read_write::<E>(params);
test_loworder::<E>(params);
test_read_write::<E>(params);
}

fn is_on_mont_curve<E: JubjubEngine, P: JubjubParams<E>>(
Expand Down Expand Up @@ -259,10 +259,10 @@ fn test_read_write<E: JubjubEngine>(params: &E::Params) {
for _ in 0..1000 {
let e = edwards::Point::<E, _>::rand(rng, params);

let mut v = vec![];
e.write(&mut v).unwrap();
let mut v = vec![];
e.write(&mut v).unwrap();

let e2 = edwards::Point::read(&mut &v[..], params).unwrap();
let e2 = edwards::Point::read(&mut &v[..], params).unwrap();

assert!(e == e2);
}
Expand Down Expand Up @@ -310,7 +310,7 @@ fn test_back_and_forth<E: JubjubEngine>(params: &E::Params) {
}
}

fn test_jubjub_params<E: JubjubEngine>(params: &E::Params)
fn test_jubjub_params<E: JubjubEngine>(params: &E::Params)
where <E as pairing::Engine>::Fr: Debug
{
// a = -1
Expand Down
48 changes: 24 additions & 24 deletions core/proofs/src/circuit_mimc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// use pairing::{
// PrimeField,
// PrimeFieldRepr,
// Field,
// Field,
// };

// // We'll use these interfaces to construct our circuit.
Expand Down Expand Up @@ -50,7 +50,7 @@
// use zcrypto::constants::DEFAULT_MIMC_ROUND;

// /// This is an implementation of MiMC.
// /// See http://eprint.iacr.org/2016/492 for more
// /// See http://eprint.iacr.org/2016/492 for more
// /// information about this construction.
// fn mimc<E: JubjubEngine>(
// mut x: E::Fs,
Expand All @@ -63,13 +63,13 @@
// for i in 0..DEFAULT_MIMC_ROUND {
// let mut tmp1 = x;
// tmp1.add_assign(&k);
// tmp1.add_assign(&constants[i]);
// tmp1.add_assign(&constants[i]);
// let mut tmp2 = tmp1;
// tmp1.square();
// tmp1.square();
// tmp1.square();
// tmp1.mul_assign(&tmp2);

// tmp1.mul_assign(&tmp2);
// x = tmp1;
// }
// x.add_assign(&k);
Expand All @@ -94,18 +94,18 @@
// cs: &mut CS
// ) -> Result<(), SynthesisError>
// {
// assert_eq!(self.constants.len(), DEFAULT_MIMC_ROUND);
// assert_eq!(self.constants.len(), DEFAULT_MIMC_ROUND);

// // Allocate the plaintext.
// let mut x_value = self.x;
// // let x = boolean::field_into_boolean_vec_le(
// // cs.namespace(|| "plaintext x"),
// // cs.namespace(|| "plaintext x"),
// // self.x
// // )?;

// // let k_value = self.k;
// // let k = boolean::field_into_boolean_vec_le(
// // cs.namespace(|| "key k"),
// // cs.namespace(|| "key k"),
// // self.k
// // )?;
// let mut x = cs.alloc(|| "plaintext x", || {
Expand All @@ -121,7 +121,7 @@
// for i in 0..DEFAULT_MIMC_ROUND {
// // x, k := (x + k + Ci)^7
// let cs = &mut cs.namespace(|| format!("round {}", i));


// // tmp2 = (x + k + Ci)^2
// let mut tmp2_value = x_value.map(|mut e| {
Expand All @@ -145,7 +145,7 @@
// // let mut tmp4_value = tmp2_value.map(|mut e| {
// // e.square();
// // e
// // });
// // });

// // let mut tmp4 = cs.alloc(|| "tmp4", || {
// // tmp4_value.ok_or(SynthesisError::AssignmentMissing)
Expand Down Expand Up @@ -183,7 +183,7 @@

// // let mut tmp1 = cs.alloc(|| "tmp1", || {
// // tmp1_value.ok_or(SynthesisError::AssignmentMissing)
// // })?;
// // })?;

// // // tmp7 = (x + k + Ci)^7
// // let mut tmp7_value = tmp6_value.map(|mut e| {
Expand All @@ -200,7 +200,7 @@
// // |lc| lc + tmp6,
// // |lc| lc + x + k + (self.constants[i], CS::one()),
// // |lc| lc + tmp7
// // );
// // );

// // if i == DEFAULT_MIMC_ROUND - 1 {
// // let mut res_value = tmp7_value.map(|mut e| {
Expand All @@ -211,29 +211,29 @@
// // let mut res = cs.alloc_input(|| "res", || {
// // res_value.ok_or(SynthesisError::AssignmentMissing)
// // })?;

// // cs.enforce(
// // || "res = k + tmp7",
// // |lc| lc + tmp7,
// // |lc| lc + CS::one(),
// // |lc| lc + res - k
// // );
// // );
// // } else {
// // x = tmp7;
// // x_value = tmp7_value;
// // }
// }
// // }
// }

// Ok(())
// }
// }

// #[cfg(test)]
// use pairing::bls12_381::*;
// // use rand::{SeedableRng, Rng, XorShiftRng};
// // use rand::{SeedableRng, Rng, XorShiftRng};
// use super::circuit_test::TestConstraintSystem;
// use scrypto::jubjub::{JubjubBls12, fs, edwards};
// use scrypto::jubjub::{JubjubBls12, fs, edwards};


// #[test]
// fn test_mimc() {
Expand All @@ -243,21 +243,21 @@
// let params = &JubjubBls12::new();

// // Generate the MiMC round constants

// let constants = (0..DEFAULT_MIMC_ROUND).map(|_| {
// let crng: fs::Fs = rng.gen();
// Some(crng)
// }).collect::<Vec<_>>();
// }).collect::<Vec<_>>();


// // Just a place to put the proof data, so we can
// // benchmark deserialization.
// // let mut proof_vec = vec![];

// // Generate a random preimage and compute the image
// let x: fs::Fs = rng.gen();
// let k: fs::Fs = rng.gen();
// // let image = mimc::<Bls12>(x, k, &constants);
// // let image = mimc::<Bls12>(x, k, &constants);

// let instance = MiMC {
// x: Some(x),
Expand All @@ -271,7 +271,7 @@
// instance.synthesize(&mut cs).unwrap();
// println!("{:?}", cs.num_constraints());
// assert!(cs.is_satisfied());


// // let start = Instant::now();
// // {
Expand Down
Loading

0 comments on commit 4fc2d06

Please sign in to comment.