You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm porting New Hope to JavaScript and want to make sure my code behaves exactly the same and generates the same test vectors as reference implementation. I found the following nits:
PRNG in testvectors.c is very strange: it seems like there's confusion between uint32 (out) and unsigned char (x) https://github.com/tpoeppelmann/newhope/blob/master/ref/test/testvectors.c#L51 It kinda works, since randombytes always gets 32 bytes, but will write past the buffer if length is not divisible by 4. I propose replacing the whole construction with ChaCha-based PRNG:
staticunsigned charkey[32] = { 3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6,2,6,4,3,3,8,3,2,7,9,5 } ;
staticunsigned charnonce[8];
staticunsigned charout[64];
staticintoutleft=0;
voidrandombytes(unsigned char*x,unsigned long longxlen)
{
while (xlen>0) {
if (outleft==0) {
if (!++nonce[0]) if (!++nonce[1]) if (!++nonce[2]) ++nonce[3];
crypto_stream_chacha20(out, 64, nonce, key);
outleft=64;
}
*x=out[--outleft];
++x;
--xlen;
}
}
Also, I could build reference implementation on OS X only if I removed -msse2avx -march=corei7-avx from CFLAGS. It seems like they are not needed for ref, so perhaps should be removed?
Thank you!
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Hello!
I'm porting New Hope to JavaScript and want to make sure my code behaves exactly the same and generates the same test vectors as reference implementation. I found the following nits:
helprec
nonce byte is put at the end00000000B
(https://github.com/tpoeppelmann/newhope/blob/master/ref/error_correction.c#L81), while inpoly_getnoise
it's in the beginningB00000000
(https://github.com/tpoeppelmann/newhope/blob/master/ref/poly.c#L105). Since nonce bytes are different anyway, I see no reason for this (well, other than to make sure it's really-really different).testvectors.c
is very strange: it seems like there's confusion betweenuint32
(out) andunsigned char
(x) https://github.com/tpoeppelmann/newhope/blob/master/ref/test/testvectors.c#L51 It kinda works, sincerandombytes
always gets 32 bytes, but will write past the buffer if length is not divisible by 4. I propose replacing the whole construction with ChaCha-based PRNG:Also, I could build reference implementation on OS X only if I removed
-msse2avx -march=corei7-avx
fromCFLAGS
. It seems like they are not needed forref
, so perhaps should be removed?Thank you!
The text was updated successfully, but these errors were encountered: