Permaweb Standard Seeds v1.0

Arweave RSA-4096 wallets from a seed phrase.

Status: version 1.0, second edition. The test vectors of section 9 are published with this document. This edition corrects the wording of the first, published the same day at `393082836460114.arweave.net`, and its reference program now refuses a phrase that is not valid. The scheme and the vectors are the same.

Published with this document

FileWhat it isSHA-256
seed-engine.wasmThe derivation as a WebAssembly module (seed-engine 0.2.0)204c6d65b6327378e5e7473f13ed2c53fcee147070ec3a9a45a01f43c27a94ce
derive.mjsRuns the module with Node.jsac2073e85eca75a8bc518e31e3f437cfc85b7f62f3adeb0fe361579530513914
reference.pyThe independent reference, in Python0e5b4cf717e802406b70f53cc802894ef8074c0ec2b19863129df99aa61096c0
vectors.jsonTest vectors878065fd50077baa64a8bdc51ba38aa48b0bccc3406a438cc677723f6e701520
legacy-vectors.jsonTest vectors of the legacy formc4d65c3da615370f950a57f28b5544757fca84544cd1333483846fe08012822d
permaweb-standard-seeds-v1.0.mdThis document, as Markdownb7a93b587b35373651816d2e09aa74dd3a0f4e00b8097ca4ea7355f80175f163

Appendix B says how to use them. Check a file against its SHA-256 before running it.

1. Scope

This document specifies how a numbered sequence of RSA-4096 Arweave wallets is derived from one BIP-39 seed phrase. The same phrase and wallet number give the same wallet in every conforming implementation, in software and on a hardware device.

The key words MUST, MUST NOT, SHOULD and MAY are used as in RFC 2119.

An implementation is compatible only if, for every valid phrase and wallet number, it produces the same primes p and q as this document defines, and refuses the same wallet numbers. Everything else follows from those two numbers.

A seed phrase does not say which scheme its wallets were made with. Whoever writes a phrase down SHOULD write the name of this scheme, Permaweb Standard Seeds v1.0, beside it.

2. Overview

seed phrase ──BIP-39──▶ seed (64 bytes)
seed + path m/44'/472'/N'/0'/0' ──section 5──▶ wallet secret M (32 bytes)
M ──section 6──▶ two starting points (2048 bits each)
starting points ──section 7──▶ primes p, q
p, q ──section 8──▶ RSA-4096 key, owner, address

Each wallet depends only on the phrase, the optional passphrase and its own number N. No state is shared between wallets, so a wallet is the same whether it is derived alone, in a range, or after any other wallet.

3. Standards used

StepStandard
Phrase validation and phrase to seedBIP-39
Path layoutBIP-44
Coin type 472 (Arweave)SLIP-44
Path derivation on Ed25519BIP32-Ed25519 (Khovratovich and Law), in the variant specified in section 5
HashesSHA-256, SHA-512 (FIPS 180-4); HMAC (RFC 2104)
RSA key and signature formatsRFC 8017; JWK per RFC 7517 and RFC 7518
Validity of the RSA key pairNIST SP 800-56B Rev. 2, section 6.4.1.2.3; FIPS 186-5, appendix A.1

Sections 4 to 8 are normative in full. Where they differ from a cited standard, this document governs. Section 12 says exactly how the keys relate to the NIST standards.

4. Inputs

4.1 Seed phrase

The phrase MUST be a valid BIP-39 mnemonic of 12, 15, 18, 21 or 24 words from the English wordlist, with a correct checksum. Before validation, an implementation MUST convert the input to Unicode NFKD, lower-case it, trim it, and join the words with single spaces.

The seed S is the 64-byte BIP-39 seed: PBKDF2-HMAC-SHA512, 2048 iterations, password the normalized phrase, salt the string mnemonic followed by the passphrase. The passphrase is the empty string unless the user supplies one; a passphrase is converted to Unicode NFKD and is otherwise used exactly as given. A different passphrase gives an unrelated set of wallets.

4.2 Wallet number

The wallet number N is an integer with 0 <= N <= 2^31 - 1. Wallet 0 is the default wallet.

