Skip to content

Commit

Permalink
Merge pull request #118 from iden3/feature/linked-poc-link-id
Browse files Browse the repository at this point in the history
linkID to output
  • Loading branch information
OBrezhniev authored Dec 7, 2023
2 parents d9563d1 + 7eeeb9c commit 4de8737
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
11 changes: 9 additions & 2 deletions circuits/linked/multiQuery.circom
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ include "../lib/utils/spongeHash.circom";
template LinkedMultiQuery(N, claimLevels, valueArraySize) {

// linked proof signals
signal input linkID;
signal input linkNonce;
signal input issuerClaim[8];

Expand All @@ -29,6 +28,7 @@ template LinkedMultiQuery(N, claimLevels, valueArraySize) {
signal input value[N][valueArraySize];

// Outputs
signal output linkID;
signal output merklized;
signal output operatorOutput[N];
signal output circuitQueryHash[N];
Expand All @@ -38,7 +38,7 @@ template LinkedMultiQuery(N, claimLevels, valueArraySize) {
/////////////////////////////////////////////////////////////////

// get safe one values to be used in ForceEqualIfEnabled
signal one <== SafeOne()(linkID); // 7 constraints
signal one <== SafeOne()(linkNonce); // 7 constraints

// get claim header
component issuerClaimHeader = getClaimHeader(); // 300 constraints
Expand All @@ -60,6 +60,13 @@ template LinkedMultiQuery(N, claimLevels, valueArraySize) {
signal isQueryOp[N];
signal valueHash[N];

signal issuerClaimHash, issuerClaimHi, issuerClaimHv;
(issuerClaimHash, issuerClaimHi, issuerClaimHv) <== getClaimHash()(issuerClaim); // 834 constraints
////////////////////////////////////////////////////////////////////////
// calculate linkID
////////////////////////////////////////////////////////////////////////
linkID <== LinkID()(issuerClaimHash, linkNonce); // 243 constraints

/////////////////////////////////////////////////////////////////
// Query Processing Loop
/////////////////////////////////////////////////////////////////
Expand Down
13 changes: 6 additions & 7 deletions circuits/linked/nullifier.circom
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ pragma circom 2.1.5;

include "../../node_modules/circomlib/circuits/comparators.circom";
include "../lib/linked/linkId.circom";
include "../lib/query/nullify.circom";
include "../lib/utils/nullify.circom";
include "../lib/utils/safeOne.circom";
include "../lib/utils/claimUtils.circom";

// This circuit generates nullifier for a given claim using linked proof
template LinkedNullifier(){

// linked proof signals
signal input linkID;
signal input linkNonce;
signal input issuerClaim[8];

Expand All @@ -19,9 +18,10 @@ template LinkedNullifier(){
signal input claimSubjectProfileNonce;
signal input claimSchema;
signal input verifierID;
signal input verifierSessionID;
signal input nullifierSessionID;

signal output nullifier;
signal output linkID;

// get safe one values to be used in ForceEqualIfEnabled
signal one <== SafeOne()(userGenesisID); // 7 constraints
Expand Down Expand Up @@ -49,10 +49,9 @@ template LinkedNullifier(){
(issuerClaimHash, issuerClaimHi, issuerClaimHv) <== getClaimHash()(issuerClaim); // 834 constraints

////////////////////////////////////////////////////////////////////////
// verify linkID
// calculate linkID
////////////////////////////////////////////////////////////////////////
signal calculatedLinkID <== LinkID()(issuerClaimHash, linkNonce); // 243 constraints
ForceEqualIfEnabled()(one, [calculatedLinkID, linkID]);
linkID <== LinkID()(issuerClaimHash, linkNonce); // 243 constraints

signal linkIDisNotZero <== NOT()(IsZero()(linkID));
ForceEqualIfEnabled()(one, [linkIDisNotZero, one]);
Expand All @@ -65,7 +64,7 @@ template LinkedNullifier(){
claimSubjectProfileNonce,
claimSchema,
verifierID,
verifierSessionID
nullifierSessionID
); // 330 constraints

}
2 changes: 1 addition & 1 deletion circuits/linkedMultiQuery10.circom
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pragma circom 2.1.1;

include "linked/multiQuery.circom";

component main {public [linkID]} = LinkedMultiQuery(10, 32, 64); // 163694 constraints
component main = LinkedMultiQuery(10, 32, 64); // 163694 constraints
2 changes: 1 addition & 1 deletion circuits/linkedMultiQuery3.circom
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pragma circom 2.1.1;

include "linked/multiQuery.circom";

component main {public [linkID]} = LinkedMultiQuery(3, 32, 64); // 49300 constraints
component main = LinkedMultiQuery(3, 32, 64); // 49300 constraints
2 changes: 1 addition & 1 deletion circuits/linkedNullifier.circom
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ pragma circom 2.1.1;

include "linked/nullifier.circom";

component main {public [linkID, verifierID, verifierSessionID]} = LinkedNullifier();
component main {public [verifierID, nullifierSessionID]} = LinkedNullifier();

0 comments on commit 4de8737

Please sign in to comment.