clean up
This commit is contained in:
parent
0b6f5e3db5
commit
53debfd866
11 changed files with 40 additions and 165 deletions
11
test/dune
11
test/dune
|
|
@ -4,13 +4,6 @@
|
|||
(libraries mte fmt))
|
||||
|
||||
(test
|
||||
(name crypto)
|
||||
(modules crypto)
|
||||
(name test_crypto)
|
||||
(modules test_crypto)
|
||||
(libraries mte fmt))
|
||||
|
||||
; TODO
|
||||
; cram test?
|
||||
; gcc -o a.out ./test/signatures.c && ./a.out > a.output
|
||||
; rm ./a.out
|
||||
; dune exec ./test/test.exe > b.output
|
||||
; cmp -l a.output b.output
|
||||
|
|
|
|||
|
|
@ -1,55 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct H64 {
|
||||
uint8_t hash[64];
|
||||
};
|
||||
struct Hhh {
|
||||
struct H64 hash;
|
||||
};
|
||||
struct Purpose {
|
||||
uint32_t size;
|
||||
uint32_t purpose;
|
||||
};
|
||||
|
||||
struct PS {
|
||||
struct Purpose purpose;
|
||||
struct Hhh h;
|
||||
uint32_t noreveal_index;
|
||||
};
|
||||
|
||||
int main(void) {
|
||||
struct Purpose purpose;
|
||||
struct PS ps;
|
||||
|
||||
purpose.size = 3 * 4 + 64;
|
||||
purpose.purpose = 1050;
|
||||
|
||||
struct Hhh h = {
|
||||
.hash = {
|
||||
.hash = {
|
||||
1 , 2 , 3 , 4 , 5, 6, 7, 8,
|
||||
9 , 10, 11, 12, 13, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23, 24,
|
||||
25, 26, 27, 28, 29, 30, 31, 32,
|
||||
33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48,
|
||||
49, 50, 51, 52, 53, 54, 55, 56,
|
||||
57, 58, 59, 60, 61, 62, 63, 64
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
uint32_t noreveal_index = 0;
|
||||
|
||||
ps.purpose = purpose;
|
||||
ps.h = h;
|
||||
ps.noreveal_index = noreveal_index;
|
||||
|
||||
|
||||
fwrite(&ps, sizeof(ps), 1, stdout);
|
||||
|
||||
// printf("\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
21
test/test.ml
21
test/test.ml
|
|
@ -97,19 +97,14 @@ let () =
|
|||
|
||||
()
|
||||
|
||||
(*
|
||||
|
||||
let () =
|
||||
let open Binary_formats.WithdrawConfirmationPS in
|
||||
let str64 = String.init 64 (fun i -> Char.unsafe_chr (i + 1)) in
|
||||
let dummy_t = { h_planchets= { hash= str64 }; noreveal_index= 0_l } in
|
||||
let size = Bin.size_of_value bin dummy_t |> Option.get in
|
||||
assert (size = 76);
|
||||
let round_trip s =
|
||||
let s' = s |> B32.encode |> B32.decode |> Result.get_ok in
|
||||
assert (s = s')
|
||||
in
|
||||
let s = String.init 0xff Char.chr in
|
||||
round_trip s;
|
||||
let s_l = List.init 0x0f (fun i -> String.init i Char.chr) in
|
||||
List.iter round_trip s_l;
|
||||
|
||||
(* for cmp test with signatures.c output *)
|
||||
(*
|
||||
let raw_str = Bin.to_string bin dummy_t in
|
||||
Printf.printf "%s" raw_str;
|
||||
*)
|
||||
()
|
||||
*)
|
||||
|
|
|
|||
|
|
@ -1,21 +1,9 @@
|
|||
(* Test vectors taken from GNUnet:
|
||||
https://git.gnunet.org/gnunet/gnunet/file/src/cli/util/crypto-test-vectors.json.html *)
|
||||
|
||||
let encode = B32.encode
|
||||
let decode s = B32.decode s |> Result.get_ok
|
||||
|
||||
let round_trip s =
|
||||
let s' = s |> encode |> decode in
|
||||
match s' = s with
|
||||
| false -> Fmt.failwith "b32 round trip failure: @\nin :`%S`@\nout:`%S`" s' s
|
||||
| true -> ()
|
||||
|
||||
let () =
|
||||
let s = String.init 0xff Char.chr in
|
||||
round_trip s;
|
||||
let s_l = List.init 0x0f (fun i -> String.init i Char.chr) in
|
||||
List.iter round_trip s_l; ()
|
||||
|
||||
(* test vectors from:
|
||||
https://git.gnunet.org/gnunet/gnunet/file/src/cli/util/crypto-test-vectors.json.html *)
|
||||
|
||||
let () =
|
||||
(* hash *)
|
||||
let input = "91JPRV3F5GG4EKJNDSJQ8" in
|
||||
|
|
@ -96,7 +84,7 @@ let () =
|
|||
()
|
||||
|
||||
let () =
|
||||
(* rsa blinding *)
|
||||
(* rsa_blind_signing *)
|
||||
(* rsa_private_key data is given in gcrypt sexpr format.. *)
|
||||
let message_hash =
|
||||
"XKQMJ4CNTXBFE1V2WR6JS063J7PZQE4XMB5JH3RS5X0THQ1JQSQ69Y7KDBC9TYRJEZH48MEPY2SF4QHQ4VHXC0YQX5935MQEGP0AX6R"
|
||||
Loading…
Add table
Add a link
Reference in a new issue