/secret-sharing

Implementation of Shamir's secret sharing scheme

Primary LanguageScalaMIT LicenseMIT

secret-sharing

This is an implementation of the Shamir's secret sharing scheme in Scala 3

Dealer test

To run the dealer test (share a secret and reconstruct the secret in several configurations)

Run dealer test: sbt "testOnly *.DealerTest"

Improvement

The sharing scheme is using polynomials in finite fields, this implementation makes use of an improved way of evaluating polynomials

How to use

Given your secret s as bytes:

  1. Initiate the sharing scheme for your dealer:
val sharingScheme = ShamirSecretSharingScheme(
  Config(
    BigInt(s), // Your secret
    threshold, // The minium number of shares required to recover the secret
    numberOfParticipants, // Total number of participants/shares
    bitLen // The bit length of the prime number used to define the finite field (should be larger than the size of the secret)
  )
)

val dealer = Dealer(sharingScheme)
  1. Share your secret with your trusted parties:
val shares = dealer.share(s)
  1. Later on, reconstruct your secret, given at least threshold shares:
val recoveredSecret = dealer.recover(colectedShares)