mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-16 04:29:08 +00:00
Updated tests
This commit is contained in:
parent
0bc1b70c4a
commit
b34be66a9c
26
tests.c
26
tests.c
@ -168,7 +168,7 @@ START_TEST(test_bip32_vector_1)
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
// init m
|
// init m
|
||||||
hdnode_from_seed(fromhex("000102030405060708090a0b0c0d0e0f"), 16, &node);
|
hdnode_from_seed(fromhex("000102030405060708090a0b0c0d0e0f"), 16, SECP256K1_NAME, &node);
|
||||||
|
|
||||||
// [Chain m]
|
// [Chain m]
|
||||||
ck_assert_int_eq(node.fingerprint, 0x00000000);
|
ck_assert_int_eq(node.fingerprint, 0x00000000);
|
||||||
@ -281,7 +281,7 @@ START_TEST(test_bip32_vector_2)
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
// init m
|
// init m
|
||||||
hdnode_from_seed(fromhex("fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542"), 64, &node);
|
hdnode_from_seed(fromhex("fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542"), 64, SECP256K1_NAME, &node);
|
||||||
|
|
||||||
// [Chain m]
|
// [Chain m]
|
||||||
ck_assert_int_eq(node.fingerprint, 0x00000000);
|
ck_assert_int_eq(node.fingerprint, 0x00000000);
|
||||||
@ -390,7 +390,7 @@ START_TEST(test_bip32_vector_2)
|
|||||||
ck_assert_mem_eq(&node2, &node3, sizeof(HDNode));
|
ck_assert_mem_eq(&node2, &node3, sizeof(HDNode));
|
||||||
|
|
||||||
// init m
|
// init m
|
||||||
hdnode_from_seed(fromhex("fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542"), 64, &node);
|
hdnode_from_seed(fromhex("fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542"), 64, SECP256K1_NAME, &node);
|
||||||
|
|
||||||
// test public derivation
|
// test public derivation
|
||||||
// [Chain m/0]
|
// [Chain m/0]
|
||||||
@ -407,8 +407,8 @@ START_TEST(test_bip32_compare)
|
|||||||
{
|
{
|
||||||
HDNode node1, node2, node3;
|
HDNode node1, node2, node3;
|
||||||
int i, r;
|
int i, r;
|
||||||
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, &node1);
|
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, SECP256K1_NAME, &node1);
|
||||||
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, &node2);
|
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, SECP256K1_NAME, &node2);
|
||||||
for (i = 0; i < 100; i++) {
|
for (i = 0; i < 100; i++) {
|
||||||
memcpy(&node3, &node1, sizeof(HDNode));
|
memcpy(&node3, &node1, sizeof(HDNode));
|
||||||
r = hdnode_private_ckd(&node1, i); ck_assert_int_eq(r, 1);
|
r = hdnode_private_ckd(&node1, i); ck_assert_int_eq(r, 1);
|
||||||
@ -436,8 +436,8 @@ START_TEST(test_bip32_cache_1)
|
|||||||
int i, r;
|
int i, r;
|
||||||
|
|
||||||
// test 1 .. 8
|
// test 1 .. 8
|
||||||
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, &node1);
|
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, SECP256K1_NAME, &node1);
|
||||||
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, &node2);
|
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, SECP256K1_NAME, &node2);
|
||||||
|
|
||||||
uint32_t ii[] = {0x80000001, 0x80000002, 0x80000003, 0x80000004, 0x80000005, 0x80000006, 0x80000007, 0x80000008};
|
uint32_t ii[] = {0x80000001, 0x80000002, 0x80000003, 0x80000004, 0x80000005, 0x80000006, 0x80000007, 0x80000008};
|
||||||
|
|
||||||
@ -447,8 +447,8 @@ START_TEST(test_bip32_cache_1)
|
|||||||
r = hdnode_private_ckd_cached(&node2, ii, 8); ck_assert_int_eq(r, 1);
|
r = hdnode_private_ckd_cached(&node2, ii, 8); ck_assert_int_eq(r, 1);
|
||||||
ck_assert_mem_eq(&node1, &node2, sizeof(HDNode));
|
ck_assert_mem_eq(&node1, &node2, sizeof(HDNode));
|
||||||
|
|
||||||
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, &node1);
|
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, SECP256K1_NAME, &node1);
|
||||||
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, &node2);
|
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, SECP256K1_NAME, &node2);
|
||||||
|
|
||||||
// test 1 .. 7, 20
|
// test 1 .. 7, 20
|
||||||
ii[7] = 20;
|
ii[7] = 20;
|
||||||
@ -459,8 +459,8 @@ START_TEST(test_bip32_cache_1)
|
|||||||
ck_assert_mem_eq(&node1, &node2, sizeof(HDNode));
|
ck_assert_mem_eq(&node1, &node2, sizeof(HDNode));
|
||||||
|
|
||||||
// test different root node
|
// test different root node
|
||||||
hdnode_from_seed(fromhex("000000002ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, &node1);
|
hdnode_from_seed(fromhex("000000002ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, SECP256K1_NAME, &node1);
|
||||||
hdnode_from_seed(fromhex("000000002ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, &node2);
|
hdnode_from_seed(fromhex("000000002ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, SECP256K1_NAME, &node2);
|
||||||
|
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
r = hdnode_private_ckd(&node1, ii[i]); ck_assert_int_eq(r, 1);
|
r = hdnode_private_ckd(&node1, ii[i]); ck_assert_int_eq(r, 1);
|
||||||
@ -476,8 +476,8 @@ START_TEST(test_bip32_cache_2)
|
|||||||
int i, j, r;
|
int i, j, r;
|
||||||
|
|
||||||
for (j = 0; j < 9; j++) {
|
for (j = 0; j < 9; j++) {
|
||||||
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, &(nodea[j]));
|
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, SECP256K1_NAME, &(nodea[j]));
|
||||||
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, &(nodeb[j]));
|
hdnode_from_seed(fromhex("301133282ad079cbeb59bc446ad39d333928f74c46997d3609cd3e2801ca69d62788f9f174429946ff4e9be89f67c22fae28cb296a9b37734f75e73d1477af19"), 64, SECP256K1_NAME, &(nodeb[j]));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ii[] = {0x80000001, 0x80000002, 0x80000003, 0x80000004, 0x80000005, 0x80000006, 0x80000007, 0x80000008};
|
uint32_t ii[] = {0x80000001, 0x80000002, 0x80000003, 0x80000004, 0x80000005, 0x80000006, 0x80000007, 0x80000008};
|
||||||
|
Loading…
Reference in New Issue
Block a user