How to build a Private key?

In Bitcoin and Ethereum, a private key is just a 256-bit number. Isn’t it the same in Avalanche too?

What I’d like to do is to create a private key from a SHA256(“big passphrase”), without having to use a lib or a mnemonic key phrase.

Thanks for your help.

2 Likes

Here is the documentation on it Cryptographic Primitives - Avalanche (avax.network)

Hope it will help you

1 Like

Thanks for this link, Nicolas. I already read this page before asking my question, because unless I am mistaken, it does not explain how to forge a private key.

My hunch tells me that it can be any 256-bit number. But I would like to have a clear confirmation.

Edit: actually not any, but from 0x1 to 0xFFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFE BAAE DCE6 AF48 A03B BFD2 5E8C D036 4140 to be a valid private key. And as Avalanche’s keys belong to secp256k1, it should be the same.

If you would like to create a private key from a passphrase and be sure that it never left your computer, you can deploy the wallet locally, and use that to create keys.

Alternatively, without using the mnemonic key phrase, you can do that with AvalancheJS, a library for interaction with the Avalanche network.

I have built a tiny Python tool for this: https://github.com/Determinant/keytree.py. It supports generating mnemonics and deriving arbitrary keys from them (AVAX wallet standard, but also could be customized). It can import (decrypt)/export JSON keystore file generated by the official wallet. It works out of the box because all dependencies are frozen, as an ideal offline command-line tool to manage your wallets. For a bonus feature, you can use any UTF-8 string as the seeding source (yeah, the “big passphrase” you just mentioned, including any special characters in your language) and the generated wallet can be read and used by the official wallet app. Finally, it also derives the corresponding BTC/ETH addresses (and private keys) from the same keys. That means you only need one mnemonics for all AVAX/BTC/LTC/ETH/USDT coins. I made it for my personal use. Use it at your own risk.

3 Likes

So, after spelunking in our GitHub repos yesterday in search of something else, I stumbled upon this:

That’s a set of scripts one of which can be used to generate keys totally offline. It might be what you’re after.

2 Likes