@@ -140,16 +140,6 @@ static void _test_keystore_create_and_store_seed(void** state)
140
140
}
141
141
}
142
142
143
- static void _mock_with_mnemonic (const char * mnemonic , const char * passphrase )
144
- {
145
- uint8_t seed [32 ] = {0 };
146
- size_t seed_len ;
147
- assert_true (keystore_bip39_mnemonic_to_seed (mnemonic , seed , & seed_len ));
148
-
149
- _mock_unlocked (seed , seed_len , NULL );
150
- assert_true (keystore_unlock_bip39 (passphrase ));
151
- }
152
-
153
143
// This tests that `secp256k1_schnorrsig_sign()` is the correct function to be used for schnorr sigs
154
144
// in taproot. It is a separate test because there are test vectors available for this which cannot
155
145
// be made to work with `keystore_secp256k1_schnorr_bip86_sign()`.
@@ -208,59 +198,13 @@ static void _test_secp256k1_schnorr_sign(void** state)
208
198
}
209
199
}
210
200
211
- static void _test_keystore_secp256k1_schnorr_sign (void * * state )
212
- {
213
- _mock_with_mnemonic (
214
- "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon "
215
- "about" ,
216
- "" );
217
- const uint32_t keypath [] = {
218
- 86 + BIP32_INITIAL_HARDENED_CHILD ,
219
- 0 + BIP32_INITIAL_HARDENED_CHILD ,
220
- 0 + BIP32_INITIAL_HARDENED_CHILD ,
221
- 0 ,
222
- 0 ,
223
- };
224
- struct ext_key xpub = {0 };
225
- assert_true (keystore_get_xpub (keypath , 5 , & xpub ));
226
-
227
- uint8_t msg [32 ] = {0 };
228
- memset (msg , 0x88 , sizeof (msg ));
229
- uint8_t sig [64 ] = {0 };
230
- uint8_t mock_aux_rand [32 ] = {0 };
231
-
232
- // Test without tweak
233
- will_return (__wrap_random_32_bytes , mock_aux_rand );
234
- assert_true (keystore_secp256k1_schnorr_sign (keypath , 5 , msg , NULL , sig ));
235
- const secp256k1_context * ctx = wally_get_secp_context ();
236
- secp256k1_pubkey pubkey = {0 };
237
- assert_true (secp256k1_ec_pubkey_parse (ctx , & pubkey , xpub .pub_key , sizeof (xpub .pub_key )));
238
- secp256k1_xonly_pubkey xonly_pubkey = {0 };
239
- assert_true (secp256k1_xonly_pubkey_from_pubkey (ctx , & xonly_pubkey , NULL , & pubkey ));
240
- assert_true (secp256k1_schnorrsig_verify (ctx , sig , msg , sizeof (msg ), & xonly_pubkey ));
241
-
242
- // Test with tweak
243
- const uint8_t tweak [32 ] =
244
- "\xa3\x9f\xb1\x63\xdb\xd9\xb5\xe0\x84\x0a\xf3\xcc\x1e\xe4\x1d\x5b\x31\x24\x5c\x5d\xd8\xd6"
245
- "\xbd\xc3\xd0\x26\xd0\x9b\x89\x64\x99\x7c" ;
246
- will_return (__wrap_random_32_bytes , mock_aux_rand );
247
- assert_true (keystore_secp256k1_schnorr_sign (keypath , 5 , msg , tweak , sig ));
248
- secp256k1_pubkey tweaked_pubkey = {0 };
249
- assert_true (secp256k1_xonly_pubkey_tweak_add (ctx , & tweaked_pubkey , & xonly_pubkey , tweak ));
250
- secp256k1_xonly_pubkey tweaked_xonly_pubkey = {0 };
251
- assert_true (
252
- secp256k1_xonly_pubkey_from_pubkey (ctx , & tweaked_xonly_pubkey , NULL , & tweaked_pubkey ));
253
- assert_true (secp256k1_schnorrsig_verify (ctx , sig , msg , sizeof (msg ), & tweaked_xonly_pubkey ));
254
- }
255
-
256
201
int main (void )
257
202
{
258
203
mock_memory_set_salt_root (_salt_root );
259
204
260
205
const struct CMUnitTest tests [] = {
261
206
cmocka_unit_test (_test_keystore_create_and_store_seed ),
262
207
cmocka_unit_test (_test_secp256k1_schnorr_sign ),
263
- cmocka_unit_test (_test_keystore_secp256k1_schnorr_sign ),
264
208
};
265
209
return cmocka_run_group_tests (tests , NULL , NULL );
266
210
}
0 commit comments