Michelson: unpair input of CHECK_SIGNATURE
This commit is contained in:
parent
8e28c790ea
commit
530427c813
@ -1538,7 +1538,7 @@ Cryptographic primitives
|
||||
|
||||
::
|
||||
|
||||
:: key : pair signature string : 'S -> bool : 'S
|
||||
:: key : signature : string : 'S -> bool : 'S
|
||||
|
||||
- ``COMPARE``:
|
||||
|
||||
|
@ -17,7 +17,7 @@ code { DUP; CAR;
|
||||
# Withdrawl
|
||||
{ DUP; DUP; DUP; DUP;
|
||||
# Check signature on data
|
||||
CAR; DIIP{ CDAR; H }; DIP{ CDDR; PAIR }; CHECK_SIGNATURE;
|
||||
CAR; DIIP{ CDAR; H }; DIP{ CDDR }; CHECK_SIGNATURE;
|
||||
IF {} { FAIL };
|
||||
# Get user account information
|
||||
DIIP{ CDR; DUP }; CAR; HASH_KEY; DIP{ SWAP }; GET;
|
||||
|
@ -3,6 +3,6 @@ storage (pair signature string);
|
||||
code { DUP; DUP;
|
||||
DIP{ CDR; DUP; CAR;
|
||||
DIP{CDR; H}; PAIR};
|
||||
CAR; CHECK_SIGNATURE;
|
||||
CAR; DIP {UNPAIR}; CHECK_SIGNATURE;
|
||||
IF {} {FAIL} ;
|
||||
CDR; NIL operation ; PAIR};
|
||||
|
@ -1,7 +1,7 @@
|
||||
parameter (pair signature (pair string nat));
|
||||
storage (pair (pair key nat) string);
|
||||
code { DUP; CAR; DIP{CDR; DUP};
|
||||
SWAP; DIP{DUP}; CAAR; DIP{DUP; CAR; DIP{CDR; H}; PAIR};
|
||||
SWAP; DIP{DUP}; CAAR; DIP{DUP; CAR; DIP{CDR; H}};
|
||||
CHECK_SIGNATURE;
|
||||
IF { CDR; DUP; DIP{CAR; DIP{CAAR}}; CDR; PUSH nat 1; ADD;
|
||||
DIP{SWAP}; SWAP; PAIR; PAIR; NIL operation; PAIR}
|
||||
|
@ -7,7 +7,7 @@ code {DUP; DUP; CAR;
|
||||
# Provide the data
|
||||
CDR; DIP {CDDR}}
|
||||
{DUP; DIP{SWAP}; SWAP; CDAR; # Move key to the top
|
||||
DIP {DUP; CAR; DIP {CDR; H}; PAIR}; # Arrange the new piece of data
|
||||
DIP {DUP; CAR; DIP {CDR; H}}; # Arrange the new piece of data
|
||||
CHECK_SIGNATURE; # Check to ensure the data is authentic
|
||||
# Update data
|
||||
IF {CDR; SWAP; DIP{DUP}; CDAR; PAIR}
|
||||
|
@ -7,14 +7,14 @@ code { DUP; CAR; DIP{CDDR}; # Stack rangling
|
||||
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; CAR; DIP{DUP; UNPAIR}; 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;
|
||||
{ DIP{DIP{DUP; CDR}; SWAP; DIP {UNPAIR}; 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}
|
||||
|
@ -6,7 +6,7 @@ storage (pair (pair (contract @lt unit)
|
||||
(pair nat key));
|
||||
code { DUP; DUP;
|
||||
CAR; MAP_CDR{H};
|
||||
SWAP; CDDDR; CHECK_SIGNATURE; # Check if the data has been correctly signed
|
||||
SWAP; CDDDR; DIP {UNPAIR} ; CHECK_SIGNATURE; # Check if the data has been correctly signed
|
||||
ASSERT; # If signature is not correct, end the execution
|
||||
DUP; DUP; DUP; DIIIP{CDR}; # Place storage type on bottom of stack
|
||||
DIIP{CDAR}; # Place contracts below numbers
|
||||
|
@ -714,7 +714,7 @@ let rec interp
|
||||
Lwt.return (Gas.consume ctxt Interp_costs.now) >>=? fun ctxt ->
|
||||
let now = Script_timestamp.now ctxt in
|
||||
logged_return (Item (now, rest), ctxt)
|
||||
| Check_signature, Item (key, Item ((signature, message), rest)) ->
|
||||
| Check_signature, Item (key, Item (signature, Item (message, rest))) ->
|
||||
Lwt.return (Gas.consume ctxt Interp_costs.check_signature) >>=? fun ctxt ->
|
||||
let message = MBytes.of_string message in
|
||||
let res = Signature.check key signature message in
|
||||
|
@ -2134,7 +2134,7 @@ and parse_instr
|
||||
typed ctxt loc Hash_key
|
||||
(Item_t (Key_hash_t, rest, instr_annot))
|
||||
| Prim (loc, I_CHECK_SIGNATURE, [], instr_annot),
|
||||
Item_t (Key_t, Item_t (Pair_t ((Signature_t, _), (String_t, _)), rest, _), _) ->
|
||||
Item_t (Key_t, Item_t (Signature_t, Item_t (String_t, rest, _), _), _) ->
|
||||
typed ctxt loc Check_signature
|
||||
(Item_t (Bool_t, rest, instr_annot))
|
||||
| Prim (loc, I_H, [], instr_annot),
|
||||
|
@ -351,7 +351,7 @@ and ('bef, 'aft) instr =
|
||||
| Balance :
|
||||
('rest, Tez.t * 'rest) instr
|
||||
| Check_signature :
|
||||
(public_key * ((signature * string) * 'rest), bool * 'rest) instr
|
||||
(public_key * (signature * (string * 'rest)), bool * 'rest) instr
|
||||
| Hash_key :
|
||||
(public_key * 'rest, public_key_hash * 'rest) instr
|
||||
| H : 'a ty ->
|
||||
|
@ -17,7 +17,7 @@ code { DUP; CAR;
|
||||
# Withdrawl
|
||||
{ DUP; DUP; DUP; DUP;
|
||||
# Check signature on data
|
||||
CAR; DIIP{ CDAR; H }; DIP{ CDDR; PAIR }; CHECK_SIGNATURE;
|
||||
CAR; DIIP{ CDAR; H }; DIP{ CDDR }; CHECK_SIGNATURE;
|
||||
IF {} { FAIL };
|
||||
# Get user account information
|
||||
DIIP{ CDR; DUP }; CAR; HASH_KEY; DIP{ SWAP }; GET;
|
||||
|
@ -3,6 +3,6 @@ storage (pair signature string);
|
||||
code { DUP; DUP;
|
||||
DIP{ CDR; DUP; CAR;
|
||||
DIP{CDR; H}; PAIR};
|
||||
CAR; CHECK_SIGNATURE;
|
||||
CAR; DIP {UNPAIR}; CHECK_SIGNATURE;
|
||||
IF {} {FAIL} ;
|
||||
CDR; NIL operation ; PAIR};
|
||||
|
@ -1,7 +1,7 @@
|
||||
parameter (pair signature (pair string nat));
|
||||
storage (pair (pair key nat) string);
|
||||
code { DUP; CAR; DIP{CDR; DUP};
|
||||
SWAP; DIP{DUP}; CAAR; DIP{DUP; CAR; DIP{CDR; H}; PAIR};
|
||||
SWAP; DIP{DUP}; CAAR; DIP{DUP; CAR; DIP{CDR; H}};
|
||||
CHECK_SIGNATURE;
|
||||
IF { CDR; DUP; DIP{CAR; DIP{CAAR}}; CDR; PUSH nat 1; ADD;
|
||||
DIP{SWAP}; SWAP; PAIR; PAIR; NIL operation; PAIR}
|
||||
|
@ -7,7 +7,7 @@ code {DUP; DUP; CAR;
|
||||
# Provide the data
|
||||
CDR; DIP {CDDR}}
|
||||
{DUP; DIP{SWAP}; SWAP; CDAR; # Move key to the top
|
||||
DIP {DUP; CAR; DIP {CDR; H}; PAIR}; # Arrange the new piece of data
|
||||
DIP {DUP; CAR; DIP {CDR; H}}; # Arrange the new piece of data
|
||||
CHECK_SIGNATURE; # Check to ensure the data is authentic
|
||||
# Update data
|
||||
IF {CDR; SWAP; DIP{DUP}; CDAR; PAIR}
|
||||
|
@ -7,14 +7,14 @@ code { DUP; CAR; DIP{CDDR}; # Stack rangling
|
||||
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; CAR; DIP{DUP; UNPAIR}; 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;
|
||||
{ DIP{DIP{DUP; CDR}; SWAP; DIP {UNPAIR}; 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}
|
||||
|
@ -6,7 +6,7 @@ storage (pair (pair (contract @lt unit)
|
||||
(pair nat key));
|
||||
code { DUP; DUP;
|
||||
CAR; MAP_CDR{H};
|
||||
SWAP; CDDDR; CHECK_SIGNATURE; # Check if the data has been correctly signed
|
||||
SWAP; CDDDR; DIP {UNPAIR} ; CHECK_SIGNATURE; # Check if the data has been correctly signed
|
||||
ASSERT; # If signature is not correct, end the execution
|
||||
DUP; DUP; DUP; DIIIP{CDR}; # Place storage type on bottom of stack
|
||||
DIIP{CDAR}; # Place contracts below numbers
|
||||
|
Loading…
Reference in New Issue
Block a user