public class MakwaDelegation
extends java.lang.Object
A MakwaDelegation
instance contains the parameters needed
to perform work delegation to an external system (the "delegation
server"). Such a set of parameters is specific to a given modulus
and work factor. Under normal conditions, it is expected that sets
of parameters are created once, then saved in encoded format
(as returned by export()
), and decoded again at application
start-up.
A new set of parameters (for a newly created modulus, or an hitherto
unused work factor) can be obtained with generate(byte[], int)
. The modulus
is provided as either an encoded modulus, or an encoded Makwa private
key. Since generating a set of parameters has a cost similar to computing
Makwa 300 times, it is recommended to use a Makwa private key, which
enables the "fast path".
Instances are immutable and thread-safe.
Modifier and Type | Field and Description |
---|---|
static int |
GENERATOR_EXPAND
Symbolic identifier for delegation parameters computed from
a generator of invertible quadratic residues.
|
static int |
GENERATOR_ONLY
Symbolic identifier for delegation parameters computed from
a generator of invertible quadratic residues.
|
static int |
RANDOM_PAIRS
Symbolic identifier for "classic" delegation parameters (300
random mask pairs).
|
Constructor and Description |
---|
MakwaDelegation(byte[] params)
Create an instance by decoding a set of delegation parameters.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
export()
Encode this set of parameters.
|
static MakwaDelegation |
generate(byte[] mparam,
int workFactor)
Generate a new set of delegation parameters.
|
static MakwaDelegation |
generate(byte[] mparam,
int workFactor,
int paramType)
Generate a new set of delegation parameters.
|
java.math.BigInteger |
getModulus()
Get the modulus used by this set of delegation parameters.
|
int |
getWorkFactor()
Get the work factor for which this set of parameters was created.
|
public static final int RANDOM_PAIRS
public static final int GENERATOR_EXPAND
public static final int GENERATOR_ONLY
public MakwaDelegation(byte[] params)
params
- the encoded parametersMakwaException
- on decoding errorpublic byte[] export()
public java.math.BigInteger getModulus()
public int getWorkFactor()
public static MakwaDelegation generate(byte[] mparam, int workFactor)
mparam
argument must contains an encoded Makwa modulus, or an
encoded Makwa private key (the latter is recommended; otherwise,
the generation can be computationally expensive). This method
produces "classic" parameters (300 random mask pairs).mparam
- the Makwa modulus or private keyworkFactor
- the work factorMakwaException
- on errorpublic static MakwaDelegation generate(byte[] mparam, int workFactor, int paramType)
Generate a new set of delegation parameters. The mparam
argument must contains an encoded Makwa modulus, or
an encoded Makwa private key (the latter is recommended;
otherwise, the generation can be computationally
expensive).
The kind of generated parameters is specified with the
paramType
argument. If the provided modulus or
private key does not include a generator of invertible
quadratic residues, then only RANDOM_PAIRS
can
be used.
RANDOM_PAIRS
: 300 random mask pairs are
produced.GENERATOR_EXPAND
: n+64 mask pairs are
precomputed, for a modulus of n bits.GENERATOR_ONLY
: only one mask pair is
precomputed, using the generator of invertible quadratic
residues.mparam
- the Makwa modulus or private keyworkFactor
- the work factorparamType
- the kind of generated parametersMakwaException
- on error