references/kyber-submission-nist-round2/NIST-PQ-Submission-Kyber-20190330/Reference_Implementation/crypto_kem/kyber768/cbd.c
/*************************************************
* Name:        cbd
*
* Description: Given an array of uniformly random bytes, compute
*              polynomial with coefficients distributed according to
*              a centered binomial distribution with parameter KYBER_ETA
*
* Arguments:   - poly *r:                  pointer to output polynomial
*              - const unsigned char *buf: pointer to input byte array
**************************************************/
cbd
Description: Given an array of uniformly random bytes, compute
polynomial with coefficients distributed according to
a centered binomial distribution with parameter KYBER_ETA

- poly *r:                  pointer to output polynomial
const unsigned char *buf: pointer to input byte array
cbd Description : Given an array of uniformly random bytes compute polynomial with coefficients distributed according to a centered binomial distribution with parameter KYBER_ETA - poly * r : pointer to output polynomial const unsigned char * buf : pointer to input byte array
void cbd(poly *r, const unsigned char *buf)
{
#if KYBER_ETA == 2
  uint32_t d,t;
  int16_t a,b;
  int i,j;
  for(i=0;i<KYBER_N/8;i++)
  {
    t = load32_littleendian(buf+4*i);
    d  = t & 0x55555555;
    d += (t>>1) & 0x55555555;
    for(j=0;j<8;j++)
    {
      a = (d >>  4*j)    & 0x3;
      b = (d >> (4*j+2)) & 0x3;
      r->coeffs[8*i+j] = a - b;
    }
  }
#else
#error "poly_getnoise in poly.c only supports eta=2"
#endif
}
void cbd ( poly * r , const unsigned char * buf ) { #if KYBER_ETA == 2 uint32_t d , t ; int16_t a , b ; int i , j ; for ( i = 0 ; i < KYBER_N / 8 ; i ++ ) { t = load32_littleendian ( buf + 4 * i ) ; d = t & 0x55555555 ; d += ( t >> 1 ) & 0x55555555 ; for ( j = 0 ; j < 8 ; j ++ ) { a = ( d >> 4 * j ) & 0x3 ; b = ( d >> ( 4 * j + 2 ) ) & 0x3 ; r -> coeffs [ 8 * i + j ] = a - b ; } } #else #error  "poly_getnoise in poly.c only supports eta=2" #endif }
Name:        cbd
Description: Given an array of uniformly random bytes, compute
polynomial with coefficients distributed according to
a centered binomial distribution with parameter KYBER_ETA
Name : cbd Description : Given an array of uniformly random bytes compute polynomial with coefficients distributed according to a centered binomial distribution with parameter KYBER_ETA