← Back to SatoshiLabs Improvement Proposals
SLIP 39specificationFinalwallet

Shamir's Secret-Sharing for Mnemonic Codes

This SLIP describes a standard and interoperable implementation of Shamir's secret-sharing (SSS) and a specification for its use in backing up Hierarchical Deterministic Wallets described in [BIP-0032](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki). SSS splits a master secret into unique parts which can be distributed among participants. A specified minimum number of parts is requ

No reviews
Pavol Rusnak·Updated Mar 29, 2026·0 reviews·0 attestations·View source
Collections:SLIPs — Merged

Specification

Table of contents

Abstract

This SLIP describes a standard and interoperable implementation of Shamir's secret-sharing (SSS) and a specification for its use in backing up Hierarchical Deterministic Wallets described in BIP-0032. SSS splits a master secret into unique parts which can be distributed among participants. A specified minimum number of parts is required to be supplied in order to reconstruct the original secret. Knowledge of fewer than the required number of parts does not leak information about the master secret. This SLIP is mainly intended as a replacement for BIP-0039 and for the most part, the two are not compatible.

Notation

Notation | Meaning ----------------|--------------------------------------------------------------- G | total number of groups, a positive integer, 1 ≤ G ≤ 16 N<sub>i</sub> | total number of members in group i, a positive integer, 1 ≤ N<sub>i</sub> ≤ 16 GT | group threshold, a positive integer, 1 ≤ GTG T<sub>i</sub> | member threshold for group i, a positive integer, 1 ≤ T<sub>i</sub>N<sub>i</sub> id | random identifier, a 15-bit unsigned integer ext | extendable backup flag e | iteration exponent, a 4-bit unsigned integer MS | master secret, an octet string n | length of the master secret in bytes EMS | encrypted master secret, an octet string || | concatenation operator xor | bit-wise exclusive-or of two octet strings

Motivation

Preservation of digital assets is generally important and it is especially important in the case of decentralized payments systems such as Bitcoin, where there is no recourse in the case of loss of an asset. The usual approach to protecting digital assets is redundant backups, but when the asset itself is of significant and liquidable value, there is a substantial risk of the backup holder absconding with the asset. Shamir's secret-sharing provides a better mechanism for backing up secrets by distributing custodianship among a number of trusted parties in a manner that can prevent loss even if one or a few of those parties become compromised.

However, the lack of SSS standardization to date presents a risk of being unable to perform secret recovery in the future should the tooling change. Therefore, we propose standardizing SSS so that SLIP-0039 compatible implementations will be interoperable.

Shamir's secret-sharing

Shamir's secret-sharing (SSS) is a cryptographic mechanism describing how to split a secret into N unique parts, where any T of them are required to reconstruct the secret. First, a polynomial f of degree T − 1 is constructed and each party is given a corresponding point - an integer input x to the polynomial and the corresponding output f(x).

When any T points are provided, they exactly define the polynomial. Usually the value of the polynomial f(0) is used as the shared secret. In this specification the shared secret is stored as f(255)<sup>3</sup>. More details on SSS can be found on Wikipedia.

We propose that given a secret, T − 2 shares be generated randomly and the remaining shares be computed in such a way that f(255) encodes the shared secret and f(254) encodes the digest<sup>4</sup> of the shared secret. Encoding the digest makes it possible to verify that the shared secret has been correctly recovered. The diagram below illustrates the splitting of a secret into five shares such that any three are required to recover the shared secret (N = 5 and T = 3).

curve

Shamir's secret sharing scheme is applied separately to each byte of the shared secret and GF(256) is used as the underlying finite field<sup>1</sup>. Bytes are interpreted as elements of GF(256) using polynomial representation with operations modulo the Rijndael irreducible polynomial x<sup>8</sup> + x<sup>4</sup> + x<sup>3</sup> + x + 1, see AES sections 3.2, 4.1 and 4.2.

Two-level scheme

