cl: doc zero commitment; drop Ptx::balance_delta, rm InputProof

This commit is contained in:
David Rusu 2024-07-22 16:39:15 +04:00
parent 05fbbdfe81
commit 61388121fb
3 changed files with 4 additions and 12 deletions

View File

@ -19,6 +19,10 @@ pub struct BalanceWitness(pub Scalar);
impl Balance {
/// A commitment to zero, blinded by the provided balance witness
pub fn zero(blinding: BalanceWitness) -> Self {
// Since, balance commitments are `value * UnitPoint + blinding * H`, when value=0, the commmitment is unitless.
// So we use the generator point as a stand in for the unit point.
//
// TAI: we can optimize this further from `0*G + r*H` to just `r*H` to save a point scalar mult + point addition.
Self(balance(
0,
curve25519_dalek::constants::RISTRETTO_BASEPOINT_POINT,

View File

@ -54,13 +54,6 @@ impl PartialTxWitness {
}
}
pub fn balance_delta(&self) -> i128 {
let in_sum: i128 = self.inputs.iter().map(|i| i.note.value as i128).sum();
let out_sum: i128 = self.outputs.iter().map(|o| o.note.value as i128).sum();
out_sum - in_sum
}
pub fn balance_blinding(&self) -> BalanceWitness {
let in_sum: Scalar = self.inputs.iter().map(|i| i.balance_blinding.0).sum();
let out_sum: Scalar = self.outputs.iter().map(|o| o.balance_blinding.0).sum();

View File

@ -77,11 +77,6 @@ impl ProvedInput {
}
}
#[derive(Debug, Clone)]
pub struct InputProof {}
impl InputProof {}
fn note_commitment_leaves(note_commitments: &[cl::NoteCommitment]) -> [[u8; 32]; MAX_NOTE_COMMS] {
let note_comm_bytes = Vec::from_iter(note_commitments.iter().map(|c| c.as_bytes().to_vec()));
let cm_leaves = cl::merkle::padded_leaves::<MAX_NOTE_COMMS>(&note_comm_bytes);