Skip to content

Instantly share code, notes, and snippets.

@nothingmuch
Last active November 16, 2019 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nothingmuch/62a504414ccc37ed195741738b089a8f to your computer and use it in GitHub Desktop.
Save nothingmuch/62a504414ccc37ed195741738b089a8f to your computer and use it in GitHub Desktop.
// PoC for 2-of-3 multisig where one of the keys is an opendime (sealed at time of scriptPubKey creation)
// see on https://ivy-lang.org/bitcoin
// the script ivy generates seems sub-optimal (some unconditional rotation and rolling of stack elements)
// but this is just a yucky PoC, and the ivy source is arguably easier to understand anyway
contract LockWithKeyHashMultisig(
pubKey1: PublicKey,
pubKey2: PublicKey,
pubKey3hash: Ripemd160(Sha256(PublicKey)), // opendime address
dummyKey: PublicKey, // should be a curve point with no known discrete log
val: Value
) {
// this path can spends with the opendime key which must be provided in the scriptSig much like p2pkh
// (the 2 signatures can still correspond to pubKey1 and pubKey2)
clause spendHash(sig1: Signature, sig2: Signature, pubKey3: PublicKey) {
verify ripemd160(sha256(pubKey3)) == pubKey3hash
verify checkMultiSig([pubKey1, pubKey2, pubKey3], [sig1, sig2])
unlock val
}
// this path can only spend from pubKey1 and pubKey2 if the dummy key really is unusable
clause spend(sig1: Signature, sig2: Signature) {
verify checkMultiSig([pubKey1, pubKey2, dummyKey], [sig1, sig2])
unlock val
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment