Package net.i2p.crypto
Class YKGenerator
java.lang.Object
net.i2p.crypto.YKGenerator
Precalculate the Y and K for ElGamal encryption operations.
This class precalcs a set of values on its own thread, using those transparently
when a new instance is created.
Whenever the pool has
less than the minimum, it fills it up again to the max. There is a delay after
each precalculation so that the CPU isn't hosed during startup.
These three parameters are controlled by java environmental variables and
can be adjusted via:
-Dcrypto.yk.precalc.min=40 -Dcrypto.yk.precalc.max=100 -Dcrypto.yk.precalc.delay=60000
(delay is milliseconds)
To disable precalculation, set min to 0
- Author:
- jrandom
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionYKGenerator(I2PAppContext context) Caller must also call start() to start the background precalc thread. -
Method Summary
-
Field Details
-
PROP_YK_PRECALC_MIN
- See Also:
-
PROP_YK_PRECALC_MAX
- See Also:
-
PROP_YK_PRECALC_DELAY
- See Also:
-
DEFAULT_YK_PRECALC_MIN
public static final int DEFAULT_YK_PRECALC_MIN- See Also:
-
DEFAULT_YK_PRECALC_MAX
public static final int DEFAULT_YK_PRECALC_MAX- See Also:
-
DEFAULT_YK_PRECALC_DELAY
public static final int DEFAULT_YK_PRECALC_DELAY- See Also:
-
-
Constructor Details
-
YKGenerator
Caller must also call start() to start the background precalc thread. Unit tests will still work without calling start().
-
-
Method Details
-
start
public void start()Start the background precalc thread. Must be called for normal operation. If not called, all generation happens in the foreground. Not required for unit tests.- Since:
- 0.9.14
-
shutdown
public void shutdown()Stop the background precalc thread. Can be restarted. Not required for unit tests.- Since:
- 0.8.8
-
getNextYK
- Returns:
- rv[0] = Y; rv[1] = K
-