Fix remaining cases of cm -> cmu.

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2020-08-21 20:43:19 +01:00
parent ee6c21f95b
commit 20c5096793
4 changed files with 20 additions and 20 deletions

View File

@ -1005,19 +1005,19 @@ mod tests {
assert_eq!(tree.size(), 0);
let mut witnesses = vec![];
let mut last_cm = None;
let mut last_cmu = None;
let mut paths_i = 0;
let mut witness_ser_i = 0;
for i in 0..16 {
let cm = hex::decode(commitments[i]).unwrap();
let cmu = hex::decode(commitments[i]).unwrap();
let cm = Node::new(cm[..].try_into().unwrap());
let cmu = Node::new(cmu[..].try_into().unwrap());
// Witness here
witnesses.push((TestIncrementalWitness::from_tree(&tree), last_cm));
witnesses.push((TestIncrementalWitness::from_tree(&tree), last_cmu));
// Now append a commitment to the tree
assert!(tree.append(cm).is_ok());
assert!(tree.append(cmu).is_ok());
// Size incremented by one.
assert_eq!(tree.size(), i + 1);
@ -1030,7 +1030,7 @@ mod tests {
for (witness, leaf) in witnesses.as_mut_slice() {
// Append the same commitment to all the witnesses
assert!(witness.append(cm).is_ok());
assert!(witness.append(cmu).is_ok());
if let Some(leaf) = leaf {
let path = witness.path().expect("should be able to create a path");
@ -1054,7 +1054,7 @@ mod tests {
assert_eq!(witness.root(), tree.root());
}
last_cm = Some(cm);
last_cmu = Some(cmu);
}
// Tree should be full now

View File

@ -368,14 +368,14 @@ impl<P: consensus::Parameters, R: RngCore + CryptoRng> Builder<P, R> {
merkle_path: MerklePath<Node>,
) -> Result<(), Error> {
// Consistency check: all anchors must equal the first one
let cm = Node::new(note.cmu().into());
let cmu = Node::new(note.cmu().into());
if let Some(anchor) = self.anchor {
let path_root: bls12_381::Scalar = merkle_path.root(cm).into();
let path_root: bls12_381::Scalar = merkle_path.root(cmu).into();
if path_root != anchor {
return Err(Error::AnchorMismatch);
}
} else {
self.anchor = Some(merkle_path.root(cm).into())
self.anchor = Some(merkle_path.root(cmu).into())
}
let alpha = jubjub::Fr::random(&mut self.rng);

View File

@ -576,8 +576,8 @@ fn test_input_circuit_with_bls12_381() {
};
let mut position = 0u64;
let cm = note.cmu();
let mut cur = cm.clone();
let cmu = note.cmu();
let mut cur = cmu.clone();
for (i, val) in auth_path.clone().into_iter().enumerate() {
let (uncle, b) = val.unwrap();
@ -635,7 +635,7 @@ fn test_input_circuit_with_bls12_381() {
"d37c738e83df5d9b0bb6495ac96abf21bcb2697477e2c15c2c7916ff7a3b6a89"
);
assert_eq!(cs.get("randomization of note commitment/x3/num"), cm);
assert_eq!(cs.get("randomization of note commitment/x3/num"), cmu);
assert_eq!(cs.num_inputs(), 8);
assert_eq!(cs.get_input(0, "ONE"), bls12_381::Scalar::one());
@ -757,8 +757,8 @@ fn test_input_circuit_with_bls12_381_external_test_vectors() {
};
let mut position = 0u64;
let cm = note.cmu();
let mut cur = cm.clone();
let cmu = note.cmu();
let mut cur = cmu.clone();
for (i, val) in auth_path.clone().into_iter().enumerate() {
let (uncle, b) = val.unwrap();
@ -816,7 +816,7 @@ fn test_input_circuit_with_bls12_381_external_test_vectors() {
"d37c738e83df5d9b0bb6495ac96abf21bcb2697477e2c15c2c7916ff7a3b6a89"
);
assert_eq!(cs.get("randomization of note commitment/x3/num"), cm);
assert_eq!(cs.get("randomization of note commitment/x3/num"), cmu);
assert_eq!(cs.num_inputs(), 8);
assert_eq!(cs.get_input(0, "ONE"), bls12_381::Scalar::one());
@ -904,7 +904,7 @@ fn test_output_circuit_with_bls12_381() {
"c26d5cdfe6ccd65c03390902c02e11393ea6bb96aae32a7f2ecb12eb9103faee"
);
let expected_cm = payment_address
let expected_cmu = payment_address
.create_note(
value_commitment.value,
Rseed::BeforeZip212(commitment_randomness),
@ -936,7 +936,7 @@ fn test_output_circuit_with_bls12_381() {
cs.get_input(4, "epk/y/input variable"),
expected_epk.get_v()
);
assert_eq!(cs.get_input(5, "commitment/input variable"), expected_cm);
assert_eq!(cs.get_input(5, "commitment/input variable"), expected_cmu);
}
}
}

View File

@ -95,7 +95,7 @@ impl SaplingVerificationContext {
pub fn check_output(
&mut self,
cv: jubjub::ExtendedPoint,
cm: bls12_381::Scalar,
cmu: bls12_381::Scalar,
epk: jubjub::ExtendedPoint,
zkproof: Proof<Bls12>,
verifying_key: &PreparedVerifyingKey<Bls12>,
@ -121,7 +121,7 @@ impl SaplingVerificationContext {
public_input[2] = x;
public_input[3] = y;
}
public_input[4] = cm;
public_input[4] = cmu;
// Verify the proof
verify_proof(verifying_key, &zkproof, &public_input[..]).is_ok()