The function cbd2 takes a pointer to a polynomial r and a pointer to a byte array buf of length 2*KYBER_N/4. It is used to generate a centered-binomial distribution from the input bytes.

The function iterates over the byte array, taking 8 bytes at a time and processing them into 8 coefficients of the polynomial. For each 8 bytes, it performs the following steps:

  1. It loads the bytes as a little-endian 32-bit integer t.
  2. It extracts the even-indexed bits of t and adds them to the odd-indexed bits of t>>1, obtaining a 32-bit integer d with 16 bits of weight 1.
  3. It extracts two bits at a time from d, starting from the least significant bit, and maps each pair of bits to a value in the set {-1, 0, 1} by subtracting the value of the second bit from the value of the first bit. The resulting values are assigned to the coefficients of the polynomial.

After processing all the bytes in the input array, the polynomial r should represent a centered-binomial distribution over the set {-1, 0, 1} for use in the Kyber key exchange protocol

static void cbd2poly r const uint8_t buf2KYBER_N4 unsigned int ij; uint32_t td; int16_t ab; fori=0;iKYBER_N8;i++ t = load32_littleendianbuf+4i; d = t & 0x55555555; d += t1 & 0x55555555

原文地址: https://www.cveoy.top/t/topic/g84Q 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录