Class 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.

Logi Ragnarsson (

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


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


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


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


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


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


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.

InvalidCDSException - if the CDS is malformed.
See Also:


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


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


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

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