Skip to content

Commit

Permalink
Added VerifiableCommitment circuit
Browse files Browse the repository at this point in the history
  • Loading branch information
KyrylR committed Jun 29, 2024
1 parent 2f182be commit d2961b7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
33 changes: 33 additions & 0 deletions circuits/VerifiableCommitment.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
pragma circom 2.0.0;

include "../node_modules/circomlib/circuits/poseidon.circom";
include "../node_modules/circomlib/circuits/comparators.circom";

template VerifiableCommitment() {
signal output credentialId;

// Public signals
signal input contractId;
signal input nftId;
signal input nftOwner;
signal input deadline;

// Private signals
signal input babyJubJubPK;
signal input timestamp;

component computedCredId = Poseidon(5);
computedCredId.inputs[0] <== contractId;
computedCredId.inputs[1] <== nftId;
computedCredId.inputs[2] <== nftOwner;
computedCredId.inputs[3] <== babyJubJubPK;
computedCredId.inputs[4] <== timestamp;

credentialId <== computedCredId.out;

component greaterEqThanLowerTime = GreaterEqThan(64); // compare up to 2**64
greaterEqThanLowerTime.in[0] <== timestamp;
greaterEqThanLowerTime.in[1] <== deadline;
}

component main { public [contractId, nftId, nftOwner, deadline] } = VerifiableCommitment();
8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"@iden3/contracts": "^2.1.1",
"@openzeppelin/contracts": "5.0.2",
"@openzeppelin/contracts-upgradeable": "5.0.2",
"@solarity/solidity-lib": "2.7.9"
"@solarity/solidity-lib": "2.7.9",
"circomlib": "^2.0.5"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.0.7",
Expand Down

0 comments on commit d2961b7

Please sign in to comment.