Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.DSI.MLC

ML-KEM ON AVX2.

  The NTT, the inverse NTT, MultiplyNTTs, the polynomial additions and a
  4-way Keccak-f[1600] (used to expand A-hat and to sample the noise four
  polynomials at a time) have AVX2 bodies in the MLKEMAvx2*.inc files. Each
  body is written once against a neutral register assignment and is included
  by three hosts:

    Delphi Win64, Delphi 11 or later - built-in assembler below. Earlier
      dcc64 releases do not know the AVX instruction set.
    FPC on System V x86-64 (Linux, macOS, BSD) - FPC assembler below.
    Delphi Linux64 - dcclinux64 has no assembler, so the bodies come from
      stMLKEMAvx2Func.o, assembled by FPC from stMLKEMAvx2Func.pas and linked
      by declaration. The object must be on the object path (-O, DCC_ObjPath)
      beside stAESNIFunc.o; see the LINUX64 notes in stAESNI.pas for why
      neither $L nor $LINK can be used. That object is a build product of
      the .inc files, so an edit to any of them must be followed by a
      rebuild of the object with the FPC steps in stMLKEMAvx2Func.pas, or
      Delphi Linux64 keeps running the old code.

  AVX2 is not part of the x86-64 baseline. Initialization checks the CPU
  (AVX, AVX2) and that the operating system saves the YMM state, and the
  portable Pascal code runs wherever that check fails. ST4_NO_AVX2 - or the
  library-wide ST4_NO_ASM - compiles the AVX2 code out, which also removes
  the object from a Linux64 link. All targets produce identical results.

Classes, interfaces and records

classeMLKEMWrongKeySize

inherits from eMLError

(no public members)

classeMLKEMCorruptPublicKey

inherits from eMLError

(no public members)

classeMLKEMCorruptPrivateKey

inherits from eMLError

(no public members)

classeMLKEMWrongCipherTextSize

inherits from eMLError

(no public members)

interfaceiMLKEMKeyExpansion

Implemented by the key classes below. tDSIML reaches a key's expanded public data through it: the matrix A-hat, the decoded t-hat and H(ek). The expansion is built the first time a key is used and then serves every later encapsulation or decapsulation with that key object. It holds public data only, in a record private to this unit, and lives as long as the key object. Applications have no need to call it.

function GetExpansion: Pointer;

classtMLKEMKey

inherits from TInterfacedObject

implements iMLKEMKey, iMLKEMKeyExpansion

destructor Destroy; override;

classtMLKEMPublicKey

inherits from tMLKEMKey

implements iMLKEMPublicKey

constructor Create(aKeySize: tMLKEMSize; const aKey: tBytes);
the constructor parses aKey and performs standard coherence testing aKeySize might be mlkemAuto

classtMLKEMPrivateKey

inherits from tMLKEMKey

implements iMLKEMPrivateKey

constructor Create(aKeySize: tMLKEMSize; const aKey : tBytes; const aSeed : iSecretKey = nil);
the constructor parses aKey and performs standard coherence testing aKeySize might be mlkemAuto
constructor CreateFromSeed(aKeySize: tMLKEMSize; const aSeed : iSecretKey); destructor Destroy; override;
wipes secret key material (audit: zeroization)

interfaceiDSIMLKEMInternal

The iDSIMLInternal interface is used internally and for testing of internal methods. Use the iDSIML interface for application development.

procedure KEMKeyGenInternal(aKeySize : tMLKEMSize; const aD, aZ: tBytes; var aPublicKey : iMLKEMPublicKey; var aPrivateKey: iMLKEMPrivateKey; aSaveSeed : Boolean = False);
Test vectors are run against the following methods:
procedure KEMEncapsInternal(const aPublicKey : iMLKEMPublicKey; const aM : tByteArray32d1; var aK : tBytes; var aC : tBytes); procedure KEMDecapsInternal(const aPrivateKey: iMLKEMPrivateKey; const aC: tBytes; var aK: tBytes);

classeMLDSAWrongKeySize

inherits from eMLError

(no public members)

classeMLDSACorruptPublicKey

inherits from eMLError

(no public members)

classeMLDSAIllegalParameter

inherits from eMLError

(no public members)

classeMLDSACorruptPrivateKey

inherits from eMLError

