Beispiel #1
0
void newhope_sharedb(unsigned char *sharedkey, unsigned char *send, const unsigned char *received)
{
  poly sp, ep, v, a, pka, c, epp, bp;
  unsigned char seed[NEWHOPE_SEEDBYTES];
  unsigned char noiseseed[32];
  
  randombytes(noiseseed, 32);

  decode_a(&pka, seed, received);
  gen_a(&a, seed);

  poly_getnoise(&sp,noiseseed,0);
  poly_ntt(&sp);
  poly_getnoise(&ep,noiseseed,1);
  poly_ntt(&ep);

  poly_pointwise(&bp, &a, &sp);
  poly_add(&bp, &bp, &ep);
  
  poly_pointwise(&v, &pka, &sp);
  poly_bitrev(&v);
  poly_invntt(&v);

  poly_getnoise(&epp,noiseseed,2);
  poly_add(&v, &v, &epp);

  helprec(&c, &v, noiseseed, 3);

  encode_b(send, &bp, &c);
  
  rec(sharedkey, &v, &c);

  sha3256(sharedkey, sharedkey, 32);
}
Beispiel #2
0
void newhope_shareda(unsigned char *sharedkey, const poly *sk, const unsigned char *received)
{
  poly v,bp, c;

  decode_b(&bp, &c, received);

  poly_pointwise(&v,sk,&bp);
  poly_bitrev(&v);
  poly_invntt(&v);
 
  rec(sharedkey, &v, &c);
  sha3256(sharedkey, sharedkey, 32); 
}
Beispiel #3
0
void newhope_shareda(unsigned char *sharedkey, const poly *sk, const unsigned char *received)
{
  poly v,bp, c;

  decode_b(&bp, &c, received);

  poly_pointwise(&v,sk,&bp);
  poly_invntt(&v);
 
  rec(sharedkey, &v, &c);

#ifndef STATISTICAL_TEST 
  sha3256(sharedkey, sharedkey, 32); 
#endif
}
Beispiel #4
0
void newhope_keygen(unsigned char *send, poly *sk)
{
  poly a, e, r, pk;
  unsigned char seed[NEWHOPE_SEEDBYTES];
  unsigned char noiseseed[32];

  randombytes(seed, NEWHOPE_SEEDBYTES);
  randombytes(noiseseed, 32);

  gen_a(&a, seed); //unsigned

  poly_getnoise(sk,noiseseed,0);
  poly_ntt(sk); //unsigned
  
  poly_getnoise(&e,noiseseed,1);
  poly_ntt(&e); //unsigned

  poly_pointwise(&r,sk,&a); //unsigned
  poly_add(&pk,&e,&r); //unsigned
  encode_a(send, &pk, seed);
}