EIPs Explained

ERC-3450 · Stagnant · ERC · 2021-03-29

ERC-3450: Standardized Shamir Secret Sharing Scheme for BIP-39 Mnemonics

A proposed standard for splitting a BIP-39 seed phrase into N shares with Shamir's Secret Sharing, where any T shares rebuild it and every share is itself a valid BIP-39 mnemonic.

What problem does it solve?

Most wallets back up keys as a BIP-39 mnemonic, the familiar 12 or 24 words. That phrase is a single point of failure: lose it and the funds are gone, let someone see it and they can take everything.

Shamir's Secret Sharing is the classic fix: split a secret into N shares so that any T of them reconstruct it, while fewer than T reveal nothing. The catch, the spec argues, is that there was no canonical implementation for mnemonics, so shares made with one tool might not be recoverable with another years later. ERC-3450 pins down one exact algorithm.

How it works

  1. Mnemonic → entropy. Decode the words to their underlying entropy (128–256 bits), dropping the checksum bits. Only the BIP-39 English word list is supported.
  2. Split each byte. Treat every entropy byte as an element of GF(256), using the AES (Rijndael) polynomial x⁸ + x⁴ + x³ + x + 1. For each byte, build a random polynomial of degree T − 1 whose constant term is that byte, using a cryptographically secure random source for the other coefficients.
  3. Make shares. For each share ID x = 1 … N, evaluate the polynomials at x. The resulting byte vector is encoded as a new BIP-39 mnemonic with a freshly computed checksum, so it has the same length as the original and passes normal mnemonic validation.
  4. Recover. Take any T shares, convert each back to entropy, and use Lagrange interpolation at x = 0 to get the original entropy, then the original mnemonic.

Constraints: 1 < T ≤ N < 256. A share is the pair (ID, mnemonic); the ID is the x-coordinate and is not encoded in the words.

Sample code

Core GF(256) arithmetic and recovery of one byte (TypeScript, illustrative only):

// Multiply in GF(256) with the AES polynomial 0x11b
function gmul(a: number, b: number): number {
  let p = 0;
  while (b) {
    if (b & 1) p ^= a;
    a = (a << 1) ^ (a & 0x80 ? 0x11b : 0);
    b >>= 1;
  }
  return p & 0xff;
}

function ginv(a: number): number {   // a^254 = a^-1 in GF(256)
  let r = 1;
  for (let i = 0; i < 254; i++) r = gmul(r, a);
  return r;
}

// Lagrange interpolation at x = 0 for one byte position
export function recoverByte(shares: { x: number; y: number }[]): number {
  let secret = 0;
  for (const i of shares) {
    let num = 1, den = 1;
    for (const j of shares) {
      if (i === j) continue;
      num = gmul(num, j.x);           // (0 - x_j) = x_j in GF(2^8)
      den = gmul(den, i.x ^ j.x);     // (x_i - x_j) = x_i XOR x_j
    }
    secret ^= gmul(i.y, gmul(num, ginv(den)));
  }
  return secret;
}

Things to know

  • Status: Stagnant. The spec's test vectors are marked "coming soon", so interoperability between implementations is not guaranteed.
  • This is not compatible with SLIP-39, a different and more widely known Shamir scheme for seeds that uses its own word list and encodes metadata in the shares.
  • You must keep each share's ID together with its words. Without the IDs, recovery may be impossible. The spec also suggests storing the ID in a way that does not reveal what it is.
  • There is deliberately no check on recovery: with fewer than T shares you get a valid-looking but wrong mnemonic, with no error.
  • Splitting is only as safe as the device doing it. Do it offline, use a secure random source, and destroy the original afterwards only once recovery has been tested.

#wallet #mnemonic #bip-39 #secret-sharing #key-management

Details

Authors
Daniel Streit (@danielstreit)
Status
Stagnant
Type
Standards Track / ERC
Created
2021-03-29

Machine-readable: Markdown · JSON