Skip to content

Commit

Permalink
fix(dbc_owner): verify input owner proofs
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrusu authored and dan-da committed May 19, 2021
1 parent b83e0eb commit ffb5b66
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub enum Error {
UnrecognisedAuthority,
#[error("At least one transaction input is missing a signature.")]
MissingSignatureForInput,
#[error("At least one input is missing an ownership proof")]
MissingInputOwnerProof,
#[error("Mint request doesn't balance out sum(input) == sum(output)")]
DbcMintRequestDoesNotBalance { input: u64, output: u64 },
#[error("Outputs must be numbered 0..N where N = # of outputs")]
Expand Down
10 changes: 9 additions & 1 deletion src/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,16 @@ impl Mint {
mint_request: MintRequest,
) -> Result<(DbcTransaction, InputSignatures)> {
mint_request.transaction.validate(self.key_cache())?;

let transaction = mint_request.transaction.blinded();
let transaction_hash = transaction.hash();
for input_dbc in mint_request.transaction.inputs.iter() {
let owner_key = input_dbc.content.owner.public_key();
match mint_request.input_ownership_proofs.get(&input_dbc.name()) {
Some(sig) if owner_key.verify(&sig, &transaction_hash) => (),
Some(_) => return Err(Error::FailedSignature),
None => return Err(Error::MissingInputOwnerProof),
}
}

// Validate that each input has not yet been spent.
for input in transaction.inputs.iter() {
Expand Down

0 comments on commit ffb5b66

Please sign in to comment.