Created
March 3, 2022 04:57
-
-
Save botdad/79cddf286438bf96edffa49ed5ccc0f7 to your computer and use it in GitHub Desktop.
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
pragma circom 2.0.0; | |
include "../node_modules/circomlib/circuits/mimcsponge.circom"; | |
template attestValidMove () { | |
signal input move; | |
signal input secret; | |
signal output moveAttestation; | |
component mimcAttestation = MiMCSponge(2, 220, 1); | |
signal temp; | |
temp <== (move - 1) * (move - 2); | |
0 === temp * move; // ensure that the move is 0, 1, or 2 | |
mimcAttestation.ins[0] <== move; | |
mimcAttestation.ins[1] <== secret; | |
mimcAttestation.k <== 0; | |
moveAttestation <== mimcAttestation.outs[0]; | |
} | |
component main = attestValidMove(); |
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
pragma circom 2.0.0; | |
include "../node_modules/circomlib/circuits/mimcsponge.circom"; | |
include "../node_modules/circomlib/circuits/comparators.circom"; | |
template revealMove(N) { | |
signal input secret; | |
signal input moveAttestation; | |
signal output move[N]; | |
component mimcAttestation[N]; | |
component isEqual[N]; | |
for(var i = 0; i < N; i++){ | |
mimcAttestation[i] = MiMCSponge(2, 220, 1); | |
isEqual[i] = IsEqual(); | |
mimcAttestation[i].ins[0] <== i; | |
mimcAttestation[i].ins[1] <== secret; | |
mimcAttestation[i].k <== 0; | |
isEqual[i].in[0] <== moveAttestation; | |
isEqual[i].in[1] <== mimcAttestation[i].outs[0]; | |
move[i] <== isEqual[i].out; | |
} | |
} | |
component main {public [moveAttestation]} = revealMove(3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment