diff --git a/src/lib_client_base/test/bip39_tests.ml b/src/lib_client_base/test/bip39_tests.ml index 274bca83bb9c8df8df052e205a9a04893ff52133..7177432d2817c6bf192fe066f31b96da2fac00d0 100644 --- a/src/lib_client_base/test/bip39_tests.ml +++ b/src/lib_client_base/test/bip39_tests.ml @@ -1,3 +1,11 @@ +(** Testing + ------- + Component: Client Base + Invocation: dune build @src/lib_client_base/runtest + Subject: BIP39 seed phrases. Mnemonic sentences for the + generation of deterministic wallets. +*) + type vector = {entropy : Hex.t; words : string; seed : Hex.t} let vectors = @@ -248,6 +256,11 @@ let pp_diff ppf (l1, l2) = w2 ; succ i) +(** This code tests the BIP39 implementation by 1) checking that + feeding the algorithm a given entropy string will result in the + expected mnemonic and 2) checking that using this mnemonic with the + passphrase "TREZOR" will result in the expected seed. +*) let vectors () = ListLabels.iteri vectors ~f:(fun _ {entropy; words; seed} -> let words = String.split_on_char ' ' words in diff --git a/src/lib_client_base/test/pbkdf_tests.ml b/src/lib_client_base/test/pbkdf_tests.ml index a1fb32d33aa7b252c76b1267c8b3b3f8b22493e6..506b04e1849a74c0447375213301490d25e451b3 100644 --- a/src/lib_client_base/test/pbkdf_tests.ml +++ b/src/lib_client_base/test/pbkdf_tests.ml @@ -1,3 +1,11 @@ +(** Testing + ------- + Component: Client Base + Invocation: dune build @src/lib_client_base/runtest + Subject: On Password-Based Key Derivation Function 2 (PBKDF2) + when using hash functions SHA256 and SHA512. +*) + open Tezos_crypto (* PBKDF2 *) @@ -23,6 +31,11 @@ let test_pbkdf2 (module A : Hacl.Hash.S) ~password ~salt ~count ~dk_len ~dk = (* Taken from https://github.com/randombit/botan/blob/master/src/tests/data/pbkdf/pbkdf2.vec *) +(** Using SHA256 hash. From password "xyz" and salt + "0001020304050607", iterates 10,000 times the derivation algorithm + to derive a 48-byte key. The expected derived key shall equal to + [~dk]. +*) let pbkdf2_test11 = test_pbkdf2 (module Hacl.Hash.SHA256) @@ -33,6 +46,11 @@ let pbkdf2_test11 = ~dk: "defd2987fa26a4672f4d16d98398432ad95e896bf619f6a6b8d4ed1faf98e8b531b39ffb66966d0e115a6cd8e70b72d0" +(** Using SHA512 hash. From password "xyz" and salt + "0001020304050607", iterates 10,000 times the derivation algorithm + to derive a 48-byte key. The expected derived key shall equal to + [~dk]. +*) let pbkdf2_test13 = test_pbkdf2 (module Hacl.Hash.SHA512)