# Emulating OP\_RAND

**URL:** <https://delvingbitcoin.org/t/emulating-op-rand/1409>\
**Category:** Protocol Design\
**Tags:** cryptography\
**Created:** [January 29, 2025, 11:17am UTC](https://delvingbitcoin.org/t/emulating-op-rand/1409 "2025-01-29T11:17:08Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![AdamISZ](https://delvingbitcoin.org/user_avatar/delvingbitcoin.org/adamisz/32/418_2.png) [@AdamISZ](https://delvingbitcoin.org/u/AdamISZ)\
**Post date:** [February 9, 2025, 4:20pm UTC](https://delvingbitcoin.org/t/emulating-op-rand/1409/7 "2025-02-09T16:20:45Z")

</div>

Yes, I believe that works. So the process would be:

(The following is modifications to Algorithm 2 per the doc): Alice provides:

- the unsigned transaction template for TX1, with the output address now being (taproot) key X
- T
- \pi\_a which now is modified to prove that X = (a\_1 + x\_a)T OR =(a\_2 + x\_a)T and additionally proves knowledge of the DL of T (or just sign on it, same thing). Using formal notation it becomes R\_a = \{a\_1, a\_2, t, x\_a: H\_1, H\_2, T, P\_a, X, G: \\ a\_1 G = A\_1 \land a\_2G = A\_2 \land T = tG \land \textrm{hash}\_p(A\_1) = h\_1 \land \textrm{hash}\_p(A\_2) = h\_2 \\ \land H\_1 = h\_1 G \land H\_2 = h\_2G \\ \land (X = t(P\_a + A\_1) \lor X = t(P\_a + A\_2)) \}

To explain the next steps, though, we need a slight sidetrack: X is now not the output address \textrm{addr}\_a! The reason I say that is, we need to use an adaptor secret atomic revelation in signing (which plays the role analogous to the fact that in a hashlock output signing, you reveal the hash preimage, i.e. the pubkey), and to make that enforced, you need fixed R, which can only be accomplished by a collaborative signing.

So we define \textrm{addr}\_a as MuSig(X, P\_b). Using the simpler MuSig1 model the process would be:

- X and P\_b are the input pubkeys. Hashes of the two participant nonces H(R\_a), H(R\_b) are shared as usual then R\_a, R\_b are shared. P\_{agg} is calculated as normal from each key.
- Bob gives his partial sig on the TX1 message m, so \sigma\_b = k\_b + H(R\_{agg} + T, P\_{agg}, m)x\_b
- Alice gives adaptor on her partial: \sigma\_a' = k\_a + H(R\_{agg} + T, P\_{agg}, m)x where x = t(x\_a + a\_1) (if a\_1 was chosen).
- Bob verifies the adaptor to ensure that t will be revealed, by doing \sigma\_a' G \stackrel{?}{=} R\_a + H(R\_{agg} + T, P\_{agg}, m)X

(To be clear, I am not asserting that this is secure, because it does have at least one feature that is very non-standard: the private key for the signature adaptor depends on the adaptor secret x = t(x\_a + a\_1). I actually really doubt that that is a security problem, since all of the RHS there is secret, but I’m certainly not claiming to _know_ it’s secure.)

At this point Bob is convinced that Alice’s behaviour is correct, and proceeds to do the other side: choosing say H\_1 he’ll construct \textrm{addr}\_b as t\_b(P\_b + H\_1). The situation is not entirely symmetrical: he _does_ need to convince Alice that the address has the given structure, so the ZKP is needed (basically proving that it is H\_1 \lor H\_2). And it still needs to be hidden from Alice, so we still need some blinding factor, hence t\_b. But we do _not_ need any adaptor secret business here; Alice doesn’t need to extract the key, only wait for a timeout. So just for completeness, Bob’s ZKP will now be (not much changed): R\_b = \{P\_b, \sigma, t\_b: H\_1, H\_2, X\_b, G: \textrm{sigVer}(\sigma, P\_b, X\_b) = \textrm{true} \\ \land (X\_b = t\_b(P\_b + H\_1) \lor X\_b = t\_b(P\_b + H\_2)) \}

with of course X\_b = \textrm{addr}\_b and \sigma being as described in Algo. 2.

With this structure, when Alice broadcasts, with her signature \sigma\_a she will reveal t = \sigma\_a - \sigma\_a'. Bob can then extract the A\_{1,2} value by calculating t^{-1}X = P\_a + A\_{1,2} and subtracting P\_a, from there getting the necessary tweak value h\_{1,2} to spend the coin if he won the bet.

Obviously this (a) makes it more complicated, at least somewhat, but it was already interactive so at least that part is not a stretch and (b) this is a rough draft and it might need modifying. The reason it interests me is I think you could make “native” ZKPs work with good performance here (i.e. not slow proving) using bulletproofs, the circuits would be very small, heck, you could even just use generalised schnorr proofs.

---

_[View the full topic](https://delvingbitcoin.org/t/emulating-op-rand/1409)._
