From ffc0189f19c2b11f4a9b7f8211cdebbf2be82055 Mon Sep 17 00:00:00 2001 From: Eitan Chatav Date: Fri, 18 Nov 2016 14:07:27 -0800 Subject: [PATCH] default target takes a couple seconds on my laptop to generate a proof of work with this target --- src/utils/crypto_box.ml | 6 +++++- src/utils/crypto_box.mli | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/crypto_box.ml b/src/utils/crypto_box.ml index 328a71036..3ab89a7f4 100644 --- a/src/utils/crypto_box.ml +++ b/src/utils/crypto_box.ml @@ -43,7 +43,11 @@ let compare_target xs target = let bytes = MBytes.of_string hash in let get_16 = EndianBigstring.BigEndian.get_uint16 bytes in let offsets = [0;2;4;6;8;10;12;14;16;18;20;22;24;26;28;30] in - List.for_all2 (fun o t -> get_16 o < t) offsets target + List.for_all2 (fun o t -> get_16 o <= t) offsets target + +let default_target = + let x = 1 lsl 16 - 1 in + [0;1 lsl 13;x;x;x;x;x;x;x;x;x;x;x;x;x;x] let check_proof_of_work pk nonce target = let what_to_hash = diff --git a/src/utils/crypto_box.mli b/src/utils/crypto_box.mli index 3cb55d3d6..ac50b23bf 100644 --- a/src/utils/crypto_box.mli +++ b/src/utils/crypto_box.mli @@ -18,6 +18,7 @@ val nonce_encoding : nonce Data_encoding.t type target val compare_target : MBytes.t list -> target -> bool val validate_target : target -> unit +val default_target : target type secret_key type public_key