Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update js-sdk to v1.9.4 #85

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
515 changes: 234 additions & 281 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iden3/js-iden3-auth",
"version": "1.1.1",
"version": "1.2.0",
"description": "iden3-auth implementation in JavaScript",
"main": "dist/cjs/index.js",
"source": "./src/index.ts",
Expand Down Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"@iden3/js-crypto": "1.0.3",
"@0xpolygonid/js-sdk": "1.9.0",
"@0xpolygonid/js-sdk": "1.9.4",
"@iden3/js-iden3-core": "1.2.1",
"@iden3/js-jsonld-merklization": "1.1.2",
"@iden3/js-jwz": "1.3.0",
Expand Down
19 changes: 15 additions & 4 deletions src/circuits/atomicMtpV2.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { getDateFromUnixTimestamp } from '@iden3/js-iden3-core';
import { Resolvers } from '@lib/state/resolver';
import { checkQueryRequest, ClaimOutputs, Query } from '@lib/circuits/query';
import { checkQueryV2Circuits, ClaimOutputs, Query } from '@lib/circuits/query';
import { PubSignalsVerifier, VerifyOpts } from '@lib/circuits/registry';
import { IDOwnershipPubSignals } from '@lib/circuits/ownershipVerifier';
import { checkIssuerNonRevState, checkUserState, getResolverByID } from '@lib/circuits/common';
import { DocumentLoader } from '@iden3/js-jsonld-merklization';
import { AtomicQueryMTPV2PubSignals, BaseConfig, byteEncoder } from '@0xpolygonid/js-sdk';
import {
AtomicQueryMTPV2PubSignals,
BaseConfig,
byteEncoder,
CircuitId
} from '@0xpolygonid/js-sdk';

const valuesSize = 64;
const defaultProofVerifyOpts = 1 * 60 * 60 * 1000; // 1 hour
Expand Down Expand Up @@ -52,7 +57,14 @@ export class AtomicQueryMTPV2PubSignalsVerifier
valueArraySize: valuesSize,
isRevocationChecked: this.pubSignals.isRevocationChecked
};
await checkQueryRequest(query, outs, schemaLoader, verifiablePresentation, false, opts);
await checkQueryV2Circuits(
CircuitId.AtomicQueryMTPV2,
query,
outs,
schemaLoader,
opts,
verifiablePresentation
);

return this.pubSignals;
}
Expand All @@ -79,7 +91,6 @@ export class AtomicQueryMTPV2PubSignalsVerifier
if (opts?.acceptedStateTransitionDelay) {
acceptedStateTransitionDelay = opts.acceptedStateTransitionDelay;
}

if (!issuerNonRevStateResolved.latest) {
const timeDiff =
Date.now() -
Expand Down
19 changes: 16 additions & 3 deletions src/circuits/atomicSigV2.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { PubSignalsVerifier, VerifyOpts } from '@lib/circuits/registry';
import { checkQueryRequest, ClaimOutputs, Query } from '@lib/circuits/query';
import { checkQueryV2Circuits, ClaimOutputs, Query } from '@lib/circuits/query';
import { Resolvers } from '@lib/state/resolver';
import { IDOwnershipPubSignals } from '@lib/circuits/ownershipVerifier';
import { checkIssuerNonRevState, checkUserState, getResolverByID } from '@lib/circuits/common';
import { getDateFromUnixTimestamp } from '@iden3/js-iden3-core';
import { DocumentLoader } from '@iden3/js-jsonld-merklization';
import { AtomicQuerySigV2PubSignals, BaseConfig, byteEncoder } from '@0xpolygonid/js-sdk';
import {
AtomicQuerySigV2PubSignals,
BaseConfig,
byteEncoder,
CircuitId
} from '@0xpolygonid/js-sdk';

const valuesSize = 64;
const defaultProofVerifyOpts = 1 * 60 * 60 * 1000; // 1 hour
Expand Down Expand Up @@ -45,7 +50,15 @@ export class AtomicQuerySigV2PubSignalsVerifier
valueArraySize: valuesSize,
isRevocationChecked: this.pubSignals.isRevocationChecked
};
await checkQueryRequest(query, outs, schemaLoader, verifiablePresentation, false, opts);