(no public members)

classtMLDSAKey

inherits from TInterfacedObject

implements iMLDSAKey, iSignKey

(no public members)

classtMLDSAPublicKey

inherits from tMLDSAKey

implements iMLDSAPublicKey, iSignPublicKey

constructor Create(aKeySize: tMLDSASize; const aEncodedKey: tBytes);

classtMLDSAPrivateKey

inherits from tMLDSAKey

implements iMLDSAPrivateKey, iSignPrivateKey

constructor Create(aKeySize : tMLDSASize; const aEncodedKey: tBytes; const aPublicKey : tBytes; const aSeed : iSecretKey = nil); constructor CreateFromSeed(aKeySize: tMLDSASize; const aSeed : iSecretKey); function SignBuf(const aMsg : tBytes; aMOffset: Integer; aMLen : Integer; var aSign : tBytes; aSOffset: Integer; aSLen : Integer) : Integer; overload; function SignDig(const aDigest : tBytes; aDOffset: Integer; aDLen : Integer; var aSign : tBytes; aSOffset: Integer; aSLen : Integer; aHashAlg: tHashAlgorithm = haDefault) : Integer; overload; function SignBuf(const aMsg : tBytes; aMOffset: Integer; aMLen : Integer; var aSign : tBytes) : Integer; overload; function SignDig(const aDigest : tBytes; aDOffset: Integer; aDLen : Integer; var aSign : tBytes; aHashAlg: tHashAlgorithm = haDefault) : Integer; overload; function Validate(const aPublicKey: IUnknown): Boolean; overload; function CheckConsistency: Boolean; procedure SetAttributes(const aPublicKey: IUnknown); function GetUseVerboseFormat: Boolean;
Returns the GetUseVerboseFormat value, obtained via tDSA.
destructor Destroy; override;
wipes secret key material (audit: zeroization)

interfaceiDSIMLDSAInternal

procedure SetPRNG(const Value: iRawRandom); function GetPRNG: iRawRandom; procedure DSAKeyGenInternal(aKeySize : tMLDSASize; const aXi : tBytes; var aPublicKey : iMLDSAPublicKey; var aPrivateKey: iMLDSAPrivateKey; aSaveSeed : Boolean = False); procedure DSASignInternal(const aPrivateKey: iMLDSAPrivateKey; const aMPrim : tBytes; const aRnd : tBytes; var aSignature : tBytes); function DSAVerifyInternal(const aPublicKey: iMLDSAPublicKey; const aMPrim : tBytes; const aSignature: tBytes) : Boolean; procedure DSAKeyGen(aKeySize : tMLDSASize; var aPublicKey : iMLDSAPublicKey; var aPrivateKey: iMLDSAPrivateKey; aSaveSeed : Boolean = False); function DSASign(const aPrivateKey: iMLDSAPrivateKey; const aMsg : tBytes; const aCtx : tBytes) : tBytes; function DSAVerify(const aPublicKey: iMLDSAPublicKey; const aMsg : tBytes; const aCtx : tBytes; const aSignature: tBytes) : Boolean; function HashDSASign(const aPrivateKey: iMLDSAPrivateKey; const aMsg : tBytes; const aCtx : tBytes; const aHashAlg : tHashAlgorithm) : tBytes; function HashDSAVerify(const aPublicKey: iMLDSAPublicKey; const aMsg : tBytes; const aCtx : tBytes; const aHashAlg : tHashAlgorithm; const aSignature: tBytes) : Boolean; property PRNG: iRawRandom read GetPRNG write SetPRNG;

classtDSIML

inherits from TInterfacedObject

implements iDSIMLKEMInternal, iDSIMLDSAInternal, iDSIML

