Class BikeKemContext
java.lang.Object
zeroecho.core.alg.bike.BikeKemContext
- All Implemented Interfaces:
Closeable, AutoCloseable, CryptoContext, KemContext
BIKE Key Encapsulation Mechanism context
ImplementsKemContext for the BIKE (Bit
Flipping Key Encapsulation) post-quantum algorithm. Encapsulation and
decapsulation flows are separated by constructor:
- Construct with a
PublicKeyto create an encapsulation context. - Construct with a
PrivateKeyto create a decapsulation context.
Usage
BikeKemContext enc = new BikeKemContext(algo, recipientPubKey);
KemResult r = enc.encapsulate();
BikeKemContext dec = new BikeKemContext(algo, myPrivateKey);
byte[] secret = dec.decapsulate(r.ciphertext());
- Since:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface KemContext
KemContext.KemResult -
Constructor Summary
ConstructorsConstructorDescriptionBikeKemContext(CryptoAlgorithm algorithm, PrivateKey k) Creates a decapsulation context bound to the holder's private key.BikeKemContext(CryptoAlgorithm algorithm, PublicKey k) Creates an encapsulation context bound to the recipient's public key. -
Method Summary
Modifier and TypeMethodDescriptionReturns the algorithm that created this context.voidclose()Releases resources associated with this context.byte[]decapsulate(byte[] ciphertext) Recovers the shared secret from a ciphertext using the holder's private key.Generates a new shared secret and ciphertext using the recipient's public key.key()Returns the underlying key bound to this context.
-
Constructor Details
-
BikeKemContext
Creates an encapsulation context bound to the recipient's public key.- Parameters:
algorithm- parent algorithm instancek- recipient's public key- Throws:
NullPointerException- if any argument is null
-
BikeKemContext
Creates a decapsulation context bound to the holder's private key.- Parameters:
algorithm- parent algorithm instancek- private key for decapsulation- Throws:
NullPointerException- if any argument is null
-
-
Method Details
-
algorithm
Returns the algorithm that created this context.- Specified by:
algorithmin interfaceCryptoContext- Returns:
- parent algorithm
-
key
Returns the underlying key bound to this context.- Specified by:
keyin interfaceCryptoContext- Returns:
- public or private key depending on mode
-
close
public void close()Releases resources associated with this context.No-op for BIKE; provided for API symmetry.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceCryptoContext
-
encapsulate
Generates a new shared secret and ciphertext using the recipient's public key.- Specified by:
encapsulatein interfaceKemContext- Returns:
- encapsulation result containing ciphertext and shared secret
- Throws:
IOException- if encapsulation failsIllegalStateException- if this context is not initialized for encapsulation
-
decapsulate
Recovers the shared secret from a ciphertext using the holder's private key.- Specified by:
decapsulatein interfaceKemContext- Parameters:
ciphertext- encapsulated key material- Returns:
- recovered shared secret bytes
- Throws:
IOException- if decapsulation failsIllegalStateException- if this context is not initialized for decapsulation
-