nxt.crypto

## Class SecretSharingGenerator

- java.lang.Object
- - nxt.crypto.SecretSharingGenerator

-     public class SecretSharingGenerator
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SecretSharingGenerator()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `combine(java.lang.String[] encodedSecretPhrasePieces)` Given minPieces pieces out of totalPieces of a secretPhrase, combine the pieces into the original phrase.* Pieces are formatted as [version]:[split id]:[total pieces]:[minimum pieces]:[prime field size or zero]:[piece number]:[piece content]
    `static java.math.BigInteger` | `getModPrime(java.lang.String secretPhrase)` Given a secret phrase calculate the modulo prime finite field size which is sufficiently large to split the shared secrets
    `static java.lang.String[]` | `split(java.lang.String secretPhrase, int totalPieces, int minPieces, java.math.BigInteger declaredModePrime)` Given a secretPhrase split it into totalPieces pieces where each minPieces of them are enough to reproduce the secret.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SecretSharingGenerator

          public SecretSharingGenerator()

  - ### Method Detail

    - #### split

          public static java.lang.String[] split(java.lang.String secretPhrase,
                                                 int totalPieces,
                                                 int minPieces,
                                                 java.math.BigInteger declaredModePrime)

      Given a secretPhrase split it into totalPieces pieces where each minPieces of them are enough to reproduce the secret. If the secret phrase is 12 words from the list, the secret is converted into 128 bit number which is very compact. Otherwise the secret phrase is converted to bytes using UTF8 then to a BigInteger. Pieces are returned with a piece number followed by : and the piece content. The piece number is required when reproducing the secret.
      Parameters:
        `secretPhrase` - the secret phrase
        `totalPieces` - the number of generated pieces
        `minPieces` - the number of pieces needed to reproduce the secret phrase
        `declaredModePrime` - the modulo prime used for secret sharing calculations. Specify BigInteger.ZERO to calculate automatically
      Returns:
        the secret pieces

    - #### combine

          public static java.lang.String combine(java.lang.String[] encodedSecretPhrasePieces)

      Given minPieces pieces out of totalPieces of a secretPhrase, combine the pieces into the original phrase.* Pieces are formatted as [version]:[split id]:[total pieces]:[minimum pieces]:[prime field size or zero]:[piece number]:[piece content]
      Parameters:
        `encodedSecretPhrasePieces` - the pieces of the secret phrase formatted as specified above
      Returns:
        the reproduced secret phrase

    - #### getModPrime

          public static java.math.BigInteger getModPrime(java.lang.String secretPhrase)

      Given a secret phrase calculate the modulo prime finite field size which is sufficiently large to split the shared secrets
      Parameters:
        `secretPhrase` - the secret phrase
      Returns:
        the prime number representing the finite field size