storage (pair (map nat (pair bool bool)) (pair key key)); return bool; parameter (or nat (pair signature nat)); code { DUP; CAR; DIP{CDR}; # Stack rangling IF_LEFT { DIP{DUP; CAR}; GET; # Get the value stored for that index IF_NONE { PUSH bool False} # If not referenced, reject { DUP; CAR; DIP{CDR}; AND}; PAIR} { DUP; CAR; DIP{CDR; DUP; H}; PAIR; SWAP; # Create the signature pair DIP{ DIP{DUP; CDR; DIP{CAR}; DUP}; SWAP; CAR; DIP{DUP}; CHECK_SIGNATURE }; # Check the first signature SWAP; # If the signature typechecked, get and update the first element of the pair IF { DIP{DROP; SWAP; DUP}; DUP; DIP{ GET; IF_NONE{PUSH (pair bool bool) (Pair False False)} {}; CDR; PUSH bool True; PAIR; SOME }} # Check the second signature { DIP{DIP{DUP; CDR}; SWAP; CHECK_SIGNATURE}; SWAP; IF { DUP; DIP{DIP{SWAP; DUP}; GET}; SWAP; IF_NONE {PUSH (pair bool bool) (Pair False False)} {}; CAR; PUSH bool True; SWAP; PAIR; SOME; SWAP} {FAIL}}; # Update the stored value and finish off UPDATE; PAIR; PUSH bool False; PAIR}}