await checkQueryV2Circuits(
CircuitId.AtomicQuerySigV2,
query,
outs,
schemaLoader,
opts,
verifiablePresentation
);

return this.pubSignals;
}
Expand Down
84 changes: 80 additions & 4 deletions src/circuits/atomicV3.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
import { PubSignalsVerifier, VerifyOpts } from '@lib/circuits/registry';
import { checkQueryRequest, ClaimOutputs, Query } from '@lib/circuits/query';
import { ClaimOutputs, Query } from '@lib/circuits/query';
import { Resolvers } from '@lib/state/resolver';
import { IDOwnershipPubSignals } from '@lib/circuits/ownershipVerifier';
import { checkIssuerNonRevState, checkUserState, getResolverByID } from '@lib/circuits/common';
import { DID, getDateFromUnixTimestamp } from '@iden3/js-iden3-core';
import { DocumentLoader } from '@iden3/js-jsonld-merklization';
import { DocumentLoader, getDocumentLoader } from '@iden3/js-jsonld-merklization';
import {
AtomicQueryV3PubSignals,
BaseConfig,
byteEncoder,
checkCircuitOperator,
checkQueryRequest,
CircuitId,
JSONObject,
ProofType
Operators,
parseQueriesMetadata,
ProofType,
validateDisclosureNativeSDSupport,
validateEmptyCredentialSubjectNoopNativeSupport,
validateOperators,
verifyFieldValueInclusionNativeExistsSupport
} from '@0xpolygonid/js-sdk';
import { JsonLd } from 'jsonld/jsonld-spec';

const valuesSize = 64;
const defaultProofVerifyOpts = 1 * 60 * 60 * 1000; // 1 hour
Expand Down Expand Up @@ -56,7 +66,73 @@ export class AtomicQueryV3PubSignalsVerifier
isRevocationChecked: this.pubSignals.isRevocationChecked,
operatorOutput: this.pubSignals.operatorOutput
};
await checkQueryRequest(query, outs, schemaLoader, verifiablePresentation, true, opts);

if (!query.type) {
throw new Error(`proof query type is undefined`);
}

const loader = schemaLoader ?? getDocumentLoader();

// validate schema
let context: JsonLd;
try {
context = (await loader(query.context ?? '')).document;
} catch (e) {
throw new Error(`can't load schema for request query`);
}

const queriesMetadata = await parseQueriesMetadata(
query.type,
JSON.stringify(context),
query.credentialSubject as JSONObject,
{
documentLoader: loader
}
);

const circuitId = CircuitId.AtomicQueryV3;
await checkQueryRequest(
query,
queriesMetadata,
context,
outs,
CircuitId.AtomicQueryV3,
loader,
opts
);

const queryMetadata = queriesMetadata[0]; // only one query is supported

checkCircuitOperator(circuitId, outs.operator);
// validate selective disclosure
if (queryMetadata.operator === Operators.SD) {
try {
await validateDisclosureNativeSDSupport(
queryMetadata,
outs,
verifiablePresentation,
loader
);
} catch (e) {
throw new Error(`failed to validate selective disclosure: ${(e as Error).message}`);
}
} else if (!queryMetadata.fieldName && queryMetadata.operator == Operators.NOOP) {
try {
await validateEmptyCredentialSubjectNoopNativeSupport(outs);
} catch (e: unknown) {
throw new Error(`failed to validate operators: ${(e as Error).message}`);
}
} else {
try {
await validateOperators(queryMetadata, outs);
} catch (e) {
throw new Error(`failed to validate operators: ${(e as Error).message}`);
}
}

// verify field inclusion / non-inclusion

verifyFieldValueInclusionNativeExistsSupport(outs, queryMetadata);

const { proofType, verifierID, nullifier, nullifierSessionID, linkID } = this.pubSignals;

Expand Down
Loading
Loading