function NewKEMPrivateKey(aKeySize: tMLKEMSize; const aKey : tBytes; const aSeed : iSecretKey = nil) : iMLKEMPrivateKey; function NewKEMPrivateKeyFromSeed(aKeySize: tMLKEMSize; const aSeed : iSecretKey) : iMLKEMPrivateKey; function NewKEMPublicKey(aKeySize: tMLKEMSize; const aKey : tBytes) : iMLKEMPublicKey;
Delegates to tMLKEMPublicKey.Create, forwarding aKeySize and aKey, and returns its result.
function NewDSAPrivateKey(aKeySize: tMLDSASize; const aKey : tBytes; const aPublKey: tBytes; const aSeed : iSecretKey = nil) : iMLDSAPrivateKey; function NewDSAPrivateKeyFromSeed(aKeySize: tMLDSASize; const aSeed : iSecretKey) : iMLDSAPrivateKey; function NewDSAPublicKey(aKeySize: tMLDSASize; const aKey : tBytes) : iMLDSAPublicKey;
Delegates to tMLDSAPublicKey.Create, forwarding aKeySize and aKey, and returns its result.
procedure KEMKeyGen(aKeySize : tMLKEMSize; var aPublicKey : iMLKEMPublicKey; var aPrivateKey: iMLKEMPrivateKey; aSaveSeed : Boolean = False); procedure KEMEncaps(const aPublicKey: iMLKEMPublicKey; var aK : tBytes; var aC : tBytes); procedure KEMDecaps(const aPrivateKey: iMLKEMPrivateKey; const aC: tBytes; var aK: tBytes); procedure DSAKeyGen(aKeySize : tMLDSASize; var aPublicKey : iMLDSAPublicKey; var aPrivateKey: iMLDSAPrivateKey; aSaveSeed : Boolean = False); function DSASign(const aPrivateKey: iMLDSAPrivateKey; const aMsg : tBytes; const aCtx : tBytes) : tBytes; function DSAVerify(const aPublicKey: iMLDSAPublicKey; const aMsg : tBytes; const aCtx : tBytes; const aSignature: tBytes) : Boolean; function HashDSASign(const aPrivateKey: iMLDSAPrivateKey; const aMsg : tBytes; const aCtx : tBytes; const aHashAlg : tHashAlgorithm) : tBytes; function HashDSASignDigest(const aPrivateKey: iMLDSAPrivateKey; const aDigest : tBytes; const aCtx : tBytes; const aHashAlg : tHashAlgorithm) : tBytes; function HashDSAVerify(const aPublicKey: iMLDSAPublicKey; const aMsg : tBytes; const aCtx : tBytes; const aHashAlg : tHashAlgorithm; const aSignature: tBytes) : Boolean; function HashDSAVerifyDigest(const aPublicKey: iMLDSAPublicKey; const aDigest : tBytes; const aCtx : tBytes; const aHashAlg : tHashAlgorithm; const aSignature: tBytes) : Boolean; property PRNG: iRawRandom read GetPRNG write SetPRNG;

classtKEM

This class is for internal consumption only. It contains internal functions and constants used by the ML-KEM implementation.

