Skip to content

Instantly share code, notes, and snippets.

@vio1etus
Last active June 5, 2023 04:42
Show Gist options
  • Save vio1etus/1117e8e808bc0519e38ddeba248b7368 to your computer and use it in GitHub Desktop.
Save vio1etus/1117e8e808bc0519e38ddeba248b7368 to your computer and use it in GitHub Desktop.

Open this in zkREPL →

This file can be included into other zkREPLs with include "gist:1117e8e808bc0519e38ddeba248b7368";

pragma circom 2.1.4;
include "circomlib/poseidon.circom";
// include "https://github.com/0xPARC/circom-secp256k1/blob/master/circuits/bigint.circom";
template Secret2Public () {
signal input sk;
signal output pk;
component poseidon = Poseidon(1); // the input of poseidon hash is the number of variables you want to hash, normally one or two
poseidon.inputs[0] <== sk;
pk <== poseidon.out;
log("pk:", pk);
}
template Sign(){
signal input m;
signal input sk; // private
signal output pk;
component checker = Secret2Public();
checker.sk <== sk;
pk <== checker.pk;
}
template GroupSign(n){
signal input m;
signal input sk; // private
signal input pk[n];
component checker = Secret2Public();
checker.sk <== sk;
signal zeroChecker[n+1];
zeroChecker[0] <== 1;
for(var i = 0; i < n; i++){
// the following line is not work because cirom cannot multiple more than 2-order to one variable
// and the self multiple is not allowed,too
// zeroChecker <== zeroChecker * (pk[i] - checker.pk);
zeroChecker[i+1] <== zeroChecker[i] * (pk[i] - checker.pk);
}
zeroChecker[n] === 0;
}
component main = GroupSign(5);
/* INPUT = {
"m": "3",
"sk": "5",
"pk": ["19065150524771031435284970883882288895168425523179566388456001105768498065277",
"2",
"3",
"4",
"5"]
} */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment