arnaucube
arnaucube/keccak256-circomPublic Self-hosted repository
keccak256-circom/circuits/iota.circom
circuits/iota.circomRaw
 1pragma circom 2.0.0;
 2
 3include "./utils.circom";
 4
 5template RC(r) {
 6    signal output out[64];
 7    var rc[24] = [
 8        0x0000000000000001, 0x0000000000008082, 0x800000000000808A,
 9        0x8000000080008000, 0x000000000000808B, 0x0000000080000001,
10        0x8000000080008081, 0x8000000000008009, 0x000000000000008A,
11        0x0000000000000088, 0x0000000080008009, 0x000000008000000A,
12        0x000000008000808B, 0x800000000000008B, 0x8000000000008089,
13        0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
14        0x000000000000800A, 0x800000008000000A, 0x8000000080008081,
15        0x8000000000008080, 0x0000000080000001, 0x8000000080008008
16    ];
17    for (var i=0; i<64; i++) {
18        out[i] <== (rc[r] >> i) & 1;
19    }
20}
21
22template Iota(r) {
23    signal input in[25*64];
24    signal output out[25*64];
25    var i;
26
27    component rc = RC(r);
28
29    component iota = XorArray(64);
30    for (var i=0; i<64; i++) {
31        iota.a[i] <== in[i];
32        iota.b[i] <== rc.out[i];
33    }
34    for (i=0; i<64; i++) {
35        out[i] <== iota.out[i];
36    }
37    for (i=64; i<25*64; i++) {
38        out[i] <== in[i];
39    }
40}
41