Skip to content
Permalink
Browse files

Remove a few unnecessary clones

  • Loading branch information
huitseeker authored and Pratyush committed Dec 2, 2019
1 parent 7228d06 commit 8d9330f8c36ac565920cdc1eaf1a06d418650d11
@@ -180,7 +180,7 @@ where
P::miller_loop(
cs.ns(|| "Miller loop 4"),
&[a_prep, pvk.g_gamma_pc.clone()],
&[pvk.h_gamma_pc.clone(), b_prep],
&[pvk.h_gamma_pc, b_prep],
)?
};
let test2 = P::final_exponentiation(cs.ns(|| "Final Exp 2"), &test2_exp)?;
@@ -261,7 +261,7 @@ where

let given_commitment =
RecCGadget::OutputGadget::alloc(&mut declare_cs.ns(|| "Commitment"), || {
Ok(record.commitment().clone())
Ok(record.commitment())
})?;
old_rec_comms.push(given_commitment.clone());

@@ -255,7 +255,7 @@ where

let given_commitment =
RecCGadget::OutputGadget::alloc(&mut declare_cs.ns(|| "Commitment"), || {
Ok(record.commitment().clone())
Ok(record.commitment())
})?;
old_rec_comms.push(given_commitment.clone());

@@ -73,8 +73,8 @@ fn test_execute_constraint_systems() {
);

// Set the input records for our transaction to be the initial dummy records.
let old_records = vec![genesis_record.clone(); NUM_INPUT_RECORDS];
let old_asks = vec![genesis_address.secret_key.clone(); NUM_INPUT_RECORDS];
let old_records = vec![genesis_record; NUM_INPUT_RECORDS];
let old_asks = vec![genesis_address.secret_key; NUM_INPUT_RECORDS];

// Construct new records.

@@ -86,12 +86,12 @@ fn test_execute_constraint_systems() {
// Create a payload.
let new_payload = [1u8; 32];
// Set the new record's predicate to be the "always-accept" predicate.
let new_predicate = Predicate::new(pred_nizk_vk_bytes.clone());
let new_predicate = Predicate::new(pred_nizk_vk_bytes);

let new_apks = vec![new_address.public_key.clone(); NUM_OUTPUT_RECORDS];
let new_apks = vec![new_address.public_key; NUM_OUTPUT_RECORDS];
let new_payloads = vec![new_payload.clone(); NUM_OUTPUT_RECORDS];
let new_birth_predicates = vec![new_predicate.clone(); NUM_OUTPUT_RECORDS];
let new_death_predicates = vec![new_predicate.clone(); NUM_OUTPUT_RECORDS];
let new_death_predicates = vec![new_predicate; NUM_OUTPUT_RECORDS];
let new_dummy_flags = vec![false; NUM_OUTPUT_RECORDS];
let auxiliary = [122u8; 32];
let memo = [238u8; 32];
@@ -97,12 +97,12 @@ fn integration_test() {
// Create a payload.
let new_payload = [2u8; 32];
// Set the new records' predicate to be the "always-accept" predicate.
let new_predicate = Predicate::new(genesis_pred_vk_bytes.clone());
let new_predicate = Predicate::new(genesis_pred_vk_bytes);

let new_apks = vec![new_address.public_key.clone(); NUM_OUTPUT_RECORDS];
let new_apks = vec![new_address.public_key; NUM_OUTPUT_RECORDS];
let new_payloads = vec![new_payload.clone(); NUM_OUTPUT_RECORDS];
let new_birth_predicates = vec![new_predicate.clone(); NUM_OUTPUT_RECORDS];
let new_death_predicates = vec![new_predicate.clone(); NUM_OUTPUT_RECORDS];
let new_death_predicates = vec![new_predicate; NUM_OUTPUT_RECORDS];
let new_dummy_flags = vec![false; NUM_OUTPUT_RECORDS];

let auxiliary = [3u8; 32];
@@ -76,8 +76,8 @@ impl<P: Fp2Parameters<Fp = ConstraintF>, ConstraintF: PrimeField> FieldGadget<Fp
#[inline]
fn get_variable(&self) -> Self::Variable {
(
self.c0.get_variable().clone(),
self.c1.get_variable().clone(),
self.c0.get_variable(),
self.c1.get_variable(),
)
}

@@ -39,15 +39,15 @@ impl<P: Bls12Parameters> PairingGadget<P> {
TwistType::M => {
let c0 = coeffs.0.clone();
let mut c1 = coeffs.1.clone();
let c2 = Fp2G::<P>::new(p.y.clone(), zero.clone());
let c2 = Fp2G::<P>::new(p.y.clone(), zero);

c1.c0 = c1.c0.mul(cs.ns(|| "mul c1.c0"), &p.x)?;
c1.c1 = c1.c1.mul(cs.ns(|| "mul c1.c1"), &p.x)?;
*f = f.mul_by_014(cs.ns(|| "sparse mul f"), &c0, &c1, &c2)?;
Ok(())
},
TwistType::D => {
let c0 = Fp2G::<P>::new(p.y.clone(), zero.clone());
let c0 = Fp2G::<P>::new(p.y.clone(), zero);
let mut c1 = coeffs.0.clone();
let c2 = coeffs.1.clone();

@@ -108,7 +108,7 @@ mod test {
let (ans1_g, ans1_n) = {
let ans_g = PairingGadget::pairing(
cs.ns(|| "pair(sa, b)"),
sa_prep_g.clone(),
sa_prep_g,
b_prep_g.clone(),
)
.unwrap();
@@ -120,7 +120,7 @@ mod test {
let ans_g = PairingGadget::pairing(
cs.ns(|| "pair(a, sb)"),
a_prep_g.clone(),
sb_prep_g.clone(),
sb_prep_g,
)
.unwrap();
let ans_n = Bls12_377::pairing(a, sb);
@@ -129,11 +129,11 @@ mod test {

let (ans3_g, ans3_n) = {
let s_iter = BitIterator::new(s.into_repr())
.map(|bit| Boolean::constant(bit))
.map(Boolean::constant)
.collect::<Vec<_>>();

let mut ans_g =
PairingGadget::pairing(cs.ns(|| "pair(a, b)"), a_prep_g.clone(), b_prep_g.clone())
PairingGadget::pairing(cs.ns(|| "pair(a, b)"), a_prep_g, b_prep_g)
.unwrap();
let mut ans_n = Bls12_377::pairing(a, b);
ans_n = ans_n.pow(s.into_repr());
@@ -212,7 +212,7 @@ impl<ConstraintF: Field> ConstraintSystem<ConstraintF> for TestConstraintSystem<
{
let name = name_fn().into();
let path = compute_path(&self.current_namespace, name.clone());
self.set_named_obj(path.clone(), NamedObject::Namespace);
self.set_named_obj(path, NamedObject::Namespace);
self.current_namespace.push(name);
}

0 comments on commit 8d9330f

Please sign in to comment.
You can’t perform that action at this time.