Key pair
TON Blockchain uses asymmetric cryptography, such as the Ed25519 signature scheme. There are multiple ways to derive a key pair from a mnemonic. Below is the most common approach in TON.Some apps in the TON ecosystem may use a different derivation method, eventually producing an Ed25519-conformant key pair.
Key pair from a mnemonic
To transform a mnemonic phrase into a key pair, aseed
is first derived using PBKDF2, and the key pair is then derived from that seed
.
PBKDF2 has five input parameters: PRF
, Password
, Salt
, c
, and dkLen
. Each of those parameters is assigned a concrete value.
The most commonly used values are:
Parameter | Description | Value |
---|---|---|
PRF | Pseudo-random function of two parameters | HMAC‑SHA512 |
Password | Master password from which a derived key is generated | "" |
Salt | Sequence of bits, known as a cryptographic salt | "TON default seed" |
c | Number of iterations desired | 100000 |
dkLen | Desired bit-length of the derived key | 64 |
Generate a key pair
TypeScript
ImportantSave the generated mnemonic seed phrase. If you need deterministic behavior during development, print and reuse the exact phrase so the wallet derives the same key pair on every run.
Mnemonic validation
- Check that all the words are from the list of BIP-39.
- If a password is used: the first byte of the derived
seed
computed withc = 1
andsalt = 'TON fast seed version'
must equal0
. - If no password is used: the first byte of the derived
seed
computed withc = floor(100000/256) = 390
andsalt = 'TON seed version'
must equal1
.
Generate a mnemonic
TypeScript