Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse make_context in signing/validation #738

Closed
SethDusek opened this issue Apr 4, 2024 · 0 comments
Closed

Reuse make_context in signing/validation #738

SethDusek opened this issue Apr 4, 2024 · 0 comments
Assignees

Comments

@SethDusek
Copy link
Collaborator

Currently tx_input_proof/verify_tx_input_proof remake make_context for each input:

pub fn sign_tx_input(
    prover: &dyn Prover,
    tx_context: &TransactionContext<UnsignedTransaction>,
    state_context: &ErgoStateContext,
    tx_hints: Option<&TransactionHintsBag>,
    input_idx: usize,
    message_to_sign: &[u8],
) -> Result<Input, TxSigningError> {
    let unsigned_input = tx_context
        .spending_tx
        .inputs
        .get(input_idx)
        .ok_or(TransactionContextError::InputBoxNotFound(input_idx))?;
    let input_box = tx_context
        .get_input_box(&unsigned_input.box_id)
        .ok_or(TransactionContextError::InputBoxNotFound(input_idx))?;
    let ctx = Rc::new(make_context(state_context, tx_context, input_idx)?);

make_context ends up being very expensive for transactions with multiple inputs. Instead pass a reference to sign_tx_input/verify_tx_input_proof, and only modify the self box/contextextension for each input instead of recreating context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants