Xecrets.Slip39.md
May 26, 2026 · View on GitHub
Xecrets.Slip39
Xecrets.Slip39 Namespace
The main entry point for the library is through the IShamirsSecretSharing interface, which has a default implementation in ShamirsSecretSharing. The only other public type of importance is Share which is how generated shares are represented and returned. It also has a static method to parse a share string into a Share object.
| Classes | |
|---|---|
| Extensions | A set of useful extensions. |
| Group | Defines the main parameter of a group. |
| GroupedShares | A collection of groups of shares, possibly complete, or incomplete. |
| ShamirsSecretSharing | A class for implementing Shamir's Secret Sharing with SLIP-0039 enhancements. |
| Share | A representation of a Shamir secret sharing share. |
| SharePrefix | A representation of the share prefix, which consists of the parameters for the share. |
| Slip39Exception | Creates an exception for catcheable Slip39 errors. This will only be thrown when the error is due to incorrect input data, not due to an internal error or programming errors et. |
| StrongRandom | An IRandom implementation using System.Security.Cryptography.RandomNumberGenerator. |
Interfaces
IRandom Interface
Generate sequences of random bytes.
public interface IRandom
Derived
↳ StrongRandom
Methods
IRandom.GetBytes(byte[]) Method
Fill the provided buffer with random byte values.
void GetBytes(byte[] buffer);
Parameters
buffer System.Byte[]
The buffer to fill.
IRandom.GetBytes(int) Method
Get a System.Byte[] with random bytes.
byte[] GetBytes(int count);
Parameters
count System.Int32
The number of random bytes to get.
Returns
System.Byte[]
A System.Byte[] with random bytes.
IShamirsSecretSharing Interface
Implement Shamirs Secret Sharing according to
public interface IShamirsSecretSharing
Derived
↳ ShamirsSecretSharing
Methods
IShamirsSecretSharing.CombineShares(Share[], string) Method
Recover the master secret from an appropriate set of shares.
Xecrets.Slip39.GroupedShares CombineShares(Xecrets.Slip39.Share[] shares, string passphrase);
Parameters
The shares to recover the secret from.
passphrase System.String
The (optional) passphrase to decrypt the encrypted master secret with.
Returns
GroupedShares
The original master secret.
IShamirsSecretSharing.GenerateShares(bool, int, int, Group[], string, byte[]) Method
Generate shares according to the given parameters.
Xecrets.Slip39.Share[][] GenerateShares(bool extendable, int iterationExponent, int groupThreshold, Xecrets.Slip39.Group[] groups, string passphrase, byte[] masterSecret);
Parameters
extendable System.Boolean
Indicates that the id is used as salt in the encryption of the master secret when false.
iterationExponent System.Int32
The total number of iterations to be used in PBKDF2, calculated as 10000×2^e.
groupThreshold System.Int32
The number of group shares needed to reconstruct the master secret.
The group definitions as a Group[].
passphrase System.String
The (optional) passphrase used to encrypt the master secret.
masterSecret System.Byte[]
The master secret, at least 128 bits and a multiple of 16 bits.
Returns
Share[][]
A Share[][] with shares that can be distributed according to the threshold
parameters.
| Enums | |
|---|---|
| ErrorCode | Error codes used in Slip39Exception to facilitate UI error messages to users with localization etc. The full english text of the actual error is found in the message property of the exception. |
| StringEncoding | The master secret string encoding |