org.logi.crypto.secretshare
Class PolySecretShare

java.lang.Object
  |
  +--org.logi.crypto.Crypto
        |
        +--org.logi.crypto.secretshare.SecretShare
              |
              +--org.logi.crypto.secretshare.PolySecretShare

public class PolySecretShare
extends SecretShare

This class stores a share of a secret.

The polynomial method can be used for m/n sharing, where n shares are created and m are needed to retrieve the secret. The shares s[0..n-1] are points on a polynomial curve which crosses the x-axis

Author:
Logi Ragnarsson (logir@logi.org)

Fields inherited from class org.logi.crypto.Crypto
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO
 
Constructor Summary
PolySecretShare(int m, int n, java.math.BigInteger x, java.math.BigInteger y, java.math.BigInteger p)
          Create an object for an m/n polynomial share.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 int hashCode()
           
static PolySecretShare parseCDS(java.lang.String[] param)
          Used by Crypto.fromString when parsing a CDS.
static byte[] retrieve(SecretShare[] shares)
          retrieve the secret from an array of shares.
static PolySecretShare[] share(int m, int n, java.math.BigInteger p, java.math.BigInteger[] x, byte[] secret)
          Split the secret in n parts such that m are needed to retrieve it.
static PolySecretShare[] share(int m, int n, byte[] secret, int b)
          Split the secret in n parts such that m are needed to retrieve it.
 java.lang.String toString()
          Return a CDS for this object.
 
Methods inherited from class org.logi.crypto.secretshare.SecretShare
getM, getN
 
Methods inherited from class org.logi.crypto.Crypto
binString, binString, ensureArrayLength, ensureArrayLength, equal, equalRelaxed, equalSub, fromHexNibble, fromHexString, fromString, fromString, hexString, hexString, hexString, hexString, hexString, initRandom, initRandom, makeClass, makeInt, makeLong, makeSessionKey, pastSpace, pickBits, pickBits, prettyPrint, prettyPrint, readBlock, readInt, trimArrayLength, trimArrayLength, trimLeadingZeroes, writeBytes, writeBytes, writeInt
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PolySecretShare

public PolySecretShare(int m,
                       int n,
                       java.math.BigInteger x,
                       java.math.BigInteger y,
                       java.math.BigInteger p)
Create an object for an m/n polynomial share.
Method Detail

share

public static PolySecretShare[] share(int m,
                                      int n,
                                      byte[] secret,
                                      int b)
                               throws SecretSharingException
Split the secret in n parts such that m are needed to retrieve it. A random prime number will be used for the modulus, at least one bit longer than the secret, but no less than b bits in length. You should make b>=512
Throws:
SecretSharingException - if the secret can't be m/n-shared.

share

public static PolySecretShare[] share(int m,
                                      int n,
                                      java.math.BigInteger p,
                                      java.math.BigInteger[] x,
                                      byte[] secret)
                               throws SecretSharingException
Split the secret in n parts such that m are needed to retrieve it. Arithmetic will be performed modulus p, which must be longer than the secret.
Throws:
SecretSharingException - if the secret can't be m/n-shared.

retrieve

public static byte[] retrieve(SecretShare[] shares)
                       throws SecretSharingException
retrieve the secret from an array of shares.
Throws:
SecretSharingException - if the secret can't be retrieved.

parseCDS

public static PolySecretShare parseCDS(java.lang.String[] param)
                                throws InvalidCDSException
Used by Crypto.fromString when parsing a CDS.

A valid CDS can be created by calling the toString() method.

Throws:
InvalidCDSException - if the CDS is malformed.
See Also:
Crypto.fromString(String)

toString

public java.lang.String toString()
Return a CDS for this object.
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


Copyright (c) 1997-2001 Logi Ragnarsson - Distributed under the GPL