references/kyber-submission-nist-round2/NIST-PQ-Submission-Kyber-20190330/Reference_Implementation/crypto_kem/kyber768/poly.c
/*************************************************
* Name:        poly_tobytes
*
* Description: Serialization of a polynomial
*
* Arguments:   - unsigned char *r: pointer to output byte array (needs space for KYBER_POLYBYTES bytes)
*              - const poly *a:    pointer to input polynomial
**************************************************/
poly_tobytes
Description: Serialization of a polynomial

- unsigned char *r: pointer to output byte array (needs space for KYBER_POLYBYTES bytes)
const poly *a:    pointer to input polynomial
poly_tobytes Description : Serialization of a polynomial - unsigned char * r : pointer to output byte array ( needs space for KYBER_POLYBYTES bytes ) const poly * a : pointer to input polynomial
void poly_tobytes(unsigned char *r, poly *a)
{
  int i;
  uint16_t t0, t1;
  poly_csubq(a);
  for(i=0;i<KYBER_N/2;i++){
    t0 = a->coeffs[2*i];
    t1 = a->coeffs[2*i+1];
    r[3*i] = t0 & 0xff;
    r[3*i+1] = (t0 >> 8) | ((t1 & 0xf) << 4);
    r[3*i+2] = t1 >> 4;
  }
}
void poly_tobytes ( unsigned char * r , poly * a ) { int i ; uint16_t t0 , t1 ; poly_csubq ( a ) ; for ( i = 0 ; i < KYBER_N / 2 ; i ++ ) { t0 = a -> coeffs [ 2 * i ] ; t1 = a -> coeffs [ 2 * i + 1 ] ; r [ 3 * i ] = t0 & 0xff ; r [ 3 * i + 1 ] = ( t0 >> 8 ) | ( ( t1 & 0xf ) << 4 ) ; r [ 3 * i + 2 ] = t1 >> 4 ; } }
Name:        poly_tobytes
Description: Serialization of a polynomial
Name : poly_tobytes Description : Serialization of a polynomial