Commit 367cc4e9 authored by Grégoire Henry's avatar Grégoire Henry

Faucet: rename `secret` into `activation_code`

parent 92bb69e7
Pipeline #23144614 canceled with stages
......@@ -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] )
......
{
"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",
......
......@@ -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
......
......@@ -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 ;
......
......@@ -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 =
......
......@@ -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 ->
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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 =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment