Timed Commit
Timed commitment with open and forfeit paths.
txt
# A commitment can be opened by Alice, while the alternate branch requires both signatures.
Contract TimedCommit:
def main(aliceNonce: hex, aliceSig: hex, bobSig: hex, path: number):
if path == 1:
# Opening consumes Alice's nonce and proves it matches the stored hash.
Delete(bobSig)
EqualVerify(Sha256(aliceNonce), self.aliceHash)
CheckSigVerify(aliceSig, self.alice)
else:
# The fallback branch discards the nonce and asks both parties to sign.
Delete(aliceNonce)
CheckSigVerify(aliceSig, self.alice)
CheckSigVerify(bobSig, self.bob)