public abstract class Scheme extends Object
| Constructor and Description |
|---|
Scheme() |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
join(Map<Integer,byte[]> parts)
Joins the given parts to recover the original secret.
|
abstract int |
k()
The number of parts the scheme will require to re-create a secret.
|
abstract int |
n()
The number of parts the scheme will generate when splitting a secret.
|
static Scheme |
of(int n,
int k)
Creates a new
Scheme instance. |
Map<Integer,byte[]> |
split(byte[] secret)
Splits the given secret into
n parts, of which any k or more can be combined
to recover the original secret. |
@CheckReturnValue public static Scheme of(@Nonnegative int n, @Nonnegative int k)
Scheme instance.n - the number of parts to produce (must be >1)k - the threshold of joinable parts (must be <= n)N/K Schemepublic abstract int n()
Npublic abstract int k()
K@CheckReturnValue public Map<Integer,byte[]> split(byte[] secret)
n parts, of which any k or more can be combined
to recover the original secret.secret - the secret to splitn part IDs and their values@CheckReturnValue public byte[] join(Map<Integer,byte[]> parts)
N.B.: There is no way to determine whether or not the returned value is actually the original secret. If the parts are incorrect, or are under the threshold value used to split the secret, a random value will be returned.
parts - a map of part IDs to part valuesIllegalArgumentException - if parts is empty or contains values of varying
lengthsCopyright © 2017. All rights reserved.