Michelson: s/H/BLAKE2B/

This commit is contained in:
Benjamin Canou 2018-06-14 15:52:05 +02:00
parent c3f4aa1454
commit 96f6ef1c78
15 changed files with 26 additions and 26 deletions

View File

@ -1451,7 +1451,7 @@ Cryptographic primitives
:: key : 'S -> key_hash : 'S :: 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. Blake2B cryptographic hash function.
:: ::
@ -2030,7 +2030,7 @@ The instructions which accept at most one variable annotation are:
BALANCE BALANCE
HASH_KEY HASH_KEY
CHECK_SIGNATURE CHECK_SIGNATURE
H BLAKE2B
STEPS_TO_QUOTA STEPS_TO_QUOTA
SOURCE SOURCE
SENDER SENDER
@ -2913,7 +2913,7 @@ XII - Full grammar
| AMOUNT | AMOUNT
| BALANCE | BALANCE
| CHECK_SIGNATURE | CHECK_SIGNATURE
| H | BLAKE2B
| HASH_KEY | HASH_KEY
| STEPS_TO_QUOTA | STEPS_TO_QUOTA
| SOURCE | SOURCE

View File

@ -24,7 +24,7 @@ code { DUP; CAR;
{ DUP; DUP; DUP; DUP; { DUP; DUP; DUP; DUP;
# Check signature on data # Check signature on data
CAR %from; CAR %from;
DIIP{ CDAR %withdraw_amount; H @signed_amount }; DIIP{ CDAR %withdraw_amount; BLAKE2B @signed_amount };
DIP{ CDDR %sig }; CHECK_SIGNATURE; DIP{ CDDR %sig }; CHECK_SIGNATURE;
IF {} { PUSH string "Bad signature"; FAILWITH }; IF {} { PUSH string "Bad signature"; FAILWITH };
# Get user account information # Get user account information

View File

@ -2,7 +2,7 @@ parameter key;
storage (pair signature string); storage (pair signature string);
code { DUP; DUP; code { DUP; DUP;
DIP{ CDR; DUP; CAR; DIP{ CDR; DUP; CAR;
DIP{CDR; H}; PAIR}; DIP{CDR; BLAKE2B}; PAIR};
CAR; DIP {UNPAIR}; CHECK_SIGNATURE; CAR; DIP {UNPAIR}; CHECK_SIGNATURE;
IF {} {FAIL} ; IF {} {FAIL} ;
CDR; NIL operation ; PAIR}; CDR; NIL operation ; PAIR};

View File

@ -1,7 +1,7 @@
parameter (pair signature (pair string nat)); parameter (pair signature (pair string nat));
storage (pair (pair key nat) string); storage (pair (pair key nat) string);
code { DUP; CAR; DIP{CDR; DUP}; 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; CHECK_SIGNATURE;
IF { CDR; DUP; DIP{CAR; DIP{CAAR}}; CDR; PUSH nat 1; ADD; IF { CDR; DUP; DIP{CAR; DIP{CAAR}}; CDR; PUSH nat 1; ADD;
DIP{SWAP}; SWAP; PAIR; PAIR; NIL operation; PAIR} DIP{SWAP}; SWAP; PAIR; PAIR; NIL operation; PAIR}

View File

@ -1,3 +1,3 @@
parameter (pair mutez (pair timestamp int)) ; parameter (pair mutez (pair timestamp int)) ;
storage string ; storage string ;
code { CAR ; H ; NIL operation ; PAIR } code { CAR ; BLAKE2B ; NIL operation ; PAIR }

View File

@ -1,3 +1,3 @@
parameter string; parameter string;
storage string; storage string;
code {CAR; H; NIL operation; PAIR}; code {CAR; BLAKE2B; NIL operation; PAIR};

View File

@ -7,7 +7,7 @@ code {DUP; DUP; CAR;
# Provide the data # Provide the data
CDR; DIP {CDDR}} CDR; DIP {CDDR}}
{DUP; DIP{SWAP}; SWAP; CDAR; # Move key to the top {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 CHECK_SIGNATURE; # Check to ensure the data is authentic
# Update data # Update data
IF {CDR; SWAP; DIP{DUP}; CDAR; PAIR} IF {CDR; SWAP; DIP{DUP}; CDAR; PAIR}

View File

@ -5,7 +5,7 @@ code { DUP; CAR; DIP{CDDR}; # Stack rangling
IF_NONE { PUSH bool False} # If not referenced, reject IF_NONE { PUSH bool False} # If not referenced, reject
{ DUP; CAR; DIP{CDR}; AND}; { DUP; CAR; DIP{CDR}; AND};
PAIR} 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}; DIP{ DIP{DUP; CDR; DIP{CAR}; DUP};
SWAP; CAR; DIP{DUP; UNPAIR}; CHECK_SIGNATURE }; # Check the first signature SWAP; CAR; DIP{DUP; UNPAIR}; CHECK_SIGNATURE }; # Check the first signature
SWAP; SWAP;

View File

@ -4,7 +4,7 @@ storage (pair (pair (contract %under_key unit)
(contract %over_key unit)) (contract %over_key unit))
(pair (nat :rain %rain_level) (key %weather_service_key))); (pair (nat :rain %rain_level) (key %weather_service_key)));
code { DUP; DUP; code { DUP; DUP;
CAR; MAP_CDR{H}; CAR; MAP_CDR{BLAKE2B};
SWAP; CDDDR %weather_service_key; SWAP; CDDDR %weather_service_key;
DIP {UNPAIR} ; CHECK_SIGNATURE @sigok; # Check if the data has been correctly signed DIP {UNPAIR} ; CHECK_SIGNATURE @sigok; # Check if the data has been correctly signed
ASSERT; # If signature is not correct, end the execution ASSERT; # If signature is not correct, end the execution

View File

@ -177,7 +177,7 @@ module Script : sig
| D_Some | D_Some
| D_True | D_True
| D_Unit | D_Unit
| I_H | I_BLAKE2B
| I_ABS | I_ABS
| I_ADD | I_ADD
| I_AMOUNT | I_AMOUNT

View File

@ -26,7 +26,7 @@ type prim =
| D_Some | D_Some
| D_True | D_True
| D_Unit | D_Unit
| I_H | I_BLAKE2B
| I_ABS | I_ABS
| I_ADD | I_ADD
| I_AMOUNT | I_AMOUNT
@ -154,7 +154,7 @@ let string_of_prim = function
| D_Some -> "Some" | D_Some -> "Some"
| D_True -> "True" | D_True -> "True"
| D_Unit -> "Unit" | D_Unit -> "Unit"
| I_H -> "H" | I_BLAKE2B -> "BLAKE2B"
| I_ABS -> "ABS" | I_ABS -> "ABS"
| I_ADD -> "ADD" | I_ADD -> "ADD"
| I_AMOUNT -> "AMOUNT" | I_AMOUNT -> "AMOUNT"
@ -263,7 +263,7 @@ let prim_of_string = function
| "Some" -> ok D_Some | "Some" -> ok D_Some
| "True" -> ok D_True | "True" -> ok D_True
| "Unit" -> ok D_Unit | "Unit" -> ok D_Unit
| "H" -> ok I_H | "BLAKE2B" -> ok I_BLAKE2B
| "ABS" -> ok I_ABS | "ABS" -> ok I_ABS
| "ADD" -> ok I_ADD | "ADD" -> ok I_ADD
| "AMOUNT" -> ok I_AMOUNT | "AMOUNT" -> ok I_AMOUNT
@ -417,7 +417,7 @@ let prim_encoding =
("Some", D_Some) ; ("Some", D_Some) ;
("True", D_True) ; ("True", D_True) ;
("Unit", D_Unit) ; ("Unit", D_Unit) ;
("H", I_H) ; ("BLAKE2B", I_BLAKE2B) ;
("ABS", I_ABS) ; ("ABS", I_ABS) ;
("ADD", I_ADD) ; ("ADD", I_ADD) ;
("AMOUNT", I_AMOUNT) ; ("AMOUNT", I_AMOUNT) ;

View File

@ -24,7 +24,7 @@ type prim =
| D_Some | D_Some
| D_True | D_True
| D_Unit | D_Unit
| I_H | I_BLAKE2B
| I_ABS | I_ABS
| I_ADD | I_ADD
| I_AMOUNT | I_AMOUNT

View File

@ -684,7 +684,7 @@ let rec interp
| Hash_key, Item (key, rest) -> | Hash_key, Item (key, rest) ->
Lwt.return (Gas.consume ctxt Interp_costs.hash_key) >>=? fun ctxt -> Lwt.return (Gas.consume ctxt Interp_costs.hash_key) >>=? fun ctxt ->
logged_return (Item (Signature.Public_key.hash key, rest), 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 -> Lwt.return (Gas.consume ctxt (Interp_costs.hash v)) >>=? fun ctxt ->
hash_data ctxt ty v >>=? fun (hash, ctxt) -> hash_data ctxt ty v >>=? fun (hash, ctxt) ->
logged_return (Item (hash, rest), ctxt) logged_return (Item (hash, rest), ctxt)

View File

@ -202,7 +202,7 @@ let number_of_generated_growing_types : type b a. (b, a) instr -> int = function
| Balance -> 0 | Balance -> 0
| Check_signature -> 0 | Check_signature -> 0
| Hash_key -> 0 | Hash_key -> 0
| H _ -> 0 | Blake2b _ -> 0
| Steps_to_quota -> 0 | Steps_to_quota -> 0
| Source -> 0 | Source -> 0
| Sender -> 0 | Sender -> 0
@ -239,7 +239,7 @@ let namespace = function
| D_Some | D_Some
| D_True | D_True
| D_Unit -> Constant_namespace | D_Unit -> Constant_namespace
| I_H | I_BLAKE2B
| I_ABS | I_ABS
| I_ADD | I_ADD
| I_AMOUNT | I_AMOUNT
@ -2345,10 +2345,10 @@ and parse_instr
parse_var_annot loc annot >>=? fun annot -> parse_var_annot loc annot >>=? fun annot ->
typed ctxt loc Check_signature typed ctxt loc Check_signature
(Item_t (Bool_t None, rest, annot)) (Item_t (Bool_t None, rest, annot))
| Prim (loc, I_H, [], annot), | Prim (loc, I_BLAKE2B, [], annot),
Item_t (t, rest, _) -> Item_t (t, rest, _) ->
parse_var_annot loc annot >>=? fun annot -> parse_var_annot loc annot >>=? fun annot ->
typed ctxt loc (H t) typed ctxt loc (Blake2b t)
(Item_t (String_t None, rest, annot)) (Item_t (String_t None, rest, annot))
| Prim (loc, I_STEPS_TO_QUOTA, [], annot), | Prim (loc, I_STEPS_TO_QUOTA, [], annot),
stack -> stack ->
@ -2390,7 +2390,7 @@ and parse_instr
| I_CREATE_CONTRACT | I_SET_DELEGATE | I_NOW | I_CREATE_CONTRACT | I_SET_DELEGATE | I_NOW
| I_IMPLICIT_ACCOUNT | I_AMOUNT | I_BALANCE | I_IMPLICIT_ACCOUNT | I_AMOUNT | I_BALANCE
| I_CHECK_SIGNATURE | I_HASH_KEY | I_SOURCE | I_SENDER | 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), _), _ -> as name), (_ :: _ as l), _), _ ->
fail (Invalid_arity (loc, name, 0, List.length l)) fail (Invalid_arity (loc, name, 0, List.length l))
| Prim (loc, (I_NONE | I_LEFT | I_RIGHT | I_NIL | I_MAP | I_ITER | 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, [], _), | Prim (loc, I_TRANSFER_TOKENS, [], _),
stack -> stack ->
fail (Bad_stack (loc, I_TRANSFER_TOKENS, 4, 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_IF_NONE | I_LEFT | I_RIGHT | I_IF_LEFT | I_IF
| I_LOOP | I_IF_CONS | I_IMPLICIT_ACCOUNT | I_LOOP | I_IF_CONS | I_IMPLICIT_ACCOUNT
| I_NEG | I_ABS | I_INT | I_NOT | I_NEG | I_ABS | I_INT | I_NOT
@ -2458,7 +2458,7 @@ and parse_instr
I_LT ; I_GT ; I_LE ; I_GE ; I_LT ; I_GT ; I_LE ; I_GE ;
I_TRANSFER_TOKENS ; I_CREATE_ACCOUNT ; I_TRANSFER_TOKENS ; I_CREATE_ACCOUNT ;
I_CREATE_CONTRACT ; I_NOW ; I_AMOUNT ; I_BALANCE ; 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_STEPS_TO_QUOTA ;
I_PUSH ; I_NONE ; I_LEFT ; I_RIGHT ; I_NIL ; I_PUSH ; I_NONE ; I_LEFT ; I_RIGHT ; I_NIL ;
I_EMPTY_SET ; I_DIP ; I_LOOP ; I_EMPTY_SET ; I_DIP ; I_LOOP ;

View File

@ -339,7 +339,7 @@ and ('bef, 'aft) instr =
(public_key * (signature * (string * 'rest)), bool * 'rest) instr (public_key * (signature * (string * 'rest)), bool * 'rest) instr
| Hash_key : | Hash_key :
(public_key * 'rest, public_key_hash * 'rest) instr (public_key * 'rest, public_key_hash * 'rest) instr
| H : 'a ty -> | Blake2b : 'a ty ->
('a * 'rest, string * 'rest) instr ('a * 'rest, string * 'rest) instr
| Steps_to_quota : (* TODO: check that it always returns a nat *) | Steps_to_quota : (* TODO: check that it always returns a nat *)
('rest, n num * 'rest) instr ('rest, n num * 'rest) instr