One characteristic of Shamir’s secret sharing scheme is that all shares are equal. Thus if the owner of the secret needs to distribute the amount of trust unevenly between shareholders, then some shareholders need to be given multiple shares. Furthermore, as discussed by Allen and Friedenbach, the owner might want to restrict the combinations of shareholders which are able to reconstruct the secret, because some combinations of shareholders might be more likely to collude against the owner than others. To facilitate this we propose that the encrypted master secret (EMS) is first split using a GT-of-G scheme to obtain a set of first-level shares, aka group shares. The i-th group share, 1 ≤ iG, is then split using a T<sub>i</sub>-of-N<sub>i</sub> scheme to obtain a set of second-level shares, aka member shares, which are distributed among the shareholders. Two levels are assumed to be sufficient to accommodate the majority of use cases while maintaining a comprehensive user interface.

For example, Alice wants to be able to reconstruct her EMS on her own using her 2 shares, which she has stored at different locations. In case these shares get destroyed, she also wants to have a backup with her friends and family in such a way that 3 of her 5 friends together with 2 of her 6 family members are required to reconstruct the EMS. A two-level secret sharing scheme can easily accommodate such requirements. In the given example Alice first splits the EMS using a 2-of-4 scheme to obtain the group shares A, B, C and D. She keeps A and B for herself and splits C further using a 3-of-5 scheme to obtain member shares C1, ... , C5, giving one to each friend. Similarly, Alice splits D among her family members using a 2-of-6 scheme. Thus family members receive a greater amount of trust than friends, without having to give one person multiple shares. However, even if all six family members collude against Alice, they cannot obtain the EMS without the help of at least three of Alice's friends or without stealing one of Alice's own shares.

All shares created in accordance with this specification use the two-level secret sharing scheme. If the creator of the shares wishes to use only a basic single-level T-of-N scheme, then they SHOULD<sup>2</sup> create a single group and conduct the splitting at the second level, i.e. GT = 1, G = 1, T<sub>1</sub> = T and N<sub>1</sub> = N.

If the member threshold T<sub>i</sub> of a group is 1, then the size N<sub>i</sub> of the group SHOULD<sup>2</sup> also be equal to 1. The one share can then be given to multiple members.

Format of the share mnemonic

We propose the following format of the shares:

| Identifier (id) | Extendable (ext) | Iteration exponent (e) | Group index (GI) | Group threshold (Gt) | Group count (g) | Member index (I) | Member threshold (t) | Padded share value (ps) | Checksum (C) | |---------|-------|--------|--------|--------|--------|--------|--------|---------------------|---------| | 15 bits | 1 bit | 4 bits | 4 bits | 4 bits | 4 bits | 4 bits | 4 bits | padding + 8n bits | 30 bits |

  • The identifier (id) field is a random 15-bit value which is the same for all shares and is used to verify that the shares belong together.
  • The extendable backup flag (ext) field<sup>10</sup> indicates that the id is used as salt in the encryption of the master secret when ext = 0.
  • The iteration exponent (e) field indicates the total number of iterations to be used in PBKDF2. The number of iterations is calculated as 10000×2<sup>e</sup>.
  • The group index (GI) field<sup>3</sup> is the x value of the group share.
  • The group threshold (Gt) field<sup>3</sup> indicates how many group shares are needed to reconstruct the master secret. The actual value is encoded as Gt = GT − 1, so a value of 0 indicates that a single group share is needed (GT = 1), a value of 1 indicates that two group shares are needed (GT = 2) etc.
  • The group count (g) indicates the total number of groups. The actual value is encoded as g = G − 1.
  • The member index (I) field<sup>3</sup> is the x value of the member share in the given group.
  • The member threshold (t) field<sup>3</sup> indicates how many member shares are needed to reconstruct the group share. The actual value is encoded as t = T − 1.
  • The padded share value (ps) field corresponds to a list of the SSS part's f<sub>k</sub>(x) values (see the diagram above), 1 ≤ kn. Each f<sub>k</sub>(x) value is encoded as a string of eight bits in big-endian order. The concatenation of these bit strings is the share value. This value is left-padded with "0" bits so that the length of the padded share value in bits becomes the nearest multiple of 10.
  • The checksum (C) field is an RS1024 checksum (see below) of the data part of the share (that is id || ext || e || GI || Gt || g || I || t || ps). The customization string (cs) of RS1024 is "shamir" if ext = 0 and "shamir_extendable" if ext = 1.

