Format mqdss-48

This commit is contained in:
Joost Rijneveld 2019-04-30 10:54:16 +02:00
parent 2e304246c4
commit 8357fb1c80
No known key found for this signature in database
GPG Key ID: A4FE39CF49CBC553
3 changed files with 73 additions and 80 deletions

View File

@ -3,8 +3,7 @@
/* Computes all products x_i * x_j, returns in reduced form */ /* Computes all products x_i * x_j, returns in reduced form */
inline static inline static
void generate_quadratic_terms( gf31 * xij , const gf31 * x ) void generate_quadratic_terms( gf31 *xij, const gf31 *x ) {
{
int i, j, k; int i, j, k;
k = 0; k = 0;
for (i = 0; i < N; i++) { for (i = 0; i < N; i++) {
@ -17,8 +16,7 @@ void generate_quadratic_terms( gf31 * xij , const gf31 * x )
/* Computes all terms (x_i * y_j) + (x_j * y_i), returns in reduced form */ /* Computes all terms (x_i * y_j) + (x_j * y_i), returns in reduced form */
inline static inline static
void generate_xiyj_p_xjyi_terms( gf31 * xij , const gf31 * x , const gf31 * y ) void generate_xiyj_p_xjyi_terms( gf31 *xij, const gf31 *x, const gf31 *y ) {
{
int i, j, k; int i, j, k;
k = 0; k = 0;
for (i = 0; i < N; i++) { for (i = 0; i < N; i++) {
@ -33,8 +31,7 @@ void generate_xiyj_p_xjyi_terms( gf31 * xij , const gf31 * x , const gf31 * y )
in reduced 5-bit representation). Expects the coefficients in F to be in in reduced 5-bit representation). Expects the coefficients in F to be in
signed representation (i.e. [-15, 15], packed bytewise). signed representation (i.e. [-15, 15], packed bytewise).
Outputs M gf31 elements in unique 16-bit representation as fx. */ Outputs M gf31 elements in unique 16-bit representation as fx. */
void PQCLEAN_MQDSS48_CLEAN_MQ(gf31 *fx, const gf31 *x, const signed char *F) void PQCLEAN_MQDSS48_CLEAN_MQ(gf31 *fx, const gf31 *x, const signed char *F) {
{
int i, j; int i, j;
gf31 _xij[N * (N + 1) >> 1]; gf31 _xij[N * (N + 1) >> 1];
int r[M] = {0}; int r[M] = {0};
@ -64,8 +61,7 @@ void PQCLEAN_MQDSS48_CLEAN_MQ(gf31 *fx, const gf31 *x, const signed char *F)
N gf31 elements x (expected to be in reduced 5-bit representation). Expects N gf31 elements x (expected to be in reduced 5-bit representation). Expects
the coefficients in F to be in signed representation (i.e. [-15, 15], packed the coefficients in F to be in signed representation (i.e. [-15, 15], packed
bytewise). Outputs M gf31 elements in unique 16-bit representation as fx. */ bytewise). Outputs M gf31 elements in unique 16-bit representation as fx. */
void PQCLEAN_MQDSS48_CLEAN_G(gf31 *fx, const gf31 *x, const gf31 *y, const signed char *F) void PQCLEAN_MQDSS48_CLEAN_G(gf31 *fx, const gf31 *x, const gf31 *y, const signed char *F) {
{
int i, j; int i, j;
gf31 _xij[N * (N + 1) >> 1]; gf31 _xij[N * (N + 1) >> 1];
int r[M] = {0}; int r[M] = {0};

View File

@ -12,8 +12,7 @@
/* Takes an array of len bytes and computes a hash digest. /* Takes an array of len bytes and computes a hash digest.
This is used as a hash function in the Fiat-Shamir transform. */ This is used as a hash function in the Fiat-Shamir transform. */
static void H(unsigned char *out, const unsigned char *in, const size_t len) static void H(unsigned char *out, const unsigned char *in, const size_t len) {
{
shake256(out, HASH_BYTES, in, len); shake256(out, HASH_BYTES, in, len);
} }
@ -22,8 +21,7 @@ static void H(unsigned char *out, const unsigned char *in, const size_t len)
static void com_0(unsigned char *c, static void com_0(unsigned char *c,
const unsigned char *rho, const unsigned char *rho,
const unsigned char *inn, const unsigned char *inn2, const unsigned char *inn, const unsigned char *inn2,
const unsigned char *inm) const unsigned char *inm) {
{
unsigned char buffer[HASH_BYTES + 2 * NPACKED_BYTES + MPACKED_BYTES]; unsigned char buffer[HASH_BYTES + 2 * NPACKED_BYTES + MPACKED_BYTES];
memcpy(buffer, rho, HASH_BYTES); memcpy(buffer, rho, HASH_BYTES);
memcpy(buffer + HASH_BYTES, inn, NPACKED_BYTES); memcpy(buffer + HASH_BYTES, inn, NPACKED_BYTES);
@ -36,8 +34,7 @@ static void com_0(unsigned char *c,
and computes a HASH_BYTES commitment. */ and computes a HASH_BYTES commitment. */
static void com_1(unsigned char *c, static void com_1(unsigned char *c,
const unsigned char *rho, const unsigned char *rho,
const unsigned char *inn, const unsigned char *inm) const unsigned char *inn, const unsigned char *inm) {
{
unsigned char buffer[HASH_BYTES + NPACKED_BYTES + MPACKED_BYTES]; unsigned char buffer[HASH_BYTES + NPACKED_BYTES + MPACKED_BYTES];
memcpy(buffer, rho, HASH_BYTES); memcpy(buffer, rho, HASH_BYTES);
memcpy(buffer + HASH_BYTES, inn, NPACKED_BYTES); memcpy(buffer + HASH_BYTES, inn, NPACKED_BYTES);