Skip to content

Commit

Permalink
Allow modifications to get sum inputs == sum outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
j-berman committed Feb 17, 2025
1 parent 7875471 commit 74805e5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crypto/fcmps/src/prover/blinds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ where
let R = *self.i_blind_blind.0.scalar_mul_and_divisor.point - self.i_blind.v.point.deref();
Input::new(O_tilde, I_tilde, R, C_tilde)
}

/// Update the existing c_blind
///
/// This allows recalculating a c_blind at tx construction time when making sure
/// sum of inputs == sum of outputs.
pub fn set_c_blind(&mut self, c_blind: CBlind<G>) {
self.c_blind = c_blind;
}
}

/// A blind for a branch.
Expand Down
11 changes: 11 additions & 0 deletions networks/monero/ringct/fcmp++/src/sal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ impl RerandomizedOutput {
-self.r_c
}

/// The scalar used to re-randomize the amount commitment
pub fn r_c(&self) -> <Ed25519 as Ciphersuite>::F {
self.r_c
}

/// Allow changing r_c and C_tilde (the pseudo out) to balance the tx
pub fn set_r_c(&mut self, C: <Ed25519 as Ciphersuite>::G, r_c: <Ed25519 as Ciphersuite>::F) {
self.r_c = r_c;
self.input.C_tilde = C + (<Ed25519 as Ciphersuite>::generator() * r_c);
}

/// The input tuple produced by this output and set of rerandomizations.
pub fn input(&self) -> Input {
self.input
Expand Down

0 comments on commit 74805e5

Please sign in to comment.