@0xpolygonid/js-sdk 1.17.8 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/browser/esm/index.js +976 -64
  2. package/dist/browser/esm/index.js.map +1 -1
  3. package/dist/browser/umd/index.js +976 -63
  4. package/dist/browser/umd/index.js.map +1 -1
  5. package/dist/node/cjs/circuits/atomic-query-mtp-v2-on-chain.js +10 -0
  6. package/dist/node/cjs/circuits/atomic-query-sig-v2-on-chain.js +10 -0
  7. package/dist/node/cjs/circuits/atomic-query-v3-on-chain.js +10 -0
  8. package/dist/node/cjs/iden3comm/constants.js +2 -0
  9. package/dist/node/cjs/iden3comm/handlers/contract-request.js +73 -10
  10. package/dist/node/cjs/storage/blockchain/abi/ZkpVerifier.json +530 -9
  11. package/dist/node/cjs/storage/blockchain/onchain-zkp-verifier.js +293 -42
  12. package/dist/node/cjs/utils/did-helper.js +37 -1
  13. package/dist/node/esm/circuits/atomic-query-mtp-v2-on-chain.js +10 -0
  14. package/dist/node/esm/circuits/atomic-query-sig-v2-on-chain.js +10 -0
  15. package/dist/node/esm/circuits/atomic-query-v3-on-chain.js +10 -0
  16. package/dist/node/esm/iden3comm/constants.js +2 -0
  17. package/dist/node/esm/iden3comm/handlers/contract-request.js +73 -10
  18. package/dist/node/esm/storage/blockchain/abi/ZkpVerifier.json +530 -9
  19. package/dist/node/esm/storage/blockchain/onchain-zkp-verifier.js +293 -42
  20. package/dist/node/esm/utils/did-helper.js +35 -0
  21. package/dist/types/circuits/atomic-query-mtp-v2-on-chain.d.ts +4 -2
  22. package/dist/types/circuits/atomic-query-sig-v2-on-chain.d.ts +4 -2
  23. package/dist/types/circuits/atomic-query-v3-on-chain.d.ts +4 -2
  24. package/dist/types/circuits/common.d.ts +31 -0
  25. package/dist/types/iden3comm/constants.d.ts +1 -0
  26. package/dist/types/iden3comm/handlers/contract-request.d.ts +14 -3
  27. package/dist/types/iden3comm/types/protocol/auth.d.ts +11 -1
  28. package/dist/types/iden3comm/types/protocol/contract-request.d.ts +16 -1
  29. package/dist/types/proof/verifiers/pub-signals-verifier.d.ts +2 -2
  30. package/dist/types/proof/verifiers/query.d.ts +4 -3
  31. package/dist/types/storage/blockchain/onchain-zkp-verifier.d.ts +44 -12
  32. package/dist/types/storage/entities/state.d.ts +44 -0
  33. package/dist/types/storage/interfaces/onchain-zkp-verifier.d.ts +22 -1
  34. package/dist/types/utils/did-helper.d.ts +12 -1
  35. package/dist/types/verifiable/presentation.d.ts +2 -2
  36. package/package.json +1 -1
@@ -1,7 +1,25 @@
1
1
  import { Signer } from 'ethers';
2
2
  import { EthConnectionConfig } from './state';
3
3
  import { IOnChainZKPVerifier } from '../interfaces/onchain-zkp-verifier';
4
- import { ContractInvokeTransactionData, ZeroKnowledgeProofResponse } from '../../iden3comm';
4
+ import { ContractInvokeTransactionData, JsonDocumentObjectValue, ZeroKnowledgeProofResponse } from '../../iden3comm';
5
+ /**
6
+ * Supported function signature for SubmitZKPResponse
7
+ */
8
+ export declare enum FunctionSignatures {
9
+ /**
10
+ * solidity identifier for function signature:
11
+ * function submitZKPResponse(uint64 requestId, uint256[] calldata inputs,
12
+ * uint256[2] calldata a, uint256[2][2] calldata b, uint256[2] calldata c) public
13
+ */
14
+ SumbitZKPResponseV1 = "b68967e2",
15
+ SumbitZKPResponseV2 = "ade09fcd"
16
+ }
17
+ /**
18
+ * OnChainZKPVerifierOptions represents OnChainZKPVerifier options
19
+ */
20
+ export type OnChainZKPVerifierOptions = {
21
+ didResolverUrl?: string;
22
+ };
5
23
  /**
6
24
  * OnChainZKPVerifier is a class that allows to interact with the OnChainZKPVerifier contract
7
25
  * and submitZKPResponse.
@@ -11,26 +29,40 @@ import { ContractInvokeTransactionData, ZeroKnowledgeProofResponse } from '../..
11
29
  */
