From 26c7c9f71cf494b15ab53b27f1be6aba2a5797fe Mon Sep 17 00:00:00 2001 From: moana Date: Fri, 31 May 2024 17:18:06 +0200 Subject: [PATCH 1/2] circuits: Rename `crossover` to `deposit` --- circuits/CHANGELOG.md | 2 ++ circuits/README.md | 2 +- circuits/src/transaction.rs | 25 ++++++++++++------------- circuits/tests/transaction.rs | 14 +++++++------- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/circuits/CHANGELOG.md b/circuits/CHANGELOG.md index 3d3be3b..7487eef 100644 --- a/circuits/CHANGELOG.md +++ b/circuits/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Remove `ViewKey` from `TxOutputNote::new()` parameters [#191] - Make `rng` the first param in `TxInputNote::new` [#189] +- Rename `crossover` to `deposit` [#190] ## [0.1.0] - 2024-05-22 @@ -29,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#191]: https://github.com/dusk-network/phoenix/issues/191 +[#190]: https://github.com/dusk-network/phoenix/issues/190 [#189]: https://github.com/dusk-network/phoenix/issues/189 [#179]: https://github.com/dusk-network/phoenix/issues/179 [#177]: https://github.com/dusk-network/phoenix/issues/177 diff --git a/circuits/README.md b/circuits/README.md index a79192b..345e2d0 100644 --- a/circuits/README.md +++ b/circuits/README.md @@ -8,4 +8,4 @@ This library contains the implementation of the Phoenix-circuits, to prove, in z 2. Ownership: the sender holds the note secret key for every note that is about to be spent. 3. Nullification: the nullifier is calculated correctly. 4. Minting: the value commitment for the newly minted notes are computed correctly. -5. Balance integrity: the sum of the values of all spent notes is equal to the sum of the values of all minted notes + the gas fee + a crossover, where a crossover refers to funds being transfered to a contract. +5. Balance integrity: the sum of the values of all spent notes is equal to the sum of the values of all minted notes + the gas fee + a deposit, where a deposit refers to funds being transfered to a contract. diff --git a/circuits/src/transaction.rs b/circuits/src/transaction.rs index c185f59..38f3ff0 100644 --- a/circuits/src/transaction.rs +++ b/circuits/src/transaction.rs @@ -181,8 +181,7 @@ impl TxOutputNote { /// correctly. /// 5. Balance integrity: the sum of the values of all [`TxInputNote`] is equal /// to the sum of the values of all [`TxOutputNote`] + the gas fee + a -/// crossover, where a crossover refers to funds being transfered to a -/// contract. +/// deposit, where a deposit refers to funds being transfered to a contract. /// /// The gadget appends the following public input values to the circuit: /// - `skeleton_hash` @@ -190,7 +189,7 @@ impl TxOutputNote { /// - `[nullifier; I]` /// - `[output_value_commitment; 2]` /// - `max_fee` -/// - `crossover` +/// - `deposit` pub fn gadget( composer: &mut Composer, skeleton_hash: &BlsScalar, @@ -198,7 +197,7 @@ pub fn gadget( tx_input_notes: &[TxInputNote; I], tx_output_notes: &[TxOutputNote; TX_OUTPUT_NOTES], max_fee: u64, - crossover: u64, + deposit: u64, ) -> Result<(), Error> { let skeleton_hash_pi = composer.append_public(*skeleton_hash); let root_pi = composer.append_public(*root); @@ -307,16 +306,16 @@ pub fn gadget( } let max_fee = composer.append_public(max_fee); - let crossover = composer.append_public(crossover); + let deposit = composer.append_public(deposit); - // SUM UP THE CROSSOVER AND THE MAX FEE + // SUM UP THE DEPOSIT AND THE MAX FEE let constraint = Constraint::new() .left(1) .a(tx_output_sum) .right(1) .b(max_fee) .fourth(1) - .d(crossover); + .d(deposit); tx_output_sum = composer.gate_add(constraint); // VERIFY BALANCE @@ -332,7 +331,7 @@ pub struct TxCircuit { tx_output_notes: [TxOutputNote; TX_OUTPUT_NOTES], skeleton_hash: BlsScalar, root: BlsScalar, - crossover: u64, + deposit: u64, max_fee: u64, } @@ -377,7 +376,7 @@ impl Default for TxCircuit { let tx_output_notes = [tx_output_note_1, tx_output_note_2]; let root = BlsScalar::default(); - let crossover = u64::default(); + let deposit = u64::default(); let max_fee = u64::default(); Self { @@ -385,7 +384,7 @@ impl Default for TxCircuit { tx_output_notes, skeleton_hash, root, - crossover, + deposit, max_fee, } } @@ -398,7 +397,7 @@ impl TxCircuit { tx_output_notes: [TxOutputNote; TX_OUTPUT_NOTES], skeleton_hash: BlsScalar, root: BlsScalar, - crossover: u64, + deposit: u64, max_fee: u64, ) -> Self { Self { @@ -406,7 +405,7 @@ impl TxCircuit { tx_output_notes, skeleton_hash, root, - crossover, + deposit, max_fee, } } @@ -421,7 +420,7 @@ impl Circuit for TxCircuit { &self.tx_input_notes, &self.tx_output_notes, self.max_fee, - self.crossover, + self.deposit, )?; Ok(()) } diff --git a/circuits/tests/transaction.rs b/circuits/tests/transaction.rs index 71dcefb..0857d59 100644 --- a/circuits/tests/transaction.rs +++ b/circuits/tests/transaction.rs @@ -26,7 +26,7 @@ struct TestingParameters { tx_input_notes: [TxInputNote; 4], skeleton_hash: BlsScalar, root: BlsScalar, - crossover: u64, + deposit: u64, max_fee: u64, } @@ -45,10 +45,10 @@ lazy_static! { // retrieve the root from the tree after inserting the notes let root = tree.root().hash; - let crossover = 5; + let deposit = 5; let max_fee = 5; - TestingParameters { pp, tx_input_notes, skeleton_hash, root, crossover, max_fee } + TestingParameters { pp, tx_input_notes, skeleton_hash, root, deposit, max_fee } }; } @@ -137,7 +137,7 @@ fn test_transfer_circuit_1_2() { tx_output_notes, TP.skeleton_hash, TP.root, - TP.crossover, + TP.deposit, TP.max_fee, ), ) @@ -171,7 +171,7 @@ fn test_transfer_circuit_2_2() { tx_output_notes, TP.skeleton_hash, TP.root, - TP.crossover, + TP.deposit, TP.max_fee, ), ) @@ -208,7 +208,7 @@ fn test_transfer_circuit_3_2() { tx_output_notes, TP.skeleton_hash, TP.root, - TP.crossover, + TP.deposit, TP.max_fee, ), ) @@ -239,7 +239,7 @@ fn test_transfer_circuit_4_2() { tx_output_notes, TP.skeleton_hash, TP.root, - TP.crossover, + TP.deposit, TP.max_fee, ), ) From e37864eb5f451f2361835b01b405921fe455a679 Mon Sep 17 00:00:00 2001 From: moana Date: Fri, 31 May 2024 17:20:08 +0200 Subject: [PATCH 2/2] core: Rename `crossover` to `deposit` --- core/CHANGELOG.md | 5 +++++ core/src/transaction.rs | 18 +++++++++--------- core/tests/transaction.rs | 4 ++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index fbe002b..d9f61af 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Rename `crossover` to `deposit` [#190] + ## [0.28.1] - 2024-05-23 ### Changed @@ -317,6 +321,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Canonical implementation shielded by feature. +[#190]: https://github.com/dusk-network/phoenix/issues/190 [#183]: https://github.com/dusk-network/phoenix/issues/183 [#179]: https://github.com/dusk-network/phoenix/issues/179 [#175]: https://github.com/dusk-network/phoenix/issues/175 diff --git a/core/src/transaction.rs b/core/src/transaction.rs index 2d17c21..56e6e3b 100644 --- a/core/src/transaction.rs +++ b/core/src/transaction.rs @@ -37,8 +37,8 @@ pub struct TxSkeleton { pub outputs: [Note; OUTPUT_NOTES], /// Describes the maximum fee to be paid for this transaction. pub tx_max_fee: u64, - /// A crossover is used to transferring funds to a contract - pub crossover: u64, + /// A deposit is used to transferring funds to a contract + pub deposit: u64, } impl TxSkeleton { @@ -57,7 +57,7 @@ impl TxSkeleton { } bytes.extend(self.tx_max_fee.to_bytes()); - bytes.extend(self.crossover.to_bytes()); + bytes.extend(self.deposit.to_bytes()); bytes } @@ -81,7 +81,7 @@ impl TxSkeleton { }); bytes.extend(self.tx_max_fee.to_bytes()); - bytes.extend(self.crossover.to_bytes()); + bytes.extend(self.deposit.to_bytes()); bytes } @@ -105,14 +105,14 @@ impl TxSkeleton { outputs.try_into().map_err(|_| BytesError::InvalidData)?; let tx_max_fee = u64::from_reader(&mut buffer)?; - let crossover = u64::from_reader(&mut buffer)?; + let deposit = u64::from_reader(&mut buffer)?; Ok(Self { root, nullifiers, outputs, tx_max_fee, - crossover, + deposit, }) } @@ -131,8 +131,8 @@ impl TxSkeleton { self.tx_max_fee } - /// Returns the crossover of the transaction. - pub fn crossover(&self) -> u64 { - self.crossover + /// Returns the deposit of the transaction. + pub fn deposit(&self) -> u64 { + self.deposit } } diff --git a/core/tests/transaction.rs b/core/tests/transaction.rs index c20ef53..bf19e93 100644 --- a/core/tests/transaction.rs +++ b/core/tests/transaction.rs @@ -27,14 +27,14 @@ fn transaction_parse() -> Result<(), Error> { let nullifiers = vec![BlsScalar::from(456), BlsScalar::from(789)]; let outputs = [note.clone(), note]; let tx_max_fee = 0; - let crossover = 0; + let deposit = 0; let tx_skeleton = TxSkeleton { root, nullifiers, outputs, tx_max_fee, - crossover, + deposit, }; let bytes_of_transaction = tx_skeleton.to_var_bytes(); assert_eq!(