-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
146 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::TransactionComplier; | ||
use miden_objects::transaction::ProvenTransaction; | ||
use miden_verifier::{verify, VerificationError}; | ||
|
||
/// The [TransactionVerifier] is used to verify a [ProvenTransaction]. | ||
/// | ||
/// The [TransactionVerifier] contains a [Kernel] object which we use to verify a given | ||
/// transaction against. | ||
pub struct TransactionVerifier { | ||
compiler: TransactionComplier, | ||
} | ||
|
||
impl TransactionVerifier { | ||
/// Creates a new [TransactionVerifier] object. | ||
pub fn new() -> Self { | ||
let compiler = TransactionComplier::new(); | ||
Self { compiler } | ||
} | ||
|
||
/// Verifies the provided [ProvenTransaction] against the kernel. | ||
pub fn verify(&self, transaction: ProvenTransaction) -> Result<u32, VerificationError> { | ||
let consumed_notes_hashes = | ||
transaction.consumed_notes().iter().map(|x| x.script_root()).collect(); | ||
let program_info = self | ||
.compiler | ||
.build_program_info(consumed_notes_hashes, transaction.tx_script_root()); | ||
verify( | ||
program_info, | ||
transaction.build_stack_inputs(), | ||
transaction.build_stack_outputs(), | ||
transaction.proof().clone(), | ||
) | ||
} | ||
} | ||
|
||
impl Default for TransactionVerifier { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters