Alpha: classified public key revelation error.
This commit is contained in:
parent
4e82e94ef4
commit
70e31054d1
@ -38,6 +38,7 @@
|
||||
"Fitness_storage",
|
||||
"Vote_storage",
|
||||
"Init_storage",
|
||||
"Public_key_storage",
|
||||
|
||||
"Tezos_context",
|
||||
|
||||
|
@ -109,7 +109,7 @@ let check_signature_and_update_public_key ctxt id public_key op =
|
||||
match public_key with
|
||||
| None -> return ctxt
|
||||
| Some public_key ->
|
||||
Public_key.set ctxt id public_key
|
||||
Public_key.reveal ctxt id public_key
|
||||
end >>=? fun ctxt ->
|
||||
Public_key.get ctxt id >>=? fun public_key ->
|
||||
Operation.check_signature public_key op >>=? fun () ->
|
||||
|
48
src/proto/alpha/public_key_storage.ml
Normal file
48
src/proto/alpha/public_key_storage.ml
Normal file
@ -0,0 +1,48 @@
|
||||
(**************************************************************************)
|
||||
(* *)
|
||||
(* Copyright (c) 2014 - 2016. *)
|
||||
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
||||
(* *)
|
||||
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
||||
(* *)
|
||||
(**************************************************************************)
|
||||
|
||||
open Ed25519
|
||||
|
||||
type error += Inconsistent_hash of Public_key.t * Public_key_hash.t * Public_key_hash.t
|
||||
|
||||
let () =
|
||||
register_error_kind
|
||||
`Permanent
|
||||
~id:"public_key.inconsistent_hash"
|
||||
~title:"Inconsistent public key hash"
|
||||
~description:"A revealed public key is inconsistent with the announced hash"
|
||||
~pp:(fun ppf (k, eh, ph) ->
|
||||
Format.fprintf ppf "Hash of public key %s is not %a as announced but %a"
|
||||
(Public_key.to_b58check k)
|
||||
Public_key_hash.pp ph
|
||||
Public_key_hash.pp eh)
|
||||
Data_encoding.(obj3
|
||||
(req "public_key" Public_key.encoding)
|
||||
(req "expected_hash" Public_key_hash.encoding)
|
||||
(req "provided_hash" Public_key_hash.encoding))
|
||||
(function Inconsistent_hash (k, eh, ph) -> Some (k, eh, ph) | _ -> None)
|
||||
(fun (k, eh, ph) -> Inconsistent_hash (k, eh, ph))
|
||||
|
||||
let get = Storage.Public_key.get
|
||||
|
||||
let get_option = Storage.Public_key.get_option
|
||||
|
||||
let reveal c hash key =
|
||||
let actual_hash = Ed25519.Public_key.hash key in
|
||||
if Ed25519.Public_key_hash.equal hash actual_hash then
|
||||
Storage.Public_key.init_set c hash key
|
||||
else
|
||||
fail (Inconsistent_hash (key, actual_hash, hash))
|
||||
|
||||
let remove = Storage.Public_key.remove
|
||||
|
||||
let list ctxt =
|
||||
Storage.Public_key.fold ctxt [] ~f:(fun pk_h pk acc ->
|
||||
Lwt.return @@ (pk_h, pk) :: acc) >>= fun res ->
|
||||
return res
|
24
src/proto/alpha/public_key_storage.mli
Normal file
24
src/proto/alpha/public_key_storage.mli
Normal file
@ -0,0 +1,24 @@
|
||||
(**************************************************************************)
|
||||
(* *)
|
||||
(* Copyright (c) 2014 - 2016. *)
|
||||
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
||||
(* *)
|
||||
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
||||
(* *)
|
||||
(**************************************************************************)
|
||||
|
||||
open Ed25519
|
||||
|
||||
type error += Inconsistent_hash of Public_key.t * Public_key_hash.t * Public_key_hash.t
|
||||
|
||||
val get:
|
||||
Storage.t -> Public_key_hash.t -> Public_key.t tzresult Lwt.t
|
||||
val get_option:
|
||||
Storage.t -> Public_key_hash.t -> Public_key.t option tzresult Lwt.t
|
||||
val reveal:
|
||||
Storage.t -> Public_key_hash.t -> Public_key.t -> Storage.t tzresult Lwt.t
|
||||
val remove:
|
||||
Storage.t -> Public_key_hash.t -> Storage.t Lwt.t
|
||||
|
||||
val list:
|
||||
Storage.t -> (Public_key_hash.t * Public_key.t) list tzresult Lwt.t
|
@ -75,19 +75,7 @@ module Constants = struct
|
||||
constants.dictator_pubkey
|
||||
end
|
||||
|
||||
module Public_key = struct
|
||||
|
||||
let get = Storage.Public_key.get
|
||||
let get_option = Storage.Public_key.get_option
|
||||
let set = Storage.Public_key.init_set
|
||||
let remove = Storage.Public_key.remove
|
||||
|
||||
let list ctxt =
|
||||
Storage.Public_key.fold ctxt [] ~f:(fun pk_h pk acc ->
|
||||
Lwt.return @@ (pk_h, pk) :: acc) >>= fun res ->
|
||||
return res
|
||||
|
||||
end
|
||||
module Public_key = Public_key_storage
|
||||
|
||||
module Voting_period = Voting_period_repr
|
||||
|
||||
|
@ -197,7 +197,7 @@ module Public_key : sig
|
||||
context -> public_key_hash -> public_key tzresult Lwt.t
|
||||
val get_option:
|
||||
context -> public_key_hash -> public_key option tzresult Lwt.t
|
||||
val set:
|
||||
val reveal:
|
||||
context -> public_key_hash -> public_key -> context tzresult Lwt.t
|
||||
val remove:
|
||||
context -> public_key_hash -> context Lwt.t
|
||||
|
Loading…
Reference in New Issue
Block a user