diff --git a/src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL b/src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL index d2e629b3a..32e82d17b 100644 --- a/src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL +++ b/src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL @@ -2,7 +2,10 @@ "hash": "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK", "modules": [ "Misc", - "Tezos_hash", + "State_hash", + "Nonce_hash", + "Script_expr_hash", + "Contract_hash", "Qty_repr", "Tez_repr", diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.ml b/src/proto_alpha/lib_protocol/src/alpha_context.ml index fbdfbe237..3feafd805 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/src/alpha_context.ml @@ -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 = diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.mli b/src/proto_alpha/lib_protocol/src/alpha_context.mli index a8f3245ec..6b29978e6 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_context.mli @@ -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 diff --git a/src/proto_alpha/lib_protocol/src/block_header_repr.ml b/src/proto_alpha/lib_protocol/src/block_header_repr.ml index 5265182b8..149d3af0c 100644 --- a/src/proto_alpha/lib_protocol/src/block_header_repr.ml +++ b/src/proto_alpha/lib_protocol/src/block_header_repr.ml @@ -7,8 +7,6 @@ (* *) (**************************************************************************) -open Tezos_hash - (** Block header *) (** Exported type *) diff --git a/src/proto_alpha/lib_protocol/src/block_header_repr.mli b/src/proto_alpha/lib_protocol/src/block_header_repr.mli index d84d9f4e9..2fad14041 100644 --- a/src/proto_alpha/lib_protocol/src/block_header_repr.mli +++ b/src/proto_alpha/lib_protocol/src/block_header_repr.mli @@ -7,8 +7,6 @@ (* *) (**************************************************************************) -open Tezos_hash - (** Exported type *) type t = { shell: Block_header.shell_header ; diff --git a/src/proto_alpha/lib_protocol/src/contract_hash.ml b/src/proto_alpha/lib_protocol/src/contract_hash.ml new file mode 100644 index 000000000..689fee038 --- /dev/null +++ b/src/proto_alpha/lib_protocol/src/contract_hash.ml @@ -0,0 +1,21 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* 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 diff --git a/src/proto_alpha/lib_protocol/src/contract_repr.ml b/src/proto_alpha/lib_protocol/src/contract_repr.ml index d70d6c85a..388d473c1 100644 --- a/src/proto_alpha/lib_protocol/src/contract_repr.ml +++ b/src/proto_alpha/lib_protocol/src/contract_repr.ml @@ -7,8 +7,6 @@ (* *) (**************************************************************************) -open Tezos_hash - type t = | Default of Ed25519.Public_key_hash.t | Originated of Contract_hash.t diff --git a/src/proto_alpha/lib_protocol/src/contract_repr.mli b/src/proto_alpha/lib_protocol/src/contract_repr.mli index 3fc41c9aa..5b5a100a1 100644 --- a/src/proto_alpha/lib_protocol/src/contract_repr.mli +++ b/src/proto_alpha/lib_protocol/src/contract_repr.mli @@ -7,8 +7,6 @@ (* *) (**************************************************************************) -open Tezos_hash - type t = private | Default of Ed25519.Public_key_hash.t | Originated of Contract_hash.t diff --git a/src/proto_alpha/lib_protocol/src/nonce_hash.ml b/src/proto_alpha/lib_protocol/src/nonce_hash.ml new file mode 100644 index 000000000..eb5e46eab --- /dev/null +++ b/src/proto_alpha/lib_protocol/src/nonce_hash.ml @@ -0,0 +1,21 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* 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 diff --git a/src/proto_alpha/lib_protocol/src/nonce_storage.ml b/src/proto_alpha/lib_protocol/src/nonce_storage.ml index 800b87119..7b5521489 100644 --- a/src/proto_alpha/lib_protocol/src/nonce_storage.ml +++ b/src/proto_alpha/lib_protocol/src/nonce_storage.ml @@ -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 ; } diff --git a/src/proto_alpha/lib_protocol/src/nonce_storage.mli b/src/proto_alpha/lib_protocol/src/nonce_storage.mli index 1010818f4..836439b3c 100644 --- a/src/proto_alpha/lib_protocol/src/nonce_storage.mli +++ b/src/proto_alpha/lib_protocol/src/nonce_storage.mli @@ -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 ; } diff --git a/src/proto_alpha/lib_protocol/src/script_expr_hash.ml b/src/proto_alpha/lib_protocol/src/script_expr_hash.ml new file mode 100644 index 000000000..6257e1156 --- /dev/null +++ b/src/proto_alpha/lib_protocol/src/script_expr_hash.ml @@ -0,0 +1,20 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* 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 diff --git a/src/proto_alpha/lib_protocol/src/script_ir_translator.ml b/src/proto_alpha/lib_protocol/src/script_ir_translator.ml index b5943384f..e6cef1123 100644 --- a/src/proto_alpha/lib_protocol/src/script_ir_translator.ml +++ b/src/proto_alpha/lib_protocol/src/script_ir_translator.ml @@ -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 -------------------------------------------------*) diff --git a/src/proto_alpha/lib_protocol/src/seed_repr.ml b/src/proto_alpha/lib_protocol/src/seed_repr.ml index 4d49237f3..7f914b827 100644 --- a/src/proto_alpha/lib_protocol/src/seed_repr.ml +++ b/src/proto_alpha/lib_protocol/src/seed_repr.ml @@ -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 diff --git a/src/proto_alpha/lib_protocol/src/seed_repr.mli b/src/proto_alpha/lib_protocol/src/seed_repr.mli index 06f04f42c..994987c82 100644 --- a/src/proto_alpha/lib_protocol/src/seed_repr.mli +++ b/src/proto_alpha/lib_protocol/src/seed_repr.mli @@ -7,8 +7,6 @@ (* *) (**************************************************************************) -open Tezos_hash - (** Tezos Protocol Implementation - Random number generation This is not expected to be a good cryptographic random number diff --git a/src/proto_alpha/lib_protocol/src/state_hash.ml b/src/proto_alpha/lib_protocol/src/state_hash.ml new file mode 100644 index 000000000..91790ace5 --- /dev/null +++ b/src/proto_alpha/lib_protocol/src/state_hash.ml @@ -0,0 +1,21 @@ +(**************************************************************************) +(* *) +(* Copyright (c) 2014 - 2018. *) +(* Dynamic Ledger Solutions, Inc. *) +(* *) +(* 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 + diff --git a/src/proto_alpha/lib_protocol/src/storage.ml b/src/proto_alpha/lib_protocol/src/storage.ml index cd1c822dd..b5608b222 100644 --- a/src/proto_alpha/lib_protocol/src/storage.ml +++ b/src/proto_alpha/lib_protocol/src/storage.ml @@ -7,7 +7,6 @@ (* *) (**************************************************************************) -open Tezos_hash open Storage_functors module Int32 = struct diff --git a/src/proto_alpha/lib_protocol/src/storage.mli b/src/proto_alpha/lib_protocol/src/storage.mli index 203b08f07..843c74818 100644 --- a/src/proto_alpha/lib_protocol/src/storage.mli +++ b/src/proto_alpha/lib_protocol/src/storage.mli @@ -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 ; } diff --git a/src/proto_alpha/lib_protocol/src/tezos_hash.ml b/src/proto_alpha/lib_protocol/src/tezos_hash.ml deleted file mode 100644 index 9f4d46b2b..000000000 --- a/src/proto_alpha/lib_protocol/src/tezos_hash.ml +++ /dev/null @@ -1,54 +0,0 @@ -(**************************************************************************) -(* *) -(* Copyright (c) 2014 - 2018. *) -(* Dynamic Ledger Solutions, Inc. *) -(* *) -(* 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