12
30
  export declare class OnChainZKPVerifier implements IOnChainZKPVerifier {
13
31
  private readonly _configs;
32
+ private readonly _opts?;
14
33
  /**
15
- * solidity identifier for function signature:
16
- * function submitZKPResponse(uint64 requestId, uint256[] calldata inputs,
17
- * uint256[2] calldata a, uint256[2][2] calldata b, uint256[2] calldata c) public
34
+ * supported circuits
35
+ */
36
+ private readonly _supportedCircuits;
37
+ /**
38
+ * abi coder to encode/decode structures to solidity bytes
18
39
  */
19
- private readonly _supportedMethodId;
40
+ private readonly _abiCoder;
20
41
  /**
21
42
  *
22
43
  * Creates an instance of OnChainZKPVerifier.
23
44
  * @beta
24
45
  * @param {EthConnectionConfig[]} - array of ETH configs
25
46
  */
26
- constructor(_configs: EthConnectionConfig[]);
47
+ constructor(_configs: EthConnectionConfig[], _opts?: OnChainZKPVerifierOptions | undefined);
27
48
  /**
28
- * Submit ZKP Responses to OnChainZKPVerifier contract.
29
- * @beta
30
- * @param {Signer} ethSigner - tx signer
31
- * @param {txData} ContractInvokeTransactionData - transaction data
32
- * @param {ZeroKnowledgeProofResponse[]} zkProofResponses - zkProofResponses
33
- * @returns {Promise<Map<string, ZeroKnowledgeProofResponse>>} - map of transaction hash - ZeroKnowledgeProofResponse
49
+ * {@inheritDoc IOnChainZKPVerifier.prepareTxArgsSubmitV1}
50
+ */
51
+ prepareTxArgsSubmitV1(txData: ContractInvokeTransactionData, zkProofResponse: ZeroKnowledgeProofResponse): Promise<JsonDocumentObjectValue[]>;
52
+ /**
53
+ * {@inheritDoc IOnChainZKPVerifier.submitZKPResponse}
34
54
  */
35
55
  submitZKPResponse(ethSigner: Signer, txData: ContractInvokeTransactionData, zkProofResponses: ZeroKnowledgeProofResponse[]): Promise<Map<string, ZeroKnowledgeProofResponse>>;
56
+ /**
57
+ * {@inheritDoc IOnChainZKPVerifier.submitZKPResponseV2}
58
+ */
59
+ submitZKPResponseV2(ethSigner: Signer, txData: ContractInvokeTransactionData, zkProofResponses: ZeroKnowledgeProofResponse[]): Promise<Map<string, ZeroKnowledgeProofResponse[]>>;
60
+ prepareTxArgsSubmitV2(txData: ContractInvokeTransactionData, zkProofResponses: ZeroKnowledgeProofResponse[]): Promise<JsonDocumentObjectValue[]>;
61
+ private packZkpProof;
62
+ private packCrossChainProofs;
63
+ private packGlobalStateMsg;
64
+ private packIdentityStateMsg;
65
+ private packMetadatas;
66
+ private getOnChainGistRootStatePubSignals;
67
+ private resolveDidDocumentEip712MessageAndSignature;
36
68
  }
@@ -43,3 +43,47 @@ export interface RootInfo {
43
43
  createdAtBlock: bigint;
44
44
  replacedAtBlock: bigint;
45
45
  }
46
+ /**
47
+ * identity state message
48
+ *
49
+ * @public
50
+ * @interface IdentityStateMsg
51
+ */
52
+ export interface IdentityStateMsg {
53
+ timestamp: number;
54
+ id: bigint;
55
+ state: bigint;
56
+ replacedAtTimestamp: number;
57
+ }
58
+ /**
59
+ * global state message
60
+ *
61
+ * @public
62
+ * @interface GlobalStateMsg
63
+ */
64
+ export interface GlobalStateMsg {
65
+ timestamp: number;
66
+ idType: string;
67
+ root: bigint;
68
+ replacedAtTimestamp: number;
69
+ }
70
+ /**
71
+ * identity state update
72
+ *
73
+ * @public
74
+ * @interface IdentityStateUpdate
75
+ */
76
+ export interface IdentityStateUpdate {
77
+ idStateMsg: IdentityStateMsg;
78
+ signature: string;
79
+ }
80
+ /**
81
+ * global state update
82
+ *
83
+ * @public
84
+ * @interface GlobalStateUpdate
85
+ */
86
+ export interface GlobalStateUpdate {
87
+ globalStateMsg: GlobalStateMsg;
88
+ signature: string;
89
+ }
@@ -1,5 +1,5 @@
1
1
  import { Signer } from 'ethers';
2
- import { ContractInvokeTransactionData, ZeroKnowledgeProofResponse } from '../../iden3comm';
2
+ import { ContractInvokeTransactionData, JsonDocumentObjectValue, ZeroKnowledgeProofResponse } from '../../iden3comm';
3
3
  /**
4
4
  * Interface that defines methods for ZKP verifier
5
5
  *
@@ -16,4 +16,25 @@ export interface IOnChainZKPVerifier {
16
16
  * @returns {Promise<Map<string, ZeroKnowledgeProofResponse>>} - map of transaction hash - ZeroKnowledgeProofResponse
17
17
  */
