mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-02-12 18:15:49 +00:00
Use correct personalization for merkle tree.
This commit is contained in:
parent
c6cf0c718c
commit
7bb630a4b1
@ -259,7 +259,7 @@ impl<'a, E: JubjubEngine> Circuit<E> for Spend<'a, E> {
|
|||||||
|
|
||||||
cur = pedersen_hash::pedersen_hash(
|
cur = pedersen_hash::pedersen_hash(
|
||||||
cs.namespace(|| "computation of pedersen hash"),
|
cs.namespace(|| "computation of pedersen hash"),
|
||||||
pedersen_hash::Personalization::MerkleTree(tree_depth - i),
|
pedersen_hash::Personalization::MerkleTree(i),
|
||||||
&preimage,
|
&preimage,
|
||||||
self.params
|
self.params
|
||||||
)?.x; // Injective encoding
|
)?.x; // Injective encoding
|
||||||
@ -527,7 +527,7 @@ fn test_input_circuit_with_bls12_381() {
|
|||||||
|
|
||||||
assert!(cs.is_satisfied());
|
assert!(cs.is_satisfied());
|
||||||
assert_eq!(cs.num_constraints(), 97379);
|
assert_eq!(cs.num_constraints(), 97379);
|
||||||
assert_eq!(cs.hash(), "1c5298e7f9ec46f227d3622968b092bfbc1d15a9f45fcf4910b6edb60fe4f0f8");
|
assert_eq!(cs.hash(), "3920570cfb4c9cec807d09f996d6d0745176d50e8adea0e66709628b1dd31267");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -565,6 +565,6 @@ fn test_output_circuit_with_bls12_381() {
|
|||||||
|
|
||||||
assert!(cs.is_satisfied());
|
assert!(cs.is_satisfied());
|
||||||
assert_eq!(cs.num_constraints(), 7827);
|
assert_eq!(cs.num_constraints(), 7827);
|
||||||
assert_eq!(cs.hash(), "a76f4ae0b3e078b6d3d44bf6d9c1d121884b30f74c97f77f114978196f4949b3");
|
assert_eq!(cs.hash(), "155b1aaf4ed4abb1af67481c7e099adafd6a7edd097926b1f9f6b68b1cbe2742");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ mod test {
|
|||||||
|
|
||||||
let res = pedersen_hash(
|
let res = pedersen_hash(
|
||||||
cs.namespace(|| "pedersen hash"),
|
cs.namespace(|| "pedersen hash"),
|
||||||
Personalization::NoteCommitment,
|
Personalization::MerkleTree(1),
|
||||||
&input_bools,
|
&input_bools,
|
||||||
params
|
params
|
||||||
).unwrap();
|
).unwrap();
|
||||||
@ -171,7 +171,7 @@ mod test {
|
|||||||
assert!(cs.is_satisfied());
|
assert!(cs.is_satisfied());
|
||||||
|
|
||||||
let expected = ::pedersen_hash::pedersen_hash::<Bls12, _>(
|
let expected = ::pedersen_hash::pedersen_hash::<Bls12, _>(
|
||||||
Personalization::NoteCommitment,
|
Personalization::MerkleTree(1),
|
||||||
input.clone().into_iter(),
|
input.clone().into_iter(),
|
||||||
params
|
params
|
||||||
).into_xy();
|
).into_xy();
|
||||||
@ -181,7 +181,7 @@ mod test {
|
|||||||
|
|
||||||
// Test against the output of a different personalization
|
// Test against the output of a different personalization
|
||||||
let unexpected = ::pedersen_hash::pedersen_hash::<Bls12, _>(
|
let unexpected = ::pedersen_hash::pedersen_hash::<Bls12, _>(
|
||||||
Personalization::AnotherPersonalization,
|
Personalization::MerkleTree(0),
|
||||||
input.into_iter(),
|
input.into_iter(),
|
||||||
params
|
params
|
||||||
).into_xy();
|
).into_xy();
|
||||||
|
@ -3,7 +3,6 @@ use pairing::*;
|
|||||||
|
|
||||||
pub enum Personalization {
|
pub enum Personalization {
|
||||||
NoteCommitment,
|
NoteCommitment,
|
||||||
AnotherPersonalization,
|
|
||||||
MerkleTree(usize)
|
MerkleTree(usize)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11,11 +10,9 @@ impl Personalization {
|
|||||||
pub fn get_bits(&self) -> Vec<bool> {
|
pub fn get_bits(&self) -> Vec<bool> {
|
||||||
match *self {
|
match *self {
|
||||||
Personalization::NoteCommitment =>
|
Personalization::NoteCommitment =>
|
||||||
vec![false, false, false, false, false, false],
|
vec![true, true, true, true, true, true],
|
||||||
Personalization::AnotherPersonalization =>
|
Personalization::MerkleTree(num) =>
|
||||||
vec![false, false, false, false, false, true],
|
(0..6).map(|i| (num >> i) & 1 == 1).collect()
|
||||||
Personalization::MerkleTree(_) =>
|
|
||||||
vec![false, false, false, false, true, false],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user