From 07ba685b8d4328db694e992466c4d29d0c5d3b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Fri, 23 Sep 2016 15:06:17 +0200 Subject: [PATCH] Base48: encode the "data" before its "hash" --- src/client/embedded/bootstrap/client_proto_main.ml | 2 +- src/client/embedded/demo/client_proto_main.ml | 2 +- src/node/shell/node.ml | 2 +- src/node_main.ml | 6 +++--- src/proto/bootstrap/TEZOS_PROTOCOL | 4 +++- src/proto/demo/TEZOS_PROTOCOL | 2 +- src/utils/base48.ml | 8 ++++---- test/test_context.ml | 4 ++-- test/test_state.ml | 4 ++-- test/test_store.ml | 4 ++-- 10 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/client/embedded/bootstrap/client_proto_main.ml b/src/client/embedded/bootstrap/client_proto_main.ml index bc4d0155e..18122b9f7 100644 --- a/src/client/embedded/bootstrap/client_proto_main.ml +++ b/src/client/embedded/bootstrap/client_proto_main.ml @@ -9,7 +9,7 @@ let protocol = Protocol_hash.of_b48check - "TnrnfGHMCPAcxtMAHXdpfebbnn2XvPAxq7DHbpeJbKTkJQPgcgRGr" + "4prgmSgbaeMKbgLtLjpsHaDD9QvG2dbC2bLq2XBmyxd2RJgLFpcAg" let () = Client_version.register protocol @@ diff --git a/src/client/embedded/demo/client_proto_main.ml b/src/client/embedded/demo/client_proto_main.ml index af367ffc1..355588a37 100644 --- a/src/client/embedded/demo/client_proto_main.ml +++ b/src/client/embedded/demo/client_proto_main.ml @@ -9,7 +9,7 @@ let protocol = Protocol_hash.of_b48check - "JF7Fxgeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + "2gagXCT66nmJ2mKh3a6Aeysy9CHaHsAJyDEGSyFNeFAxGCJehsKpK" let demo () = let block = Client_config.block () in diff --git a/src/node/shell/node.ml b/src/node/shell/node.ml index 22534aca5..0ee7704bb 100644 --- a/src/node/shell/node.ml +++ b/src/node/shell/node.ml @@ -330,7 +330,7 @@ module RPC = struct let prevalidation_hash = Block_hash.of_b48check - "Et22nEeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + "eeeeeeeeeeeeeegqJHARhSaNXggmMs8K3tvsgn4rBprkvpFAMVD5d" let get_net node = function | `Head _ | `Prevalidation -> node.global_validator, node.global_net diff --git a/src/node_main.ml b/src/node_main.ml index 8c52837d4..949071c9c 100644 --- a/src/node_main.ml +++ b/src/node_main.ml @@ -12,15 +12,15 @@ open Logging.Node.Main let genesis_block = Block_hash.of_b48check - "qBeeesNtMrdyRDj6hSK2PxEN9R67brGSm64EFRjJSBTTqLcQCRHNR" + "eeHfgnr9QeDNvcMgSfATNeDeec4KG4CkHHkNNJt5B9xdVmsxhsHNR" let genesis_protocol = Protocol_hash.of_b48check - "TnrnfGHMCPAcxtMAHXdpfebbnn2XvPAxq7DHbpeJbKTkJQPgcgRGr" + "4prgmSgbaeMKbgLtLjpsHaDD9QvG2dbC2bLq2XBmyxd2RJgLFpcAg" let test_protocol = Some (Protocol_hash.of_b48check - "JF7Fxgeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee") + "2gagXCT66nmJ2mKh3a6Aeysy9CHaHsAJyDEGSyFNeFAxGCJehsKpK") let genesis_time = Time.of_notation_exn "2016-08-01T00:00:00Z" diff --git a/src/proto/bootstrap/TEZOS_PROTOCOL b/src/proto/bootstrap/TEZOS_PROTOCOL index 50b9fca67..86d10d8c3 100644 --- a/src/proto/bootstrap/TEZOS_PROTOCOL +++ b/src/proto/bootstrap/TEZOS_PROTOCOL @@ -1,8 +1,10 @@ { - "hash": "TnrnfGHMCPAcxtMAHXdpfebbnn2XvPAxq7DHbpeJbKTkJQPgcgRGr", + "hash": "4prgmSgbaeMKbgLtLjpsHaDD9QvG2dbC2bLq2XBmyxd2RJgLFpcAg", "modules": [ + "Misc", "Tezos_hash", + "Qty_repr", "Tez_repr", "Period_repr", diff --git a/src/proto/demo/TEZOS_PROTOCOL b/src/proto/demo/TEZOS_PROTOCOL index ab9f2dec6..08eb00275 100644 --- a/src/proto/demo/TEZOS_PROTOCOL +++ b/src/proto/demo/TEZOS_PROTOCOL @@ -1,4 +1,4 @@ { - "hash": "JF7Fxgeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", + "hash": "2gagXCT66nmJ2mKh3a6Aeysy9CHaHsAJyDEGSyFNeFAxGCJehsKpK", "modules": ["Error", "Services", "Main"] } diff --git a/src/utils/base48.ml b/src/utils/base48.ml index 6c9d9471e..619603217 100644 --- a/src/utils/base48.ml +++ b/src/utils/base48.ml @@ -15,7 +15,7 @@ let decode_alphabet alphabet = Bytes.to_string str let default_alphabet = - "eXMNE9qvHPQDdcFx5J86rT7VRm2atAypGhgLfbS3CKjnksB4" + "eE2NXaQvHPqDdTJxfF36jb7VRmp9tAyMgG4L5cS8CKrnksBh" let default_decode_alphabet = decode_alphabet default_alphabet @@ -85,13 +85,13 @@ let sha256 s = computed_hash let safe_encode ?alphabet s = - raw_encode ?alphabet (String.sub (sha256 (sha256 s)) 0 4 ^ s) + raw_encode ?alphabet (s ^ String.sub (sha256 (sha256 s)) 0 4) let safe_decode ?alphabet s = let s = raw_decode ?alphabet s in let len = String.length s in - let msg_hash = String.sub s 0 4 in - let msg = String.sub s 4 (len-4) in + let msg = String.sub s 0 (len-4) + and msg_hash = String.sub s (len-4) 4 in if msg_hash <> String.sub (sha256 (sha256 msg)) 0 4 then invalid_arg "safe_decode" ; msg diff --git a/test/test_context.ml b/test/test_context.ml index c3f7efd5c..81c838fc7 100644 --- a/test/test_context.ml +++ b/test/test_context.ml @@ -18,11 +18,11 @@ let (//) = Filename.concat let genesis_block = Block_hash.of_b48check - "Et22nEeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + "eeeeeeeeeeeeeegqJHARhSaNXggmMs8K3tvsgn4rBprkvpFAMVD5d" let genesis_protocol = Protocol_hash.of_b48check - "JF7Fxgeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + "2gagXCT66nmJ2mKh3a6Aeysy9CHaHsAJyDEGSyFNeFAxGCJehsKpK" let genesis_time = Time.of_seconds 0L diff --git a/test/test_state.ml b/test/test_state.ml index 8d0dabf19..75497e440 100644 --- a/test/test_state.ml +++ b/test/test_state.ml @@ -16,11 +16,11 @@ let (//) = Filename.concat let genesis_block = Block_hash.of_b48check - "Et22nEeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + "eeeeeeeeeeeeeegqJHARhSaNXggmMs8K3tvsgn4rBprkvpFAMVD5d" let genesis_protocol = Protocol_hash.of_b48check - "JF7Fxgeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + "2gagXCT66nmJ2mKh3a6Aeysy9CHaHsAJyDEGSyFNeFAxGCJehsKpK" let genesis_time = Time.of_seconds 0L diff --git a/test/test_store.ml b/test/test_store.ml index 94685add2..26602189f 100644 --- a/test/test_store.ml +++ b/test/test_store.ml @@ -18,11 +18,11 @@ let (//) = Filename.concat let genesis_block = Block_hash.of_b48check - "Et22nEeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + "eeeeeeeeeeeeeegqJHARhSaNXggmMs8K3tvsgn4rBprkvpFAMVD5d" let genesis_protocol = Protocol_hash.of_b48check - "JF7Fxgeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" + "2gagXCT66nmJ2mKh3a6Aeysy9CHaHsAJyDEGSyFNeFAxGCJehsKpK" let genesis_time = Time.of_seconds 0L