Add evolved nonce
This commit is contained in:
parent
ca2c141d91
commit
5b03e070b5
|
@ -57,13 +57,11 @@ impl StateWitness {
|
|||
/// / \ / \
|
||||
/// events txs zoneid balances
|
||||
pub fn commit(&self) -> StateCommitment {
|
||||
let io_root = cl::merkle::node(self.events_root(), self.included_txs_root());
|
||||
|
||||
let root = cl::merkle::root([
|
||||
self.events_root(),
|
||||
self.included_txs_root(),
|
||||
zone_id,
|
||||
balances_root,
|
||||
self.zone_metadata.id(),
|
||||
self.balances_root(),
|
||||
]);
|
||||
|
||||
StateCommitment(root)
|
||||
|
|
|
@ -75,10 +75,7 @@ fn main() {
|
|||
);
|
||||
assert_eq!(
|
||||
out_zone_funds.output.nonce,
|
||||
in_zone_funds
|
||||
.input
|
||||
.nonce
|
||||
.evolve(&NullifierSecret::from_bytes([0; 16]))
|
||||
in_zone_funds.input.evolved_nonce()
|
||||
);
|
||||
// the state is propagated
|
||||
assert_eq!(
|
||||
|
|
|
@ -97,12 +97,7 @@ fn deposit(
|
|||
assert_eq!(zone_funds_in.nf_sk, NullifierSecret::from_bytes([0; 16])); // there is no secret in the zone funds
|
||||
assert_eq!(zone_funds_out.nf_pk, zone_funds_in.nf_sk.commit()); // the sk is the same
|
||||
// nonce is correctly evolved
|
||||
assert_eq!(
|
||||
zone_funds_out.nonce,
|
||||
zone_funds_in
|
||||
.nonce
|
||||
.evolve(&NullifierSecret::from_bytes([0; 16]))
|
||||
);
|
||||
assert_eq!(zone_funds_out.nonce, zone_funds_in.evolved_nonce());
|
||||
|
||||
// 5) Check zone state notes are correctly created
|
||||
assert_eq!(
|
||||
|
@ -114,12 +109,7 @@ fn deposit(
|
|||
assert_eq!(zone_note_in.note.unit, zone_note_out.note.unit);
|
||||
assert_eq!(zone_note_in.note.value, zone_note_out.note.value);
|
||||
// nonce is correctly evolved
|
||||
assert_eq!(
|
||||
zone_note_out.nonce,
|
||||
zone_note_in
|
||||
.nonce
|
||||
.evolve(&NullifierSecret::from_bytes([0; 16]))
|
||||
);
|
||||
assert_eq!(zone_note_out.nonce, zone_note_in.evolved_nonce());
|
||||
let nullifier = Nullifier::new(zone_note_in.nf_sk, zone_note_in.nonce);
|
||||
assert_eq!(nullifier, pub_inputs.nf);
|
||||
|
||||
|
@ -167,10 +157,7 @@ fn validate_zone_output(
|
|||
assert_eq!(output.note.unit, state.zone_metadata.unit); // the balance unit is the same as in the input
|
||||
|
||||
// the nonce is correctly evolved
|
||||
assert_eq!(
|
||||
output.nonce,
|
||||
input.nonce.evolve(&NullifierSecret::from_bytes([0; 16]))
|
||||
);
|
||||
assert_eq!(output.nonce, input.evolved_nonce());
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -41,13 +41,17 @@ impl InputWitness {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn evolved_nonce(&self) -> NullifierNonce {
|
||||
self.nonce.evolve(&self.nf_sk)
|
||||
}
|
||||
|
||||
pub fn evolve_output(&self, balance_blinding: BalanceWitness) -> crate::OutputWitness {
|
||||
crate::OutputWitness {
|
||||
note: self.note,
|
||||
balance_blinding,
|
||||
nf_pk: self.nf_sk.commit(),
|
||||
nonce: self.nonce.evolve(&self.nf_sk),
|
||||
}
|
||||
crate::OutputWitness {
|
||||
note: self.note,
|
||||
balance_blinding,
|
||||
nf_pk: self.nf_sk.commit(),
|
||||
nonce: self.evolved_nonce(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn nullifier(&self) -> Nullifier {
|
||||
|
@ -63,7 +67,7 @@ impl InputWitness {
|
|||
}
|
||||
|
||||
pub fn note_commitment(&self) -> crate::NoteCommitment {
|
||||
self.note.commit(self.nf_sk.commit(), self.nonce)
|
||||
self.note.commit(self.nf_sk.commit(), self.nonce)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue