-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to nibble-sliced representation.
Co-authored-by: Ward Beullens <[email protected]> Co-authored-by: Fabio Campos <[email protected]> Co-authored-by: Sofía Celi <[email protected]> Co-authored-by: Basil Hess <[email protected]> Co-authored-by: Matthias J. Kannwischer <[email protected]>
- Loading branch information
1 parent
1593d89
commit d81b689
Showing
50 changed files
with
4,599 additions
and
3,777 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef ARITHMETIC_128_H | ||
#define ARITHMETIC_128_H | ||
|
||
#include <stdint.h> | ||
#include <mayo.h> | ||
#include <arithmetic_common.h> | ||
|
||
// This implements arithmetic for vectors of 128 field elements in Z_2[x]/(x^4+x+1) | ||
|
||
static | ||
inline void vec_copy_128(const uint64_t *in, uint64_t *out) { | ||
out[0] = in[0]; | ||
out[1] = in[1]; | ||
out[2] = in[2]; | ||
out[3] = in[3]; | ||
out[4] = in[4]; | ||
out[5] = in[5]; | ||
out[6] = in[6]; | ||
out[7] = in[7]; | ||
} | ||
|
||
|
||
static | ||
inline void vec_add_128(const uint64_t *in, uint64_t *acc) { | ||
acc[0] ^= in[0]; | ||
acc[1] ^= in[1]; | ||
acc[2] ^= in[2]; | ||
acc[3] ^= in[3]; | ||
acc[4] ^= in[4]; | ||
acc[5] ^= in[5]; | ||
acc[6] ^= in[6]; | ||
acc[7] ^= in[7]; | ||
} | ||
|
||
inline | ||
static void m_vec_mul_add_x_128(const uint64_t *in, uint64_t *acc) { | ||
for(int i=0;i<8;i++){ | ||
acc[i] ^= gf16v_mul_u64(in[i], 0x2); | ||
} | ||
} | ||
inline | ||
static void m_vec_mul_add_x_inv_128(const uint64_t *in, uint64_t *acc) { | ||
for(int i=0;i<8;i++){ | ||
acc[i] ^= gf16v_mul_u64(in[i], 0x9); | ||
} | ||
} | ||
|
||
static | ||
inline void vec_mul_add_128(const uint64_t *in, unsigned char a, uint64_t *acc) { | ||
for(int i=0; i < 8;i++){ | ||
acc[i] ^= gf16v_mul_u64(in[i], a); | ||
} | ||
} | ||
|
||
static | ||
inline void multiply_bins_128(uint32_t *bins_32, uint32_t *out_32) { | ||
|
||
uint64_t *bins = (uint64_t *) bins_32; | ||
uint64_t *out = (uint64_t *) out_32; | ||
|
||
m_vec_mul_add_x_inv_128(bins + 5 * 8, bins + 10 * 8); | ||
m_vec_mul_add_x_128(bins + 11 * 8, bins + 12 * 8); | ||
m_vec_mul_add_x_inv_128(bins + 10 * 8, bins + 7 * 8); | ||
m_vec_mul_add_x_128(bins + 12 * 8, bins + 6 * 8); | ||
m_vec_mul_add_x_inv_128(bins + 7 * 8, bins + 14 * 8); | ||
m_vec_mul_add_x_128(bins + 6 * 8, bins + 3 * 8); | ||
m_vec_mul_add_x_inv_128(bins + 14 * 8, bins + 15 * 8); | ||
m_vec_mul_add_x_128(bins + 3 * 8, bins + 8 * 8); | ||
m_vec_mul_add_x_inv_128(bins + 15 * 8, bins + 13 * 8); | ||
m_vec_mul_add_x_128(bins + 8 * 8, bins + 4 * 8); | ||
m_vec_mul_add_x_inv_128(bins + 13 * 8, bins + 9 * 8); | ||
m_vec_mul_add_x_128(bins + 4 * 8, bins + 2 * 8); | ||
m_vec_mul_add_x_inv_128(bins + 9 * 8, bins + 1 * 8); | ||
m_vec_mul_add_x_128(bins + 2 * 8, bins + 1 * 8); | ||
vec_copy_128(bins + 8, out); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef ARITHMETIC_64_H | ||
#define ARITHMETIC_64_H | ||
|
||
#include <stdint.h> | ||
#include <mayo.h> | ||
#include <arithmetic_common.h> | ||
|
||
// This implements arithmetic for vectors of 64 field elements in Z_2[x]/(x^4+x+1) | ||
|
||
static | ||
inline void vec_copy_64(const uint64_t *in, uint64_t *out) { | ||
out[0] = in[0]; | ||
out[1] = in[1]; | ||
out[2] = in[2]; | ||
out[3] = in[3]; | ||
} | ||
|
||
static | ||
inline void vec_add_64(const uint64_t *in, uint64_t *acc) { | ||
acc[0] ^= in[0]; | ||
acc[1] ^= in[1]; | ||
acc[2] ^= in[2]; | ||
acc[3] ^= in[3]; | ||
} | ||
|
||
static | ||
inline void vec_mul_add_64(const uint64_t *in, unsigned char a, uint64_t *acc) { | ||
for(int i=0; i < 4;i++){ | ||
acc[i] ^= gf16v_mul_u64(in[i], a); | ||
} | ||
} | ||
|
||
inline | ||
static void m_vec_mul_add_x_64(const uint64_t *in, uint64_t *acc) { | ||
for(int i=0;i<4;i++){ | ||
acc[i] ^= gf16v_mul_u64(in[i], 0x2); | ||
} | ||
} | ||
inline | ||
static void m_vec_mul_add_x_inv_64(const uint64_t *in, uint64_t *acc) { | ||
for(int i=0;i<4;i++){ | ||
acc[i] ^= gf16v_mul_u64(in[i], 0x9); | ||
} | ||
} | ||
|
||
static | ||
inline void multiply_bins_64(uint32_t *bins_32, uint32_t *out_32) { | ||
|
||
uint64_t *bins = (uint64_t *) bins_32; | ||
uint64_t *out = (uint64_t *) out_32; | ||
|
||
m_vec_mul_add_x_inv_64(bins + 5 * 4, bins + 10 * 4); | ||
m_vec_mul_add_x_64(bins + 11 * 4, bins + 12 * 4); | ||
m_vec_mul_add_x_inv_64(bins + 10 * 4, bins + 7 * 4); | ||
m_vec_mul_add_x_64(bins + 12 * 4, bins + 6 * 4); | ||
m_vec_mul_add_x_inv_64(bins + 7 * 4, bins + 14 * 4); | ||
m_vec_mul_add_x_64(bins + 6 * 4, bins + 3 * 4); | ||
m_vec_mul_add_x_inv_64(bins + 14 * 4, bins + 15 * 4); | ||
m_vec_mul_add_x_64(bins + 3 * 4, bins + 8 * 4); | ||
m_vec_mul_add_x_inv_64(bins + 15 * 4, bins + 13 * 4); | ||
m_vec_mul_add_x_64(bins + 8 * 4, bins + 4 * 4); | ||
m_vec_mul_add_x_inv_64(bins + 13 * 4, bins + 9 * 4); | ||
m_vec_mul_add_x_64(bins + 4 * 4, bins + 2 * 4); | ||
m_vec_mul_add_x_inv_64(bins + 9 * 4, bins + 1 * 4); | ||
m_vec_mul_add_x_64(bins + 2 * 4, bins + 1 * 4); | ||
vec_copy_64(bins + 4, out); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#ifndef ARITHMETIC_96_H | ||
#define ARITHMETIC_96_H | ||
|
||
#include <stdint.h> | ||
#include <mayo.h> | ||
#include <arithmetic_common.h> | ||
|
||
// This implements arithmetic for vectors of 96 field elements in Z_2[x]/(x^4+x+1) | ||
|
||
static | ||
inline void vec_copy_96(const uint64_t *in, uint64_t *out) { | ||
out[0] = in[0]; | ||
out[1] = in[1]; | ||
out[2] = in[2]; | ||
out[3] = in[3]; | ||
out[4] = in[4]; | ||
out[5] = in[5]; | ||
} | ||
|
||
static | ||
inline void vec_add_96(const uint64_t *in, uint64_t *acc) { | ||
acc[0] ^= in[0]; | ||
acc[1] ^= in[1]; | ||
acc[2] ^= in[2]; | ||
acc[3] ^= in[3]; | ||
acc[4] ^= in[4]; | ||
acc[5] ^= in[5]; | ||
} | ||
|
||
inline | ||
static void m_vec_mul_add_x_96(const uint64_t *in, uint64_t *acc) { | ||
for(int i=0;i<6;i++){ | ||
acc[i] ^= gf16v_mul_u64(in[i], 0x2); | ||
} | ||
} | ||
|
||
inline | ||
static void m_vec_mul_add_x_inv_96(const uint64_t *in, uint64_t *acc) { | ||
for(int i=0;i<6;i++){ | ||
acc[i] ^= gf16v_mul_u64(in[i], 0x9); | ||
} | ||
} | ||
|
||
static | ||
inline void vec_mul_add_96(const uint64_t *in, unsigned char a, uint64_t *acc) { | ||
for(int i=0; i < 6;i++){ | ||
acc[i] ^= gf16v_mul_u64(in[i], a); | ||
} | ||
} | ||
|
||
static | ||
inline void multiply_bins_96(uint32_t *bins_32, uint32_t *out_32) { | ||
|
||
uint64_t *bins = (uint64_t *) bins_32; | ||
uint64_t *out = (uint64_t *) out_32; | ||
|
||
m_vec_mul_add_x_inv_96(bins + 5 * 6, bins + 10 * 6); | ||
m_vec_mul_add_x_96(bins + 11 * 6, bins + 12 * 6); | ||
m_vec_mul_add_x_inv_96(bins + 10 * 6, bins + 7 * 6); | ||
m_vec_mul_add_x_96(bins + 12 * 6, bins + 6 * 6); | ||
m_vec_mul_add_x_inv_96(bins + 7 * 6, bins + 14 * 6); | ||
m_vec_mul_add_x_96(bins + 6 * 6, bins + 3 * 6); | ||
m_vec_mul_add_x_inv_96(bins + 14 * 6, bins + 15 * 6); | ||
m_vec_mul_add_x_96(bins + 3 * 6, bins + 8 * 6); | ||
m_vec_mul_add_x_inv_96(bins + 15 * 6, bins + 13 * 6); | ||
m_vec_mul_add_x_96(bins + 8 * 6, bins + 4 * 6); | ||
m_vec_mul_add_x_inv_96(bins + 13 * 6, bins + 9 * 6); | ||
m_vec_mul_add_x_96(bins + 4 * 6, bins + 2 * 6); | ||
m_vec_mul_add_x_inv_96(bins + 9 * 6, bins + 1 * 6); | ||
m_vec_mul_add_x_96(bins + 2 * 6, bins + 1 * 6); | ||
vec_copy_96(bins + 6, out); | ||
} | ||
|
||
#endif |
Oops, something went wrong.