Alpha: split Tezos_hash multiple source files

This commit is contained in:
Grégoire Henry 2018-02-11 19:17:40 +01:00
parent 5fff7b3c1b
commit 3b95f77225
19 changed files with 91 additions and 80 deletions

View File

@ -2,7 +2,10 @@
"hash": "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK",
"modules": [
"Misc",
"Tezos_hash",
"State_hash",
"Nonce_hash",
"Script_expr_hash",
"Contract_hash",
"Qty_repr",
"Tez_repr",

View File

@ -54,8 +54,6 @@ type public_key_hash = Ed25519.Public_key_hash.t
type secret_key = Ed25519.Secret_key.t
type signature = Ed25519.Signature.t
include Tezos_hash
module Constants = struct
include Constants_repr
let cycle_length c =

View File

@ -17,10 +17,6 @@ end
type t
type context = t
module Contract_hash = Tezos_hash.Contract_hash
module Nonce_hash = Tezos_hash.Nonce_hash
type public_key = Ed25519.Public_key.t
type public_key_hash = Ed25519.Public_key_hash.t
type secret_key = Ed25519.Secret_key.t

View File

@ -7,8 +7,6 @@
(* *)
(**************************************************************************)
open Tezos_hash
(** Block header *)
(** Exported type *)

View File

@ -7,8 +7,6 @@
(* *)
(**************************************************************************)
open Tezos_hash
(** Exported type *)
type t = {
shell: Block_header.shell_header ;

View File

@ -0,0 +1,21 @@
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2018. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
(* 20 *)
let contract_hash = "\003\099\029" (* TZ(36) *)
include Blake2B.Make(Base58)(struct
let name = "Contract_hash"
let title = "A contract ID"
let b58check_prefix = contract_hash
let size = Some 20
end)
let () =
Base58.check_encoded_prefix b58check_encoding "TZ1" 36

View File

@ -7,8 +7,6 @@
(* *)
(**************************************************************************)
open Tezos_hash
type t =
| Default of Ed25519.Public_key_hash.t
| Originated of Contract_hash.t

View File

@ -7,8 +7,6 @@
(* *)
(**************************************************************************)
open Tezos_hash
type t = private
| Default of Ed25519.Public_key_hash.t
| Originated of Contract_hash.t

View File

@ -0,0 +1,21 @@
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2018. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
(* 32 *)
let nonce_hash = "\069\220\169" (* nce(53) *)
include Blake2B.Make(Base58)(struct
let name = "cycle_nonce"
let title = "A nonce hash"
let b58check_prefix = nonce_hash
let size = None
end)
let () =
Base58.check_encoded_prefix b58check_encoding "nce" 53

View File

@ -54,7 +54,7 @@ let reveal c level nonce =
type status = Storage.Seed.nonce_status =
| Unrevealed of {
nonce_hash: Tezos_hash.Nonce_hash.t ;
nonce_hash: Nonce_hash.t ;
delegate_to_reward: Ed25519.Public_key_hash.t ;
reward_amount: Tez_repr.t ;
}

View File

@ -7,8 +7,6 @@
(* *)
(**************************************************************************)
open Tezos_hash
type error +=
| Too_late_revelation
| Too_early_revelation
@ -30,7 +28,7 @@ val reveal:
type status =
| Unrevealed of {
nonce_hash: Tezos_hash.Nonce_hash.t ;
nonce_hash: Nonce_hash.t ;
delegate_to_reward: Ed25519.Public_key_hash.t ;
reward_amount: Tez_repr.t ;
}

View File

@ -0,0 +1,20 @@
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2018. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
let script_expr_hash = "\013\044\064\027" (* expr(54) *)
include Blake2B.Make(Base58)(struct
let name = "script_expr"
let title = "A script expression ID"
let b58check_prefix = script_expr_hash
let size = None
end)
let () =
Base58.check_encoded_prefix b58check_encoding "expr" 54

View File

@ -2130,7 +2130,7 @@ let typecheck_data
let hash_data typ data =
let unparsed = strip_annotations @@ unparse_data typ data in
let bytes = Data_encoding.Binary.to_bytes expr_encoding (Micheline.strip_locations unparsed) in
Tezos_hash.Script_expr_hash.(hash_bytes [ bytes ] |> to_b58check)
Script_expr_hash.(hash_bytes [ bytes ] |> to_b58check)
(* ---------------- Big map -------------------------------------------------*)

View File

@ -9,8 +9,6 @@
(* Tezos Protocol Implementation - Random number generation *)
open Tezos_hash
type seed = B of State_hash.t
type t = T of State_hash.t
type sequence = S of State_hash.t

View File

@ -7,8 +7,6 @@
(* *)
(**************************************************************************)
open Tezos_hash
(** Tezos Protocol Implementation - Random number generation
This is not expected to be a good cryptographic random number

View File

@ -0,0 +1,21 @@
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2018. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
let random_state_hash = "\076\064\204" (* rng(53): never used... *)
include Blake2B.Make(Base58)(struct
let name = "random"
let title = "A random generation state"
let b58check_prefix = random_state_hash
let size = None
end)
let () =
Base58.check_encoded_prefix b58check_encoding "rng" 53

View File

@ -7,7 +7,6 @@
(* *)
(**************************************************************************)
open Tezos_hash
open Storage_functors
module Int32 = struct

View File

@ -209,7 +209,7 @@ module Seed : sig
type nonce_status =
| Unrevealed of {
nonce_hash: Tezos_hash.Nonce_hash.t ;
nonce_hash: Nonce_hash.t ;
delegate_to_reward: Ed25519.Public_key_hash.t ;
reward_amount: Tez_repr.t ;
}

View File

@ -1,54 +0,0 @@
(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2018. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
module Prefix = struct
(* 20 *)
let contract_hash = "\003\099\029" (* TZ(36) *)
(* 32 *)
let nonce_hash = "\069\220\169" (* nce(53) *)
let script_expr_hash = "\013\044\064\027" (* expr(54) *)
let random_state_hash = "\076\064\204" (* rng(53): never used... *)
end
module State_hash = Blake2B.Make(Base58)(struct
let name = "random"
let title = "A random generation state"
let b58check_prefix = Prefix.random_state_hash
let size = None
end)
module Nonce_hash = Blake2B.Make(Base58)(struct
let name = "cycle_nonce"
let title = "A nonce hash"
let b58check_prefix = Prefix.nonce_hash
let size = None
end)
module Script_expr_hash = Blake2B.Make(Base58)(struct
let name = "script_expr"
let title = "A script expression ID"
let b58check_prefix = Prefix.script_expr_hash
let size = None
end)
module Contract_hash = Blake2B.Make(Base58)(struct
let name = "Contract_hash"
let title = "A contract ID"
let b58check_prefix = Prefix.contract_hash
let size = Some 20
end)
let () =
Base58.check_encoded_prefix Contract_hash.b58check_encoding "TZ1" 36 ;
Base58.check_encoded_prefix Script_expr_hash.b58check_encoding "expr" 54 ;
Base58.check_encoded_prefix Nonce_hash.b58check_encoding "nce" 53 ;
Base58.check_encoded_prefix State_hash.b58check_encoding "rng" 53