diff --git a/docs/whitedoc/michelson.rst b/docs/whitedoc/michelson.rst index 5e3f8fc8f..dc0600a1b 100644 --- a/docs/whitedoc/michelson.rst +++ b/docs/whitedoc/michelson.rst @@ -1451,7 +1451,7 @@ Cryptographic primitives :: key : 'S -> key_hash : 'S -- ``H``: Compute a cryptographic hash of the value contents using the +- ``BLAKE2B``: Compute a cryptographic hash of the value contents using the Blake2B cryptographic hash function. :: @@ -2030,7 +2030,7 @@ The instructions which accept at most one variable annotation are: BALANCE HASH_KEY CHECK_SIGNATURE - H + BLAKE2B STEPS_TO_QUOTA SOURCE SENDER @@ -2913,7 +2913,7 @@ XII - Full grammar | AMOUNT | BALANCE | CHECK_SIGNATURE - | H + | BLAKE2B | HASH_KEY | STEPS_TO_QUOTA | SOURCE diff --git a/src/bin_client/test/contracts/accounts.tz b/src/bin_client/test/contracts/accounts.tz index 63d127c09..90a90f4b7 100644 --- a/src/bin_client/test/contracts/accounts.tz +++ b/src/bin_client/test/contracts/accounts.tz @@ -24,7 +24,7 @@ code { DUP; CAR; { DUP; DUP; DUP; DUP; # Check signature on data CAR %from; - DIIP{ CDAR %withdraw_amount; H @signed_amount }; + DIIP{ CDAR %withdraw_amount; BLAKE2B @signed_amount }; DIP{ CDDR %sig }; CHECK_SIGNATURE; IF {} { PUSH string "Bad signature"; FAILWITH }; # Get user account information diff --git a/src/bin_client/test/contracts/check_signature.tz b/src/bin_client/test/contracts/check_signature.tz index 65d319d58..768b4b81f 100644 --- a/src/bin_client/test/contracts/check_signature.tz +++ b/src/bin_client/test/contracts/check_signature.tz @@ -2,7 +2,7 @@ parameter key; storage (pair signature string); code { DUP; DUP; DIP{ CDR; DUP; CAR; - DIP{CDR; H}; PAIR}; + DIP{CDR; BLAKE2B}; PAIR}; 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 23b832dd8..0e08b98f9 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}}; + SWAP; DIP{DUP}; CAAR; DIP{DUP; CAR; DIP{CDR; BLAKE2B}}; 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/hash_consistency_checker.tz b/src/bin_client/test/contracts/hash_consistency_checker.tz index 40db8e0d5..91d49a0ec 100644 --- a/src/bin_client/test/contracts/hash_consistency_checker.tz +++ b/src/bin_client/test/contracts/hash_consistency_checker.tz @@ -1,3 +1,3 @@ parameter (pair mutez (pair timestamp int)) ; storage string ; -code { CAR ; H ; NIL operation ; PAIR } \ No newline at end of file +code { CAR ; BLAKE2B ; NIL operation ; PAIR } \ No newline at end of file diff --git a/src/bin_client/test/contracts/hash_string.tz b/src/bin_client/test/contracts/hash_string.tz index 263cecb0e..76805aae3 100644 --- a/src/bin_client/test/contracts/hash_string.tz +++ b/src/bin_client/test/contracts/hash_string.tz @@ -1,3 +1,3 @@ parameter string; storage string; -code {CAR; H; NIL operation; PAIR}; +code {CAR; BLAKE2B; NIL operation; PAIR}; diff --git a/src/bin_client/test/contracts/int_publisher.tz b/src/bin_client/test/contracts/int_publisher.tz index 01820468a..7436fbc2e 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}}; # Arrange the new piece of data + DIP {DUP; CAR; DIP {CDR; BLAKE2B}}; # 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 1ad197e29..725770527 100644 --- a/src/bin_client/test/contracts/parameterized_multisig.tz +++ b/src/bin_client/test/contracts/parameterized_multisig.tz @@ -5,7 +5,7 @@ code { DUP; CAR; DIP{CDDR}; # Stack rangling 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 + { DUP; CAR; DIP{CDR; DUP; BLAKE2B}; PAIR; SWAP; # Create the signature pair DIP{ DIP{DUP; CDR; DIP{CAR}; DUP}; SWAP; CAR; DIP{DUP; UNPAIR}; CHECK_SIGNATURE }; # Check the first signature SWAP; diff --git a/src/bin_client/test/contracts/weather_insurance.tz b/src/bin_client/test/contracts/weather_insurance.tz index 0782dc65e..db03fa94e 100644 --- a/src/bin_client/test/contracts/weather_insurance.tz +++ b/src/bin_client/test/contracts/weather_insurance.tz @@ -4,7 +4,7 @@ storage (pair (pair (contract %under_key unit) (contract %over_key unit)) (pair (nat :rain %rain_level) (key %weather_service_key))); code { DUP; DUP; - CAR; MAP_CDR{H}; + CAR; MAP_CDR{BLAKE2B}; SWAP; CDDDR %weather_service_key; DIP {UNPAIR} ; CHECK_SIGNATURE @sigok; # Check if the data has been correctly signed ASSERT; # If signature is not correct, end the execution diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.mli b/src/proto_alpha/lib_protocol/src/alpha_context.mli index fd827879a..16490dec0 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_context.mli @@ -177,7 +177,7 @@ module Script : sig | D_Some | D_True | D_Unit - | I_H + | I_BLAKE2B | I_ABS | I_ADD | I_AMOUNT diff --git a/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.ml b/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.ml index a6d62e31a..999434a39 100644 --- a/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.ml +++ b/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.ml @@ -26,7 +26,7 @@ type prim = | D_Some | D_True | D_Unit - | I_H + | I_BLAKE2B | I_ABS | I_ADD | I_AMOUNT @@ -154,7 +154,7 @@ let string_of_prim = function | D_Some -> "Some" | D_True -> "True" | D_Unit -> "Unit" - | I_H -> "H" + | I_BLAKE2B -> "BLAKE2B" | I_ABS -> "ABS" | I_ADD -> "ADD" | I_AMOUNT -> "AMOUNT" @@ -263,7 +263,7 @@ let prim_of_string = function | "Some" -> ok D_Some | "True" -> ok D_True | "Unit" -> ok D_Unit - | "H" -> ok I_H + | "BLAKE2B" -> ok I_BLAKE2B | "ABS" -> ok I_ABS | "ADD" -> ok I_ADD | "AMOUNT" -> ok I_AMOUNT @@ -417,7 +417,7 @@ let prim_encoding = ("Some", D_Some) ; ("True", D_True) ; ("Unit", D_Unit) ; - ("H", I_H) ; + ("BLAKE2B", I_BLAKE2B) ; ("ABS", I_ABS) ; ("ADD", I_ADD) ; ("AMOUNT", I_AMOUNT) ; diff --git a/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.mli b/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.mli index ac41731cf..f86fc965c 100644 --- a/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.mli +++ b/src/proto_alpha/lib_protocol/src/michelson_v1_primitives.mli @@ -24,7 +24,7 @@ type prim = | D_Some | D_True | D_Unit - | I_H + | I_BLAKE2B | I_ABS | I_ADD | I_AMOUNT diff --git a/src/proto_alpha/lib_protocol/src/script_interpreter.ml b/src/proto_alpha/lib_protocol/src/script_interpreter.ml index 73894f1f9..43651a40a 100644 --- a/src/proto_alpha/lib_protocol/src/script_interpreter.ml +++ b/src/proto_alpha/lib_protocol/src/script_interpreter.ml @@ -684,7 +684,7 @@ let rec interp | Hash_key, Item (key, rest) -> Lwt.return (Gas.consume ctxt Interp_costs.hash_key) >>=? fun ctxt -> logged_return (Item (Signature.Public_key.hash key, rest), ctxt) - | H ty, Item (v, rest) -> + | Blake2b ty, Item (v, rest) -> Lwt.return (Gas.consume ctxt (Interp_costs.hash v)) >>=? fun ctxt -> hash_data ctxt ty v >>=? fun (hash, ctxt) -> logged_return (Item (hash, rest), ctxt) 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 f5e18c338..3a1694872 100644 --- a/src/proto_alpha/lib_protocol/src/script_ir_translator.ml +++ b/src/proto_alpha/lib_protocol/src/script_ir_translator.ml @@ -202,7 +202,7 @@ let number_of_generated_growing_types : type b a. (b, a) instr -> int = function | Balance -> 0 | Check_signature -> 0 | Hash_key -> 0 - | H _ -> 0 + | Blake2b _ -> 0 | Steps_to_quota -> 0 | Source -> 0 | Sender -> 0 @@ -239,7 +239,7 @@ let namespace = function | D_Some | D_True | D_Unit -> Constant_namespace - | I_H + | I_BLAKE2B | I_ABS | I_ADD | I_AMOUNT @@ -2345,10 +2345,10 @@ and parse_instr parse_var_annot loc annot >>=? fun annot -> typed ctxt loc Check_signature (Item_t (Bool_t None, rest, annot)) - | Prim (loc, I_H, [], annot), + | Prim (loc, I_BLAKE2B, [], annot), Item_t (t, rest, _) -> parse_var_annot loc annot >>=? fun annot -> - typed ctxt loc (H t) + typed ctxt loc (Blake2b t) (Item_t (String_t None, rest, annot)) | Prim (loc, I_STEPS_TO_QUOTA, [], annot), stack -> @@ -2390,7 +2390,7 @@ and parse_instr | I_CREATE_CONTRACT | I_SET_DELEGATE | I_NOW | I_IMPLICIT_ACCOUNT | I_AMOUNT | I_BALANCE | I_CHECK_SIGNATURE | I_HASH_KEY | I_SOURCE | I_SENDER - | I_H | I_STEPS_TO_QUOTA | I_ADDRESS + | I_BLAKE2B | I_STEPS_TO_QUOTA | I_ADDRESS as name), (_ :: _ as l), _), _ -> fail (Invalid_arity (loc, name, 0, List.length l)) | Prim (loc, (I_NONE | I_LEFT | I_RIGHT | I_NIL | I_MAP | I_ITER @@ -2429,7 +2429,7 @@ and parse_instr | Prim (loc, I_TRANSFER_TOKENS, [], _), stack -> fail (Bad_stack (loc, I_TRANSFER_TOKENS, 4, stack)) - | Prim (loc, (I_DROP | I_DUP | I_CAR | I_CDR | I_SOME | I_H | I_DIP + | Prim (loc, (I_DROP | I_DUP | I_CAR | I_CDR | I_SOME | I_BLAKE2B | I_DIP | I_IF_NONE | I_LEFT | I_RIGHT | I_IF_LEFT | I_IF | I_LOOP | I_IF_CONS | I_IMPLICIT_ACCOUNT | I_NEG | I_ABS | I_INT | I_NOT @@ -2458,7 +2458,7 @@ and parse_instr I_LT ; I_GT ; I_LE ; I_GE ; I_TRANSFER_TOKENS ; I_CREATE_ACCOUNT ; I_CREATE_CONTRACT ; I_NOW ; I_AMOUNT ; I_BALANCE ; - I_IMPLICIT_ACCOUNT ; I_CHECK_SIGNATURE ; I_H ; I_HASH_KEY ; + I_IMPLICIT_ACCOUNT ; I_CHECK_SIGNATURE ; I_BLAKE2B ; I_HASH_KEY ; I_STEPS_TO_QUOTA ; I_PUSH ; I_NONE ; I_LEFT ; I_RIGHT ; I_NIL ; I_EMPTY_SET ; I_DIP ; I_LOOP ; 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 a090dcdc5..460bb7a2c 100644 --- a/src/proto_alpha/lib_protocol/src/script_typed_ir.ml +++ b/src/proto_alpha/lib_protocol/src/script_typed_ir.ml @@ -339,7 +339,7 @@ and ('bef, 'aft) instr = (public_key * (signature * (string * 'rest)), bool * 'rest) instr | Hash_key : (public_key * 'rest, public_key_hash * 'rest) instr - | H : 'a ty -> + | Blake2b : 'a ty -> ('a * 'rest, string * 'rest) instr | Steps_to_quota : (* TODO: check that it always returns a nat *) ('rest, n num * 'rest) instr