This structure is then converted into a mnemonic code by splitting it up into 10-bit segments with each becoming an index into a word list containing exactly 1024 words (see below). Big-endian bit order is used in all conversions. The entropy<sup>4</sup> of the master secret MUST be at least 128 bits and its length MUST be a multiple of 16 bits. All implementations MUST support master secrets of length 128 bits and 256 bits:

| Security | Padded share value length | Total share length | |----------|---------------------------|---------------------| | 128 bits | 130 bits | 200 bits = 20 words | | 256 bits | 260 bits | 330 bits = 33 words |

This construction yields a beneficial property where the random identifier and the iteration exponent transform into the first two words of the mnemonic code, so the user can immediately tell whether the correct shares are being combined, i.e. they have to have the same first two words. Moreover, the third word encodes the group index, group threshold and part of the group count. Since the group threshold and group count are constant, all shares belonging to the same group start with the same three words.

Generating and combining the shares

Polynomial interpolation

Given a set of m points (x<sub>i</sub>, y<sub>i</sub>), 1 ≤ im, such that no two x<sub>i</sub> values equal, there exists a polynomial that assumes the value y<sub>i</sub> at each point x<sub>i</sub>. The polynomial of the lowest degree that satisfies these conditions is uniquely determined and can be obtained using the Lagrange interpolation formula given below.

Since Shamir's secret sharing scheme is applied separately to each of the n bytes of the shared secret, we work with y<sub>i</sub> as a vector of n values, where y<sub>i</sub>[k] = f<sub>k</sub>(x<sub>i</sub>), 1 ≤ kn, and f<sub>k</sub> is the polynomial in the k-th instance of the scheme.

Interpolate(x, {(x<sub>i</sub>, y<sub>i</sub>), 1 ≤ im})

Input: the desired index x, a set of index/value-vector pairs {(x<sub>i</sub>, y<sub>i</sub>), 1 ≤ im} ⊆ GF(256) × GF(256)<sup>n</sup>

Output: the value-vector (f<sub>1</sub>(x), ... , f<sub>n</sub>(x))

f_k(x) = \sum_{i=1}^m y_i[k] \prod_{\underset{j \neq i}{j=1}}^m \frac{x - x_j}{x_i - x_j}

Sharing a secret

SplitSecret(T, N, S)

Input: threshold T, number of shares N, secret S

Output: shares y<sub>1</sub>, ... , y<sub>N</sub> for share indices 0, ... , N − 1

  1. Check the following conditions:

    • 0 < TN ≤ 16
    • The length of S in bits is at least 128 and a multiple of 16.

    If any of these conditions is not satisfied, then abort.

  2. If T is 1, then let y<sub>i</sub> = S for all i, 1 ≤ iN, and return.

  3. Let n be the length of S in bytes. Generate R ∈ GF(256)<sup>n−4</sup> randomly with uniform distribution and let D be the concatenation of the first 4 bytes of HMAC-SHA256(key=R, msg=S) with the n − 4 bytes of R.

  4. Let y<sub>1</sub>, ... , y<sub>T−2</sub> ∈ GF(256)<sup>n</sup> be generated randomly, independently with uniform distribution.

  5. For i such that T − 2 < iN compute y<sub>i</sub> = Interpolation(i − 1, {(0, y<sub>1</sub>), ... , (T − 3, y<sub>T−2</sub>), (254, D), (255, S)}).

The source of randomness used to generate the values in steps 3 and 4 above MUST be suitable for generating cryptographic keys.

RecoverSecret(T, [(x<sub>1</sub>, y<sub>1</sub>), ... , (x<sub>m</sub>, y<sub>m</sub>)])

Input: threshold T, a list of m share-index/share-value pairs [(x<sub>1</sub>, y<sub>1</sub>), ... , (x<sub>m</sub>, y<sub>m</sub>)]

Output: the shared secret S

  1. If T is 1, then let S = y<sub>1</sub> and return.
  2. Compute S =

[Content truncatedview full spec at source]

Discussion (0 threads)

Loading discussions...