@@ -59,11 +59,6 @@ static const uint32_t _keypath[] = {
59
59
0 ,
60
60
5 ,
61
61
};
62
- // seckey at the above keypath with the above bip39 seed.
63
- static const uint8_t _expected_seckey [32 ] = {
64
- 0x4e , 0x64 , 0xdf , 0xd3 , 0x3a , 0xae , 0x66 , 0xc4 , 0xc7 , 0x52 , 0x6c , 0xf0 , 0x2e , 0xe8 , 0xae , 0x3f ,
65
- 0x58 , 0x92 , 0x32 , 0x9d , 0x67 , 0xdf , 0xd4 , 0xad , 0x05 , 0xe9 , 0xc3 , 0xd0 , 0x6e , 0xdf , 0x74 , 0xfb ,
66
- };
67
62
68
63
// Same as Python:
69
64
// import hmac, hashlib; hmac.digest(b"unit-test", b"password", hashlib.sha256).hex()
@@ -117,21 +112,6 @@ void _mock_unlocked(const uint8_t* seed, size_t seed_len, const uint8_t* bip39_s
117
112
keystore_mock_unlocked (seed , seed_len , bip39_seed );
118
113
}
119
114
120
- static bool _pubkeys_equal (
121
- const secp256k1_context * ctx ,
122
- const secp256k1_pubkey * pubkey1 ,
123
- const secp256k1_pubkey * pubkey2 )
124
- {
125
- uint8_t pubkey1_bytes [33 ];
126
- uint8_t pubkey2_bytes [33 ];
127
- size_t len = 33 ;
128
- assert_true (
129
- secp256k1_ec_pubkey_serialize (ctx , pubkey1_bytes , & len , pubkey1 , SECP256K1_EC_COMPRESSED ));
130
- assert_true (
131
- secp256k1_ec_pubkey_serialize (ctx , pubkey2_bytes , & len , pubkey2 , SECP256K1_EC_COMPRESSED ));
132
- return memcmp (pubkey1_bytes , pubkey2_bytes , len ) == 0 ;
133
- }
134
-
135
115
static void _test_keystore_secp256k1_nonce_commit (void * * state )
136
116
{
137
117
uint8_t msg [32 ] = {0 };
@@ -165,56 +145,6 @@ static void _test_keystore_secp256k1_nonce_commit(void** state)
165
145
}
166
146
}
167
147
168
- static void _test_keystore_secp256k1_sign (void * * state )
169
- {
170
- const secp256k1_context * ctx = wally_get_secp_context ();
171
-
172
- secp256k1_pubkey expected_pubkey ;
173
- assert_true (secp256k1_ec_pubkey_create (ctx , & expected_pubkey , _expected_seckey ));
174
-
175
- uint8_t msg [32 ] = {0 };
176
- memset (msg , 0x88 , sizeof (msg ));
177
- uint8_t sig [64 ] = {0 };
178
-
179
- uint8_t host_nonce [32 ] = {0 };
180
- memset (host_nonce , 0x56 , sizeof (host_nonce ));
181
-
182
- {
183
- _mock_unlocked (NULL , 0 , NULL );
184
- // fails because keystore is locked
185
- assert_false (keystore_secp256k1_sign (
186
- _keypath , sizeof (_keypath ) / sizeof (uint32_t ), msg , host_nonce , sig , NULL ));
187
- }
188
- {
189
- _mock_unlocked (_mock_seed , sizeof (_mock_seed ), _mock_bip39_seed );
190
-
191
- _sign_expected_seckey = _expected_seckey ;
192
- _sign_expected_msg = msg ;
193
- // check sig by verifying it against the msg.
194
- assert_true (keystore_secp256k1_sign (
195
- _keypath , sizeof (_keypath ) / sizeof (uint32_t ), msg , host_nonce , sig , NULL ));
196
- secp256k1_ecdsa_signature secp256k1_sig = {0 };
197
- assert_true (secp256k1_ecdsa_signature_parse_compact (ctx , & secp256k1_sig , sig ));
198
- assert_true (secp256k1_ecdsa_verify (ctx , & secp256k1_sig , msg , & expected_pubkey ));
199
- }
200
- { // test recoverable id (recid)
201
- int recid ;
202
- assert_true (keystore_secp256k1_sign (
203
- _keypath , sizeof (_keypath ) / sizeof (uint32_t ), msg , host_nonce , sig , & recid ));
204
- assert_int_equal (recid , 1 );
205
-
206
- // Test recid by recovering the public key from the signature and checking against the
207
- // expected puklic key.
208
- secp256k1_ecdsa_recoverable_signature recoverable_sig ;
209
- assert_true (
210
- secp256k1_ecdsa_recoverable_signature_parse_compact (ctx , & recoverable_sig , sig , recid ));
211
-
212
- secp256k1_pubkey recovered_pubkey ;
213
- assert_true (secp256k1_ecdsa_recover (ctx , & recovered_pubkey , & recoverable_sig , msg ));
214
-
215
- assert_true (_pubkeys_equal (ctx , & recovered_pubkey , & expected_pubkey ));
216
- }
217
- }
218
148
static void _expect_encrypt_and_store_seed (void )
219
149
{
220
150
will_return (__wrap_memory_is_initialized , false);
@@ -394,7 +324,6 @@ int main(void)
394
324
395
325
const struct CMUnitTest tests [] = {
396
326
cmocka_unit_test (_test_keystore_secp256k1_nonce_commit ),
397
- cmocka_unit_test (_test_keystore_secp256k1_sign ),
398
327
cmocka_unit_test (_test_keystore_lock ),
399
328
cmocka_unit_test (_test_keystore_create_and_store_seed ),
400
329
cmocka_unit_test (_test_secp256k1_schnorr_sign ),
0 commit comments