@mocanetwork/privado-js-sdk 1.0.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.
- package/README.md +75 -0
- package/dist/browser/esm/index.js +14901 -0
- package/dist/browser/esm/index.js.map +1 -0
- package/dist/browser/umd/index.global.js +678 -0
- package/dist/browser/umd/index.global.js.map +1 -0
- package/dist/node/cjs/index.cjs +15418 -0
- package/dist/node/cjs/index.cjs.map +1 -0
- package/dist/node/esm/index.js +14901 -0
- package/dist/node/esm/index.js.map +1 -0
- package/dist/types/blockchain/index.d.ts +2 -0
- package/dist/types/blockchain/index.d.ts.map +1 -0
- package/dist/types/blockchain/transaction-service.d.ts +81 -0
- package/dist/types/blockchain/transaction-service.d.ts.map +1 -0
- package/dist/types/circuits/atomic-query-mtp-v2-on-chain.d.ts +70 -0
- package/dist/types/circuits/atomic-query-mtp-v2-on-chain.d.ts.map +1 -0
- package/dist/types/circuits/atomic-query-mtp-v2.d.ts +63 -0
- package/dist/types/circuits/atomic-query-mtp-v2.d.ts.map +1 -0
- package/dist/types/circuits/atomic-query-sig-v2-on-chain.d.ts +137 -0
- package/dist/types/circuits/atomic-query-sig-v2-on-chain.d.ts.map +1 -0
- package/dist/types/circuits/atomic-query-sig-v2.d.ts +64 -0
- package/dist/types/circuits/atomic-query-sig-v2.d.ts.map +1 -0
- package/dist/types/circuits/atomic-query-v3-on-chain.d.ts +141 -0
- package/dist/types/circuits/atomic-query-v3-on-chain.d.ts.map +1 -0
- package/dist/types/circuits/atomic-query-v3.d.ts +121 -0
- package/dist/types/circuits/atomic-query-v3.d.ts.map +1 -0
- package/dist/types/circuits/auth-v2.d.ts +46 -0
- package/dist/types/circuits/auth-v2.d.ts.map +1 -0
- package/dist/types/circuits/common.d.ts +153 -0
- package/dist/types/circuits/common.d.ts.map +1 -0
- package/dist/types/circuits/comparer.d.ts +122 -0
- package/dist/types/circuits/comparer.d.ts.map +1 -0
- package/dist/types/circuits/index.d.ts +13 -0
- package/dist/types/circuits/index.d.ts.map +1 -0
- package/dist/types/circuits/linked-multi-query.d.ts +38 -0
- package/dist/types/circuits/linked-multi-query.d.ts.map +1 -0
- package/dist/types/circuits/models.d.ts +189 -0
- package/dist/types/circuits/models.d.ts.map +1 -0
- package/dist/types/circuits/state-transition.d.ts +49 -0
- package/dist/types/circuits/state-transition.d.ts.map +1 -0
- package/dist/types/credentials/credential-wallet.d.ts +200 -0
- package/dist/types/credentials/credential-wallet.d.ts.map +1 -0
- package/dist/types/credentials/index.d.ts +12 -0
- package/dist/types/credentials/index.d.ts.map +1 -0
- package/dist/types/credentials/models.d.ts +84 -0
- package/dist/types/credentials/models.d.ts.map +1 -0
- package/dist/types/credentials/rhs.d.ts +38 -0
- package/dist/types/credentials/rhs.d.ts.map +1 -0
- package/dist/types/credentials/status/agent-revocation.d.ts +20 -0
- package/dist/types/credentials/status/agent-revocation.d.ts.map +1 -0
- package/dist/types/credentials/status/credential-status-publisher.d.ts +73 -0
- package/dist/types/credentials/status/credential-status-publisher.d.ts.map +1 -0
- package/dist/types/credentials/status/did-resolver-revocation.d.ts +8 -0
- package/dist/types/credentials/status/did-resolver-revocation.d.ts.map +1 -0
- package/dist/types/credentials/status/on-chain-revocation.d.ts +58 -0
- package/dist/types/credentials/status/on-chain-revocation.d.ts.map +1 -0
- package/dist/types/credentials/status/resolver.d.ts +69 -0
- package/dist/types/credentials/status/resolver.d.ts.map +1 -0
- package/dist/types/credentials/status/reverse-sparse-merkle-tree.d.ts +126 -0
- package/dist/types/credentials/status/reverse-sparse-merkle-tree.d.ts.map +1 -0
- package/dist/types/credentials/status/sparse-merkle-tree.d.ts +38 -0
- package/dist/types/credentials/status/sparse-merkle-tree.d.ts.map +1 -0
- package/dist/types/credentials/utils.d.ts +15 -0
- package/dist/types/credentials/utils.d.ts.map +1 -0
- package/dist/types/iden3comm/constants.d.ts +61 -0
- package/dist/types/iden3comm/constants.d.ts.map +1 -0
- package/dist/types/iden3comm/errors.d.ts +10 -0
- package/dist/types/iden3comm/errors.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/auth.d.ts +157 -0
- package/dist/types/iden3comm/handlers/auth.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/common.d.ts +72 -0
- package/dist/types/iden3comm/handlers/common.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/contract-request.d.ts +96 -0
- package/dist/types/iden3comm/handlers/contract-request.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/credential-proposal.d.ts +120 -0
- package/dist/types/iden3comm/handlers/credential-proposal.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/discovery-protocol.d.ts +101 -0
- package/dist/types/iden3comm/handlers/discovery-protocol.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/fetch.d.ts +130 -0
- package/dist/types/iden3comm/handlers/fetch.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/index.d.ts +12 -0
- package/dist/types/iden3comm/handlers/index.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/message-handler.d.ts +93 -0
- package/dist/types/iden3comm/handlers/message-handler.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/payment.d.ts +167 -0
- package/dist/types/iden3comm/handlers/payment.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/problem-report.d.ts +18 -0
- package/dist/types/iden3comm/handlers/problem-report.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/refresh.d.ts +57 -0
- package/dist/types/iden3comm/handlers/refresh.d.ts.map +1 -0
- package/dist/types/iden3comm/handlers/revocation-status.d.ts +76 -0
- package/dist/types/iden3comm/handlers/revocation-status.d.ts.map +1 -0
- package/dist/types/iden3comm/index.d.ts +9 -0
- package/dist/types/iden3comm/index.d.ts.map +1 -0
- package/dist/types/iden3comm/packageManager.d.ts +47 -0
- package/dist/types/iden3comm/packageManager.d.ts.map +1 -0
- package/dist/types/iden3comm/packers/index.d.ts +4 -0
- package/dist/types/iden3comm/packers/index.d.ts.map +1 -0
- package/dist/types/iden3comm/packers/jws.d.ts +56 -0
- package/dist/types/iden3comm/packers/jws.d.ts.map +1 -0
- package/dist/types/iden3comm/packers/plain.d.ts +47 -0
- package/dist/types/iden3comm/packers/plain.d.ts.map +1 -0
- package/dist/types/iden3comm/packers/zkp.d.ts +98 -0
- package/dist/types/iden3comm/packers/zkp.d.ts.map +1 -0
- package/dist/types/iden3comm/types/index.d.ts +17 -0
- package/dist/types/iden3comm/types/index.d.ts.map +1 -0
- package/dist/types/iden3comm/types/models.d.ts +7 -0
- package/dist/types/iden3comm/types/models.d.ts.map +1 -0
- package/dist/types/iden3comm/types/packageManager.d.ts +100 -0
- package/dist/types/iden3comm/types/packageManager.d.ts.map +1 -0
- package/dist/types/iden3comm/types/packer.d.ts +158 -0
- package/dist/types/iden3comm/types/packer.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/accept-profile.d.ts +8 -0
- package/dist/types/iden3comm/types/protocol/accept-profile.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/attachment.d.ts +11 -0
- package/dist/types/iden3comm/types/protocol/attachment.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/auth.d.ts +90 -0
- package/dist/types/iden3comm/types/protocol/auth.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/common.d.ts +11 -0
- package/dist/types/iden3comm/types/protocol/common.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/contract-request.d.ts +62 -0
- package/dist/types/iden3comm/types/protocol/contract-request.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/credentials.d.ts +82 -0
- package/dist/types/iden3comm/types/protocol/credentials.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/discovery-protocol.d.ts +42 -0
- package/dist/types/iden3comm/types/protocol/discovery-protocol.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/messages.d.ts +12 -0
- package/dist/types/iden3comm/types/protocol/messages.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/payment.d.ts +178 -0
- package/dist/types/iden3comm/types/protocol/payment.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/problem-report.d.ts +17 -0
- package/dist/types/iden3comm/types/protocol/problem-report.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/proof.d.ts +22 -0
- package/dist/types/iden3comm/types/protocol/proof.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/proposal-request.d.ts +33 -0
- package/dist/types/iden3comm/types/protocol/proposal-request.d.ts.map +1 -0
- package/dist/types/iden3comm/types/protocol/revocation.d.ts +20 -0
- package/dist/types/iden3comm/types/protocol/revocation.d.ts.map +1 -0
- package/dist/types/iden3comm/utils/accept-profile.d.ts +4 -0
- package/dist/types/iden3comm/utils/accept-profile.d.ts.map +1 -0
- package/dist/types/iden3comm/utils/did.d.ts +8 -0
- package/dist/types/iden3comm/utils/did.d.ts.map +1 -0
- package/dist/types/iden3comm/utils/envelope.d.ts +32 -0
- package/dist/types/iden3comm/utils/envelope.d.ts.map +1 -0
- package/dist/types/iden3comm/utils/index.d.ts +5 -0
- package/dist/types/iden3comm/utils/index.d.ts.map +1 -0
- package/dist/types/iden3comm/utils/message.d.ts +20 -0
- package/dist/types/iden3comm/utils/message.d.ts.map +1 -0
- package/dist/types/identity/common.d.ts +27 -0
- package/dist/types/identity/common.d.ts.map +1 -0
- package/dist/types/identity/identity-wallet.d.ts +472 -0
- package/dist/types/identity/identity-wallet.d.ts.map +1 -0
- package/dist/types/identity/index.d.ts +3 -0
- package/dist/types/identity/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/kms/index.d.ts +5 -0
- package/dist/types/kms/index.d.ts.map +1 -0
- package/dist/types/kms/key-providers/bjj-provider.d.ts +54 -0
- package/dist/types/kms/key-providers/bjj-provider.d.ts.map +1 -0
- package/dist/types/kms/key-providers/ed25519-provider.d.ts +61 -0
- package/dist/types/kms/key-providers/ed25519-provider.d.ts.map +1 -0
- package/dist/types/kms/key-providers/index.d.ts +4 -0
- package/dist/types/kms/key-providers/index.d.ts.map +1 -0
- package/dist/types/kms/key-providers/secp256k1-provider.d.ts +62 -0
- package/dist/types/kms/key-providers/secp256k1-provider.d.ts.map +1 -0
- package/dist/types/kms/kms.d.ts +120 -0
- package/dist/types/kms/kms.d.ts.map +1 -0
- package/dist/types/kms/provider-helpers.d.ts +10 -0
- package/dist/types/kms/provider-helpers.d.ts.map +1 -0
- package/dist/types/kms/store/abstract-key-store.d.ts +41 -0
- package/dist/types/kms/store/abstract-key-store.d.ts.map +1 -0
- package/dist/types/kms/store/index.d.ts +6 -0
- package/dist/types/kms/store/index.d.ts.map +1 -0
- package/dist/types/kms/store/indexed-db-key-store.d.ts +44 -0
- package/dist/types/kms/store/indexed-db-key-store.d.ts.map +1 -0
- package/dist/types/kms/store/local-storage-key-store.d.ts +42 -0
- package/dist/types/kms/store/local-storage-key-store.d.ts.map +1 -0
- package/dist/types/kms/store/memory-key-store.d.ts +24 -0
- package/dist/types/kms/store/memory-key-store.d.ts.map +1 -0
- package/dist/types/kms/store/types.d.ts +21 -0
- package/dist/types/kms/store/types.d.ts.map +1 -0
- package/dist/types/proof/common.d.ts +49 -0
- package/dist/types/proof/common.d.ts.map +1 -0
- package/dist/types/proof/index.d.ts +5 -0
- package/dist/types/proof/index.d.ts.map +1 -0
- package/dist/types/proof/proof-service.d.ts +169 -0
- package/dist/types/proof/proof-service.d.ts.map +1 -0
- package/dist/types/proof/provers/index.d.ts +4 -0
- package/dist/types/proof/provers/index.d.ts.map +1 -0
- package/dist/types/proof/provers/inputs-generator.d.ts +57 -0
- package/dist/types/proof/provers/inputs-generator.d.ts.map +1 -0
- package/dist/types/proof/provers/prover.d.ts +56 -0
- package/dist/types/proof/provers/prover.d.ts.map +1 -0
- package/dist/types/proof/provers/witness_calculator.d.ts +17 -0
- package/dist/types/proof/provers/witness_calculator.d.ts.map +1 -0
- package/dist/types/proof/verifiers/index.d.ts +4 -0
- package/dist/types/proof/verifiers/index.d.ts.map +1 -0
- package/dist/types/proof/verifiers/pub-signals-verifier.d.ts +60 -0
- package/dist/types/proof/verifiers/pub-signals-verifier.d.ts.map +1 -0
- package/dist/types/proof/verifiers/query-hash.d.ts +4 -0
- package/dist/types/proof/verifiers/query-hash.d.ts.map +1 -0
- package/dist/types/proof/verifiers/query.d.ts +43 -0
- package/dist/types/proof/verifiers/query.d.ts.map +1 -0
- package/dist/types/schema-processor/index.d.ts +4 -0
- package/dist/types/schema-processor/index.d.ts.map +1 -0
- package/dist/types/schema-processor/json/index.d.ts +3 -0
- package/dist/types/schema-processor/json/index.d.ts.map +1 -0
- package/dist/types/schema-processor/json/parser.d.ts +141 -0
- package/dist/types/schema-processor/json/parser.d.ts.map +1 -0
- package/dist/types/schema-processor/json/validator.d.ts +26 -0
- package/dist/types/schema-processor/json/validator.d.ts.map +1 -0
- package/dist/types/schema-processor/jsonld/cache.d.ts +3 -0
- package/dist/types/schema-processor/jsonld/cache.d.ts.map +1 -0
- package/dist/types/schema-processor/jsonld/index.d.ts +3 -0
- package/dist/types/schema-processor/jsonld/index.d.ts.map +1 -0
- package/dist/types/schema-processor/jsonld/parser.d.ts +30 -0
- package/dist/types/schema-processor/jsonld/parser.d.ts.map +1 -0
- package/dist/types/schema-processor/utils.d.ts +54 -0
- package/dist/types/schema-processor/utils.d.ts.map +1 -0
- package/dist/types/storage/blockchain/common.d.ts +8 -0
- package/dist/types/storage/blockchain/common.d.ts.map +1 -0
- package/dist/types/storage/blockchain/did-resolver-readonly-storage.d.ts +17 -0
- package/dist/types/storage/blockchain/did-resolver-readonly-storage.d.ts.map +1 -0
- package/dist/types/storage/blockchain/erc20-helper.d.ts +20 -0
- package/dist/types/storage/blockchain/erc20-helper.d.ts.map +1 -0
- package/dist/types/storage/blockchain/errors.d.ts +4 -0
- package/dist/types/storage/blockchain/errors.d.ts.map +1 -0
- package/dist/types/storage/blockchain/index.d.ts +8 -0
- package/dist/types/storage/blockchain/index.d.ts.map +1 -0
- package/dist/types/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.d.ts +67 -0
- package/dist/types/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.d.ts.map +1 -0
- package/dist/types/storage/blockchain/onchain-issuer.d.ts +41 -0
- package/dist/types/storage/blockchain/onchain-issuer.d.ts.map +1 -0
- package/dist/types/storage/blockchain/onchain-revocation.d.ts +41 -0
- package/dist/types/storage/blockchain/onchain-revocation.d.ts.map +1 -0
- package/dist/types/storage/blockchain/onchain-zkp-verifier.d.ts +116 -0
- package/dist/types/storage/blockchain/onchain-zkp-verifier.d.ts.map +1 -0
- package/dist/types/storage/blockchain/state.d.ts +127 -0
- package/dist/types/storage/blockchain/state.d.ts.map +1 -0
- package/dist/types/storage/entities/circuitData.d.ts +8 -0
- package/dist/types/storage/entities/circuitData.d.ts.map +1 -0
- package/dist/types/storage/entities/identity.d.ts +17 -0
- package/dist/types/storage/entities/identity.d.ts.map +1 -0
- package/dist/types/storage/entities/index.d.ts +5 -0
- package/dist/types/storage/entities/index.d.ts.map +1 -0
- package/dist/types/storage/entities/mt.d.ts +22 -0
- package/dist/types/storage/entities/mt.d.ts.map +1 -0
- package/dist/types/storage/entities/state.d.ts +92 -0
- package/dist/types/storage/entities/state.d.ts.map +1 -0
- package/dist/types/storage/errors.d.ts +9 -0
- package/dist/types/storage/errors.d.ts.map +1 -0
- package/dist/types/storage/filters/index.d.ts +2 -0
- package/dist/types/storage/filters/index.d.ts.map +1 -0
- package/dist/types/storage/filters/jsonQuery.d.ts +83 -0
- package/dist/types/storage/filters/jsonQuery.d.ts.map +1 -0
- package/dist/types/storage/fs/circuits-storage.d.ts +64 -0
- package/dist/types/storage/fs/circuits-storage.d.ts.map +1 -0
- package/dist/types/storage/fs/index.d.ts +2 -0
- package/dist/types/storage/fs/index.d.ts.map +1 -0
- package/dist/types/storage/index.d.ts +10 -0
- package/dist/types/storage/index.d.ts.map +1 -0
- package/dist/types/storage/indexed-db/data-source.d.ts +44 -0
- package/dist/types/storage/indexed-db/data-source.d.ts.map +1 -0
- package/dist/types/storage/indexed-db/index.d.ts +3 -0
- package/dist/types/storage/indexed-db/index.d.ts.map +1 -0
- package/dist/types/storage/indexed-db/merkletree.d.ts +43 -0
- package/dist/types/storage/indexed-db/merkletree.d.ts.map +1 -0
- package/dist/types/storage/interfaces/circuits.d.ts +26 -0
- package/dist/types/storage/interfaces/circuits.d.ts.map +1 -0
- package/dist/types/storage/interfaces/credentials.d.ts +53 -0
- package/dist/types/storage/interfaces/credentials.d.ts.map +1 -0
- package/dist/types/storage/interfaces/data-source.d.ts +39 -0
- package/dist/types/storage/interfaces/data-source.d.ts.map +1 -0
- package/dist/types/storage/interfaces/data-storage.d.ts +17 -0
- package/dist/types/storage/interfaces/data-storage.d.ts.map +1 -0
- package/dist/types/storage/interfaces/identity.d.ts +70 -0
- package/dist/types/storage/interfaces/identity.d.ts.map +1 -0
- package/dist/types/storage/interfaces/index.d.ts +11 -0
- package/dist/types/storage/interfaces/index.d.ts.map +1 -0
- package/dist/types/storage/interfaces/merkletree.d.ts +44 -0
- package/dist/types/storage/interfaces/merkletree.d.ts.map +1 -0
- package/dist/types/storage/interfaces/onchain-issuer.d.ts +13 -0
- package/dist/types/storage/interfaces/onchain-issuer.d.ts.map +1 -0
- package/dist/types/storage/interfaces/onchain-revocation.d.ts +19 -0
- package/dist/types/storage/interfaces/onchain-revocation.d.ts.map +1 -0
- package/dist/types/storage/interfaces/onchain-zkp-verifier.d.ts +63 -0
- package/dist/types/storage/interfaces/onchain-zkp-verifier.d.ts.map +1 -0
- package/dist/types/storage/interfaces/state.d.ts +74 -0
- package/dist/types/storage/interfaces/state.d.ts.map +1 -0
- package/dist/types/storage/local-storage/data-source.d.ts +41 -0
- package/dist/types/storage/local-storage/data-source.d.ts.map +1 -0
- package/dist/types/storage/local-storage/index.d.ts +3 -0
- package/dist/types/storage/local-storage/index.d.ts.map +1 -0
- package/dist/types/storage/local-storage/merkletree.d.ts +41 -0
- package/dist/types/storage/local-storage/merkletree.d.ts.map +1 -0
- package/dist/types/storage/memory/cache-lru.d.ts +11 -0
- package/dist/types/storage/memory/cache-lru.d.ts.map +1 -0
- package/dist/types/storage/memory/data-source.d.ts +20 -0
- package/dist/types/storage/memory/data-source.d.ts.map +1 -0
- package/dist/types/storage/memory/index.d.ts +4 -0
- package/dist/types/storage/memory/index.d.ts.map +1 -0
- package/dist/types/storage/memory/merkletree.d.ts +48 -0
- package/dist/types/storage/memory/merkletree.d.ts.map +1 -0
- package/dist/types/storage/shared/circuit-storage.d.ts +39 -0
- package/dist/types/storage/shared/circuit-storage.d.ts.map +1 -0
- package/dist/types/storage/shared/credential-storage.d.ts +39 -0
- package/dist/types/storage/shared/credential-storage.d.ts.map +1 -0
- package/dist/types/storage/shared/identity-storage.d.ts +45 -0
- package/dist/types/storage/shared/identity-storage.d.ts.map +1 -0
- package/dist/types/storage/shared/index.d.ts +4 -0
- package/dist/types/storage/shared/index.d.ts.map +1 -0
- package/dist/types/storage/utils.d.ts +4 -0
- package/dist/types/storage/utils.d.ts.map +1 -0
- package/dist/types/utils/compare-func.d.ts +2 -0
- package/dist/types/utils/compare-func.d.ts.map +1 -0
- package/dist/types/utils/did-helper.d.ts +38 -0
- package/dist/types/utils/did-helper.d.ts.map +1 -0
- package/dist/types/utils/encoding.d.ts +25 -0
- package/dist/types/utils/encoding.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +8 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/message-bus.d.ts +63 -0
- package/dist/types/utils/message-bus.d.ts.map +1 -0
- package/dist/types/utils/object.d.ts +10 -0
- package/dist/types/utils/object.d.ts.map +1 -0
- package/dist/types/utils/payments/evm.d.ts +19 -0
- package/dist/types/utils/payments/evm.d.ts.map +1 -0
- package/dist/types/utils/payments/solana.d.ts +88 -0
- package/dist/types/utils/payments/solana.d.ts.map +1 -0
- package/dist/types/verifiable/constants.d.ts +188 -0
- package/dist/types/verifiable/constants.d.ts.map +1 -0
- package/dist/types/verifiable/core-utils.d.ts +87 -0
- package/dist/types/verifiable/core-utils.d.ts.map +1 -0
- package/dist/types/verifiable/credential.d.ts +150 -0
- package/dist/types/verifiable/credential.d.ts.map +1 -0
- package/dist/types/verifiable/index.d.ts +7 -0
- package/dist/types/verifiable/index.d.ts.map +1 -0
- package/dist/types/verifiable/presentation.d.ts +11 -0
- package/dist/types/verifiable/presentation.d.ts.map +1 -0
- package/dist/types/verifiable/proof.d.ts +211 -0
- package/dist/types/verifiable/proof.d.ts.map +1 -0
- package/dist/types/verifiable/schema.d.ts +3 -0
- package/dist/types/verifiable/schema.d.ts.map +1 -0
- package/package.json +104 -0
- package/src/blockchain/index.ts +1 -0
- package/src/blockchain/transaction-service.ts +121 -0
- package/src/circuits/atomic-query-mtp-v2-on-chain.ts +338 -0
- package/src/circuits/atomic-query-mtp-v2.ts +283 -0
- package/src/circuits/atomic-query-sig-v2-on-chain.ts +411 -0
- package/src/circuits/atomic-query-sig-v2.ts +340 -0
- package/src/circuits/atomic-query-v3-on-chain.ts +531 -0
- package/src/circuits/atomic-query-v3.ts +461 -0
- package/src/circuits/auth-v2.ts +159 -0
- package/src/circuits/common.ts +261 -0
- package/src/circuits/comparer.ts +227 -0
- package/src/circuits/index.ts +12 -0
- package/src/circuits/linked-multi-query.ts +180 -0
- package/src/circuits/models.ts +263 -0
- package/src/circuits/state-transition.ts +139 -0
- package/src/credentials/credential-wallet.ts +353 -0
- package/src/credentials/index.ts +11 -0
- package/src/credentials/models.ts +93 -0
- package/src/credentials/rhs.ts +176 -0
- package/src/credentials/status/agent-revocation.ts +69 -0
- package/src/credentials/status/credential-status-publisher.ts +143 -0
- package/src/credentials/status/did-resolver-revocation.ts +24 -0
- package/src/credentials/status/on-chain-revocation.ts +174 -0
- package/src/credentials/status/resolver.ts +81 -0
- package/src/credentials/status/reverse-sparse-merkle-tree.ts +366 -0
- package/src/credentials/status/sparse-merkle-tree.ts +50 -0
- package/src/credentials/utils.ts +36 -0
- package/src/iden3comm/constants.ts +119 -0
- package/src/iden3comm/errors.ts +14 -0
- package/src/iden3comm/handlers/auth.ts +520 -0
- package/src/iden3comm/handlers/common.ts +324 -0
- package/src/iden3comm/handlers/contract-request.ts +367 -0
- package/src/iden3comm/handlers/credential-proposal.ts +371 -0
- package/src/iden3comm/handlers/discovery-protocol.ts +277 -0
- package/src/iden3comm/handlers/fetch.ts +450 -0
- package/src/iden3comm/handlers/index.ts +11 -0
- package/src/iden3comm/handlers/message-handler.ts +165 -0
- package/src/iden3comm/handlers/payment.ts +698 -0
- package/src/iden3comm/handlers/problem-report.ts +41 -0
- package/src/iden3comm/handlers/refresh.ts +138 -0
- package/src/iden3comm/handlers/revocation-status.ts +228 -0
- package/src/iden3comm/index.ts +9 -0
- package/src/iden3comm/packageManager.ts +143 -0
- package/src/iden3comm/packers/index.ts +3 -0
- package/src/iden3comm/packers/jws.ts +225 -0
- package/src/iden3comm/packers/plain.ts +86 -0
- package/src/iden3comm/packers/zkp.ts +243 -0
- package/src/iden3comm/types/index.ts +17 -0
- package/src/iden3comm/types/models.ts +7 -0
- package/src/iden3comm/types/packageManager.ts +112 -0
- package/src/iden3comm/types/packer.ts +190 -0
- package/src/iden3comm/types/protocol/accept-profile.ts +14 -0
- package/src/iden3comm/types/protocol/attachment.ts +12 -0
- package/src/iden3comm/types/protocol/auth.ts +104 -0
- package/src/iden3comm/types/protocol/common.ts +10 -0
- package/src/iden3comm/types/protocol/contract-request.ts +76 -0
- package/src/iden3comm/types/protocol/credentials.ts +96 -0
- package/src/iden3comm/types/protocol/discovery-protocol.ts +49 -0
- package/src/iden3comm/types/protocol/messages.ts +13 -0
- package/src/iden3comm/types/protocol/payment.ts +231 -0
- package/src/iden3comm/types/protocol/problem-report.ts +18 -0
- package/src/iden3comm/types/protocol/proof.ts +25 -0
- package/src/iden3comm/types/protocol/proposal-request.ts +38 -0
- package/src/iden3comm/types/protocol/revocation.ts +23 -0
- package/src/iden3comm/utils/accept-profile.ts +121 -0
- package/src/iden3comm/utils/did.ts +71 -0
- package/src/iden3comm/utils/envelope.ts +101 -0
- package/src/iden3comm/utils/index.ts +4 -0
- package/src/iden3comm/utils/message.ts +41 -0
- package/src/identity/common.ts +69 -0
- package/src/identity/identity-wallet.ts +1592 -0
- package/src/identity/index.ts +2 -0
- package/src/index.ts +16 -0
- package/src/kms/index.ts +4 -0
- package/src/kms/key-providers/bjj-provider.ts +118 -0
- package/src/kms/key-providers/ed25519-provider.ts +105 -0
- package/src/kms/key-providers/index.ts +3 -0
- package/src/kms/key-providers/secp256k1-provider.ts +125 -0
- package/src/kms/kms.ts +173 -0
- package/src/kms/provider-helpers.ts +13 -0
- package/src/kms/store/abstract-key-store.ts +34 -0
- package/src/kms/store/index.ts +5 -0
- package/src/kms/store/indexed-db-key-store.ts +60 -0
- package/src/kms/store/local-storage-key-store.ts +69 -0
- package/src/kms/store/memory-key-store.ts +29 -0
- package/src/kms/store/types.ts +21 -0
- package/src/proof/common.ts +273 -0
- package/src/proof/index.ts +4 -0
- package/src/proof/proof-service.ts +623 -0
- package/src/proof/provers/index.ts +3 -0
- package/src/proof/provers/inputs-generator.ts +627 -0
- package/src/proof/provers/prover.ts +104 -0
- package/src/proof/provers/witness_calculator.ts +315 -0
- package/src/proof/verifiers/index.ts +3 -0
- package/src/proof/verifiers/pub-signals-verifier.ts +730 -0
- package/src/proof/verifiers/query-hash.ts +57 -0
- package/src/proof/verifiers/query.ts +340 -0
- package/src/schema-processor/index.ts +3 -0
- package/src/schema-processor/json/index.ts +2 -0
- package/src/schema-processor/json/parser.ts +256 -0
- package/src/schema-processor/json/validator.ts +67 -0
- package/src/schema-processor/jsonld/cache.ts +49 -0
- package/src/schema-processor/jsonld/index.ts +2 -0
- package/src/schema-processor/jsonld/parser.ts +93 -0
- package/src/schema-processor/utils.ts +84 -0
- package/src/storage/blockchain/abi/CredentialStatusResolver.json +1 -0
- package/src/storage/blockchain/abi/ERC20.json +1 -0
- package/src/storage/blockchain/abi/ERC20Permit.json +1 -0
- package/src/storage/blockchain/abi/IdentityBase.json +1 -0
- package/src/storage/blockchain/abi/State.json +1 -0
- package/src/storage/blockchain/abi/ZkpVerifier.json +789 -0
- package/src/storage/blockchain/common.ts +20 -0
- package/src/storage/blockchain/did-resolver-readonly-storage.ts +90 -0
- package/src/storage/blockchain/erc20-helper.ts +66 -0
- package/src/storage/blockchain/errors.ts +46 -0
- package/src/storage/blockchain/index.ts +7 -0
- package/src/storage/blockchain/onchain-issuer-adapter/non-merklized/version/v0.0.1/onchain-non-merklized-issuer-adapter.ts +327 -0
- package/src/storage/blockchain/onchain-issuer.ts +104 -0
- package/src/storage/blockchain/onchain-revocation.ts +143 -0
- package/src/storage/blockchain/onchain-zkp-verifier.ts +704 -0
- package/src/storage/blockchain/state.ts +471 -0
- package/src/storage/entities/circuitData.ts +7 -0
- package/src/storage/entities/identity.ts +18 -0
- package/src/storage/entities/index.ts +4 -0
- package/src/storage/entities/mt.ts +25 -0
- package/src/storage/entities/state.ts +97 -0
- package/src/storage/errors.ts +8 -0
- package/src/storage/filters/index.ts +1 -0
- package/src/storage/filters/jsonQuery.ts +368 -0
- package/src/storage/fs/circuits-storage.ts +149 -0
- package/src/storage/fs/index.ts +1 -0
- package/src/storage/index.ts +9 -0
- package/src/storage/indexed-db/data-source.ts +58 -0
- package/src/storage/indexed-db/index.ts +2 -0
- package/src/storage/indexed-db/merkletree.ts +140 -0
- package/src/storage/interfaces/circuits.ts +27 -0
- package/src/storage/interfaces/credentials.ts +53 -0
- package/src/storage/interfaces/data-source.ts +41 -0
- package/src/storage/interfaces/data-storage.ts +17 -0
- package/src/storage/interfaces/identity.ts +73 -0
- package/src/storage/interfaces/index.ts +10 -0
- package/src/storage/interfaces/merkletree.ts +52 -0
- package/src/storage/interfaces/onchain-issuer.ts +13 -0
- package/src/storage/interfaces/onchain-revocation.ts +22 -0
- package/src/storage/interfaces/onchain-zkp-verifier.ts +94 -0
- package/src/storage/interfaces/state.ts +81 -0
- package/src/storage/local-storage/data-source.ts +87 -0
- package/src/storage/local-storage/index.ts +2 -0
- package/src/storage/local-storage/merkletree.ts +137 -0
- package/src/storage/memory/cache-lru.ts +30 -0
- package/src/storage/memory/data-source.ts +45 -0
- package/src/storage/memory/index.ts +3 -0
- package/src/storage/memory/merkletree.ts +116 -0
- package/src/storage/shared/circuit-storage.ts +49 -0
- package/src/storage/shared/credential-storage.ts +70 -0
- package/src/storage/shared/identity-storage.ts +82 -0
- package/src/storage/shared/index.ts +3 -0
- package/src/storage/utils.ts +19 -0
- package/src/utils/compare-func.ts +5 -0
- package/src/utils/did-helper.ts +157 -0
- package/src/utils/encoding.ts +47 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/message-bus.ts +88 -0
- package/src/utils/object.ts +52 -0
- package/src/utils/payments/evm.ts +152 -0
- package/src/utils/payments/solana.ts +360 -0
- package/src/verifiable/constants.ts +239 -0
- package/src/verifiable/core-utils.ts +307 -0
- package/src/verifiable/credential.ts +649 -0
- package/src/verifiable/index.ts +6 -0
- package/src/verifiable/presentation.ts +97 -0
- package/src/verifiable/proof.ts +277 -0
- package/src/verifiable/schema.ts +241 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { getRandomBytes } from '@iden3/js-crypto';
|
|
2
|
+
import {
|
|
3
|
+
AcceptProfile,
|
|
4
|
+
AuthMethod,
|
|
5
|
+
AuthProof,
|
|
6
|
+
BasicMessage,
|
|
7
|
+
JsonDocumentObject,
|
|
8
|
+
JWSPackerParams,
|
|
9
|
+
ZeroKnowledgeProofAuthResponse,
|
|
10
|
+
ZeroKnowledgeProofQuery,
|
|
11
|
+
ZeroKnowledgeProofRequest,
|
|
12
|
+
ZeroKnowledgeProofResponse
|
|
13
|
+
} from '../types';
|
|
14
|
+
import { mergeObjects } from '../../utils';
|
|
15
|
+
import { RevocationStatus, VerifiableConstants, W3CCredential } from '../../verifiable';
|
|
16
|
+
import { DID, getUnixTimestamp } from '@mocanetwork/moca-iden3';
|
|
17
|
+
import { IProofService } from '../../proof';
|
|
18
|
+
import { CircuitId } from '../../circuits';
|
|
19
|
+
import { AcceptJwsAlgorithms, defaultAcceptProfile, MediaType } from '../constants';
|
|
20
|
+
import { ethers, Signer } from 'ethers';
|
|
21
|
+
import { packZkpProof, prepareZkpProof } from '../../storage/blockchain/common';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Groups the ZeroKnowledgeProofRequest objects based on their groupId.
|
|
25
|
+
* Returns a Map where the key is the groupId and the value is an object containing the query and linkNonce.
|
|
26
|
+
*
|
|
27
|
+
* @param requestScope - An array of ZeroKnowledgeProofRequest objects.
|
|
28
|
+
* @returns A Map<number, { query: ZeroKnowledgeProofQuery; linkNonce: number }> representing the grouped queries.
|
|
29
|
+
*/
|
|
30
|
+
const getGroupedQueries = (
|
|
31
|
+
requestScope: ZeroKnowledgeProofRequest[]
|
|
32
|
+
): Map<number, { query: ZeroKnowledgeProofQuery; linkNonce: number }> =>
|
|
33
|
+
requestScope.reduce((acc, proofReq) => {
|
|
34
|
+
const groupId = proofReq.query.groupId as number | undefined;
|
|
35
|
+
if (!groupId) {
|
|
36
|
+
return acc;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const existedData = acc.get(groupId);
|
|
40
|
+
if (!existedData) {
|
|
41
|
+
const seed = getRandomBytes(12);
|
|
42
|
+
const dataView = new DataView(seed.buffer);
|
|
43
|
+
const linkNonce = dataView.getUint32(0);
|
|
44
|
+
acc.set(groupId, { query: proofReq.query, linkNonce });
|
|
45
|
+
return acc;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const credentialSubject = mergeObjects(
|
|
49
|
+
existedData.query.credentialSubject as JsonDocumentObject,
|
|
50
|
+
proofReq.query.credentialSubject as JsonDocumentObject
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
acc.set(groupId, {
|
|
54
|
+
...existedData,
|
|
55
|
+
query: {
|
|
56
|
+
skipClaimRevocationCheck:
|
|
57
|
+
existedData.query.skipClaimRevocationCheck || proofReq.query.skipClaimRevocationCheck,
|
|
58
|
+
...existedData.query,
|
|
59
|
+
credentialSubject
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return acc;
|
|
64
|
+
}, new Map<number, { query: ZeroKnowledgeProofQuery; linkNonce: number }>());
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Processes zero knowledge proof requests.
|
|
68
|
+
*
|
|
69
|
+
* @param to - The identifier of the recipient.
|
|
70
|
+
* @param requests - An array of zero knowledge proof requests.
|
|
71
|
+
* @param from - The identifier of the sender.
|
|
72
|
+
* @param proofService - The proof service.
|
|
73
|
+
* @param opts - Additional options for processing the requests.
|
|
74
|
+
* @returns A promise that resolves to an array of zero knowledge proof responses.
|
|
75
|
+
*/
|
|
76
|
+
export const processZeroKnowledgeProofRequests = async (
|
|
77
|
+
to: DID,
|
|
78
|
+
requests: ZeroKnowledgeProofRequest[] | undefined,
|
|
79
|
+
from: DID | undefined,
|
|
80
|
+
proofService: IProofService,
|
|
81
|
+
opts: {
|
|
82
|
+
mediaType?: MediaType;
|
|
83
|
+
packerOptions?: JWSPackerParams;
|
|
84
|
+
supportedCircuits: CircuitId[];
|
|
85
|
+
ethSigner?: Signer;
|
|
86
|
+
challenge?: bigint;
|
|
87
|
+
}
|
|
88
|
+
): Promise<ZeroKnowledgeProofResponse[]> => {
|
|
89
|
+
const requestScope = requests ?? [];
|
|
90
|
+
|
|
91
|
+
const combinedQueries = getGroupedQueries(requestScope);
|
|
92
|
+
|
|
93
|
+
const groupedCredentialsCache = new Map<
|
|
94
|
+
number,
|
|
95
|
+
{ cred: W3CCredential; revStatus?: RevocationStatus }
|
|
96
|
+
>();
|
|
97
|
+
|
|
98
|
+
const zkpResponses = [];
|
|
99
|
+
|
|
100
|
+
for (const proofReq of requestScope) {
|
|
101
|
+
let zkpRes: ZeroKnowledgeProofResponse;
|
|
102
|
+
try {
|
|
103
|
+
const isCircuitSupported = opts.supportedCircuits.includes(proofReq.circuitId as CircuitId);
|
|
104
|
+
if (!isCircuitSupported) {
|
|
105
|
+
if (proofReq.optional) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
throw new Error(`Circuit ${proofReq.circuitId} is not allowed`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const query = proofReq.query;
|
|
112
|
+
const groupId = query.groupId as number | undefined;
|
|
113
|
+
const combinedQueryData = combinedQueries.get(groupId as number);
|
|
114
|
+
|
|
115
|
+
if (groupId) {
|
|
116
|
+
if (!combinedQueryData) {
|
|
117
|
+
throw new Error(`Invalid group id ${query.groupId}`);
|
|
118
|
+
}
|
|
119
|
+
const combinedQuery = combinedQueryData.query;
|
|
120
|
+
|
|
121
|
+
if (!groupedCredentialsCache.has(groupId)) {
|
|
122
|
+
const credWithRevStatus = await proofService.findCredentialByProofQuery(
|
|
123
|
+
to,
|
|
124
|
+
combinedQueryData.query
|
|
125
|
+
);
|
|
126
|
+
if (!credWithRevStatus.cred) {
|
|
127
|
+
if (proofReq.optional) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
throw new Error(
|
|
131
|
+
VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY +
|
|
132
|
+
`${JSON.stringify(combinedQuery)}`
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
groupedCredentialsCache.set(groupId, credWithRevStatus);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const credWithRevStatus = groupedCredentialsCache.get(groupId as number);
|
|
141
|
+
zkpRes = await proofService.generateProof(proofReq, to, {
|
|
142
|
+
verifierDid: from,
|
|
143
|
+
challenge: opts.challenge,
|
|
144
|
+
skipRevocation: Boolean(query.skipClaimRevocationCheck),
|
|
145
|
+
credential: credWithRevStatus?.cred,
|
|
146
|
+
credentialRevocationStatus: credWithRevStatus?.revStatus,
|
|
147
|
+
linkNonce: combinedQueryData?.linkNonce ? BigInt(combinedQueryData.linkNonce) : undefined
|
|
148
|
+
});
|
|
149
|
+
} catch (error: unknown) {
|
|
150
|
+
const expectedErrors = [
|
|
151
|
+
VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_IDENTITY_OR_PROFILE,
|
|
152
|
+
VerifiableConstants.ERRORS.ID_WALLET_NO_CREDENTIAL_SATISFIED_QUERY,
|
|
153
|
+
VerifiableConstants.ERRORS.CREDENTIAL_WALLET_ALL_CREDENTIALS_ARE_REVOKED
|
|
154
|
+
];
|
|
155
|
+
// handle only errors in case credential is not found and it is optional proof request - otherwise throw
|
|
156
|
+
if (
|
|
157
|
+
error instanceof Error &&
|
|
158
|
+
(expectedErrors.includes(error.message) ||
|
|
159
|
+
error.message.includes(
|
|
160
|
+
VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY
|
|
161
|
+
)) &&
|
|
162
|
+
proofReq.optional
|
|
163
|
+
) {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
zkpResponses.push(zkpRes);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return zkpResponses;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Processes auth proof requests.
|
|
177
|
+
*
|
|
178
|
+
* @param to - The identifier of the recipient.
|
|
179
|
+
* @param proofService - The proof service.
|
|
180
|
+
* @param opts - Additional options for processing the requests.
|
|
181
|
+
* @returns A promise that resolves to an auth proof response.
|
|
182
|
+
*/
|
|
183
|
+
export const processProofAuth = async (
|
|
184
|
+
to: DID,
|
|
185
|
+
proofService: IProofService,
|
|
186
|
+
opts: {
|
|
187
|
+
supportedCircuits: CircuitId[];
|
|
188
|
+
acceptProfile?: AcceptProfile;
|
|
189
|
+
senderAddress: string;
|
|
190
|
+
zkpResponses: ZeroKnowledgeProofResponse[];
|
|
191
|
+
}
|
|
192
|
+
): Promise<{ authProof: AuthProof }> => {
|
|
193
|
+
if (!opts.acceptProfile) {
|
|
194
|
+
opts.acceptProfile = defaultAcceptProfile;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
switch (opts.acceptProfile.env) {
|
|
198
|
+
case MediaType.ZKPMessage:
|
|
199
|
+
if (!opts.acceptProfile.circuits) {
|
|
200
|
+
throw new Error('Circuit not specified in accept profile');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
for (const circuitId of opts.acceptProfile.circuits) {
|
|
204
|
+
if (!opts.supportedCircuits.includes(circuitId as unknown as CircuitId)) {
|
|
205
|
+
throw new Error(`Circuit ${circuitId} is not supported`);
|
|
206
|
+
}
|
|
207
|
+
if (!opts.senderAddress) {
|
|
208
|
+
throw new Error('Sender address is not provided');
|
|
209
|
+
}
|
|
210
|
+
const challengeAuth = calcChallengeAuthV2(opts.senderAddress, opts.zkpResponses);
|
|
211
|
+
|
|
212
|
+
const zkpRes: ZeroKnowledgeProofAuthResponse = await proofService.generateAuthProof(
|
|
213
|
+
circuitId as unknown as CircuitId,
|
|
214
|
+
to,
|
|
215
|
+
{ challenge: challengeAuth }
|
|
216
|
+
);
|
|
217
|
+
return {
|
|
218
|
+
authProof: {
|
|
219
|
+
authMethod: AuthMethod.AUTHV2,
|
|
220
|
+
zkp: zkpRes
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
throw new Error(`Auth method is not supported`);
|
|
225
|
+
case MediaType.SignedMessage:
|
|
226
|
+
if (!opts.acceptProfile.alg || opts.acceptProfile.alg.length === 0) {
|
|
227
|
+
throw new Error('Algorithm not specified');
|
|
228
|
+
}
|
|
229
|
+
if (opts.acceptProfile.alg[0] === AcceptJwsAlgorithms.ES256KR) {
|
|
230
|
+
return {
|
|
231
|
+
authProof: {
|
|
232
|
+
authMethod: AuthMethod.ETH_IDENTITY,
|
|
233
|
+
userDid: to
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
throw new Error(`Algorithm ${opts.acceptProfile.alg[0]} not supported`);
|
|
238
|
+
default:
|
|
239
|
+
throw new Error('Accept env not supported');
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Processes a ZeroKnowledgeProofResponse object and prepares it for further use.
|
|
245
|
+
* @param zkProof - The ZeroKnowledgeProofResponse object containing the proof data.
|
|
246
|
+
* @returns An object containing the requestId, zkProofEncoded, and metadata.
|
|
247
|
+
*/
|
|
248
|
+
export const processProofResponse = (zkProof: ZeroKnowledgeProofResponse) => {
|
|
249
|
+
const requestId = zkProof.id;
|
|
250
|
+
const inputs = zkProof.pub_signals;
|
|
251
|
+
const emptyBytes = '0x';
|
|
252
|
+
|
|
253
|
+
if (inputs.length === 0) {
|
|
254
|
+
return { requestId, zkProofEncoded: emptyBytes, metadata: emptyBytes };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const preparedZkpProof = prepareZkpProof(zkProof.proof);
|
|
258
|
+
const zkProofEncoded = packZkpProof(
|
|
259
|
+
inputs,
|
|
260
|
+
preparedZkpProof.a,
|
|
261
|
+
preparedZkpProof.b,
|
|
262
|
+
preparedZkpProof.c
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
const metadata = emptyBytes;
|
|
266
|
+
|
|
267
|
+
return { requestId, zkProofEncoded, metadata };
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Calculates the challenge authentication V2 value.
|
|
272
|
+
* @param senderAddress - The address of the sender.
|
|
273
|
+
* @param zkpResponses - An array of ZeroKnowledgeProofResponse objects.
|
|
274
|
+
* @returns A bigint representing the challenge authentication value.
|
|
275
|
+
*/
|
|
276
|
+
export const calcChallengeAuthV2 = (
|
|
277
|
+
senderAddress: string,
|
|
278
|
+
zkpResponses: ZeroKnowledgeProofResponse[]
|
|
279
|
+
): bigint => {
|
|
280
|
+
const responses = zkpResponses.map((zkpResponse) => {
|
|
281
|
+
const response = processProofResponse(zkpResponse);
|
|
282
|
+
return {
|
|
283
|
+
requestId: response.requestId,
|
|
284
|
+
proof: response.zkProofEncoded,
|
|
285
|
+
metadata: response.metadata
|
|
286
|
+
};
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
return (
|
|
290
|
+
BigInt(
|
|
291
|
+
ethers.keccak256(
|
|
292
|
+
new ethers.AbiCoder().encode(
|
|
293
|
+
['address', '(uint256 requestId,bytes proof,bytes metadata)[]'],
|
|
294
|
+
[senderAddress, responses]
|
|
295
|
+
)
|
|
296
|
+
)
|
|
297
|
+
) & BigInt('0x0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff')
|
|
298
|
+
);
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Packs metadata into a string format suitable for encoding in a transaction.
|
|
303
|
+
* @param metas - An array of objects containing key-value pairs to be packed.
|
|
304
|
+
* @returns A string representing the packed metadata.
|
|
305
|
+
*/
|
|
306
|
+
export const packMetadatas = (
|
|
307
|
+
metas: {
|
|
308
|
+
key: string;
|
|
309
|
+
value: Uint8Array;
|
|
310
|
+
}[]
|
|
311
|
+
): string => {
|
|
312
|
+
return new ethers.AbiCoder().encode(['tuple(' + 'string key,' + 'bytes value' + ')[]'], [metas]);
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Verifies that the expires_time field of a message is not in the past. Throws an error if it is.
|
|
317
|
+
*
|
|
318
|
+
* @param message - Basic message to verify.
|
|
319
|
+
*/
|
|
320
|
+
export const verifyExpiresTime = (message: BasicMessage) => {
|
|
321
|
+
if (message?.expires_time && message.expires_time < getUnixTimestamp(new Date())) {
|
|
322
|
+
throw new Error('Message expired');
|
|
323
|
+
}
|
|
324
|
+
};
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { CircuitId } from '../../circuits/models';
|
|
2
|
+
import { IProofService } from '../../proof/proof-service';
|
|
3
|
+
import { defaultAcceptProfile, PROTOCOL_MESSAGE_TYPE, ProtocolVersion } from '../constants';
|
|
4
|
+
import {
|
|
5
|
+
AcceptProfile,
|
|
6
|
+
BasicMessage,
|
|
7
|
+
IPackageManager,
|
|
8
|
+
ZeroKnowledgeInvokeResponse,
|
|
9
|
+
ZeroKnowledgeProofResponse
|
|
10
|
+
} from '../types';
|
|
11
|
+
import { ContractInvokeRequest, ContractInvokeResponse } from '../types/protocol/contract-request';
|
|
12
|
+
import { DID, ChainIds, getUnixTimestamp, BytesHelper } from '@mocanetwork/moca-iden3';
|
|
13
|
+
import { FunctionSignatures, IOnChainZKPVerifier } from '../../storage';
|
|
14
|
+
import { Signer } from 'ethers';
|
|
15
|
+
import { processProofAuth, processZeroKnowledgeProofRequests, verifyExpiresTime } from './common';
|
|
16
|
+
import {
|
|
17
|
+
AbstractMessageHandler,
|
|
18
|
+
BasicHandlerOptions,
|
|
19
|
+
IProtocolMessageHandler
|
|
20
|
+
} from './message-handler';
|
|
21
|
+
import { parseAcceptProfile } from '../utils';
|
|
22
|
+
import { hexToBytes } from '../../utils';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Interface that allows the processing of the contract request
|
|
26
|
+
*
|
|
27
|
+
* @beta
|
|
28
|
+
* @interface IContractRequestHandler
|
|
29
|
+
*/
|
|
30
|
+
export interface IContractRequestHandler {
|
|
31
|
+
/**
|
|
32
|
+
* unpacks contract invoke request
|
|
33
|
+
* @beta
|
|
34
|
+
* @param {Uint8Array} request - raw byte message
|
|
35
|
+
* @returns `Promise<ContractInvokeRequest>`
|
|
36
|
+
*/
|
|
37
|
+
parseContractInvokeRequest(request: Uint8Array): Promise<ContractInvokeRequest>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* handle contract invoke request
|
|
41
|
+
* @beta
|
|
42
|
+
* @param {did} did - sender DID
|
|
43
|
+
* @param {Uint8Array} request - raw byte message
|
|
44
|
+
* @param {ContractInvokeHandlerOptions} opts - handler options
|
|
45
|
+
* @returns {Map<string, ZeroKnowledgeProofResponse>}` - map of transaction hash - ZeroKnowledgeProofResponse
|
|
46
|
+
*/
|
|
47
|
+
handleContractInvokeRequest(
|
|
48
|
+
did: DID,
|
|
49
|
+
request: Uint8Array,
|
|
50
|
+
opts?: ContractInvokeHandlerOptions
|
|
51
|
+
): Promise<Map<string, ZeroKnowledgeProofResponse>>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** ContractInvokeHandlerOptions represents contract invoke handler options */
|
|
55
|
+
export type ContractInvokeHandlerOptions = BasicHandlerOptions & {
|
|
56
|
+
ethSigner: Signer;
|
|
57
|
+
challenge?: bigint;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type ContractMessageHandlerOptions = {
|
|
61
|
+
senderDid: DID;
|
|
62
|
+
ethSigner: Signer;
|
|
63
|
+
challenge?: bigint;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* Allows to process ContractInvokeRequest protocol message
|
|
69
|
+
*
|
|
70
|
+
* @beta
|
|
71
|
+
|
|
72
|
+
* @class ContractRequestHandler
|
|
73
|
+
* @implements implements IContractRequestHandler interface
|
|
74
|
+
*/
|
|
75
|
+
export class ContractRequestHandler
|
|
76
|
+
extends AbstractMessageHandler
|
|
77
|
+
implements IContractRequestHandler, IProtocolMessageHandler
|
|
78
|
+
{
|
|
79
|
+
private readonly _supportedCircuits = [
|
|
80
|
+
CircuitId.AuthV2,
|
|
81
|
+
CircuitId.AtomicQueryMTPV2OnChain,
|
|
82
|
+
CircuitId.AtomicQuerySigV2OnChain,
|
|
83
|
+
CircuitId.AtomicQueryV3OnChain,
|
|
84
|
+
// Now we support off-chain circuits on-chain
|
|
85
|
+
// TODO: We need to create validators for them
|
|
86
|
+
CircuitId.AuthV2,
|
|
87
|
+
CircuitId.AtomicQueryV3,
|
|
88
|
+
CircuitId.LinkedMultiQuery10
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Creates an instance of ContractRequestHandler.
|
|
93
|
+
* @param {IPackageManager} _packerMgr - package manager to unpack message envelope
|
|
94
|
+
* @param {IProofService} _proofService - proof service to verify zk proofs
|
|
95
|
+
* @param {IOnChainZKPVerifier} _zkpVerifier - zkp verifier to submit response
|
|
96
|
+
* @param {IOnChainVerifierMultiQuery} _verifierMultiQuery - verifier multi-query to submit response
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
constructor(
|
|
101
|
+
private readonly _packerMgr: IPackageManager,
|
|
102
|
+
private readonly _proofService: IProofService,
|
|
103
|
+
private readonly _zkpVerifier: IOnChainZKPVerifier
|
|
104
|
+
) {
|
|
105
|
+
super();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async handle(
|
|
109
|
+
message: BasicMessage,
|
|
110
|
+
ctx: ContractMessageHandlerOptions
|
|
111
|
+
): Promise<BasicMessage | null> {
|
|
112
|
+
switch (message.type) {
|
|
113
|
+
case PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE: {
|
|
114
|
+
const ciMessage = message as ContractInvokeRequest;
|
|
115
|
+
const txHashResponsesMap = await this.handleContractInvoke(ciMessage, ctx);
|
|
116
|
+
return this.createContractInvokeResponse(ciMessage, txHashResponsesMap);
|
|
117
|
+
}
|
|
118
|
+
default:
|
|
119
|
+
return super.handle(message, ctx);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private async handleContractInvoke(
|
|
124
|
+
message: ContractInvokeRequest,
|
|
125
|
+
ctx: ContractMessageHandlerOptions
|
|
126
|
+
): Promise<Map<string, ZeroKnowledgeInvokeResponse>> {
|
|
127
|
+
if (message.type !== PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE) {
|
|
128
|
+
throw new Error('Invalid message type for contract invoke request');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const { senderDid: did, ethSigner, challenge } = ctx;
|
|
132
|
+
if (!ctx.ethSigner) {
|
|
133
|
+
throw new Error("Can't sign transaction. Provide Signer in options.");
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const { chain_id } = message.body.transaction_data;
|
|
137
|
+
const networkFlag = Object.keys(ChainIds).find((key) => ChainIds[key] === chain_id);
|
|
138
|
+
|
|
139
|
+
if (!networkFlag) {
|
|
140
|
+
throw new Error(`Invalid chain id ${chain_id}`);
|
|
141
|
+
}
|
|
142
|
+
const verifierDid = message.from ? DID.parse(message.from) : undefined;
|
|
143
|
+
|
|
144
|
+
const { scope = [] } = message.body;
|
|
145
|
+
|
|
146
|
+
const zkpResponses = await processZeroKnowledgeProofRequests(
|
|
147
|
+
did,
|
|
148
|
+
scope,
|
|
149
|
+
verifierDid,
|
|
150
|
+
this._proofService,
|
|
151
|
+
{
|
|
152
|
+
ethSigner,
|
|
153
|
+
challenge: challenge ?? BytesHelper.bytesToInt(hexToBytes(await ethSigner.getAddress())),
|
|
154
|
+
supportedCircuits: this._supportedCircuits
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const methodId = message.body.transaction_data.method_id.replace('0x', '');
|
|
159
|
+
switch (methodId) {
|
|
160
|
+
case FunctionSignatures.SubmitZKPResponseV2: {
|
|
161
|
+
const txHashZkpResponsesMap = await this._zkpVerifier.submitZKPResponseV2(
|
|
162
|
+
ethSigner,
|
|
163
|
+
message.body.transaction_data,
|
|
164
|
+
zkpResponses
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
const response = new Map<string, ZeroKnowledgeInvokeResponse>();
|
|
168
|
+
for (const [txHash, zkpResponses] of txHashZkpResponsesMap) {
|
|
169
|
+
response.set(txHash, { responses: zkpResponses });
|
|
170
|
+
}
|
|
171
|
+
// set txHash of the first response
|
|
172
|
+
message.body.transaction_data.txHash = txHashZkpResponsesMap.keys().next().value;
|
|
173
|
+
return response;
|
|
174
|
+
}
|
|
175
|
+
case FunctionSignatures.SubmitZKPResponseV1: {
|
|
176
|
+
const txHashZkpResponseMap = await this._zkpVerifier.submitZKPResponse(
|
|
177
|
+
ethSigner,
|
|
178
|
+
message.body.transaction_data,
|
|
179
|
+
zkpResponses
|
|
180
|
+
);
|
|
181
|
+
const response = new Map<string, ZeroKnowledgeInvokeResponse>();
|
|
182
|
+
for (const [txHash, zkpResponse] of txHashZkpResponseMap) {
|
|
183
|
+
response.set(txHash, { responses: [zkpResponse] });
|
|
184
|
+
}
|
|
185
|
+
// set txHash of the first response
|
|
186
|
+
message.body.transaction_data.txHash = txHashZkpResponseMap.keys().next().value;
|
|
187
|
+
return response;
|
|
188
|
+
}
|
|
189
|
+
case FunctionSignatures.SubmitResponse: {
|
|
190
|
+
// We need to
|
|
191
|
+
// 1. Generate auth proof from message.body.accept -> authResponse
|
|
192
|
+
// 2. Generate proofs for each query in scope -> zkpResponses
|
|
193
|
+
|
|
194
|
+
// Build auth response from accept
|
|
195
|
+
if (!message.to) {
|
|
196
|
+
throw new Error(`failed message. empty 'to' field`);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Get first supported accept profile and pass it to processProofAuth
|
|
200
|
+
const acceptProfile = this.getFirstSupportedProfile(
|
|
201
|
+
PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE,
|
|
202
|
+
message.body.accept
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const identifier = DID.parse(message.to);
|
|
206
|
+
|
|
207
|
+
const { authProof } = await processProofAuth(identifier, this._proofService, {
|
|
208
|
+
supportedCircuits: this._supportedCircuits,
|
|
209
|
+
acceptProfile,
|
|
210
|
+
senderAddress: await ethSigner.getAddress(),
|
|
211
|
+
zkpResponses: zkpResponses
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// we return txHash because responsesMap could be empty if there are no queries in scope
|
|
215
|
+
const txHashZkpResponsesMap = await this._zkpVerifier.submitResponse(
|
|
216
|
+
ethSigner,
|
|
217
|
+
message.body.transaction_data,
|
|
218
|
+
zkpResponses,
|
|
219
|
+
authProof
|
|
220
|
+
);
|
|
221
|
+
message.body.transaction_data.txHash = txHashZkpResponsesMap.keys().next().value;
|
|
222
|
+
|
|
223
|
+
return txHashZkpResponsesMap;
|
|
224
|
+
}
|
|
225
|
+
default:
|
|
226
|
+
throw new Error(
|
|
227
|
+
`Not supported method id. Only '${FunctionSignatures.SubmitZKPResponseV1}, ${FunctionSignatures.SubmitZKPResponseV2} and ${FunctionSignatures.SubmitResponse} are supported.'`
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
private getFirstSupportedProfile(
|
|
233
|
+
responseType: string,
|
|
234
|
+
profile?: string[] | undefined
|
|
235
|
+
): AcceptProfile {
|
|
236
|
+
if (profile?.length) {
|
|
237
|
+
for (const acceptProfileString of profile) {
|
|
238
|
+
// 1. check protocol version
|
|
239
|
+
const acceptProfile = parseAcceptProfile(acceptProfileString);
|
|
240
|
+
const responseTypeVersion = Number(responseType.split('/').at(-2));
|
|
241
|
+
if (
|
|
242
|
+
acceptProfile.protocolVersion !== ProtocolVersion.V1 ||
|
|
243
|
+
(acceptProfile.protocolVersion === ProtocolVersion.V1 &&
|
|
244
|
+
(responseTypeVersion < 1 || responseTypeVersion >= 2))
|
|
245
|
+
) {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
// 2. check packer support
|
|
249
|
+
if (this._packerMgr.isProfileSupported(acceptProfile.env, acceptProfileString)) {
|
|
250
|
+
return acceptProfile;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// if we don't have supported profiles, we use default
|
|
256
|
+
return defaultAcceptProfile;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* unpacks contract-invoke request
|
|
261
|
+
* @beta
|
|
262
|
+
* @param {Uint8Array} request - raw byte message
|
|
263
|
+
* @returns `Promise<ContractInvokeRequest>`
|
|
264
|
+
*/
|
|
265
|
+
async parseContractInvokeRequest(request: Uint8Array): Promise<ContractInvokeRequest> {
|
|
266
|
+
const { unpackedMessage: message } = await this._packerMgr.unpack(request);
|
|
267
|
+
const ciRequest = message as unknown as ContractInvokeRequest;
|
|
268
|
+
if (message.type !== PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE) {
|
|
269
|
+
throw new Error('Invalid media type');
|
|
270
|
+
}
|
|
271
|
+
ciRequest.body.scope = ciRequest.body.scope || [];
|
|
272
|
+
return ciRequest;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* creates contract invoke response
|
|
277
|
+
* @private
|
|
278
|
+
* @beta
|
|
279
|
+
* @param {ContractInvokeRequest} request - ContractInvokeRequest
|
|
280
|
+
* @param { Map<string, ZeroKnowledgeInvokeResponse>} responses - map tx hash to array of ZeroKnowledgeInvokeResponse
|
|
281
|
+
* @returns `Promise<ContractInvokeResponse>`
|
|
282
|
+
*/
|
|
283
|
+
private async createContractInvokeResponse(
|
|
284
|
+
request: ContractInvokeRequest,
|
|
285
|
+
txHashToZkpResponseMap: Map<string, ZeroKnowledgeInvokeResponse>
|
|
286
|
+
): Promise<ContractInvokeResponse> {
|
|
287
|
+
const contractInvokeResponse: ContractInvokeResponse = {
|
|
288
|
+
id: request.id,
|
|
289
|
+
thid: request.thid,
|
|
290
|
+
type: PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_RESPONSE_MESSAGE_TYPE,
|
|
291
|
+
from: request.to,
|
|
292
|
+
to: request.from,
|
|
293
|
+
body: {
|
|
294
|
+
transaction_data: request.body.transaction_data,
|
|
295
|
+
scope: []
|
|
296
|
+
},
|
|
297
|
+
created_time: getUnixTimestamp(new Date())
|
|
298
|
+
};
|
|
299
|
+
for (const [txHash, zkpResponses] of txHashToZkpResponseMap) {
|
|
300
|
+
for (const zkpResponse of zkpResponses.responses) {
|
|
301
|
+
contractInvokeResponse.body.scope.push({
|
|
302
|
+
txHash,
|
|
303
|
+
...zkpResponse
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
contractInvokeResponse.body = {
|
|
307
|
+
...contractInvokeResponse.body,
|
|
308
|
+
crossChainProof: zkpResponses.crossChainProof,
|
|
309
|
+
authProof: zkpResponses.authProof
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
return contractInvokeResponse;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* handle contract invoke request
|
|
317
|
+
* supports only 0xb68967e2 method id
|
|
318
|
+
* @beta
|
|
319
|
+
* @deprecated
|
|
320
|
+
* @param {did} did - sender DID
|
|
321
|
+
* @param {ContractInvokeRequest} request - contract invoke request
|
|
322
|
+
* @param {ContractInvokeHandlerOptions} opts - handler options
|
|
323
|
+
* @returns {Map<string, ZeroKnowledgeProofResponse>}` - map of transaction hash - ZeroKnowledgeProofResponse
|
|
324
|
+
*/
|
|
325
|
+
async handleContractInvokeRequest(
|
|
326
|
+
did: DID,
|
|
327
|
+
request: Uint8Array,
|
|
328
|
+
opts: ContractInvokeHandlerOptions
|
|
329
|
+
): Promise<Map<string, ZeroKnowledgeProofResponse>> {
|
|
330
|
+
const ciRequest = await this.parseContractInvokeRequest(request);
|
|
331
|
+
if (!opts.allowExpiredMessages) {
|
|
332
|
+
verifyExpiresTime(ciRequest);
|
|
333
|
+
}
|
|
334
|
+
if (ciRequest.body.transaction_data.method_id !== FunctionSignatures.SubmitZKPResponseV1) {
|
|
335
|
+
throw new Error(`please use handle method to work with other method ids`);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (ciRequest.type !== PROTOCOL_MESSAGE_TYPE.CONTRACT_INVOKE_REQUEST_MESSAGE_TYPE) {
|
|
339
|
+
throw new Error('Invalid message type for contract invoke request');
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const { ethSigner, challenge } = opts;
|
|
343
|
+
if (!ethSigner) {
|
|
344
|
+
throw new Error("Can't sign transaction. Provide Signer in options.");
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const { chain_id } = ciRequest.body.transaction_data;
|
|
348
|
+
const networkFlag = Object.keys(ChainIds).find((key) => ChainIds[key] === chain_id);
|
|
349
|
+
|
|
350
|
+
if (!networkFlag) {
|
|
351
|
+
throw new Error(`Invalid chain id ${chain_id}`);
|
|
352
|
+
}
|
|
353
|
+
const verifierDid = ciRequest.from ? DID.parse(ciRequest.from) : undefined;
|
|
354
|
+
const zkpResponses = await processZeroKnowledgeProofRequests(
|
|
355
|
+
did,
|
|
356
|
+
ciRequest?.body?.scope,
|
|
357
|
+
verifierDid,
|
|
358
|
+
this._proofService,
|
|
359
|
+
{ ethSigner, challenge, supportedCircuits: this._supportedCircuits }
|
|
360
|
+
);
|
|
361
|
+
return this._zkpVerifier.submitZKPResponse(
|
|
362
|
+
ethSigner,
|
|
363
|
+
ciRequest.body.transaction_data,
|
|
364
|
+
zkpResponses
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
}
|