iancoleman / bip39

A web tool for converting BIP39 mnemonic codes
https://iancoleman.io/bip39/
MIT License
3.41k stars 1.42k forks source link

BIP 86 / P2TR #620

Open jansocz opened 1 year ago

jansocz commented 1 year ago

Would it be possible to add support for BIP 86 derivation path? Now that latest LND release switched to p2tr address by default, this is very needed now..

openMolNike commented 1 year ago

@jansocz I've created Android app with taproot support. This app can derivate Bitcoin and Ethereum absolutely offline. Select "Restore seed" and "Seed to addresses" BIP-39 Coin-flip for crypto Legacy and segwit addresses are equal to iancoleman. Taproot addresses are equal to this tool

openMolNike commented 1 year ago

I made changes to native segwit to get taproot addresses as here

1)Get compressed public key K0 and repalce 03 to 02. Parse it to variable K1. (So, new K1.y may be not equal to original K0.y) 2)t = sha256(sha256("TapTweak")+sha256("TapTweak")+K1.x)
where "+" is the byte array concatenation
sha256("TapTweak")+sha256("TapTweak") - is always same, you can save it to constant 3)K2.xy = (K1.xy + t*G.xy) - ecliptic curve secp256k1 math 4)address = bech32m(K2.x)

the bech32m function has the following differences compared to bech32: 1)when you add 00 byte at the between "bc1" and data, replace it to 01. 2)add new byte between data and checksum with formula:
if K2.x mod 2==0 then 0 else 16(decimal,0x10-hex) 3)when use polymod checksum replace ^1 to ^0x2bc830a3 in function ending