18
18
  submitZKPResponse(ethSigner: Signer, txData: ContractInvokeTransactionData, zkProofResponses: ZeroKnowledgeProofResponse[]): Promise<Map<string, ZeroKnowledgeProofResponse>>;
19
+ /**
20
+ * Submit ZKP Response V2 to OnChainZKPVerifier contract.
21
+ * @beta
22
+ * @param {Signer} ethSigner - tx signer
23
+ * @param {txData} ContractInvokeTransactionData - transaction data
24
+ * @param {ZeroKnowledgeProofResponse[]} zkProofResponses - zkProofResponses
25
+ * @returns {Promise<Map<string, ZeroKnowledgeProofResponse[]>>} - map of transaction hash - ZeroKnowledgeProofResponse[]
26
+ */
27
+ submitZKPResponseV2(ethSigner: Signer, txData: ContractInvokeTransactionData, zkProofResponses: ZeroKnowledgeProofResponse[]): Promise<Map<string, ZeroKnowledgeProofResponse[]>>;
28
+ /**
29
+ * Returns tx args for the ZKP verifier contract submission (singe tx args for each response).
30
+ * @param txData
31
+ * @param zkProofResponse
32
+ */
33
+ prepareTxArgsSubmitV1(txData: ContractInvokeTransactionData, zkProofResponse: ZeroKnowledgeProofResponse): Promise<JsonDocumentObjectValue[]>;
34
+ /**
35
+ * Returns args for the ZKP verifier contract submission V2 (single tx args for an array of responses).
36
+ * @param txData
37
+ * @param zkProofResponses
38
+ */
39
+ prepareTxArgsSubmitV2(txData: ContractInvokeTransactionData, zkProofResponses: ZeroKnowledgeProofResponse[]): Promise<JsonDocumentObjectValue[]>;
19
40
  }
@@ -1,6 +1,12 @@
1
1
  import { Id, DID } from '@iden3/js-iden3-core';
2
2
  import { Hash } from '@iden3/js-merkletree';
3
- import { VerificationMethod } from 'did-resolver';
3
+ import { VerificationMethod, DIDResolutionMetadata } from 'did-resolver';
4
+ /**
5
+ * Supported DID Document Signatures
6
+ */
7
+ export declare enum DIDDocumentSignature {
8
+ EthereumEip712Signature2021 = "EthereumEip712Signature2021"
9
+ }
4
10
  /**
5
11
  * Checks if state is genesis state
6
12
  *
@@ -23,4 +29,9 @@ export declare const buildVerifierId: (address: string, info: {
23
29
  }) => Id;
24
30
  export declare const validateDIDDocumentAuth: (did: DID, resolverURL: string, state: Hash) => Promise<void>;
25
31
  export declare const resolveDIDDocumentAuth: (did: DID, resolveURL: string, state?: Hash) => Promise<VerificationMethod | undefined>;
32
+ export declare const resolveDidDocument: (did: DID, resolverUrl: string, opts?: {
33
+ state?: Hash;
34
+ gist?: Hash;
35
+ signature?: DIDDocumentSignature;
36
+ }) => Promise<DIDResolutionMetadata>;
26
37
  export declare const buildDIDFromEthPubKey: (didType: Uint8Array, pubKeyEth: string) => DID;
@@ -1,10 +1,10 @@
1
1
  import { Options, Path } from '@iden3/js-jsonld-merklization';
2
2
  import { W3CCredential } from './credential';
3
3
  import { QueryMetadata } from '../proof';
4
- import { JsonDocumentObject } from '../iden3comm';
4
+ import { VerifiablePresentation, JsonDocumentObject } from '../iden3comm';
5
5
  export declare const stringByPath: (obj: {
6
6
  [key: string]: unknown;
7
7
  }, path: string) => string;
8
8
  export declare const buildFieldPath: (ldSchema: string, contextType: string, field: string, opts?: Options) => Promise<Path>;
9
9
  export declare const findValue: (fieldName: string, credential: W3CCredential) => JsonDocumentObject;
10
- export declare const createVerifiablePresentation: (context: string, tp: string, credential: W3CCredential, queries: QueryMetadata[]) => object;
10
+ export declare const createVerifiablePresentation: (context: string, tp: string, credential: W3CCredential, queries: QueryMetadata[]) => VerifiablePresentation;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xpolygonid/js-sdk",
3
- "version": "1.17.8",
3
+ "version": "1.18.0",
4
4
  "description": "SDK to work with Polygon ID",
5
5
  "main": "dist/node/cjs/index.js",
6
6
  "module": "dist/node/esm/index.js",