abla/crypto/mlkem
Generated from source.
Import with import "abla/crypto/mlkem".
Source: abla/crypto/mlkem/entry.ab
Re-exports abla/crypto/result.
MLKEM768_ENCAPSULATION_KEY_SIZE (val)
val MLKEM768_ENCAPSULATION_KEY_SIZE
Gives the size in bytes of an ML-KEM-768 encapsulation key.
MLKEM768_DECAPSULATION_KEY_SIZE (val)
val MLKEM768_DECAPSULATION_KEY_SIZE
Gives the size in bytes of an ML-KEM-768 decapsulation key.
MLKEM768_CIPHERTEXT_SIZE (val)
val MLKEM768_CIPHERTEXT_SIZE
Gives the size in bytes of an ML-KEM-768 ciphertext.
MLKEM_SHARED_SECRET_SIZE (val)
val MLKEM_SHARED_SECRET_SIZE
Gives the size in bytes of the derived ML-KEM shared secret.
MLKEM_COMPRESS_RECIPROCAL (val)
val MLKEM_COMPRESS_RECIPROCAL
ceil(2^40 / 3329): Compress multiplies by it and shifts right by 40; exact for every x 2^d + 1664 below 2^28 (the test checks the range used).
mlkemZetas (fun)
@inline trusted fun mlkemZetas(): int
The zeta^BitRev7(i) (the NTT's) and zeta^(2 BitRev7(i) + 1) (the base case's) for i = 0..127, with zeta = 17, each times R = 2^16 mod 3329, as 16-bit little endian.
mlkemGammas (fun)
@inline trusted fun mlkemGammas(): int
Returns the address of the static coefficients used in the base-case NTT products.
mlkemConstant (fun)
@inline fun mlkemConstant(value: int): secretU32
Returns the input's low 32 bits as a secret word.
mlkemSubQ (fun)
@inline fun mlkemSubQ(x: secretU32): secretU32
x - q where that does not go below zero: for x below 2q, the value mod q.
mlkemAdd (fun)
@inline fun mlkemAdd(a: secretU32, b: secretU32): secretU32
Returns the canonical sum modulo 3329 of two reduced coefficients.
mlkemSub (fun)
@inline fun mlkemSub(a: secretU32, b: secretU32): secretU32
Returns the canonical difference modulo 3329 of two reduced coefficients.
mlkemReduce (fun)
@inline fun mlkemReduce(x: secretU32): secretU32
Montgomery's reduction of x (below q * 2^16): x / 2^16 mod q, canonical.
mlkemMultiply (fun)
@inline fun mlkemMultiply(a: secretU32, b: secretU32): secretU32
a * b / 2^16 mod q, for a and b in 0..q-1.
mlkem768KeyGenFromSeeds (fun)
fun mlkem768KeyGenFromSeeds(d: string, z: string): CryptoResult
ML-KEM-768.KeyGen_internal: the decapsulation key from the 32-byte seeds d and z.
mlkem768GenerateKey (fun)
fun mlkem768GenerateKey(): CryptoResult
A new key pair: the decapsulation key (2400 bytes, whose bytes 1152 to 2336 are the encapsulation key).
mlkem768EncapsulationKey (fun)
fun mlkem768EncapsulationKey(decapsulationKey: string): string
The encapsulation key inside a decapsulation key.
mlkem768CheckEncapsulationKey (fun)
trusted fun mlkem768CheckEncapsulationKey(key: string): bool
FIPS 203 section 7.2, the check of an encapsulation key: 1184 bytes, and every 12-bit value of the vector below q (the decoding and re-encoding of the vector gives the bytes back).
mlkem768CheckDecapsulationKey (fun)
fun mlkem768CheckDecapsulationKey(key: string): bool
FIPS 203 section 7.3, the check of a decapsulation key: 2400 bytes, and the hash in it is the hash of the encapsulation key in it.
MlkemEncapsulation (class)
class MlkemEncapsulation(val ok: bool, val ciphertext: string, val sharedSecret: string, val error: string)
(ciphertext, shared secret) of an encapsulation: ok false for a key that fails the check or a wrong length.
mlkem768EncapsulateWithMessage (fun)
fun mlkem768EncapsulateWithMessage(encapsulationKey: string, m: string): MlkemEncapsulation
ML-KEM-768.Encaps_internal (algorithm 17) with the message m (32 random bytes).
mlkem768Encapsulate (fun)
fun mlkem768Encapsulate(encapsulationKey: string): MlkemEncapsulation
ML-KEM-768.Encaps: a fresh message from the random source (see cryptoSetRandom).
mlkem768Decapsulate (fun)
fun mlkem768Decapsulate(decapsulationKey: string, ciphertext: string): CryptoResult
ML-KEM-768.Decaps (algorithm 18): the shared secret. A ciphertext that was not made for this key gives a pseudorandom secret (implicit rejection), not an error; only a wrong length or a key whose hash does not match is refused.
Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.