class function Compress(d, x: Integer): Integer; static; inline;
Delegates to CompressCT, forwarding d and x, and returns its result.
class function Decompress(d, x: Integer): Integer; static; inline; class function BarrettReduce(a: UInt32): UInt32; static; inline;
Constant-time drafts for the KyberSlash-class division sites (see (1) in the security audit). BarrettReduce replaces `... mod Q`; DivQ replaces the `div Q` inside Compress; CompressCT is a division-free drop-in for Compress. The `d` (bit-width) and shift amounts are public parameters, so branching on them is safe; only the coefficient value must stay off the timing path.
class function DivQ(n: UInt32): UInt32; static; inline; class function CompressCT(d, x: Integer): Integer; static; inline; class procedure BaseCaseMultiply(a0, a1, b0, b1, gamma: Integer; var c0, c1: Integer); static; inline; class function NTT(const aF: tIntegerArray): tIntegerArray; static; class function NTTInv(const aF: tIntegerArray): tIntegerArray; static; class procedure PolyAddMod(var aR: tIntegerArray; const aA: tIntegerArray); static;
Coefficient-wise aR := aR + aA and aR := aA - aR, mod q. Both operands must be canonical (in [0,q)); the result is canonical.
class procedure PolySubMod(var aR: tIntegerArray; const aA: tIntegerArray); static; class function KeySizeToK(aKeySize: tMLKEMSize): Integer; static; class function GenerateSamplePolyCBD2(aEta: Integer; const aSigma: tBytes; var aN: Integer): tIntegerArray; static; class function GenerateNTT(const aR: tSample; aK: Integer): tSample; static; class function SampleNTT(const aB: iRawRandomEx): tIntegerArray; static; class function SamplePolyCBD2(const aB: iRawRandomEx): tIntegerArray; static; class function SamplePolyCBD3(const aB: iRawRandomEx): tIntegerArray; static; class procedure ByteEncode1(const aF: tIntegerArray; var aB: tByteArray32d1); static; class procedure ByteEncode4(const aF: tIntegerArray; var aB: tByteArray32d4); static; class procedure ByteEncode5(const aF: tIntegerArray; var aB: tByteArray32d5); static; class procedure ByteEncode10(const aF: tIntegerArray; var aB: tByteArray32d10); static; class procedure ByteEncode11(const aF: tIntegerArray; var aB: tByteArray32d11); static; class procedure ByteEncode12(const aF: tIntegerArray; var aB: tByteArray32d12); static; class procedure ByteDecode1(var aF: tIntegerArray; const aB: tByteArray32d1); static; class procedure ByteDecode4(var aF: tIntegerArray; const aB: tByteArray32d4); static; class procedure ByteDecode5(var aF: tIntegerArray; const aB: tByteArray32d5); static; class procedure ByteDecode10(var aF: tIntegerArray; const aB: tByteArray32d10); static; class procedure ByteDecode11(var aF: tIntegerArray; const aB: tByteArray32d11); static; class procedure ByteDecode12(var aF: tIntegerArray; const aB: tByteArray32d12); static; class function MultiplyNTTs(const aF,aG: tIntegerArray): tIntegerArray; static; class function GenerateMatrixAHat(const aRho: tBytes; aK: Integer): tAHat; static; class function GenerateSamplePolyCBD(const aSigma: tBytes; aK, aEta: Integer; var aN: Integer): tSample; static; class procedure SetUseVerboseFormat(Value: Boolean); class function GetUseVerboseFormat: Boolean;
Returns the value of gUseVerboseFormat.
class function Avx2Available: Boolean; static;
True when the AVX2 code is compiled in and the CPU and operating system support it (see the note at the top of the unit).
class function GetUseAvx2: Boolean; static;
Whether the AVX2 code is in use. It is when Avx2Available is True, unless SetUseAvx2(False) selects the portable code, e.g. to test both against each other. SetUseAvx2(True) cannot enable what Avx2Available rejects. Not for use while other threads are running ML-KEM operations.
class procedure SetUseAvx2(Value: Boolean); static;

classtDSA

This class is for internal consumption only. It contains internal functions and constants used by the ML-DSA implementation.

