@@ -47,8 +47,10 @@ const HASH_DOMAIN_SEPARATOR: &[u8] = b"MlKemOt";
4747// Number of coefficients per polynomial (FIPS 203, Section 2: n = 256).
4848const NUM_COEFFICIENTS : usize = 256 ;
4949
50- /// rho is a 32-byte seed used to derive the public matrix A_hat (FIPS 203).
51- type Rho = [ u8 ; 32 ] ;
50+ type Seed = [ u8 ; 32 ] ;
51+
52+ /// rho is the seed used to derive the public matrix A_hat (FIPS 203).
53+ type Rho = Seed ;
5254
5355// Serialized t_hat is the encapsulation key minus the rho suffix.
5456const T_HAT_BYTES_LEN : usize = ENCAPSULATION_KEY_LEN - size_of :: < Rho > ( ) ;
@@ -98,13 +100,14 @@ fn xof(seed: &Rho, j: u8, i: u8) -> impl XofReader {
98100fn sample_ntt_poly ( xof : & mut impl XofReader ) -> NttPolynomial < MlKemField > {
99101 const Q : u16 = MlKemField :: Q ;
100102 // Read 32 triples (3 bytes each) at a time from the XOF.
101- const BUF_LEN : usize = 96 ;
103+ const BUF_LEN : usize = 32 * 3 ;
102104 let mut poly = NttPolynomial :: < MlKemField > :: default ( ) ;
103105 let mut buf = [ 0u8 ; BUF_LEN ] ;
104106 let mut pos = BUF_LEN ; // start at end to trigger first read
105107 let mut i = 0 ;
106108
107109 while i < NUM_COEFFICIENTS {
110+ // Read BUF_LEN chunks from the XOF, consume and then refill once exhausted.
108111 if pos >= BUF_LEN {
109112 xof. read ( & mut buf) ;
110113 pos = 0 ;
@@ -128,9 +131,9 @@ fn sample_ntt_poly(xof: &mut impl XofReader) -> NttPolynomial<MlKemField> {
128131}
129132
130133/// SampleNTTVector: call SampleNTT k times with FIPS 203 domain separation.
131- /// Produces a pseudorandom NttVector<k> from a 32-byte seed.
134+ /// Produces a pseudorandom NttVector<k> from a seed.
132135/// Each polynomial j uses XOF(seed || j || 0).
133- fn sample_ntt_vector ( seed : & Rho ) -> NttVector {
136+ fn sample_ntt_vector ( seed : & Seed ) -> NttVector {
134137 NttVector :: new (
135138 ( 0 ..K :: USIZE )
136139 . map ( |j| {
0 commit comments