Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
231 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.0.0 | ||
1.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
(dirs :standard \ vendor) | ||
(dirs :standard \ vendor _site .bundle) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(lang dune 1.9) | ||
(name nocoiner) | ||
(version 1.0.0) | ||
(version 1.0.1) | ||
(using fmt 1.1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Sys = Core.Sys | ||
module Option = Core.Option | ||
module Int = Core.Int | ||
|
||
let get variable default = | ||
let optional = Sys.getenv variable in | ||
Option.value optional ~default | ||
|
||
|
||
let _KDF_COST = get "NOCOINER_KDF_COST" "8192" |> Int.of_string | ||
|
||
let _KDF_WORKERS = get "NOCOINER_KDF_WORKERS" "2" |> Int.of_string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
val _KDF_COST : int | ||
|
||
val _KDF_WORKERS : int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
open Constants | ||
|
||
let kdf ~size ~salt password = | ||
Scrypt_kdf.scrypt_kdf ~password ~salt ~dk_len:size ~r:8 ~p:2 ~n:8192 | ||
Scrypt_kdf.scrypt_kdf | ||
~password | ||
~salt | ||
~dk_len:size | ||
~r:8 | ||
~p:_KDF_WORKERS | ||
~n:_KDF_COST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
(test | ||
(name timing) | ||
(modules timing) | ||
(action | ||
(run %{test} time cycles alloc gc percentage speedup samples -all-values | ||
-ascii -fork -no-compactions -overheads -quota 15 -stabilize-gc -width | ||
300 -v -display tall)) | ||
(libraries nocoiner.bench)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Estimated testing time 45s (3 benchmarks x 15s). Change using -quota SECS. | ||
bound opening: Total time taken 15.14s (156 samples, max runs 156). | ||
unbound commitment: Total time taken 15.1478s (158 samples, max runs 158). | ||
unbound opening: Total time taken 15.0146s (157 samples, max runs 157). | ||
|
||
Name Runs @ Samples Time/Run Cycls/Run mWd/Run mWd Overhd mjWd/Run mjWd Overhd Prom/Run Prom Overhd mGC/Run mjGC/Run Comp/Run Percentage Speedup | ||
-------------------- ---------------- ---------- ----------- --------- ------------ ---------- ------------- ---------- ------------- ---------- ---------- ---------- ------------ --------- | ||
bound opening 156 @ 156 841.47us 874.71kc 19.78kw 25.82w 18.59w 35.39w 18.59w 35.39w 70.62e-3 0.00e-9 0.00e-9 100.00% 1.02 | ||
unbound commitment 158 @ 158 823.70us 856.24kc 19.69kw 23.02w 22.75w -132.15w 22.75w -132.15w 70.32e-3 0.00e-9 0.00e-9 97.89% 1.00 | ||
unbound opening 157 @ 157 826.47us 859.12kc 19.69kw 23.02w 22.81w -135.02w 22.81w -135.02w 70.33e-3 0.00e-9 0.00e-9 98.22% 1.00 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
open Nocoiner_bench | ||
open Core_bench.Bench | ||
module Command = Core.Command | ||
|
||
let reveals c o = | ||
try | ||
ignore @@ Nocoiner.reveal ~commitment:c ~opening:o ; | ||
true | ||
with | ||
| Nocoiner.Reasons.BindingFailure -> | ||
false | ||
|
||
|
||
let _RIGHT_SECRET = "P = NP would prove God's existence." | ||
|
||
let _WRONG_SECRET = "The Quantum Nature is just Godel..." | ||
|
||
let _RIGHT_C, _RIGHT_O = Nocoiner.commit _RIGHT_SECRET | ||
|
||
let _WRONG_C, _WRONG_O = Nocoiner.commit _WRONG_SECRET | ||
|
||
let __test_case_01 () = assert (reveals _RIGHT_C _RIGHT_O) | ||
|
||
let __test_case_02 () = assert (not (reveals _WRONG_C _RIGHT_O)) | ||
|
||
let __test_case_03 () = assert (not (reveals _RIGHT_C _WRONG_O)) | ||
|
||
let _TEST_NAME_01 = "bound opening" | ||
|
||
let _TEST_NAME_02 = "unbound commitment" | ||
|
||
let _TEST_NAME_03 = "unbound opening" | ||
|
||
let __test_01 = Test.create ~name:_TEST_NAME_01 __test_case_01 | ||
|
||
let __test_02 = Test.create ~name:_TEST_NAME_02 __test_case_02 | ||
|
||
let __test_03 = Test.create ~name:_TEST_NAME_03 __test_case_03 | ||
|
||
let suite = [ __test_01; __test_02; __test_03 ] | ||
|
||
let _ = Command.run @@ make_command suite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
;; wrapper library just to enable optional core_bench | ||
;; library installation on ocaml versions >= 4.04.1 | ||
|
||
(library | ||
(name nocoiner_bench) | ||
(optional) | ||
(public_name nocoiner.bench) | ||
(modules nocoiner_bench) | ||
(libraries core_bench nocoiner)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Nocoiner = struct | ||
include Nocoiner | ||
end | ||
|
||
module Core_bench = struct | ||
include Core_bench | ||
end |