Skip to content

Commit

Permalink
bip44 generate public key from account extended public key
Browse files Browse the repository at this point in the history
  • Loading branch information
iskyd committed Jun 28, 2024
1 parent f3943d9 commit a8e65b7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/bip44.zig
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ pub fn generateAccountPrivate(epk: bip32.ExtendedPrivateKey, purpose: u32, coint
return indexepk;
}

pub fn generatePublicFromAccountPublicKey(pk: bip32.ExtendedPublicKey, change: u32, index: u32) !bip32.PublicKey {
const changepk = try bip32.deriveChildFromExtendedPublicKey(pk, change);
const indexepk = try bip32.deriveChildFromExtendedPublicKey(changepk, index);

return indexepk.key;
}

test "generateAccount" {
const serializedAddr = "tprv8ZgxMBicQKsPefj8cBDzcXJYcnvWBLQwG9sAvKyAYRPiLtdZXvdAmqtjzeHbX7ZX2LY8Sfb7SaLSJbGCFBPMFZdnmv4D7UebvyLTC974BA4".*;
const masterExtendedPrivate = try bip32.ExtendedPrivateKey.fromAddress(serializedAddr);
Expand Down

0 comments on commit a8e65b7

Please sign in to comment.