class procedure CoeffFromThreeBytes(b0, b1, b2: UInt8; var aResult: DsaInt; var aIndex: Integer); static; inline; class procedure CoeffFromHalfByteEta2(b: UInt8; var aResult: DsaInt; var aIndex: Integer); static; inline; class procedure CoeffFromHalfByteEta4(b: UInt8; var aResult: DsaInt; var aIndex: Integer); static; inline; class procedure SimpleBitPack(const w: tPolynomial; bitlen: Integer; var aResult); static; inline; class procedure BitPack(const w: tPolynomial; bitlen: Integer; b: UInt64; var aResult); static; inline; class procedure SimpleBitUnpack(v: pByte; bitlen: Integer; var w: tPolynomial); static; inline; class procedure BitUnpack(v: pByte; bitlen: Integer; b: UInt64; var w: tPolynomial); static; inline; class procedure HintBitPackOmega80k4(const h: tBinaryPolynomialVectork4; var y); static; class procedure HintBitPackOmega55k6(const h: tBinaryPolynomialVectork6; var y); static; class procedure HintBitPackOmega75k8(const h: tBinaryPolynomialVectork8; var y); static; class function HintBitUnpackOmega80k4(const y; var h: tBinaryPolynomialVectork4): Boolean; static; class function HintBitUnpackOmega55k6(const y; var h: tBinaryPolynomialVectork6): Boolean; static; class function HintBitUnpackOmega75k8(const y; var h: tBinaryPolynomialVectork8): Boolean; static; class function pkEncodek4(const rho: tBytes; t1: tPolynomialVectork4): tBytes; static; class function pkEncodek6(const rho: tBytes; t1: tPolynomialVectork6): tBytes; static; class function pkEncodek8(const rho: tBytes; t1: tPolynomialVectork8): tBytes; static; class function pkDecodek4(const pk: tBytes; var rho: tBytes; var t1: tPolynomialVectork4): Boolean; static; class function pkDecodek6(const pk: tBytes; var rho: tBytes; var t1: tPolynomialVectork6): Boolean; static; class function pkDecodek8(const pk: tBytes; var rho: tBytes; var t1: tPolynomialVectork8): Boolean; static; class function skEncodek4l4eta2(const rho, kseed, tr: tBytes; const s1: tPolynomialVectorl4; const s2, t0: tPolynomialVectork4): tBytes; static; class function skEncodek6l5eta4(const rho, kseed, tr: tBytes; const s1: tPolynomialVectorl5; const s2, t0: tPolynomialVectork6): tBytes; static; class function skEncodek8l7eta2(const rho, kseed, tr: tBytes; const s1: tPolynomialVectorl7; const s2, t0: tPolynomialVectork8): tBytes; static; class procedure skDecodek4l4eta2(const sk: tBytes; var rho, kseed, tr: tBytes; var s1: tPolynomialVectorl4; var s2, t0: tPolynomialVectork4); static; class procedure skDecodek6l5eta4(const sk: tBytes; var rho, kseed, tr: tBytes; var s1: tPolynomialVectorl5; var s2, t0: tPolynomialVectork6); static; class procedure skDecodek8l7eta2(const sk: tBytes; var rho, kseed, tr: tBytes; var s1: tPolynomialVectorl7; var s2, t0: tPolynomialVectork8); static; class function sigEncode128(const ctilde: tBytes; const z: tPolynomialVectorl4; const h: tBinaryPolynomialVectork4): tBytes; static; class function sigEncode192(const ctilde: tBytes; const z: tPolynomialVectorl5; const h: tBinaryPolynomialVectork6): tBytes; static; class function sigEncode256(const ctilde: tBytes; const z: tPolynomialVectorl7; const h: tBinaryPolynomialVectork8): tBytes; static; class function sigDecode128(const sigma: tBytes; var ctilde: tBytes; var z: tPolynomialVectorl4; var h: tBinaryPolynomialVectork4): Boolean; static; class function sigDecode192(const sigma: tBytes; var ctilde: tBytes; var z: tPolynomialVectorl5; var h: tBinaryPolynomialVectork6): Boolean; static; class function sigDecode256(const sigma: tBytes; var ctilde: tBytes; var z: tPolynomialVectorl7; var h: tBinaryPolynomialVectork8): Boolean; static; class function w1Encodek4(const w1: tPolynomialVectork4): tBytes; static; class function w1Encodek6(const w1: tPolynomialVectork6): tBytes; static; class function w1Encodek8(const w1: tPolynomialVectork8): tBytes; static; class procedure SampleInBalltau39(const rho: tBytes; var c: tPolynomial); static; class procedure SampleInBalltau49(const rho: tBytes; var c: tPolynomial); static; class procedure SampleInBalltau60(const rho: tBytes; var c: tPolynomial); static; class procedure RejNTTPoly(const rho: tBytes; var ahat: tPolynomial); static; class procedure RejBoundedPolyEta2(const rho: tBytes; var a: tPolynomial); static; class procedure RejBoundedPolyEta4(const rho: tBytes; var a: tPolynomial); static; class procedure ExpandAk4l4(const rho: tBytes; var aHat: tPolynomialMatrixk4l4); static; class procedure ExpandAk6l5(const rho: tBytes; var aHat: tPolynomialMatrixk6l5); static; class procedure ExpandAk8l7(const rho: tBytes; var aHat: tPolynomialMatrixk8l7); static; class procedure ExpandSk4l4(const rho: tBytes; var s1: tPolynomialVectorl4; var s2: tPolynomialVectork4); static; class procedure ExpandSk6l5(const rho: tBytes; var s1: tPolynomialVectorl5; var s2: tPolynomialVectork6); static; class procedure ExpandSk8l7(const rho: tBytes; var s1: tPolynomialVectorl7; var s2: tPolynomialVectork8); static; class function H(const aSeed: tBytes; aLength: Integer): tBytes; static; class procedure ExpandMaskl4(const rho: tBytes; micro: Cardinal; var y: tPolynomialVectorl4); static; class procedure ExpandMaskl5(const rho: tBytes; micro: Cardinal; var y: tPolynomialVectorl5); static; class procedure ExpandMaskl7(const rho: tBytes; micro: Cardinal; var y: tPolynomialVectorl7); static; class procedure Power2Roundk4(const r: tPolynomialVectork4; var r1, r0: tPolynomialVectork4); static; class procedure Power2Roundk6(const r: tPolynomialVectork6; var r1, r0: tPolynomialVectork6); static; class procedure Power2Roundk8(const r: tPolynomialVectork8; var r1, r0: tPolynomialVectork8); static; class procedure Decomposek4(const r: tPolynomialVectork4; var r1, r0: tPolynomialVectork4); static; class procedure Decomposek6(const r: tPolynomialVectork6; var r1, r0: tPolynomialVectork6); static; class procedure Decomposek8(const r: tPolynomialVectork8; var r1, r0: tPolynomialVectork8); static; class procedure HighBitsk4(const r: tPolynomialVectork4; var r1: tPolynomialVectork4); static; class procedure HighBitsk6(const r: tPolynomialVectork6; var r1: tPolynomialVectork6); static; class procedure HighBitsk8(const r: tPolynomialVectork8; var r1: tPolynomialVectork8); static; class procedure LowBitsk4(const r: tPolynomialVectork4; var r0: tPolynomialVectork4); static; class procedure LowBitsk6(const r: tPolynomialVectork6; var r0: tPolynomialVectork6); static; class procedure LowBitsk8(const r: tPolynomialVectork8; var r0: tPolynomialVectork8); static; class procedure MakeHintk4(const z, r: tPolynomialVectork4; var h: tBinaryPolynomialVectork4); static; class procedure MakeHintk6(const z, r: tPolynomialVectork6; var h: tBinaryPolynomialVectork6); static; class procedure MakeHintk8(const z, r: tPolynomialVectork8; var h: tBinaryPolynomialVectork8); static; class procedure UseHintk4(const h: tBinaryPolynomialVectork4; const r: tPolynomialVectork4; var r1: tPolynomialVectork4); static; class procedure UseHintk6(const h: tBinaryPolynomialVectork6; const r: tPolynomialVectork6; var r1: tPolynomialVectork6); static; class procedure UseHintk8(const h: tBinaryPolynomialVectork8; const r: tPolynomialVectork8; var r1: tPolynomialVectork8); static; class procedure NTT(const w: tPolynomial; var what: tPolynomial); static; class procedure NTTInv(const what: tPolynomial; var w: tPolynomial); static; class procedure AddNTT(const ahat, bhat: tPolynomial; var chat: tPolynomial); static; class procedure SubNTT(const ahat, bhat: tPolynomial; var chat: tPolynomial); static; class procedure MultiplyNTT(const ahat, bhat: tPolynomial; var chat: tPolynomial); static; class procedure AddVectorNTTl4(const vhat, what: tPolynomialVectorl4; var uhat: tPolynomialVectorl4); static; class procedure AddVectorNTTl5(const vhat, what: tPolynomialVectorl5; var uhat: tPolynomialVectorl5); static; class procedure AddVectorNTTl7(const vhat, what: tPolynomialVectorl7; var uhat: tPolynomialVectorl7); static; class procedure SubVectorNTTk4(const vhat, what: tPolynomialVectork4; var uhat: tPolynomialVectork4); static; class procedure SubVectorNTTk6(const vhat, what: tPolynomialVectork6; var uhat: tPolynomialVectork6); static; class procedure SubVectorNTTk8(const vhat, what: tPolynomialVectork8; var uhat: tPolynomialVectork8); static; class procedure ScalarVectorNTTl4(const chat: tPolynomial; const vhat: tPolynomialVectorl4; var what: tPolynomialVectorl4); static; class procedure ScalarVectorNTTl5(const chat: tPolynomial; const vhat: tPolynomialVectorl5; var what: tPolynomialVectorl5); static; class procedure ScalarVectorNTTl7(const chat: tPolynomial; const vhat: tPolynomialVectorl7; var what: tPolynomialVectorl7); static; class procedure ScalarVectorNTTk4(const chat: tPolynomial; const vhat: tPolynomialVectork4; var what: tPolynomialVectork4); static; class procedure ScalarVectorNTTk6(const chat: tPolynomial; const vhat: tPolynomialVectork6; var what: tPolynomialVectork6); static; class procedure ScalarVectorNTTk8(const chat: tPolynomial; const vhat: tPolynomialVectork8; var what: tPolynomialVectork8); static; class procedure MatrixVectorNTTk4l4(const Mhat: tPolynomialMatrixk4l4; const vhat: tPolynomialVectorl4; var what: tPolynomialVectork4); static; class procedure MatrixVectorNTTk6l5(const Mhat: tPolynomialMatrixk6l5; const vhat: tPolynomialVectorl5; var what: tPolynomialVectork6); static; class procedure MatrixVectorNTTk8l7(const Mhat: tPolynomialMatrixk8l7; const vhat: tPolynomialVectorl7; var what: tPolynomialVectork8); static; class function InfinityNorm(const w: tPolynomial): Int64; class function MontReduce(const a: Int64): UInt32; static; class function BarrettReduce(const a: Int64): Int64; static; inline;
Constant-time reduction a mod Q in [0,Q), Q=8380417 (audit item 1). Replaces the secret-dependent `mod q` idiv in the ML-DSA NTT / decode path. Two-step Barrett (fold the high 32 bits via 2^32 mod Q, then one multiply-shift) with a Q-multiple offset that absorbs the negative raw coefficients the NTT sees. Valid for a in [-Q*2^21, ~2^46]; returns the canonical [0,Q) representative.
class function modu(const v, m: Int64): Int64; static; class function moda(const v, m, a: Int64): Int64; static; class procedure SetUseVerboseFormat(Value: Boolean); class function GetUseVerboseFormat: Boolean;
Returns the value of gUseVerboseFormat.

