diff --git a/scripts/create_genesis/create_genesis_info.py b/scripts/create_genesis/create_genesis_info.py index 90fe763bc..b28fee478 100755 --- a/scripts/create_genesis/create_genesis_info.py +++ b/scripts/create_genesis/create_genesis_info.py @@ -104,7 +104,7 @@ if __name__ == '__main__': "email" : email, "password" : password, "amount" : str(amount), - "secret" : secret } + "activation_code" : secret } for pkh, (mnemonic, email, password, amount, secret) in secrets.iteritems()], f, indent=1) else: wallets = get_wallets( sys.argv[1] ) diff --git a/src/bin_client/test/queen_commitment.json b/src/bin_client/test/queen_commitment.json index 0534e38cf..7928579d6 100644 --- a/src/bin_client/test/queen_commitment.json +++ b/src/bin_client/test/queen_commitment.json @@ -1,6 +1,6 @@ { "mnemonic": ["flag", "quote", "will", "valley", "mouse", "chat", "hold", "prosper", "silk", "tent", "cruel", "cause", "demise", "bottom", "practice"], - "secret": "41f98b15efc63fa893d61d7d6eee4a2ce9427ac4", + "activation_code": "41f98b15efc63fa893d61d7d6eee4a2ce9427ac4", "amount": "72954577464032", "pkh": "tz1X4maqF9tC1Yn4jULjHRAyzjAtc25Z68TX", "password": "MHErskWPE6", diff --git a/src/proto_alpha/lib_client/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml index 9634cebd8..d8be3a892 100644 --- a/src/proto_alpha/lib_client/client_proto_context.ml +++ b/src/proto_alpha/lib_client/client_proto_context.ml @@ -237,26 +237,49 @@ let originate_contract type activation_key = { pkh : Ed25519.Public_key_hash.t ; amount : Tez.t ; - secret : Blinded_public_key_hash.secret ; + activation_code : Blinded_public_key_hash.activation_code ; mnemonic : string list ; password : string ; email : string ; } +let raw_activation_key_encoding = + let open Data_encoding in + obj6 + (req "pkh" Ed25519.Public_key_hash.encoding) + (req "amount" Tez.encoding) + (req "activation_code" Blinded_public_key_hash.activation_code_encoding) + (req "mnemonic" (list string)) + (req "password" string) + (req "email" string) + let activation_key_encoding = + (* Hack: allow compatibility with older encoding *) let open Data_encoding in conv - (fun { pkh ; amount ; secret ; mnemonic ; password ; email } -> - ( pkh, amount, secret, mnemonic, password, email )) - (fun ( pkh, amount, secret, mnemonic, password, email ) -> - { pkh ; amount ; secret ; mnemonic ; password ; email }) - (obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) - (req "amount" Tez.encoding) - (req "secret" Blinded_public_key_hash.secret_encoding) - (req "mnemonic" (list string)) - (req "password" string) - (req "email" string)) + (fun { pkh ; amount ; activation_code ; mnemonic ; password ; email } -> + ( pkh, amount, activation_code, mnemonic, password, email )) + (fun ( pkh, amount, activation_code, mnemonic, password, email ) -> + { pkh ; amount ; activation_code ; mnemonic ; password ; email }) @@ + splitted + ~binary:raw_activation_key_encoding + ~json: + (union [ + case Json_only + raw_activation_key_encoding + (fun x -> Some x) + (fun x -> x) ; + case Json_only + (obj6 + (req "pkh" Ed25519.Public_key_hash.encoding) + (req "amount" Tez.encoding) + (req "secret" Blinded_public_key_hash.activation_code_encoding) + (req "mnemonic" (list string)) + (req "password" string) + (req "email" string)) + (fun _ -> None) + (fun x -> x) ; + ]) let read_key key = match Bip39.of_words key.mnemonic with @@ -283,7 +306,7 @@ let claim_commitment (cctxt : #Proto_alpha.full) Ed25519.Public_key_hash.pp key.pkh) >>=? fun () -> let contents = Anonymous_operations - [ Activation { id = key.pkh ; secret = key.secret } ] in + [ Activation { id = key.pkh ; activation_code = key.activation_code } ] in Injection.inject_operation cctxt ?confirmations block contents >>=? fun (_oph, _op, _result as res) -> let pk_uri = Tezos_signer_backends.Unencrypted.make_pk pk in begin diff --git a/src/proto_alpha/lib_client/client_proto_context.mli b/src/proto_alpha/lib_client/client_proto_context.mli index 734476eec..dd3d31235 100644 --- a/src/proto_alpha/lib_client/client_proto_context.mli +++ b/src/proto_alpha/lib_client/client_proto_context.mli @@ -141,7 +141,7 @@ val dictate : type activation_key = { pkh : Ed25519.Public_key_hash.t ; amount : Tez.t ; - secret : Blinded_public_key_hash.secret ; + activation_code : Blinded_public_key_hash.activation_code ; mnemonic : string list ; password : string ; email : string ; diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.mli b/src/proto_alpha/lib_protocol/src/alpha_context.mli index dc151b47a..e1f9c6bc4 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_context.mli @@ -745,7 +745,7 @@ and anonymous_operation = } | Activation of { id: Ed25519.Public_key_hash.t ; - secret: Blinded_public_key_hash.secret ; + activation_code: Blinded_public_key_hash.activation_code ; } and sourced_operation = diff --git a/src/proto_alpha/lib_protocol/src/apply.ml b/src/proto_alpha/lib_protocol/src/apply.ml index a73c40922..3ca7f1514 100644 --- a/src/proto_alpha/lib_protocol/src/apply.ml +++ b/src/proto_alpha/lib_protocol/src/apply.ml @@ -690,8 +690,9 @@ let apply_anonymous_operation ctxt kind = | Error _ -> Tez.zero in add_rewards ctxt reward >>=? fun ctxt -> return (ctxt, Double_baking_evidence_result [(* FIXME *)]) - | Activation { id = pkh ; secret } -> - let blinded_pkh = Blinded_public_key_hash.of_ed25519_pkh secret pkh in + | Activation { id = pkh ; activation_code } -> + let blinded_pkh = + Blinded_public_key_hash.of_ed25519_pkh activation_code pkh in Commitment.get_opt ctxt blinded_pkh >>=? function | None -> fail (Invalid_activation { pkh }) | Some amount -> diff --git a/src/proto_alpha/lib_protocol/src/blinded_public_key_hash.ml b/src/proto_alpha/lib_protocol/src/blinded_public_key_hash.ml index e07a313bb..ab85cd428 100644 --- a/src/proto_alpha/lib_protocol/src/blinded_public_key_hash.ml +++ b/src/proto_alpha/lib_protocol/src/blinded_public_key_hash.ml @@ -17,17 +17,17 @@ include Blake2B.Make(Base58)(struct let () = Base58.check_encoded_prefix b58check_encoding "btz1" 37 -let of_ed25519_pkh secret pkh = - hash_bytes ~key:secret [ Ed25519.Public_key_hash.to_bytes pkh ] +let of_ed25519_pkh activation_code pkh = + hash_bytes ~key:activation_code [ Ed25519.Public_key_hash.to_bytes pkh ] -type secret = MBytes.t +type activation_code = MBytes.t -let secret_size = Ed25519.Public_key_hash.size -let secret_encoding = Data_encoding.Fixed.bytes secret_size +let activation_code_size = Ed25519.Public_key_hash.size +let activation_code_encoding = Data_encoding.Fixed.bytes activation_code_size -let secret_of_hex h = - if Compare.Int.(String.length h <> secret_size * 2) then - invalid_arg "Blinded_public_key_hash.secret_of_hex" ; +let activation_code_of_hex h = + if Compare.Int.(String.length h <> activation_code_size * 2) then + invalid_arg "Blinded_public_key_hash.activation_code_of_hex" ; MBytes.of_hex (`Hex h) module Index = struct diff --git a/src/proto_alpha/lib_protocol/src/blinded_public_key_hash.mli b/src/proto_alpha/lib_protocol/src/blinded_public_key_hash.mli index 7be2efba0..7e7da12cf 100644 --- a/src/proto_alpha/lib_protocol/src/blinded_public_key_hash.mli +++ b/src/proto_alpha/lib_protocol/src/blinded_public_key_hash.mli @@ -9,12 +9,12 @@ include S.HASH -type secret -val secret_encoding : secret Data_encoding.t +type activation_code +val activation_code_encoding : activation_code Data_encoding.t -val of_ed25519_pkh : secret -> Ed25519.Public_key_hash.t -> t +val of_ed25519_pkh : activation_code -> Ed25519.Public_key_hash.t -> t -val secret_of_hex : string -> secret +val activation_code_of_hex : string -> activation_code module Index : sig type nonrec t = t diff --git a/src/proto_alpha/lib_protocol/src/operation_repr.ml b/src/proto_alpha/lib_protocol/src/operation_repr.ml index 6e7f7df57..d06778bfe 100644 --- a/src/proto_alpha/lib_protocol/src/operation_repr.ml +++ b/src/proto_alpha/lib_protocol/src/operation_repr.ml @@ -45,7 +45,7 @@ and anonymous_operation = } | Activation of { id: Ed25519.Public_key_hash.t ; - secret: Blinded_public_key_hash.secret ; + activation_code: Blinded_public_key_hash.activation_code ; } and sourced_operation = @@ -368,15 +368,15 @@ module Encoding = struct (obj3 (req "kind" (constant "activation")) (req "pkh" Ed25519.Public_key_hash.encoding) - (req "secret" Blinded_public_key_hash.secret_encoding)) + (req "activation_code" Blinded_public_key_hash.activation_code_encoding)) let activation_case tag = case tag activation_encoding (function - | Activation { id ; secret } -> Some ((), id, secret) + | Activation { id ; activation_code } -> Some ((), id, activation_code) | _ -> None ) - (fun ((), id, secret) -> Activation { id ; secret }) + (fun ((), id, activation_code) -> Activation { id ; activation_code }) let anonymous_operations_case tag op_encoding = case tag diff --git a/src/proto_alpha/lib_protocol/src/operation_repr.mli b/src/proto_alpha/lib_protocol/src/operation_repr.mli index bdd855b5d..4f1bec011 100644 --- a/src/proto_alpha/lib_protocol/src/operation_repr.mli +++ b/src/proto_alpha/lib_protocol/src/operation_repr.mli @@ -45,7 +45,7 @@ and anonymous_operation = } | Activation of { id: Ed25519.Public_key_hash.t ; - secret: Blinded_public_key_hash.secret ; + activation_code: Blinded_public_key_hash.activation_code ; } and sourced_operation =