-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
The ability to re-use deserialized data types makes this library very useful when verifying multiple inputs in a transaction. The only remaining problem is that there is still a risk of quadratic hashing, without a cached PrecomputedTransactionData that can be re-used across inputs.
I'm not sure what the answer is, but I think it may be worth updating the verify API or introducing a second verify_with_precomputed_data API, so that quadratic hashing can be avoided. In either case, a new API to get the precomputed transaction data would be required.
Possible API:
fn get_precomputed_tx_data(
tx_to: &impl TransactionExt,
) -> Result<PrecomputedTransactionData, KernelError>;
// Uses `precomputed_data` if Some, otherwise proceeds as-is.
fn verify(
script_pubkey: &impl ScriptPubkeyExt,
amount: Option<i64>,
tx_to: &impl TransactionExt,
precomputed_data: Option<&impl PrecomputedTransactionDataExt>,
input_index: usize,
flags: Option<u32>,
spent_outputs: &[impl TxOutExt],
) -> Result<(), KernelError>;Alternatively:
fn get_precomputed_tx_data(
tx_to: &impl TransactionExt,
) -> Result<PrecomputedTransactionData, KernelError>;
fn verify_with_precomputed_data(
script_pubkey: &impl ScriptPubkeyExt,
amount: Option<i64>,
tx_to: &impl TransactionExt,
precomputed_data: &impl PrecomputedTransactionDataExt,
input_index: usize,
flags: Option<u32>,
spent_outputs: &[impl TxOutExt],
) -> Result<(), KernelError>;Metadata
Metadata
Assignees
Labels
No labels