KemPure class
Pure Dart development KEM implementation for protocol testing.
WARNING: This is NOT a cryptographically secure KEM. It is a deterministic simulation that enables correct protocol-level testing without requiring native ML-KEM (Kyber) bindings.
Construction:
keyGen(): seed = 32 random bytes, pk = SHA-256(seed) padded to SecurityLevel.kemPublicKeySize, sk = seed || pk padded to SecurityLevel.kemSecretKeySize.encap(pk): ephemeral = 32 random bytes, ss = HMAC-SHA256(pk0:32, ephemeral), ct = ephemeral padded to SecurityLevel.kemCiphertextSize.decap(sk, ct): extract seed from sk, recompute pk = SHA-256(seed), extract ephemeral from ct, ss = HMAC-SHA256(pk0:32, ephemeral).
Encap and decap produce identical shared secrets because both use the same pk-derived HMAC key and the same ephemeral value.
- Implemented types
Constructors
- KemPure(SecurityLevel level)
-
Creates a KemPure for the given
level.const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- level → SecurityLevel
-
The security level that determines parameter sizes.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
decap(
Uint8List secretKey, Uint8List ciphertext) → Uint8List -
Decapsulates a shared secret from
ciphertextusingsecretKey.override -
encap(
Uint8List publicKey) → KemEncapsulation -
Encapsulates a shared secret under the given
publicKey.override -
keyGen(
) → KemKeyPair -
Generates a fresh KEM key pair.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited