nomic-io / bitcoin-peg

Bitcoin sidechain module for Lotion and Coins (A Cosmos Bitcoin peg zone implementation)
MIT License
72 stars 14 forks source link

Pay/Sign to Contract instead of OP_RETURN for destination address #9

Open gakonst opened 4 years ago

gakonst commented 4 years ago

Have you considered using pay-to-contract or sign-to-contract to commit to the destination address in the Tendermint chain instead of OP_RETURNs?

Puts less state on the chain, as well as guarantees the data can be retrieved by nodes which are not run with txindex=1

sign-to-contract basically modifies R in an ECDSA signature to also include the message you want to commit to (you also modify the nonce to ensure that the verification algorithm evaluates to true)

From the linked article:

def ECDSAsign2contract(x,m,c):
    k = deterministic_nonce(x,m)
    R = k*G
    e = k + h(R || c)
    Q = R + h(R || c)*G  # which is Q = e*G = C(c,R)
    q = Q.x mod n
    z = e^(-1) * (m + q*x) mod n
    return (q,z), R