org.logi.crypto.secretshare
Class XorSecretShare

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

public class XorSecretShare
extends SecretShare

This class stores a share of a secret.

The xor method can only be used for n/n sharing, where n shares are created and all are needed to retrieve the secret. The shares s[0..n-2] are simply random numbers, while s[n] is the exclusive or of all the other shares along with the secret.

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
XorSecretShare(int n, byte[] share)
          Create an object for an n/n xor-share.
XorSecretShare(int n, byte[] share, boolean copy)
          Create an object for an n/n xor-share.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 byte[] getShare()
          Get the actual bytes of the share.
 int hashCode()
           
static XorSecretShare 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 XorSecretShare[] share(int n, byte[] secret)
          Split the secret in n parts.
 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

XorSecretShare

public XorSecretShare(int n,
                      byte[] share)
Create an object for an n/n xor-share.

XorSecretShare

public XorSecretShare(int n,
                      byte[] share,
                      boolean copy)
Create an object for an n/n xor-share. If copy is true, then the content of the array is copied to a new array. Otherwise only the reference is copied and tme content should not be changed by the caller.
Method Detail

share

public static XorSecretShare[] share(int n,
                                     byte[] secret)
Split the secret in n parts. All are needed to retrieve it.

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.

getShare

public byte[] getShare()
Get the actual bytes of the share.

parseCDS

public static XorSecretShare 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