4.3 Path

The derivation path for wallet N is:

m / 44' / 472' / N' / 0' / 0'

All five components are hardened. As 32-bit integers they are 0x8000002C, 0x800001D8, 0x80000000 + N, 0x80000000, 0x80000000.

5. Path derivation

This section derives the 32-byte wallet secret M from S and the path. It is the Ed25519 hierarchical derivation that Ledger devices perform in their default mode. It is not SLIP-10.

Notation: || is concatenation. le32(i) is i as 4 bytes, least significant first. int_le(b) reads bytes as a little-endian unsigned integer, and bytes_le(x, 32) writes one as 32 bytes. The HMAC key in section 5.1 is the 12 ASCII bytes ed25519 seed.

5.1 Root node

c = HMAC-SHA256(key = "ed25519 seed", message = 0x01 || S)          (32 bytes)
I = HMAC-SHA512(key = "ed25519 seed", message = S)                  (64 bytes)
while (I[31] & 0x20) != 0:
    I = HMAC-SHA512(key = "ed25519 seed", message = I)
I[0]  = I[0] & 0xF8
I[31] = (I[31] & 0x7F) | 0x40
kL = I[0..32]        kR = I[32..64]

The loop re-hashes all 64 bytes. The chain code c is computed once from S and is not changed by the loop.

5.2 Hardened child

For each path component i, in order, replace (kL, kR, c):

Z   = HMAC-SHA512(key = c, message = 0x00 || kL || kR || le32(i))
zl  = int_le(Z[0..28])                     (the low 28 bytes only)
kL' = bytes_le((8 * zl + int_le(kL)) mod 2^256, 32)
kR' = bytes_le((int_le(Z[32..64]) + int_le(kR)) mod 2^256, 32)
c'  = HMAC-SHA512(key = c, message = 0x01 || kL || kR || le32(i))[32..64]

Both HMACs use the parent's kL, kR and c. Non-hardened components are never used and are not specified here.

5.3 Wallet secret

After the fifth component, M = kL (32 bytes, in the byte order held). kR and c are discarded.

6. Starting points

For prime index j in {0, 1}:

B_j = SHA-256(0x01 || j || M || 0x00) || SHA-256(0x01 || j || M || 0x01) || … || SHA-256(0x01 || j || M || 0x07)

Each hash input is 35 bytes: the form byte 0x01, the prime index, M, and a counter byte from 0 to 7. B_j is 256 bytes. Then set the two most significant bits, B_j[0] = B_j[0] | 0xC0, and read the starting point as a big-endian integer s_j. So 3 * 2^2046 <= s_j < 2^2048.

The form byte belongs to this version of the scheme. It makes the starting points of this version independent of those of any other form derived from the same phrase (appendix A).

For each starting point s:

o = s        if s is odd
o = s + 1    if s is even
prime(s) = the smallest prime strictly greater than o

The starting point itself is never returned, even if it is prime. For an even starting point, s + 1 is also never returned.

prime(s) MUST be less than 2^2048. If it is not, wallet N is invalid.

The result is a number, not the output of a procedure. An implementation MAY use any sieve, primality test and scheduling, provided it never accepts a composite and never skips a prime. A probabilistic test MUST have an error probability below 2^-100 for these inputs.

8. Key, owner and address

p = prime(s_0)        q = prime(s_1)        e = 65537
n = p * q
d  = e^-1 mod lcm(p - 1, q - 1)
dp = d mod (p - 1)    dq = d mod (q - 1)    qi = q^-1 mod p

p and q are not reordered. Wallet N is invalid if any of these holds:

An implementation MUST refuse an invalid wallet number and MUST NOT substitute another key. Software and device MUST agree on which numbers are invalid. About one wallet number in 32,768 is invalid by the second rule. The first, third and fourth are not expected to occur for any phrase: each has a probability below 2^-96.

The modulus n has exactly 4096 bits, since each prime is at least 3 * 2^2046.

A device that never exports the private key MAY sign with a different private exponent: any valid one produces signatures that verify under the same owner. It still applies the fourth rule to d as defined here.

