28 typedef typename LogicCircuit::template bitvec<64> v64;
30 const LogicCircuit& lc_;
32 v64 of_scalar(uint64_t x)
const {
return lc_.template vbit<64>(x); }
35 explicit Sha3Circuit(
const LogicCircuit& lc) : lc_(lc) {}
37 void keccak_f_1600(v64 A[5][5]) {
38 for (
size_t round = 0; round < 24; ++round) {
41 for (
size_t x = 0; x < 5; ++x) {
42 auto a01 = lc_.vxor(&A[x][0], A[x][1]);
43 auto a23 = lc_.vxor(&A[x][2], A[x][3]);
44 C[x] = lc_.vxor(&a01, lc_.vxor(&a23, A[x][4]));
47 for (
size_t x = 0; x < 5; ++x) {
48 v64 D_x = lc_.vxor(&C[(x + 4) % 5], lc_.vrotl(C[(x + 1) % 5], 1));
49 for (
size_t y = 0; y < 5; ++y) {
50 A[x][y] = lc_.vxor(&A[x][y], D_x);
57 for (
size_t t = 0; t < 24; ++t) {
58 A[x][y] = lc_.vrotl(A[x][y], sha3_rotc[t]);
59 size_t nx = y, ny = (2 * x + 3 * y) % 5;
67 for (
size_t x = 0; x < 5; ++x) {
68 for (
size_t y = 0; y < 5; ++y) {
69 A1[x][y] = A[(x + 3 * y) % 5][x];
74 for (
size_t x = 0; x < 5; ++x) {
75 for (
size_t y = 0; y < 5; ++y) {
76 A[x][y] = lc_.vxor(&A1[x][y], lc_.vand(&A1[(x + 2) % 5][y],
77 lc_.vnot(A1[(x + 1) % 5][y])));
82 A[0][0] = lc_.vxor(&A[0][0], of_scalar(sha3_rc[round]));