-rw-r--r-- 576 libntruprime-20241008/src/core/weightsntrupP/ref/weight.c raw
// 20240812 djb: more cryptoint usage
#include "crypto_core.h"
#include "crypto_int8.h"
#include "crypto_int16.h"
#define int8 crypto_int8
#define int16 crypto_int16
#include "crypto_encode_int16.h"
#include "params.h"
/* out = little-endian weight of bottom bits of in */
void crypto_core(unsigned char *outbytes,const unsigned char *inbytes,const unsigned char *kbytes,const unsigned char *cbytes)
{
int8 *in = (void *) inbytes;
int16 weight = 0;
int i;
for (i = 0;i < p;++i) weight += crypto_int8_bottombit_01(in[i]);
crypto_encode_int16(outbytes,&weight);
}