Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename crossover to deposit #194

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions circuits/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -29,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- ISSUES -->
[#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
Expand Down
2 changes: 1 addition & 1 deletion circuits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
25 changes: 12 additions & 13 deletions circuits/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,23 @@ 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`
/// - `root`
/// - `[nullifier; I]`
/// - `[output_value_commitment; 2]`
/// - `max_fee`
/// - `crossover`
/// - `deposit`
pub fn gadget<const H: usize, const I: usize>(
composer: &mut Composer,
skeleton_hash: &BlsScalar,
root: &BlsScalar,
tx_input_notes: &[TxInputNote<H>; 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);
Expand Down Expand Up @@ -307,16 +306,16 @@ pub fn gadget<const H: usize, const I: usize>(
}

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
Expand All @@ -332,7 +331,7 @@ pub struct TxCircuit<const H: usize, const I: usize> {
tx_output_notes: [TxOutputNote; TX_OUTPUT_NOTES],
skeleton_hash: BlsScalar,
root: BlsScalar,
crossover: u64,
deposit: u64,
max_fee: u64,
}

Expand Down Expand Up @@ -377,15 +376,15 @@ impl<const H: usize, const I: usize> Default for TxCircuit<H, I> {
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 {
tx_input_notes: tx_input_notes.try_into().unwrap(),
tx_output_notes,
skeleton_hash,
root,
crossover,
deposit,
max_fee,
}
}
Expand All @@ -398,15 +397,15 @@ impl<const H: usize, const I: usize> TxCircuit<H, I> {
tx_output_notes: [TxOutputNote; TX_OUTPUT_NOTES],
skeleton_hash: BlsScalar,
root: BlsScalar,
crossover: u64,
deposit: u64,
max_fee: u64,
) -> Self {
Self {
tx_input_notes,
tx_output_notes,
skeleton_hash,
root,
crossover,
deposit,
max_fee,
}
}
Expand All @@ -421,7 +420,7 @@ impl<const H: usize, const I: usize> Circuit for TxCircuit<H, I> {
&self.tx_input_notes,
&self.tx_output_notes,
self.max_fee,
self.crossover,
self.deposit,
)?;
Ok(())
}
Expand Down
14 changes: 7 additions & 7 deletions circuits/tests/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct TestingParameters {
tx_input_notes: [TxInputNote<HEIGHT>; 4],
skeleton_hash: BlsScalar,
root: BlsScalar,
crossover: u64,
deposit: u64,
max_fee: u64,
}

Expand All @@ -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 }
};
}

Expand Down Expand Up @@ -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,
),
)
Expand Down Expand Up @@ -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,
),
)
Expand Down Expand Up @@ -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,
),
)
Expand Down Expand Up @@ -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,
),
)
Expand Down
5 changes: 5 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -317,6 +321,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Canonical implementation shielded by feature.

<!-- ISSUES -->
[#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
Expand Down
18 changes: 9 additions & 9 deletions core/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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,
})
}

Expand All @@ -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
}
}
4 changes: 2 additions & 2 deletions core/tests/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down