Skip to content

Commit

Permalink
feat(api): decouple the verification of Tx and spentproofs from DbcBu…
Browse files Browse the repository at this point in the history
…ilder::build

- A new DbcBuilder::build_without_verifying API is introduced which doesn't perform
Tx or spentproofs verification.
  • Loading branch information
bochaco committed Apr 20, 2022
1 parent 16e02c9 commit 918b076
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
16 changes: 8 additions & 8 deletions examples/mint-repl/mint-repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ fn print_dbc_human(dbc: &Dbc, outputs: bool, secret_key_base: Option<SecretKey>)
Ok(())
}

/// handles decode command.
/// handles decode command.
fn decode_input() -> Result<()> {
let t = readline_prompt(
"\n[d: DBC, rt: RingCtTransaction, pks: PublicKeySet, sks: SecretKeySet]\nType: ",
Expand Down Expand Up @@ -508,14 +508,14 @@ fn decode_input() -> Result<()> {
fn print_logo() {
println!(
r#"
__ _
(_ _._|__ |\ | __|_ _ ._|
__)(_| |(/_ | \|(/_|_\/\/(_)| |<
____ ____ ____ __ __ _ _
| _ \| __ ) / ___| | \/ (_)_ __ | |_
__ _
(_ _._|__ |\ | __|_ _ ._|
__)(_| |(/_ | \|(/_|_\/\/(_)| |<
____ ____ ____ __ __ _ _
| _ \| __ ) / ___| | \/ (_)_ __ | |_
| | | | _ \| | | |\/| | | '_ \| __|
| |_| | |_) | |___ | | | | | | | | |_
|____/|____/ \____| |_| |_|_|_| |_|\__|
| |_| | |_) | |___ | | | | | | | | |_
|____/|____/ \____| |_| |_|_|_| |_|\__|
"#
);
}
Expand Down
17 changes: 16 additions & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ impl DbcBuilder {
self
}

/// Build the output DBCs
/// Build the output DBCs, verifying the transaction and spentproofs.
///
/// see TransactionVerifier::verify() for a description of
/// verifier requirements.
Expand All @@ -401,6 +401,21 @@ impl DbcBuilder {
// note that we do this just once for entire Tx, not once per output Dbc.
TransactionVerifier::verify(verifier, &self.transaction, &spent_proofs)?;

// build output DBCs
self.build_output_dbcs(spent_proofs)
}

/// Build the output DBCs (no verification over Tx or spentproof is performed).
pub fn build_without_verifying(self) -> Result<Vec<(Dbc, OwnerOnce, AmountSecrets)>> {
let spent_proofs = self.spent_proofs()?;
self.build_output_dbcs(spent_proofs)
}

// Private helper to build output DBCs
fn build_output_dbcs(
self,
spent_proofs: BTreeSet<SpentProof>,
) -> Result<Vec<(Dbc, OwnerOnce, AmountSecrets)>> {
let pc_gens = PedersenGens::default();
let output_commitments: Vec<(Commitment, RevealedCommitment)> = self
.revealed_commitments
Expand Down
2 changes: 1 addition & 1 deletion src/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl From<OwnerOnce> for Owner {
/// The one-time-use Owner key(pair) is derived from a reusable
/// base Owner key(pair) using the DerivationIndex.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
pub struct OwnerOnce {
pub owner_base: Owner,
pub derivation_index: DerivationIndex,
Expand Down

0 comments on commit 918b076

Please sign in to comment.