references/kyber-submission-nist-round2/NIST-PQ-Submission-Kyber-20190330/Reference_Implementation/crypto_kem/kyber768/poly.c
/*************************************************
* Name:        poly_tomsg
*
* Description: Convert polynomial to 32-byte message
*
* Arguments:   - unsigned char *msg: pointer to output message
*              - const poly *a:      pointer to input polynomial
**************************************************/
poly_tomsg
Description: Convert polynomial to 32-byte message

- unsigned char *msg: pointer to output message
const poly *a:      pointer to input polynomial
poly_tomsg Description : Convert polynomial to 32 - byte message - unsigned char * msg : pointer to output message const poly * a : pointer to input polynomial
void poly_tomsg(unsigned char msg[KYBER_SYMBYTES], poly *a)
{
  uint16_t t;
  int i,j;
  poly_csubq(a);
  for(i=0;i<KYBER_SYMBYTES;i++)
  {
    msg[i] = 0;
    for(j=0;j<8;j++)
    {
      t = (((a->coeffs[8*i+j] << 1) + KYBER_Q/2) / KYBER_Q) & 1;
      msg[i] |= t << j;
    }
  }
}
void poly_tomsg ( unsigned char msg [ KYBER_SYMBYTES ] , poly * a ) { uint16_t t ; int i , j ; poly_csubq ( a ) ; for ( i = 0 ; i < KYBER_SYMBYTES ; i ++ ) { msg [ i ] = 0 ; for ( j = 0 ; j < 8 ; j ++ ) { t = ( ( ( a -> coeffs [ 8 * i + j ] << 1 ) + KYBER_Q / 2 ) / KYBER_Q ) & 1 ; msg [ i ] |= t << j ; } } }
Name:        poly_tomsg
Description: Convert polynomial to 32-byte message
Name : poly_tomsg Description : Convert polynomial to 32 - byte message