solana-py icon indicating copy to clipboard operation
solana-py copied to clipboard

keypair with solana's Ed25519 standard

Open napangelo opened this issue 4 years ago • 6 comments

Hello, I'm trying to generate the keypair with solana's Ed25519 standard, but when I generating it with "Keypair" of "python.py" generates a different key. I would like to know with "python.py" how can I achieve the same result with solana standard Ed25519.

Ref: https://yihau.github.io/solana-web3-demo/tour/create-keypair.html#bip44

Code;

    #memo 
    mnemo = Mnemonic("english")
    seed = mnemo.to_seed("ball job print luggage agent list ride awful quantum stamp month school")

    # with bip_utils - Ed25519
    bip44_mst_ctx = Bip44.FromSeed(seed, Bip44Coins.SOLANA)
    bip44_acc_ctx = bip44_mst_ctx.Purpose().Coin().Account(0)
    bip44_chg_ctx = bip44_acc_ctx.Change(Bip44Changes.CHAIN_EXT)
    print(bip44_chg_ctx.PublicKey().ToAddress())

    # with Keypair "python.py"
    keypair = Keypair.from_secret_key(seed[0:32])
    print(keypair.public_key)

Results:

result with bip_utils - Ed25519
H6jk4FuVfTj4A5kT3hqJLa7pgHrdPN6BF7ur9Ea8wctu

result with Keypair
3sxS3BBsNgJwwxojFYrNdywPKDC9P7ZNHPFNG91zH44i

Can someone help me?

Thanks Angelo

napangelo avatar Nov 25 '22 17:11 napangelo

What version of solana-py did you download?

michaelhly avatar Nov 25 '22 19:11 michaelhly

What version of solana-py did you download?

V. 0.28.0

napangelo avatar Nov 25 '22 21:11 napangelo

@napangelo our library uses https://crates.io/crates/curve25519-dalek under the hood. Can you check what the underlying Ed25519 library is used for your bip_utils library?

michaelhly avatar Nov 25 '22 21:11 michaelhly

From documentation: https://pypi.org/project/bip-utils/

ed25519-blake2b for ed25519-blake2b curve pynacl for ed25519 curve

With standard BIP44

https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki

napangelo avatar Nov 25 '22 22:11 napangelo

😬 see https://github.com/solana-labs/solana/issues/17106. Unfortunately we don't have a good solution for this incompatibility.

michaelhly avatar Nov 25 '22 22:11 michaelhly

Ok thanks. Nice weekend

napangelo avatar Nov 26 '22 16:11 napangelo