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.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
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
seedcomputed withc = 1andsalt = 'TON fast seed version'must equal0. - If no password is used: the first byte of the derived
seedcomputed withc = floor(100000/256) = 390andsalt = 'TON seed version'must equal1.
Generate a mnemonic
TypeScript