SecretSharing

de.christofreichardt.scala.shamir.SecretSharing
class SecretSharing(val shares: Int, val threshold: Int, val secretBytes: IndexedSeq[Byte], val random: SecureRandom) extends Tracing

A secret sharing sheme.

Value parameters

random

the secure random source

secretBytes

the actual secret

shares

the number of shares

threshold

the number of shares required for the recovery of the secret bytes

Attributes

Constructor

Creates a new SecretSharing sheme with shares, threshold, secretBytes and a secure random source.

Graph
Supertypes
trait Tracing
class Object
trait Matchable
class Any

Members list

Type members

Classlikes

case class CertificationResult(falsified: Int, verified: Int)

A mere data holder for recording the certification (both falsification and verification) results of a sharepoint partition.

A mere data holder for recording the certification (both falsification and verification) results of a sharepoint partition.

Value parameters

falsified

the number of falsified slice combinations with a sharepoint count below the threshold

verified

the number of verified slice combinations with a sharepoint count equal or above the threshold

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Value members

Constructors

def this(secretBytes: IndexedSeq[Byte])

Creates a new SecretSharing sheme with 6 shares, threshold == 3, the given secretBytes and a default secure random source.

Creates a new SecretSharing sheme with 6 shares, threshold == 3, the given secretBytes and a default secure random source.

Value parameters

secretBytes

the actual secret

Attributes

def this(shares: Int, threshold: Int, secretBytes: IndexedSeq[Byte])

Creates a new SecretSharing sheme with shares, threshold, secretBytes and a default secure random source.

Creates a new SecretSharing sheme with shares, threshold, secretBytes and a default secure random source.

Value parameters

secretBytes

the actual secret

shares

the number of shares

threshold

the number of shares required for the recovery of the secret bytes

Attributes

def this(shares: Int, threshold: Int, secretBytes: Array[Byte])

Creates a new SecretSharing sheme with shares, threshold, secretBytes and a default secure random source. This is convenient when calling from Java.

Creates a new SecretSharing sheme with shares, threshold, secretBytes and a default secure random source. This is convenient when calling from Java.

Value parameters

secretBytes

the actual secret

shares

the number of shares

threshold

the number of shares required for the recovery of the secret bytes

Attributes

def this(shares: Int, threshold: Int, password: CharSequence)

Creates a new SecretSharing sheme with shares, threshold, password and a default secure random source.

Creates a new SecretSharing sheme with shares, threshold, password and a default secure random source.

Value parameters

password

the actual secret, will be encoded with UTF-8

shares

the number of shares

threshold

the number of shares required for the recovery of the secret bytes

Attributes

Concrete methods

def certifySharePointPartition(partition: List[IndexedSeq[(BigInt, BigInt)]]): CertificationResult

Certifies a given sharepoint partition by falsifying all slice combinations with a sharepoint count below the threshold and vice versa by verifying all valid slice combinations with a sharepoint count equal or above the threshold. This is a potentially very expensive calculation (both time and memory at present) since all combinations from 'n choose 1' up to 'n choose n' must be considered whereby n is given by the number of slices within the partition

Certifies a given sharepoint partition by falsifying all slice combinations with a sharepoint count below the threshold and vice versa by verifying all valid slice combinations with a sharepoint count equal or above the threshold. This is a potentially very expensive calculation (both time and memory at present) since all combinations from 'n choose 1' up to 'n choose n' must be considered whereby n is given by the number of slices within the partition

Value parameters

partition

the given sharepoint partition

Attributes

Returns

the result of the certification if successful

def chooseCanonicalCoefficients: IndexedSeq[BigInt]

Calculates a batch of coefficients needed for the polynomial in the canonical form.

Calculates a batch of coefficients needed for the polynomial in the canonical form.

Attributes

Returns

the random coefficients

final def choosePolynomial(degree: Int): Polynomial

Chooses a random polynomial with the given degrre in the canonical form.

Chooses a random polynomial with the given degrre in the canonical form.

Value parameters

degree

the degree of the polynomial

Attributes

Returns

the random polynomial

def choosePrime: BigInt

Calculates a random prime p with the property s < p.

Calculates a random prime p with the property s < p.

Attributes

Returns

a random prime

def computeShares: IndexedSeq[(BigInt, BigInt)]

Computes the required number of random and distinct shares.

Computes the required number of random and distinct shares.

Attributes

Returns

the shares

def falsifyAll: (Boolean, Int)
def partitionAsJson(sizes: Array[Int]): JsonArray

Partitions the shares according to the given sizes and converts the different slices containing the shares into a JSON array containing the slices as JSON objects.

Partitions the shares according to the given sizes and converts the different slices containing the shares into a JSON array containing the slices as JSON objects.

Value parameters

sizes

denotes a partition

Attributes

Returns

the JSON array of slices containing the shares

