Skip to content

Commit

Permalink
Check the balance for shielded data in TransactionVerifier
Browse files Browse the repository at this point in the history
  • Loading branch information
dconnolly committed Oct 8, 2020
1 parent d7958f2 commit eca674a
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions zebra-consensus/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,29 @@ where
binding_sig,
} = shielded_data_d;

self.redjubjub
.call((
pub_key.into(),
binding_sig.into(),
tx.sighash(
Network::Sapling, // TODO: pass this in
HashType::ALL, // TODO: check these
None, // TODO: check these
),
))
.map_err(VerifyTransactionError::Redjubjub)
.boxed();
let sighash = tx.sighash(
Network::Sapling, // TODO: pass this in
HashType::ALL, // TODO: check these
None, // TODO: check these
);

// Checks the balance.
//
// The net value of Spend transfers minus Output transfers in a
// transaction is called the balancing value, measured in zatoshi as
// a signed integer v_balance.
//
// Consistency of v_balance with the value commitments in Spend
// descriptions and Output descriptions is enforced by the binding
// signature.
//
// Instead of generating a key pair at random, we generate it as a
// function of the value commitments in the Spend descriptions and
// Output descriptions of the transaction, and the balancing value.
//
// https://zips.z.cash/protocol/canopy.pdf#saplingbalance
let bsk = shielded_data_d.binding_validating_key(value_balance);
bsk.verify(sighash, &binding_sig);
}
}
}

0 comments on commit eca674a

Please sign in to comment.