Michelson: s/H/BLAKE2B/
This commit is contained in:
parent
c3f4aa1454
commit
96f6ef1c78
@ -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
|
||||
|
@ -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
|
||||
|
@ -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};
|
||||
|
@ -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}
|
||||
|
@ -1,3 +1,3 @@
|
||||
parameter (pair mutez (pair timestamp int)) ;
|
||||
storage string ;
|
||||
code { CAR ; H ; NIL operation ; PAIR }
|
||||
code { CAR ; BLAKE2B ; NIL operation ; PAIR }
|
@ -1,3 +1,3 @@
|
||||
parameter string;
|
||||
storage string;
|
||||
code {CAR; H; NIL operation; PAIR};
|
||||
code {CAR; BLAKE2B; 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}}; # 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}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -177,7 +177,7 @@ module Script : sig
|
||||
| D_Some
|
||||
| D_True
|
||||
| D_Unit
|
||||
| I_H
|
||||
| I_BLAKE2B
|
||||
| I_ABS
|
||||
| I_ADD
|
||||
| I_AMOUNT
|
||||
|
@ -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) ;
|
||||
|
@ -24,7 +24,7 @@ type prim =
|
||||
| D_Some
|
||||
| D_True
|
||||
| D_Unit
|
||||
| I_H
|
||||
| I_BLAKE2B
|
||||
| I_ABS
|
||||
| I_ADD
|
||||
| I_AMOUNT
|
||||
|
@ -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)
|
||||
|
@ -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 ;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user