Skip to content

Commit

Permalink
syntax for circom version + paths in tests (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJepsen authored Aug 11, 2024
1 parent 82621af commit 64ec276
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 19 deletions.
2 changes: 1 addition & 1 deletion circuits/aes-gcm/gfmul_int.circom
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma circom 2.1.9
pragma circom 2.1.9;

include "vclmul_emulator.circom";
include "helper_functions.circom";
Expand Down
5 changes: 2 additions & 3 deletions circuits/aes-gcm/ghash.circom
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma circom 2.0.0;
pragma circom 2.1.9;

include "gfmul_int.circom";
include "helper_functions.circom";
Expand Down Expand Up @@ -74,5 +74,4 @@ template GHASH(n_msg_bits)
{
for(j=0; j<64; j++) result[i][j] <== current_res[i][j];
}
}
component main = GHASH(128);
}
2 changes: 1 addition & 1 deletion circuits/aes-gcm/helper_functions.circom
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma circom 2.1.9
pragma circom 2.1.9;

include "../lib_circuits/bitify.circom";
include "../lib_circuits/gates.circom";
Expand Down
2 changes: 1 addition & 1 deletion circuits/aes-gcm/mul.circom
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma circom 2.1.9
pragma circom 2.1.9;

include "helper_functions.circom";

Expand Down
62 changes: 62 additions & 0 deletions circuits/aes-gcm/polyval.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
pragma circom 2.1.9;

include "gfmul_int.circom";
include "helper_functions.circom";

template POLYVAL(n_bits)
{
var msg_len = n_bits/8;
signal input in[n_bits];
signal input H[128];
signal input T[2][64];
signal output result[2][64];

var current_res[2][64] = T, in_t[2][64];

var i, j, k;
var blocks = msg_len/16;

component xor_1[blocks][2][64];
component gfmul_int_1[blocks];

if(blocks != 0)
{
for(i=0; i<blocks; i++)
{
for(j=0; j<64; j++)
{
in_t[0][j] = in[2*i*64+j];
in_t[1][j] = in[(2*i+1)*64+j];
}

for(j=0; j<2; j++)
{
for(k=0; k<64; k++)
{
xor_1[i][j][k] = XOR();
xor_1[i][j][k].a <== current_res[j][k];
xor_1[i][j][k].b <== in_t[j][k];

current_res[j][k] = xor_1[i][j][k].out;
}
}

gfmul_int_1[i] = GFMULInt();
for(j=0; j<2; j++)
{
for(k=0; k<64; k++)
{
gfmul_int_1[i].a[j][k] <== current_res[j][k];
gfmul_int_1[i].b[j][k] <== H[j*64+k];
}
}

current_res = gfmul_int_1[i].res;
}
}

for(i=0; i<2; i++)
{
for(j=0; j<64; j++) result[i][j] <== current_res[i][j];
}
}
2 changes: 1 addition & 1 deletion circuits/aes-gcm/vclmul_emulator.circom
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma circom 2.1.9
pragma circom 2.1.9;

include "mul.circom";

Expand Down
2 changes: 1 addition & 1 deletion circuits/lib_circuits/aliascheck.circom
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with circom. If not, see <https://www.gnu.org/licenses/>.
*/
pragma circom 2.1.9
pragma circom 2.1.9;

include "compconstant.circom";

Expand Down
2 changes: 1 addition & 1 deletion circuits/lib_circuits/binsum.circom
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ To waranty binary outputs:
/*
This function calculates the number of extra bits in the output to do the full sum.
*/
pragma circom 2.1.9
pragma circom 2.1.9;

function nbits(a) {
var n = 1;
Expand Down
2 changes: 1 addition & 1 deletion circuits/lib_circuits/bitify.circom
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with circom. If not, see <https://www.gnu.org/licenses/>.
*/
pragma circom 2.1.9
pragma circom 2.1.9;

include "comparators.circom";
include "aliascheck.circom";
Expand Down
2 changes: 1 addition & 1 deletion circuits/lib_circuits/comparators.circom
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with circom. If not, see <https://www.gnu.org/licenses/>.
*/
pragma circom 2.1.9
pragma circom 2.1.9;

include "bitify.circom";
include "binsum.circom";
Expand Down
2 changes: 1 addition & 1 deletion circuits/lib_circuits/compconstant.circom
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with circom. If not, see <https://www.gnu.org/licenses/>.
*/
pragma circom 2.1.9
pragma circom 2.1.9;

include "bitify.circom";

Expand Down
2 changes: 1 addition & 1 deletion circuits/lib_circuits/gates.circom
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with circom. If not, see <https://www.gnu.org/licenses/>.
*/
pragma circom 2.1.9
pragma circom 2.1.9;

template XOR() {
signal input a;
Expand Down
2 changes: 1 addition & 1 deletion circuits/lib_circuits/mux1.circom
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with circom. If not, see <https://www.gnu.org/licenses/>.
*/
pragma circom 2.1.9
pragma circom 2.1.9;

template MultiMux1(n) {
signal input c[n][2]; // Constants
Expand Down
2 changes: 1 addition & 1 deletion circuits/lib_circuits/sha256.circom
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma circom 2.1.9
pragma circom 2.1.9;

include "constants.circom";
include "sha256compression.circom";
Expand Down
5 changes: 2 additions & 3 deletions circuits/test/gfmulint/gfmulint.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { assert } from "chai";
import { WitnessTester } from "circomkit";
import { circomkit } from "../common";
import { assert } from "chai";
import { parse } from "path";

// input and output type of GFMULInt
type Arr128 = number[][];
Expand All @@ -11,7 +10,7 @@ describe("gfmulint", () => {

before(async () => {
circuit = await circomkit.WitnessTester("gfmulint", {
file: "aes/gfmul_int",
file: "aes-gcm/gfmul_int",
template: "GFMULInt",
});
console.log("#constraints:", await circuit.getConstraintCount());
Expand Down
2 changes: 1 addition & 1 deletion circuits/test/ghash/polyval.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe("polyval", () => {

before(async () => {
circuit = await circomkit.WitnessTester(`polyval`, {
file: "aes/polyval",
file: "aes-gcm/polyval",
template: "POLYVAL",
params: [128],
});
Expand Down

0 comments on commit 64ec276

Please sign in to comment.