def saveCertifiedPartition(sizes: Array[Int], path: Path): CertificationResult

a convenience method. Demands that the desired partition is to be certified before saving, see savePartition.

a convenience method. Demands that the desired partition is to be certified before saving, see savePartition.

Value parameters

path

the path to the partition file

sizes

denotes the partition

Attributes

Returns

the certification result indicating the number of verified and falsified slice combinations

def savePartition(sizes: Iterable[Int], path: Path, certified: Boolean): Option[CertificationResult]

Saves the desired partition. The partition can optionally be certified by verifying all slice combinations containing share points equal or above the threshold and by falsifying all other (invalid) slice combinations.

Saves the desired partition. The partition can optionally be certified by verifying all slice combinations containing share points equal or above the threshold and by falsifying all other (invalid) slice combinations.

Value parameters

certified

indicates if the partition is to be certified

path

the path to the partition file

sizes

denotes the partition

Attributes

Returns

the optional certification result indicating the number of verified and falsified slice combinations

def savePartition(sizes: Array[Int], path: Path): Option[CertificationResult]

A convenience method. Saves the partition in the order as given by the sizes.

A convenience method. Saves the partition in the order as given by the sizes.

Value parameters

path

the path to the partition file

sizes

denotes the partition

Attributes

def sharePointPartition(sizes: Iterable[Int]): List[IndexedSeq[(BigInt, BigInt)]]

Partitions the share points into disjunct sequences according to the given sizes.

Partitions the share points into disjunct sequences according to the given sizes.

Value parameters

sizes

denotes the sizes of the desired share point sequences

Attributes

Returns

a list of share point sequences

def sharePointsAsJson(ps: IndexedSeq[(BigInt, BigInt)]): JsonObject

Translates the given shares into JSON.

Translates the given shares into JSON.

Value parameters

ps

the shares

Attributes

Returns

the JSON containing the shares

override def toString: String

Gives a textual representation of this particular secret sharing sheme.

Gives a textual representation of this particular secret sharing sheme.

Attributes

Returns

the textual representation

Definition Classes
Any
def verifyAll: (Boolean, Int)

Verifies that all valid combinations of shares recover the secret bytes. That is all combinations of shares with a sharepoint count that equals the threshold will be considered.

Verifies that all valid combinations of shares recover the secret bytes. That is all combinations of shares with a sharepoint count that equals the threshold will be considered.

Attributes

Returns

indicates the outcome of all possible and valid cross checks

Inherited methods

def getCurrentTracer(): AbstractTracer

Returns the present tracer for this object.

Returns the present tracer for this object.

Attributes

Returns

the current tracer, by default the NullTracer

Inherited from:
Tracing
def withTracer[T](resultType: String, callee: AnyRef, method: String)(block: => T): T

Custom control structure for tracing of embraced code blocks.

Custom control structure for tracing of embraced code blocks.

Type parameters

T

the actual type of the embraced code block

Value parameters

block

the embraced code block

callee

the call site

method

denotes the method signature

resultType

denotes the return type

Attributes

Returns

returns whatever block returns

Inherited from:
Tracing

Concrete fields

Indicates that both verified and falsified have produced the expected results

Indicates that both verified and falsified have produced the expected results

Attributes

lazy val falsified: (Boolean, Int)

Ensures that all combinations of shares below the threshold have failed to produce the secret. This is backed by a potentially very expensive operation.

Ensures that all combinations of shares below the threshold have failed to produce the secret. This is backed by a potentially very expensive operation.

Attributes

val id: String

The partition id

The partition id

Attributes

val k: Int

An alias for threshold

An alias for threshold

Attributes

val n: Int

An alias for shares

An alias for shares

Attributes

A random polynomial in the canonical form used to compute the shares

A random polynomial in the canonical form used to compute the shares

Attributes

val prime: BigInt

The prime modulus

The prime modulus

Attributes

val random: SecureRandom

Used to compute a LazyList of random BigInt numbers

Used to compute a LazyList of random BigInt numbers

Attributes

val s: BigInt

The secret encoded as non-negative BigInt

The secret encoded as non-negative BigInt

Attributes

val secretBytes: IndexedSeq[Byte]
val sharePoints: IndexedSeq[(BigInt, BigInt)]

The actual shares

The actual shares

Attributes

lazy val sharePointsAsJson: JsonObject

All shares converted into a JSON object

All shares converted into a JSON object

Attributes

val shares: Int
val threshold: Int
lazy val verified: (Boolean, Int)

Indicates if cross checks with all possible combinations of shares with a sharepoint count that equals the threshold have successfully produced the secret. This is backed by a potentially very expensive operation.

Indicates if cross checks with all possible combinations of shares with a sharepoint count that equals the threshold have successfully produced the secret. This is backed by a potentially very expensive operation.

Attributes