~ Get the BIP86 keys for this given index: if privkey is NULL, we * don't fill it in. This derives the full path: m/86'/0'/0'/0/index */
| 2388 | /*~ Get the BIP86 keys for this given index: if privkey is NULL, we |
| 2389 | * don't fill it in. This derives the full path: m/86'/0'/0'/0/index */ |
| 2390 | void bip86_key(struct privkey *privkey, struct pubkey *pubkey, u32 index) |
| 2391 | { |
| 2392 | struct privkey unused_priv; |
| 2393 | |
| 2394 | if (privkey == NULL) |
| 2395 | privkey = &unused_priv; |
| 2396 | |
| 2397 | if (index >= BIP32_INITIAL_HARDENED_CHILD) |
| 2398 | hsmd_status_failed(STATUS_FAIL_MASTER_IO, "Index %u too great", index); |
| 2399 | |
| 2400 | /* Derive the BIP86 base key using the helper function */ |
| 2401 | struct ext_key bip86_base; |
| 2402 | derive_bip86_base_key(&bip86_base); |
| 2403 | |
| 2404 | /* Now derive the specific index: m/86'/0'/0'/0/index */ |
| 2405 | u32 final_path[2]; |
| 2406 | final_path[0] = 0; /* change (0 for receive) */ |
| 2407 | final_path[1] = index; /* address_index */ |
| 2408 | |
| 2409 | struct ext_key final_key; |
| 2410 | if (bip32_key_from_parent_path(&bip86_base, final_path, 2, BIP32_FLAG_KEY_PRIVATE, &final_key) != WALLY_OK) { |
| 2411 | hsmd_status_failed(STATUS_FAIL_INTERNAL_ERROR, |
| 2412 | "BIP86 derivation of index %u failed", index); |
| 2413 | } |
| 2414 | |
| 2415 | /* Convert to our format */ |
| 2416 | memcpy(privkey->secret.data, final_key.priv_key+1, 32); |
| 2417 | if (!secp256k1_ec_pubkey_create(secp256k1_ctx, &pubkey->pubkey, |
| 2418 | privkey->secret.data)) |
| 2419 | hsmd_status_failed(STATUS_FAIL_INTERNAL_ERROR, |
| 2420 | "BIP86 pubkey %u create failed", index); |
| 2421 | } |
| 2422 | |
| 2423 | u8 *hsmd_init(const u8 *secret_data, size_t secret_len, const u64 hsmd_version, |
| 2424 | struct bip32_key_version bip32_key_version, u8 hsm_secret_type) |
no test coverage detected