mirror of https://github.com/oxen-io/lokinet
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
679 B
C
30 lines
679 B
C
#include "params.h"
|
|
#include "randombytes.h"
|
|
#include "int32_sort.h"
|
|
#include "small.h"
|
|
#include "crypto_stream_aes256ctr.h"
|
|
|
|
static const unsigned char n[16] = {0};
|
|
|
|
void small_seeded_weightw(small *f,const unsigned char *k)
|
|
{
|
|
crypto_int32 r[768];
|
|
int i;
|
|
|
|
crypto_stream_aes256ctr((unsigned char *) r,sizeof r,n,k);
|
|
for (i = 0;i < p;++i) r[i] ^= 0x80000000;
|
|
|
|
for (i = 0;i < w;++i) r[i] &= -2;
|
|
for (i = w;i < p;++i) r[i] = (r[i] & -3) | 1;
|
|
int32_sort(r,p);
|
|
for (i = 0;i < p;++i) f[i] = ((small) (r[i] & 3)) - 1;
|
|
for (i = p;i < 768;++i) f[i] = 0;
|
|
}
|
|
|
|
void small_random_weightw(small *f)
|
|
{
|
|
unsigned char k[32];
|
|
randombytes(k,32);
|
|
small_seeded_weightw(f,k);
|
|
}
|