mirror of
https://github.com/logos-co/nomos-pocs.git
synced 2025-01-12 10:24:48 +00:00
Add evolved nonce
This commit is contained in:
parent
ca2c141d91
commit
5b03e070b5
@ -57,13 +57,11 @@ impl StateWitness {
|
|||||||
/// / \ / \
|
/// / \ / \
|
||||||
/// events txs zoneid balances
|
/// events txs zoneid balances
|
||||||
pub fn commit(&self) -> StateCommitment {
|
pub fn commit(&self) -> StateCommitment {
|
||||||
let io_root = cl::merkle::node(self.events_root(), self.included_txs_root());
|
|
||||||
|
|
||||||
let root = cl::merkle::root([
|
let root = cl::merkle::root([
|
||||||
self.events_root(),
|
self.events_root(),
|
||||||
self.included_txs_root(),
|
self.included_txs_root(),
|
||||||
zone_id,
|
self.zone_metadata.id(),
|
||||||
balances_root,
|
self.balances_root(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
StateCommitment(root)
|
StateCommitment(root)
|
||||||
|
@ -75,10 +75,7 @@ fn main() {
|
|||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
out_zone_funds.output.nonce,
|
out_zone_funds.output.nonce,
|
||||||
in_zone_funds
|
in_zone_funds.input.evolved_nonce()
|
||||||
.input
|
|
||||||
.nonce
|
|
||||||
.evolve(&NullifierSecret::from_bytes([0; 16]))
|
|
||||||
);
|
);
|
||||||
// the state is propagated
|
// the state is propagated
|
||||||
assert_eq!(
|
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_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
|
assert_eq!(zone_funds_out.nf_pk, zone_funds_in.nf_sk.commit()); // the sk is the same
|
||||||
// nonce is correctly evolved
|
// nonce is correctly evolved
|
||||||
assert_eq!(
|
assert_eq!(zone_funds_out.nonce, zone_funds_in.evolved_nonce());
|
||||||
zone_funds_out.nonce,
|
|
||||||
zone_funds_in
|
|
||||||
.nonce
|
|
||||||
.evolve(&NullifierSecret::from_bytes([0; 16]))
|
|
||||||
);
|
|
||||||
|
|
||||||
// 5) Check zone state notes are correctly created
|
// 5) Check zone state notes are correctly created
|
||||||
assert_eq!(
|
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.unit, zone_note_out.note.unit);
|
||||||
assert_eq!(zone_note_in.note.value, zone_note_out.note.value);
|
assert_eq!(zone_note_in.note.value, zone_note_out.note.value);
|
||||||
// nonce is correctly evolved
|
// nonce is correctly evolved
|
||||||
assert_eq!(
|
assert_eq!(zone_note_out.nonce, zone_note_in.evolved_nonce());
|
||||||
zone_note_out.nonce,
|
|
||||||
zone_note_in
|
|
||||||
.nonce
|
|
||||||
.evolve(&NullifierSecret::from_bytes([0; 16]))
|
|
||||||
);
|
|
||||||
let nullifier = Nullifier::new(zone_note_in.nf_sk, zone_note_in.nonce);
|
let nullifier = Nullifier::new(zone_note_in.nf_sk, zone_note_in.nonce);
|
||||||
assert_eq!(nullifier, pub_inputs.nf);
|
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
|
assert_eq!(output.note.unit, state.zone_metadata.unit); // the balance unit is the same as in the input
|
||||||
|
|
||||||
// the nonce is correctly evolved
|
// the nonce is correctly evolved
|
||||||
assert_eq!(
|
assert_eq!(output.nonce, input.evolved_nonce());
|
||||||
output.nonce,
|
|
||||||
input.nonce.evolve(&NullifierSecret::from_bytes([0; 16]))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
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 {
|
pub fn evolve_output(&self, balance_blinding: BalanceWitness) -> crate::OutputWitness {
|
||||||
crate::OutputWitness {
|
crate::OutputWitness {
|
||||||
note: self.note,
|
note: self.note,
|
||||||
balance_blinding,
|
balance_blinding,
|
||||||
nf_pk: self.nf_sk.commit(),
|
nf_pk: self.nf_sk.commit(),
|
||||||
nonce: self.nonce.evolve(&self.nf_sk),
|
nonce: self.evolved_nonce(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn nullifier(&self) -> Nullifier {
|
pub fn nullifier(&self) -> Nullifier {
|
||||||
@ -63,7 +67,7 @@ impl InputWitness {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn note_commitment(&self) -> crate::NoteCommitment {
|
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…
x
Reference in New Issue
Block a user