Types (enumerations, sets, aliases)

typeeMLError

  eMLError = Exception;

typeDsaInt

  DsaInt = Integer;

arraytIntegerArray

  tIntegerArray = array [0..255] of DsaInt;

arraytByteArray32d1

  tByteArray32d1 = array [0..31] of UInt8;

arraytByteArray32d4

  tByteArray32d4 = array [0..32*4-1] of UInt8;

arraytByteArray32d5

  tByteArray32d5 = array [0..32*5-1] of UInt8;

arraytByteArray32d10

  tByteArray32d10 = array [0..32*10-1] of UInt8;

arraytByteArray32d11

  tByteArray32d11 = array [0..32*11-1] of UInt8;

arraytByteArray32d12

  tByteArray32d12 = array [0..32*12-1] of UInt8;

arraytAHat

  tAHat = array [0..3,0..3] of tIntegerArray;

arraytSample

  tSample = array [0..3] of tIntegerArray;

arraytPolynomial

  tPolynomial = array [0..255] of Integer;

arraytBinaryPolynomialVectork4

  tBinaryPolynomialVectork4 = array [0..4-1,0..255] of UInt8;

arraytBinaryPolynomialVectork6

  tBinaryPolynomialVectork6 = array [0..6-1,0..255] of UInt8;

arraytBinaryPolynomialVectork8

  tBinaryPolynomialVectork8 = array [0..8-1,0..255] of UInt8;

arraytPolynomialVectork4

  tPolynomialVectork4 = array [0..4-1] of tPolynomial;

arraytPolynomialVectork6

  tPolynomialVectork6 = array [0..6-1] of tPolynomial;

arraytPolynomialVectork8

  tPolynomialVectork8 = array [0..8-1] of tPolynomial;

arraytPolynomialVectorl4

  tPolynomialVectorl4 = array [0..4-1] of tPolynomial;

arraytPolynomialVectorl5

  tPolynomialVectorl5 = array [0..5-1] of tPolynomial;

arraytPolynomialVectorl7

  tPolynomialVectorl7 = array [0..7-1] of tPolynomial;

arraytPolynomialMatrixk4l4

  tPolynomialMatrixk4l4 = array[0..4-1,0..4-1] of tPolynomial;

arraytPolynomialMatrixk6l5

  tPolynomialMatrixk6l5 = array[0..6-1,0..5-1] of tPolynomial;

arraytPolynomialMatrixk8l7

  tPolynomialMatrixk8l7 = array[0..8-1,0..7-1] of tPolynomial;