cl: InputWitness does not need utxo_balance_blinding

This commit is contained in:
David Rusu 2024-07-23 13:47:27 +04:00
parent 247f3f042b
commit c5bcf3ebe7
5 changed files with 6 additions and 16 deletions

View File

@ -21,7 +21,6 @@ pub struct Input {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct InputWitness {
pub note: NoteWitness,
pub utxo_balance_blinding: BalanceWitness,
pub balance_blinding: BalanceWitness,
pub nf_sk: NullifierSecret,
pub nonce: NullifierNonce,
@ -36,7 +35,6 @@ impl InputWitness {
assert_eq!(nf_sk.commit(), output.nf_pk);
Self {
note: output.note,
utxo_balance_blinding: output.balance_blinding,
balance_blinding: BalanceWitness::random(&mut rng),
nf_sk,
nonce: output.nonce,
@ -55,13 +53,8 @@ impl InputWitness {
}
}
pub fn to_output(&self) -> crate::OutputWitness {
crate::OutputWitness {
note: self.note,
balance_blinding: self.utxo_balance_blinding,
nf_pk: self.nf_sk.commit(),
nonce: self.nonce,
}
pub fn note_commitment(&self) -> crate::NoteCommitment {
self.note.commit(self.nf_sk.commit(), self.nonce)
}
}

View File

@ -11,7 +11,7 @@ pub struct ProvedInput {
impl ProvedInput {
pub fn prove(input: &cl::InputWitness, note_commitments: &[cl::NoteCommitment]) -> Self {
let output_cm = input.to_output().commit_note();
let output_cm = input.note_commitment();
let cm_leaves = note_commitment_leaves(note_commitments);
let cm_idx = note_commitments
@ -95,13 +95,12 @@ mod test {
let input = cl::InputWitness {
note: cl::NoteWitness::basic(32, "NMO"),
utxo_balance_blinding: cl::BalanceWitness::random(&mut rng),
balance_blinding: cl::BalanceWitness::random(&mut rng),
nf_sk: cl::NullifierSecret::random(&mut rng),
nonce: cl::NullifierNonce::random(&mut rng),
};
let notes = vec![input.to_output().commit_note()];
let notes = vec![input.note_commitment()];
let mut proved_input = ProvedInput::prove(&input, &notes);

View File

@ -16,7 +16,7 @@ impl PartialTxInputPrivate {
}
pub fn cm_root(&self) -> [u8; 32] {
let leaf = merkle::leaf(self.input.to_output().commit_note().as_bytes());
let leaf = merkle::leaf(self.input.note_commitment().as_bytes());
merkle::path_root(leaf, &self.cm_path)
}
}

View File

@ -6,7 +6,7 @@ use risc0_zkvm::guest::env;
fn main() {
let secret: InputPrivate = env::read();
let out_cm = secret.input.to_output().commit_note();
let out_cm = secret.input.note_commitment();
let cm_leaf = merkle::leaf(out_cm.as_bytes());
let cm_root = merkle::path_root(cm_leaf, &secret.cm_path);

View File

@ -18,7 +18,6 @@ fn main() {
spend_event_state_path,
} = env::read();
let cm_root = in_zone_funds.cm_root();
let ptx_root = in_zone_funds.ptx_root();
let nf = Nullifier::new(in_zone_funds.input.nf_sk, in_zone_funds.input.nonce);
// check the zone funds note is the one in the spend event
@ -78,7 +77,6 @@ fn main() {
assert_eq!(spent_note.output.nf_pk, spend_event.to);
env::commit(&DeathConstraintPublic {
cm_root,
ptx_root,
nf,
});