What changed, and why it matters
This commit only changes a unit test file. It swaps one way of getting a test private key (from an older C library called libwally) for another way (from the project's newer Rust code). The actual device firmware and security logic are not changed. There is no indication this fixes or introduces a security bug.
No security action required. Treat as a normal test-maintenance/refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies test/unit-test/test_keystore_antiklepto.c to remove the libwally bip32 dependency in favor of rust_secp256k1_get_private_key plus secp256k1_ec_pubkey_create. The test still exercises the same anti-klepto (anti-exfil) protocol steps and assertions; only the key derivation path in test setup is refactored. No production code is touched.
Changed components
test/unit-test/test_keystore_antiklepto.cInspect captured patch +9 / −18
diff --git a/test/unit-test/test_keystore_antiklepto.c b/test/unit-test/test_keystore_antiklepto.c
index 2d2cb48..095783d 100644
--- a/test/unit-test/test_keystore_antiklepto.c
+++ b/test/unit-test/test_keystore_antiklepto.c
@@ -19,8 +19,8 @@
#include <keystore.h>
+#include <rust/rust.h>
#include <secp256k1_ecdsa_s2c.h>
-#include <wally_bip32.h>
#include <stdbool.h>
#include <stddef.h>
@@ -74,16 +74,11 @@ static void _test_keystore_antiklepto(void** state)
uint8_t host_nonce_commitment[32];
// Get pubkey at keypath
- struct ext_key xprv_master = {0};
- struct ext_key xprv_derived = {0};
- assert_int_equal(
- bip32_key_from_seed(
- _mock_bip39_seed, BIP32_ENTROPY_LEN_512, BIP32_VER_MAIN_PRIVATE, 0, &xprv_master),
- WALLY_OK);
- assert_int_equal(
- bip32_key_from_parent_path(
- &xprv_master, keypath, 5, BIP32_FLAG_KEY_PRIVATE, &xprv_derived),
- WALLY_OK);
+ uint8_t private_key[32] = {0};
+ assert_true(rust_secp256k1_get_private_key(
+ keypath, 5, rust_util_bytes_mut(private_key, sizeof(private_key))));
+ secp256k1_pubkey public_key = {0};
+ assert_true(secp256k1_ec_pubkey_create(ctx, &public_key, private_key));
// Protocol steps are described in secp256k1/include/secp256k1_ecdsa_s2c.h under "ECDSA
// Anti-Klepto Protocol".
@@ -93,23 +88,19 @@ static void _test_keystore_antiklepto(void** state)
// Commit - protocol step 2.
assert_true(keystore_secp256k1_nonce_commit(
- ctx, xprv_derived.priv_key + 1, msg, host_nonce_commitment, signer_commitment));
+ ctx, private_key, msg, host_nonce_commitment, signer_commitment));
// Protocol step 3: host_nonce sent from host to signer to be used in step 4
// Sign - protocol step 4.
- assert_true(
- keystore_secp256k1_sign(ctx, xprv_derived.priv_key + 1, msg, host_nonce, sig, &recid));
+ assert_true(keystore_secp256k1_sign(ctx, private_key, msg, host_nonce, sig, &recid));
// Protocol step 5: host verification.
secp256k1_ecdsa_signature parsed_signature;
assert_true(secp256k1_ecdsa_signature_parse_compact(ctx, &parsed_signature, sig));
- secp256k1_pubkey parsed_pubkey;
- assert_true(secp256k1_ec_pubkey_parse(
- ctx, &parsed_pubkey, xprv_derived.pub_key, sizeof(xprv_derived.pub_key)));
secp256k1_ecdsa_s2c_opening opening;
assert_true(secp256k1_ecdsa_s2c_opening_parse(ctx, &opening, signer_commitment));
assert_true(secp256k1_anti_exfil_host_verify(
- ctx, &parsed_signature, msg, &parsed_pubkey, host_nonce, &opening));
+ ctx, &parsed_signature, msg, &public_key, host_nonce, &opening));
}
secp256k1_context_destroy(ctx);
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.