sigma0-dev / zkbitcoin

zkBitcoin: zero-knowledge proofs on Bitcoin!
MIT License
164 stars 32 forks source link

remove `zkapp_input` from BobRequest #6

Closed mimoo closed 10 months ago

mimoo commented 10 months ago

There's no reason Bob needs to tell the MPC nodes which input of their transaction consumes the zkapp:

pub struct BobRequest {
    // TRUNCATED...
    /// The index of the input that contains the zkapp being used.
    // TODO: we should be able to infer this!
    pub zkapp_input: usize,

this is because it's easy to recompute, we can just look for the input that points to the zkapp's transaction id, which is also given in the request (bob_request.zkapp_tx.txid())

BTW this is how Bob computes it:

let zkapp_input = tx
            .input
            .iter()
            .enumerate()
            .find(|(_, x)| x.previous_output.txid == txid)
            .context("internal error: the transaction does not contain the zkapp being used")?
            .0;
dajuguan commented 10 months ago

Please give me a shot?