diff --git a/docs/whitedoc/michelson.rst b/docs/whitedoc/michelson.rst index ccd001baf..b50842202 100644 --- a/docs/whitedoc/michelson.rst +++ b/docs/whitedoc/michelson.rst @@ -1538,7 +1538,7 @@ Cryptographic primitives :: - :: key : pair signature string : 'S -> bool : 'S + :: key : signature : string : 'S -> bool : 'S - ``COMPARE``: diff --git a/src/bin_client/test/contracts/accounts.tz b/src/bin_client/test/contracts/accounts.tz index 31944fe1f..f6ca5350b 100644 --- a/src/bin_client/test/contracts/accounts.tz +++ b/src/bin_client/test/contracts/accounts.tz @@ -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; diff --git a/src/bin_client/test/contracts/check_signature.tz b/src/bin_client/test/contracts/check_signature.tz index 6e9009bbc..65d319d58 100644 --- a/src/bin_client/test/contracts/check_signature.tz +++ b/src/bin_client/test/contracts/check_signature.tz @@ -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}; diff --git a/src/bin_client/test/contracts/data_publisher.tz b/src/bin_client/test/contracts/data_publisher.tz index e161c3989..23b832dd8 100644 --- a/src/bin_client/test/contracts/data_publisher.tz +++ b/src/bin_client/test/contracts/data_publisher.tz @@ -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} diff --git a/src/bin_client/test/contracts/int_publisher.tz b/src/bin_client/test/contracts/int_publisher.tz index b81af3813..4b2a3e16a 100644 --- a/src/bin_client/test/contracts/int_publisher.tz +++ b/src/bin_client/test/contracts/int_publisher.tz @@ -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} diff --git a/src/bin_client/test/contracts/parameterized_multisig.tz b/src/bin_client/test/contracts/parameterized_multisig.tz index cc1eb7057..1ad197e29 100644 --- a/src/bin_client/test/contracts/parameterized_multisig.tz +++ b/src/bin_client/test/contracts/parameterized_multisig.tz @@ -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} diff --git a/src/bin_client/test/contracts/weather_insurance.tz b/src/bin_client/test/contracts/weather_insurance.tz index fc0a05ada..895763f78 100644 --- a/src/bin_client/test/contracts/weather_insurance.tz +++ b/src/bin_client/test/contracts/weather_insurance.tz @@ -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 diff --git a/src/proto_alpha/lib_protocol/src/script_interpreter.ml b/src/proto_alpha/lib_protocol/src/script_interpreter.ml index 30ca715c1..c66371cfc 100644 --- a/src/proto_alpha/lib_protocol/src/script_interpreter.ml +++ b/src/proto_alpha/lib_protocol/src/script_interpreter.ml @@ -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 diff --git a/src/proto_alpha/lib_protocol/src/script_ir_translator.ml b/src/proto_alpha/lib_protocol/src/script_ir_translator.ml index 04ae38bee..e22762230 100644 --- a/src/proto_alpha/lib_protocol/src/script_ir_translator.ml +++ b/src/proto_alpha/lib_protocol/src/script_ir_translator.ml @@ -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), diff --git a/src/proto_alpha/lib_protocol/src/script_typed_ir.ml b/src/proto_alpha/lib_protocol/src/script_typed_ir.ml index ece3fced3..bb7241155 100644 --- a/src/proto_alpha/lib_protocol/src/script_typed_ir.ml +++ b/src/proto_alpha/lib_protocol/src/script_typed_ir.ml @@ -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 -> diff --git a/src/proto_alpha/lib_protocol/test/contracts/accounts.tz b/src/proto_alpha/lib_protocol/test/contracts/accounts.tz index 31944fe1f..f6ca5350b 100644 --- a/src/proto_alpha/lib_protocol/test/contracts/accounts.tz +++ b/src/proto_alpha/lib_protocol/test/contracts/accounts.tz @@ -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; diff --git a/src/proto_alpha/lib_protocol/test/contracts/check_signature.tz b/src/proto_alpha/lib_protocol/test/contracts/check_signature.tz index 6e9009bbc..65d319d58 100644 --- a/src/proto_alpha/lib_protocol/test/contracts/check_signature.tz +++ b/src/proto_alpha/lib_protocol/test/contracts/check_signature.tz @@ -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}; diff --git a/src/proto_alpha/lib_protocol/test/contracts/data_publisher.tz b/src/proto_alpha/lib_protocol/test/contracts/data_publisher.tz index e161c3989..23b832dd8 100644 --- a/src/proto_alpha/lib_protocol/test/contracts/data_publisher.tz +++ b/src/proto_alpha/lib_protocol/test/contracts/data_publisher.tz @@ -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} diff --git a/src/proto_alpha/lib_protocol/test/contracts/int_publisher.tz b/src/proto_alpha/lib_protocol/test/contracts/int_publisher.tz index b81af3813..4b2a3e16a 100644 --- a/src/proto_alpha/lib_protocol/test/contracts/int_publisher.tz +++ b/src/proto_alpha/lib_protocol/test/contracts/int_publisher.tz @@ -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} diff --git a/src/proto_alpha/lib_protocol/test/contracts/parameterized_multisig.tz b/src/proto_alpha/lib_protocol/test/contracts/parameterized_multisig.tz index cc1eb7057..1ad197e29 100644 --- a/src/proto_alpha/lib_protocol/test/contracts/parameterized_multisig.tz +++ b/src/proto_alpha/lib_protocol/test/contracts/parameterized_multisig.tz @@ -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} diff --git a/src/proto_alpha/lib_protocol/test/contracts/weather_insurance.tz b/src/proto_alpha/lib_protocol/test/contracts/weather_insurance.tz index fc0a05ada..895763f78 100644 --- a/src/proto_alpha/lib_protocol/test/contracts/weather_insurance.tz +++ b/src/proto_alpha/lib_protocol/test/contracts/weather_insurance.tz @@ -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