Skip to content

Commit

Permalink
slot index is zero for merklized credentials (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmidyllic authored Aug 2, 2023
1 parent 6dc0aae commit 2b951b5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0xpolygonid/js-sdk",
"version": "1.0.0",
"version": "1.0.1",
"description": "SDK to work with Polygon ID",
"main": "dist/cjs/index.js",
"module": "dist/esm_esbuild/index.js",
Expand Down
10 changes: 5 additions & 5 deletions src/proof/proof-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,11 @@ export class ProofService implements IProofService {
}
parsedQuery.query.valueProof.value = mtEntry;

if (merklizedPosition == MerklizedRootPosition.Index) {
parsedQuery.query.slotIndex = 2; // value data slot a
} else {
parsedQuery.query.slotIndex = 5; // value data slot b
}
// for merklized credentials slotIndex in query must be equal to zero
// and not a position of merklization root.
// it has no influence on check in the off-chain circuits, but it aligns with onchain verification standard
parsedQuery.query.slotIndex = 0;

if (!parsedQuery.fieldName) {
const resultQuery = parsedQuery.query;
resultQuery.operator = QueryOperators.$eq;
Expand Down
11 changes: 8 additions & 3 deletions tests/proofs/sig-onchain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ describe('sig onchain proofs', () => {
context:
'https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld',
credentialSubject: {
documentType: {
$eq: 99
birthday: {
$lt: 20020101
}
}
}
Expand All @@ -164,12 +164,17 @@ describe('sig onchain proofs', () => {
const credsForMyUserDID = await credWallet.filterByCredentialSubject(creds, userDID);
expect(credsForMyUserDID.length).to.equal(1);

const { proof, vp } = await proofService.generateProof(proofReq, userDID, {
const { proof, vp, pub_signals } = await proofService.generateProof(proofReq, userDID, {
challenge: BigInt(2),
skipRevocation: false
});
console.log(proof);

expect(vp).to.be.undefined;

// query hash test
expect(pub_signals[2]).to.be.equal(
'15045271939084694661437431358729281571840804299863053791890179002991342242959'
);
});
});

0 comments on commit 2b951b5

Please sign in to comment.