From e19f7cd2e5be16c9044e991048592ea27fdee681 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 1 Oct 2013 16:45:26 +0200 Subject: [PATCH] add more rfc6979 test vectors by fpgaminer --- tests.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests.c b/tests.c index ff8b747dc5..2f0916edb6 100644 --- a/tests.c +++ b/tests.c @@ -181,9 +181,32 @@ START_TEST(test_rfc6979) SHA256_Raw((uint8_t *)"sample", 6, buf); res = generate_k_rfc6979(&k, fromhex("cca9fbcc1b41e5a95d369eaa6ddcff73b61a4efaa279cfc6567e8daa39cbaf50"), buf); ck_assert_int_eq(res, 0); - bn_write_be(&k, buf); ck_assert_mem_eq(buf, fromhex("2df40ca70e639d89528a6b670d9d48d9165fdc0febc0974056bdce192b8e16a3"), 32); + + SHA256_Raw((uint8_t *)"Satoshi Nakamoto", 16, buf); + res = generate_k_rfc6979(&k, fromhex("0000000000000000000000000000000000000000000000000000000000000001"), buf); + ck_assert_int_eq(res, 0); + bn_write_be(&k, buf); + ck_assert_mem_eq(buf, fromhex("8f8a276c19f4149656b280621e358cce24f5f52542772691ee69063b74f15d15"), 32); + + SHA256_Raw((uint8_t *)"Satoshi Nakamoto", 16, buf); + res = generate_k_rfc6979(&k, fromhex("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"), buf); + ck_assert_int_eq(res, 0); + bn_write_be(&k, buf); + ck_assert_mem_eq(buf, fromhex("33a19b60e25fb6f4435af53a3d42d493644827367e6453928554f43e49aa6f90"), 32); + + SHA256_Raw((uint8_t *)"Alan Turing", 11, buf); + res = generate_k_rfc6979(&k, fromhex("f8b8af8ce3c7cca5e300d33939540c10d45ce001b8f252bfbc57ba0342904181"), buf); + ck_assert_int_eq(res, 0); + bn_write_be(&k, buf); + ck_assert_mem_eq(buf, fromhex("525a82b70e67874398067543fd84c83d30c175fdc45fdeee082fe13b1d7cfdf1"), 32); + + SHA256_Raw((uint8_t *)"All those moments will be lost in time, like tears in rain. Time to die...", 74, buf); + res = generate_k_rfc6979(&k, fromhex("0000000000000000000000000000000000000000000000000000000000000001"), buf); + ck_assert_int_eq(res, 0); + bn_write_be(&k, buf); + ck_assert_mem_eq(buf, fromhex("38aa22d72376b4dbc472e06c3ba403ee0a394da63fc58d88686c611aba98d6b3"), 32); } END_TEST