Class XummExtension
Extension methods for working with XRPL Secret Numbers format. Secret Numbers encode 16 bytes of entropy into 8 groups of 6 digits each, where 5 digits represent entropy and the 6th digit is a position-dependent checksum. This format is language-agnostic and allows real-time typo detection. See XLS-12d specification: https://github.com/XRPLF/XRPL-Standards/issues/15
Inheritance
Namespace: Xrpl.Wallet
Assembly: Xrpl.dll
Syntax
public static class XummExtension
Methods
| Edit this page View SourceCalculateChecksum(int, int)
Calculates the checksum digit for a secret number at a given position. The checksum formula is: value * (position * 2 + 1) % 9 This position-dependent checksum helps detect if numbers are entered in wrong order.
Declaration
public static int CalculateChecksum(int position, int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | position | Position of the number (0-7) |
| int | value | The 5-digit entropy value (0-65535) |
Returns
| Type | Description |
|---|---|
| int | Single checksum digit (0-8) |
CheckXummNumbers(string[])
Validates all 8 secret numbers including their checksums.
Declaration
public static bool CheckXummNumbers(string[] numbers)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | numbers | Array of 8 secret number strings |
Returns
| Type | Description |
|---|---|
| bool | True if all numbers and checksums are valid |
CheckXummSum(int, string)
Validates a single secret number at a given position. Checks that the number is 6 digits and the checksum matches.
Declaration
public static bool CheckXummSum(int position, string number)
Parameters
| Type | Name | Description |
|---|---|---|
| int | position | Position of the number (0-7) |
| string | number | 6-digit secret number string |
Returns
| Type | Description |
|---|---|
| bool | True if the number format and checksum are valid |
EntropyFromXummNumbers(string[])
Converts an array of 8 secret number strings to 16 bytes of entropy. Validates checksums before conversion.
Declaration
public static byte[] EntropyFromXummNumbers(string[] numbers)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | numbers | Array of 8 secret number strings |
Returns
| Type | Description |
|---|---|
| byte[] | 16 bytes of entropy |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | When numbers are invalid or checksums don't match |
EntropyToSecretNumbers(byte[])
Converts 16 bytes of entropy to an array of 8 secret number strings. Each string contains 6 digits: 5 digits of entropy + 1 checksum digit.
Declaration
public static string[] EntropyToSecretNumbers(byte[] entropy)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | entropy | 16 bytes of entropy |
Returns
| Type | Description |
|---|---|
| string[] | Array of 8 secret number strings, each 6 digits long |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | When entropy is not exactly 16 bytes |
ParseSecretString(string)
Parses a space-separated secret numbers string into an array. Accepts formats like "554872 394230 209376 323698 140250 387423 652803 258676"
Declaration
public static string[] ParseSecretString(string secretString)
Parameters
| Type | Name | Description |
|---|---|---|
| string | secretString | Space-separated secret numbers string |
Returns
| Type | Description |
|---|---|
| string[] | Array of 8 secret number strings |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | When the string format is invalid |
RandomSecretNumbers()
Generates a cryptographically secure random set of 8 secret numbers. Uses 16 bytes of random entropy to create the secret.
Declaration
public static string[] RandomSecretNumbers()
Returns
| Type | Description |
|---|---|
| string[] | Array of 8 secret number strings, each 6 digits long |