diff --git a/goas/atomic_asset_transfer/common/src/lib.rs b/goas/atomic_asset_transfer/common/src/lib.rs index 2c9e323..dbc18c5 100644 --- a/goas/atomic_asset_transfer/common/src/lib.rs +++ b/goas/atomic_asset_transfer/common/src/lib.rs @@ -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) diff --git a/goas/atomic_asset_transfer/risc0_proofs/spend_zone_funds/src/main.rs b/goas/atomic_asset_transfer/risc0_proofs/spend_zone_funds/src/main.rs index ab89247..d4b59de 100644 --- a/goas/atomic_asset_transfer/risc0_proofs/spend_zone_funds/src/main.rs +++ b/goas/atomic_asset_transfer/risc0_proofs/spend_zone_funds/src/main.rs @@ -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!( diff --git a/goas/atomic_asset_transfer/risc0_proofs/zone_state/src/main.rs b/goas/atomic_asset_transfer/risc0_proofs/zone_state/src/main.rs index 29063f8..50216c6 100644 --- a/goas/atomic_asset_transfer/risc0_proofs/zone_state/src/main.rs +++ b/goas/atomic_asset_transfer/risc0_proofs/zone_state/src/main.rs @@ -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() { diff --git a/goas/cl/cl/src/input.rs b/goas/cl/cl/src/input.rs index 17b495c..af056a2 100644 --- a/goas/cl/cl/src/input.rs +++ b/goas/cl/cl/src/input.rs @@ -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) } }