9. Conformance

Test vectors accompany this document in vectors.json. For each entry they give the phrase, passphrase and wallet number, and the expected M, s_0, s_1 (after the two bits are set), owner, address, the keyfile, and a SHA-256 of the keyfile serialized as compact JSON in the field order of section 8. An invalid wallet number has a reason in place of a key.

A conforming implementation MUST reproduce every vector. The vectors include wallets with high numbers, an even starting point, an even starting point followed by a prime, an odd starting point that is itself prime, wallet numbers that are invalid because of each prime, a phrase whose wallet 0 is invalid, and phrases of 12, 15, 18, 21 and 24 words, one with a passphrase.

reference.py, published with this document, is an independent implementation in Python that uses the standard library only. It writes the vectors, and it derives the keyfile of any wallet from a phrase.

Implementations SHOULD run at least one built-in vector on the user's device before deriving from a user's phrase, and SHOULD sign and verify a message with each derived key before saving it. Either check failing MUST abort the import.

10. Hardware device requirements

A device application implementing this scheme:

11. Security considerations

12. Relation to the NIST standards

Every valid key of this scheme meets every condition that NIST SP 800-56B Rev. 2, section 6.4.1.2.3 (rsakpv1-crt, key-pair validation with a fixed public exponent) and FIPS 186-5, appendix A.1.1 place on an RSA key pair with a 4096-bit modulus and e = 65537:

ConditionWhy it holds
e is odd, 2^16 < e < 2^256e = 65537
n = p * q has exactly 4096 bitseach prime is at least 3 * 2^2046
sqrt(2) * 2^2047 <= p, q < 2^20483 * 2^2046 > sqrt(2) * 2^2047; section 7 bounds above
p and q are primesection 7
gcd(p - 1, e) = gcd(q - 1, e) = 1section 8, second rule
|p - q| > 2^1948section 8, third rule
2^2048 < d < lcm(p - 1, q - 1) and d * e = 1 mod lcm(p - 1, q - 1)section 8, definition of d and fourth rule
dp = d mod (p - 1), dq = d mod (q - 1), qi = q^-1 mod p, each in its rangesection 8

The scheme differs from FIPS 186-5 in one respect, which concerns how a key is generated and not what the key is. FIPS 186-5 appendix A.1.3 draws a fresh random number for each candidate prime. This scheme must give the same key every time, so it takes each prime as the first one above a starting point that is fixed by the phrase. A prime that follows a long gap between primes is therefore somewhat more likely than one that follows a short gap. Searching upwards from a random start is a long-used way to find primes, analysed by Brandt and Damgård (1992), and no weakness is known to follow from it. A key of this scheme is not a key generated by a FIPS-validated module.

Appendix A. The legacy form

Before this version, the same derivation was used in a form that the Ledger Arweave application also implements. The legacy form differs from this document in three places, and in nothing else:

PlaceLegacy formPermaweb Standard Seeds v1.0
Section 6, form byte0x000x01
Section 6, bits setthe top bit: B_j[0] | 0x80the top two bits: B_j[0] | 0xC0
Section 8, invalidityp = q, or a factor shared with ethe same, and |p - q| <= 2^1948, d <= 2^2048

A legacy modulus has 4095 bits about 39% of the time, and a legacy prime lies below sqrt(2) * 2^2047 about 41% of the time, so most legacy keys miss the size conditions of section 12. They are otherwise sound RSA keys and remain valid Arweave wallets.

The two forms give unrelated wallets from the same phrase. Software that offers the legacy form MUST offer it as a separate, named choice, and MUST NOT guess a phrase's form.

legacy-vectors.json, published with this document, holds the legacy form's test vectors. Its first wallet is the one a Ledger device derives from the test phrase of the Ledger Arweave application. reference.py reproduces that wallet before it writes anything, because sections 4, 5, 7 and 8 are the same code for both forms.

Appendix B. Deriving the wallets again

Three things are published with this document so that the wallets of a phrase can be derived again without the software that first made them:

Run them on a computer that is not connected to a network, and check a vector before trusting a result. The two share no code.