@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,704 @@
|
|
|
1
|
+
import { JsonRpcProvider, Signer, Contract, TransactionRequest, ethers } from 'ethers';
|
|
2
|
+
import { EthConnectionConfig } from './state';
|
|
3
|
+
import { IOnChainZKPVerifier } from '../interfaces/onchain-zkp-verifier';
|
|
4
|
+
import {
|
|
5
|
+
AuthMethod,
|
|
6
|
+
AuthProof,
|
|
7
|
+
AuthProofEthIdentity,
|
|
8
|
+
AuthProofZKP,
|
|
9
|
+
ContractInvokeTransactionData,
|
|
10
|
+
CrossChainProof,
|
|
11
|
+
JsonDocumentObjectValue,
|
|
12
|
+
processProofResponse,
|
|
13
|
+
ZeroKnowledgeInvokeResponse,
|
|
14
|
+
ZeroKnowledgeProofResponse
|
|
15
|
+
} from '../../iden3comm';
|
|
16
|
+
import abi from './abi/ZkpVerifier.json';
|
|
17
|
+
import { IVerifierABI } from '@iden3/universal-verifier-v2-abi';
|
|
18
|
+
import { TransactionService } from '../../blockchain';
|
|
19
|
+
import { BytesHelper, chainIDfromDID, DID, Id } from '@mocanetwork/moca-iden3';
|
|
20
|
+
import {
|
|
21
|
+
AtomicQueryMTPV2OnChainPubSignals,
|
|
22
|
+
AtomicQuerySigV2OnChainPubSignals,
|
|
23
|
+
AtomicQueryV3OnChainPubSignals,
|
|
24
|
+
AuthV2PubSignals,
|
|
25
|
+
CircuitId,
|
|
26
|
+
StatesInfo
|
|
27
|
+
} from '../../circuits';
|
|
28
|
+
import { byteEncoder, bytesToHex, DIDDocumentSignature, resolveDidDocument } from '../../utils';
|
|
29
|
+
import { GlobalStateUpdate, IdentityStateUpdate } from '../entities/state';
|
|
30
|
+
import { Hash } from '@iden3/js-merkletree';
|
|
31
|
+
import { packZkpProof, prepareZkpProof } from './common';
|
|
32
|
+
|
|
33
|
+
const maxGasLimit = 10000000n;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Supported function signature for SubmitZKPResponse
|
|
37
|
+
*/
|
|
38
|
+
export enum FunctionSignatures {
|
|
39
|
+
/**
|
|
40
|
+
* solidity identifier for function signature:
|
|
41
|
+
* function submitZKPResponse(uint64 requestId, uint256[] calldata inputs,
|
|
42
|
+
* uint256[2] calldata a, uint256[2][2] calldata b, uint256[2] calldata c) public
|
|
43
|
+
*/
|
|
44
|
+
SubmitZKPResponseV1 = 'b68967e2',
|
|
45
|
+
//function submitZKPResponseV2(tuple[](uint64 requestId,bytes zkProof,bytes data),bytes crossChainProof)
|
|
46
|
+
SubmitZKPResponseV2 = 'ade09fcd',
|
|
47
|
+
//function submitResponse(tuple(string authMethod,bytes proof),tuple(uint256 requestId,bytes proof,bytes metadata)[],bytes crossChainProof)
|
|
48
|
+
SubmitResponse = '06c86a91'
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* OnChainZKPVerifierOptions represents OnChainZKPVerifier options
|
|
52
|
+
*/
|
|
53
|
+
export type OnChainZKPVerifierOptions = {
|
|
54
|
+
didResolverUrl?: string;
|
|
55
|
+
};
|
|
56
|
+
type ProofPreparationResult = {
|
|
57
|
+
requestId: string | number;
|
|
58
|
+
proof: ZeroKnowledgeProofResponse;
|
|
59
|
+
encoded: string;
|
|
60
|
+
metadata: string;
|
|
61
|
+
};
|
|
62
|
+
export type TxPreparationResultSubmitResponse = {
|
|
63
|
+
authProof: { raw: AuthProof; encoded: string };
|
|
64
|
+
crossChainProof: { raw: CrossChainProof; encoded: string };
|
|
65
|
+
proofs: ProofPreparationResult[];
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const toTxDataArgs = function (res: TxPreparationResultSubmitResponse) {
|
|
69
|
+
return [
|
|
70
|
+
{
|
|
71
|
+
authMethod: res.authProof.raw.authMethod,
|
|
72
|
+
proof: res.authProof.encoded
|
|
73
|
+
},
|
|
74
|
+
res.proofs.map((p) => {
|
|
75
|
+
return {
|
|
76
|
+
requestId: p.requestId,
|
|
77
|
+
proof: p.encoded,
|
|
78
|
+
metadata: p.metadata
|
|
79
|
+
};
|
|
80
|
+
}),
|
|
81
|
+
res.crossChainProof.encoded
|
|
82
|
+
];
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
type OnChainZKPVerifierCircuitId =
|
|
86
|
+
| CircuitId.AuthV2
|
|
87
|
+
| CircuitId.AtomicQueryMTPV2OnChain
|
|
88
|
+
| CircuitId.AtomicQuerySigV2OnChain
|
|
89
|
+
| CircuitId.AtomicQueryV3OnChain;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* OnChainZKPVerifier is a class that allows to interact with the OnChainZKPVerifier contract
|
|
93
|
+
* and submitZKPResponse.
|
|
94
|
+
*
|
|
95
|
+
* @beta
|
|
96
|
+
* @class OnChainZKPVerifier
|
|
97
|
+
*/
|
|
98
|
+
export class OnChainZKPVerifier implements IOnChainZKPVerifier {
|
|
99
|
+
/**
|
|
100
|
+
* supported circuits
|
|
101
|
+
*/
|
|
102
|
+
private static readonly _supportedCircuits: OnChainZKPVerifierCircuitId[] = [
|
|
103
|
+
CircuitId.AuthV2,
|
|
104
|
+
CircuitId.AtomicQueryMTPV2OnChain,
|
|
105
|
+
CircuitId.AtomicQuerySigV2OnChain,
|
|
106
|
+
CircuitId.AtomicQueryV3OnChain
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
private static readonly _supportedCircuitsPubSignalsMap = {
|
|
110
|
+
[CircuitId.AtomicQueryMTPV2OnChain]: AtomicQueryMTPV2OnChainPubSignals,
|
|
111
|
+
[CircuitId.AtomicQuerySigV2OnChain]: AtomicQuerySigV2OnChainPubSignals,
|
|
112
|
+
[CircuitId.AtomicQueryV3OnChain]: AtomicQueryV3OnChainPubSignals,
|
|
113
|
+
[CircuitId.AuthV2]: AuthV2PubSignals
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
* Creates an instance of OnChainZKPVerifier.
|
|
119
|
+
* @beta
|
|
120
|
+
* @param {EthConnectionConfig[]} - array of ETH configs
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
constructor(
|
|
124
|
+
private readonly _configs: EthConnectionConfig[],
|
|
125
|
+
private readonly _opts?: OnChainZKPVerifierOptions
|
|
126
|
+
) {}
|
|
127
|
+
|
|
128
|
+
public static async prepareTxArgsSubmitV1(
|
|
129
|
+
txData: ContractInvokeTransactionData,
|
|
130
|
+
zkProofResponse: ZeroKnowledgeProofResponse
|
|
131
|
+
): Promise<JsonDocumentObjectValue[]> {
|
|
132
|
+
if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitZKPResponseV1) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
`prepareTxArgsSubmitV1 function doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitZKPResponseV1}' is supported.`
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
const requestID = zkProofResponse.id;
|
|
138
|
+
const inputs = zkProofResponse.pub_signals;
|
|
139
|
+
|
|
140
|
+
const preparedZkpProof = prepareZkpProof(zkProofResponse.proof);
|
|
141
|
+
const payload = [requestID, inputs, preparedZkpProof.a, preparedZkpProof.b, preparedZkpProof.c];
|
|
142
|
+
|
|
143
|
+
return payload;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* {@inheritDoc IOnChainZKPVerifier.prepareTxArgsSubmitV1}
|
|
147
|
+
*/
|
|
148
|
+
public async prepareTxArgsSubmitV1(
|
|
149
|
+
txData: ContractInvokeTransactionData,
|
|
150
|
+
zkProofResponse: ZeroKnowledgeProofResponse
|
|
151
|
+
): Promise<JsonDocumentObjectValue[]> {
|
|
152
|
+
return OnChainZKPVerifier.prepareTxArgsSubmitV1(txData, zkProofResponse);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* {@inheritDoc IOnChainZKPVerifier.submitZKPResponse}
|
|
157
|
+
*/
|
|
158
|
+
public async submitZKPResponse(
|
|
159
|
+
ethSigner: Signer,
|
|
160
|
+
txData: ContractInvokeTransactionData,
|
|
161
|
+
zkProofResponses: ZeroKnowledgeProofResponse[]
|
|
162
|
+
): Promise<Map<string, ZeroKnowledgeProofResponse>> {
|
|
163
|
+
const chainConfig = this._configs.find((i) => i.chainId == txData.chain_id);
|
|
164
|
+
if (!chainConfig) {
|
|
165
|
+
throw new Error(`config for chain id ${txData.chain_id} was not found`);
|
|
166
|
+
}
|
|
167
|
+
if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitZKPResponseV1) {
|
|
168
|
+
throw new Error(
|
|
169
|
+
`submitZKPResponse function doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitZKPResponseV1}' is supported.`
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
const provider = new JsonRpcProvider(chainConfig.url, chainConfig.chainId);
|
|
173
|
+
ethSigner = ethSigner.connect(provider);
|
|
174
|
+
const response = new Map<string, ZeroKnowledgeProofResponse>();
|
|
175
|
+
|
|
176
|
+
const feeData = await provider.getFeeData();
|
|
177
|
+
const maxFeePerGas = chainConfig.maxFeePerGas
|
|
178
|
+
? BigInt(chainConfig.maxFeePerGas)
|
|
179
|
+
: feeData.maxFeePerGas;
|
|
180
|
+
const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
|
|
181
|
+
? BigInt(chainConfig.maxPriorityFeePerGas)
|
|
182
|
+
: feeData.maxPriorityFeePerGas;
|
|
183
|
+
|
|
184
|
+
const verifierContract = new Contract(txData.contract_address, abi);
|
|
185
|
+
|
|
186
|
+
for (const zkProofResponse of zkProofResponses) {
|
|
187
|
+
const txArgs = await this.prepareTxArgsSubmitV1(txData, zkProofResponse);
|
|
188
|
+
const payload = await verifierContract.submitZKPResponse.populateTransaction(...txArgs);
|
|
189
|
+
const request: TransactionRequest = {
|
|
190
|
+
to: txData.contract_address,
|
|
191
|
+
data: payload.data,
|
|
192
|
+
maxFeePerGas,
|
|
193
|
+
maxPriorityFeePerGas
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
let gasLimit;
|
|
197
|
+
try {
|
|
198
|
+
gasLimit = await ethSigner.estimateGas(request);
|
|
199
|
+
} catch (e) {
|
|
200
|
+
gasLimit = maxGasLimit;
|
|
201
|
+
}
|
|
202
|
+
request.gasLimit = gasLimit;
|
|
203
|
+
|
|
204
|
+
const transactionService = new TransactionService(provider);
|
|
205
|
+
const { txnHash } = await transactionService.sendTransactionRequest(ethSigner, request);
|
|
206
|
+
response.set(txnHash, zkProofResponse);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return response;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* {@inheritDoc IOnChainZKPVerifier.submitZKPResponseV2}
|
|
214
|
+
*/
|
|
215
|
+
public async submitZKPResponseV2(
|
|
216
|
+
ethSigner: Signer,
|
|
217
|
+
txData: ContractInvokeTransactionData,
|
|
218
|
+
zkProofResponses: ZeroKnowledgeProofResponse[]
|
|
219
|
+
): Promise<Map<string, ZeroKnowledgeProofResponse[]>> {
|
|
220
|
+
const chainConfig = this._configs.find((i) => i.chainId == txData.chain_id);
|
|
221
|
+
if (!chainConfig) {
|
|
222
|
+
throw new Error(`config for chain id ${txData.chain_id} was not found`);
|
|
223
|
+
}
|
|
224
|
+
if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitZKPResponseV2) {
|
|
225
|
+
throw new Error(
|
|
226
|
+
`submitZKPResponseV2 function doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitZKPResponseV2}' is supported.`
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
if (!this._opts?.didResolverUrl) {
|
|
230
|
+
throw new Error(`did resolver url required for crosschain verification`);
|
|
231
|
+
}
|
|
232
|
+
const provider = new JsonRpcProvider(chainConfig.url, chainConfig.chainId);
|
|
233
|
+
ethSigner = ethSigner.connect(provider);
|
|
234
|
+
|
|
235
|
+
const txDataArgs = await this.prepareTxArgsSubmitV2(txData, zkProofResponses);
|
|
236
|
+
const feeData = await provider.getFeeData();
|
|
237
|
+
const maxFeePerGas = chainConfig.maxFeePerGas
|
|
238
|
+
? BigInt(chainConfig.maxFeePerGas)
|
|
239
|
+
: feeData.maxFeePerGas;
|
|
240
|
+
const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
|
|
241
|
+
? BigInt(chainConfig.maxPriorityFeePerGas)
|
|
242
|
+
: feeData.maxPriorityFeePerGas;
|
|
243
|
+
|
|
244
|
+
const verifierContract = new Contract(txData.contract_address, abi);
|
|
245
|
+
const txRequestData = await verifierContract.submitZKPResponseV2.populateTransaction(
|
|
246
|
+
...txDataArgs
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
const request: TransactionRequest = {
|
|
250
|
+
to: txData.contract_address,
|
|
251
|
+
data: txRequestData.data,
|
|
252
|
+
maxFeePerGas,
|
|
253
|
+
maxPriorityFeePerGas
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
let gasLimit;
|
|
257
|
+
try {
|
|
258
|
+
gasLimit = await ethSigner.estimateGas(request);
|
|
259
|
+
} catch (e) {
|
|
260
|
+
gasLimit = maxGasLimit;
|
|
261
|
+
}
|
|
262
|
+
request.gasLimit = gasLimit;
|
|
263
|
+
|
|
264
|
+
const transactionService = new TransactionService(provider);
|
|
265
|
+
const { txnHash } = await transactionService.sendTransactionRequest(ethSigner, request);
|
|
266
|
+
|
|
267
|
+
return new Map<string, ZeroKnowledgeProofResponse[]>().set(txnHash, zkProofResponses);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* {@inheritDoc IOnChainVerifierMultiQuery.submitResponse}
|
|
272
|
+
*/
|
|
273
|
+
public async submitResponse(
|
|
274
|
+
ethSigner: Signer,
|
|
275
|
+
txData: ContractInvokeTransactionData,
|
|
276
|
+
responses: ZeroKnowledgeProofResponse[],
|
|
277
|
+
authProof: AuthProof
|
|
278
|
+
): Promise<Map<string, ZeroKnowledgeInvokeResponse>> {
|
|
279
|
+
const chainConfig = this._configs.find((i) => i.chainId == txData.chain_id);
|
|
280
|
+
if (!chainConfig) {
|
|
281
|
+
throw new Error(`config for chain id ${txData.chain_id} was not found`);
|
|
282
|
+
}
|
|
283
|
+
if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitResponse) {
|
|
284
|
+
throw new Error(
|
|
285
|
+
`submitResponse function doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitResponse}' is supported.`
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
if (!this._opts?.didResolverUrl) {
|
|
289
|
+
throw new Error(`did resolver url required for crosschain verification`);
|
|
290
|
+
}
|
|
291
|
+
const provider = new JsonRpcProvider(chainConfig.url, chainConfig.chainId);
|
|
292
|
+
ethSigner = ethSigner.connect(provider);
|
|
293
|
+
|
|
294
|
+
const txPreparationResult = await this.prepareTxArgsSubmit(txData, responses, authProof);
|
|
295
|
+
|
|
296
|
+
const feeData = await provider.getFeeData();
|
|
297
|
+
const maxFeePerGas = chainConfig.maxFeePerGas
|
|
298
|
+
? BigInt(chainConfig.maxFeePerGas)
|
|
299
|
+
: feeData.maxFeePerGas;
|
|
300
|
+
const maxPriorityFeePerGas = chainConfig.maxPriorityFeePerGas
|
|
301
|
+
? BigInt(chainConfig.maxPriorityFeePerGas)
|
|
302
|
+
: feeData.maxPriorityFeePerGas;
|
|
303
|
+
|
|
304
|
+
const verifierContract = new Contract(txData.contract_address, IVerifierABI);
|
|
305
|
+
const txRequestData = await verifierContract.submitResponse.populateTransaction(
|
|
306
|
+
...txPreparationResult.txDataArgs
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
const request: TransactionRequest = {
|
|
310
|
+
to: txData.contract_address,
|
|
311
|
+
data: txRequestData.data,
|
|
312
|
+
maxFeePerGas,
|
|
313
|
+
maxPriorityFeePerGas
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
let gasLimit;
|
|
317
|
+
try {
|
|
318
|
+
gasLimit = await ethSigner.estimateGas(request);
|
|
319
|
+
} catch (e) {
|
|
320
|
+
gasLimit = maxGasLimit;
|
|
321
|
+
}
|
|
322
|
+
request.gasLimit = gasLimit;
|
|
323
|
+
|
|
324
|
+
const transactionService = new TransactionService(provider);
|
|
325
|
+
const { txnHash } = await transactionService.sendTransactionRequest(ethSigner, request);
|
|
326
|
+
|
|
327
|
+
// return multiple responses for all the responses (single and grouped)
|
|
328
|
+
return new Map<string, ZeroKnowledgeInvokeResponse>().set(txnHash, {
|
|
329
|
+
authProof: txPreparationResult.result.authProof.raw,
|
|
330
|
+
crossChainProof: txPreparationResult.result.crossChainProof.raw,
|
|
331
|
+
responses: txPreparationResult.result.proofs.map((m) => m.proof)
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
public static async prepareTxArgsSubmit(
|
|
336
|
+
resolverUrl: string,
|
|
337
|
+
txData: ContractInvokeTransactionData,
|
|
338
|
+
responses: ZeroKnowledgeProofResponse[],
|
|
339
|
+
authProof: AuthProof
|
|
340
|
+
): Promise<{ result: TxPreparationResultSubmitResponse; txDataArgs: JsonDocumentObjectValue[] }> {
|
|
341
|
+
if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitResponse) {
|
|
342
|
+
throw new Error(
|
|
343
|
+
`submit cross chain doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitResponse}' is supported.`
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
const gistUpdatesArr: GlobalStateUpdate[] = [];
|
|
347
|
+
const stateUpdatesArr: IdentityStateUpdate[] = [];
|
|
348
|
+
const payloadResponses = [];
|
|
349
|
+
const emptyBytes = '0x';
|
|
350
|
+
|
|
351
|
+
let encodedAuthProof = '';
|
|
352
|
+
|
|
353
|
+
switch (authProof.authMethod) {
|
|
354
|
+
case AuthMethod.AUTHV2: {
|
|
355
|
+
const preparedZkpProof = prepareZkpProof((authProof as AuthProofZKP).zkp.proof);
|
|
356
|
+
encodedAuthProof = packZkpProof(
|
|
357
|
+
(authProof as AuthProofZKP).zkp.pub_signals,
|
|
358
|
+
preparedZkpProof.a,
|
|
359
|
+
preparedZkpProof.b,
|
|
360
|
+
preparedZkpProof.c
|
|
361
|
+
);
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
case AuthMethod.ETH_IDENTITY: {
|
|
365
|
+
encodedAuthProof = packEthIdentityProof((authProof as AuthProofEthIdentity).userDid);
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
default:
|
|
369
|
+
throw new Error('auth proof must use method AuthV2 or ethIdentity');
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Process all the responses
|
|
373
|
+
for (const zkProof of responses) {
|
|
374
|
+
this.checkSupportedCircuit(zkProof.circuitId as CircuitId);
|
|
375
|
+
const { requestId, zkProofEncoded, metadata } = processProofResponse(zkProof);
|
|
376
|
+
|
|
377
|
+
payloadResponses.push({
|
|
378
|
+
proof: zkProof,
|
|
379
|
+
requestId: requestId,
|
|
380
|
+
encoded: zkProofEncoded,
|
|
381
|
+
metadata: metadata
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// Process all zkProofs and prepare cross chain proofs
|
|
386
|
+
const allZkProofs = responses.map((zkProof) => ({
|
|
387
|
+
circuitId: zkProof.circuitId as OnChainZKPVerifierCircuitId,
|
|
388
|
+
pub_signals: zkProof.pub_signals
|
|
389
|
+
}));
|
|
390
|
+
|
|
391
|
+
if (authProof.authMethod == AuthMethod.AUTHV2) {
|
|
392
|
+
allZkProofs.push({
|
|
393
|
+
circuitId: (authProof as AuthProofZKP).zkp.circuitId as OnChainZKPVerifierCircuitId,
|
|
394
|
+
pub_signals: (authProof as AuthProofZKP).zkp.pub_signals
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
for (const zkProof of allZkProofs) {
|
|
399
|
+
const { gistUpdateResolutions, stateUpdateResolutions } = this.getUpdateResolutions(
|
|
400
|
+
resolverUrl,
|
|
401
|
+
txData.chain_id,
|
|
402
|
+
zkProof.circuitId,
|
|
403
|
+
zkProof.pub_signals
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
if (gistUpdateResolutions.length > 0) {
|
|
407
|
+
gistUpdatesArr.push(...((await Promise.all(gistUpdateResolutions)) as GlobalStateUpdate[]));
|
|
408
|
+
}
|
|
409
|
+
if (stateUpdateResolutions.length > 0) {
|
|
410
|
+
stateUpdatesArr.push(
|
|
411
|
+
...((await Promise.all(stateUpdateResolutions)) as IdentityStateUpdate[])
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const encodedCrossChainProof =
|
|
417
|
+
gistUpdatesArr.length || stateUpdatesArr.length
|
|
418
|
+
? this.packCrossChainProofs(gistUpdatesArr, stateUpdatesArr)
|
|
419
|
+
: emptyBytes;
|
|
420
|
+
|
|
421
|
+
const preparationResult = {
|
|
422
|
+
authProof: { raw: authProof, encoded: encodedAuthProof },
|
|
423
|
+
proofs: payloadResponses,
|
|
424
|
+
crossChainProof: {
|
|
425
|
+
raw: {
|
|
426
|
+
globalStateProofs: gistUpdatesArr || [],
|
|
427
|
+
identityStateProofs: stateUpdatesArr || []
|
|
428
|
+
},
|
|
429
|
+
encoded: encodedCrossChainProof
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
return { result: preparationResult, txDataArgs: toTxDataArgs(preparationResult) };
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
public async prepareTxArgsSubmit(
|
|
436
|
+
txData: ContractInvokeTransactionData,
|
|
437
|
+
responses: ZeroKnowledgeProofResponse[],
|
|
438
|
+
authProof: AuthProof
|
|
439
|
+
): Promise<{ result: TxPreparationResultSubmitResponse; txDataArgs: JsonDocumentObjectValue[] }> {
|
|
440
|
+
if (!this._opts?.didResolverUrl) {
|
|
441
|
+
throw new Error(`did resolver url required for crosschain verification`);
|
|
442
|
+
}
|
|
443
|
+
return OnChainZKPVerifier.prepareTxArgsSubmit(
|
|
444
|
+
this._opts.didResolverUrl,
|
|
445
|
+
txData,
|
|
446
|
+
responses,
|
|
447
|
+
authProof
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
private static checkSupportedCircuit(circuitId: CircuitId) {
|
|
452
|
+
if (!this._supportedCircuits.includes(circuitId as OnChainZKPVerifierCircuitId)) {
|
|
453
|
+
throw new Error(`Circuit ${circuitId} not supported by OnChainZKPVerifier`);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
private static getCrossChainResolvers(
|
|
458
|
+
source: {
|
|
459
|
+
id: Id;
|
|
460
|
+
root?: Hash;
|
|
461
|
+
state?: Hash;
|
|
462
|
+
}[],
|
|
463
|
+
txDataChainId: number,
|
|
464
|
+
type: 'gist' | 'state',
|
|
465
|
+
didResolverUrl: string
|
|
466
|
+
) {
|
|
467
|
+
return [
|
|
468
|
+
...new Set(
|
|
469
|
+
source.map((info) =>
|
|
470
|
+
JSON.stringify({
|
|
471
|
+
id: info.id.string(),
|
|
472
|
+
[type]: type === 'gist' ? info.root?.string() : info.state?.string()
|
|
473
|
+
})
|
|
474
|
+
)
|
|
475
|
+
)
|
|
476
|
+
].reduce((acc: Promise<unknown>[], s: string) => {
|
|
477
|
+
const info = JSON.parse(s);
|
|
478
|
+
const id = Id.fromString(info.id);
|
|
479
|
+
const chainId = chainIDfromDID(DID.parseFromId(id));
|
|
480
|
+
|
|
481
|
+
if (txDataChainId === chainId) {
|
|
482
|
+
return acc;
|
|
483
|
+
}
|
|
484
|
+
const promise = this.resolveDidDocumentEip712MessageAndSignature(
|
|
485
|
+
DID.parseFromId(Id.fromString(info.id)),
|
|
486
|
+
didResolverUrl,
|
|
487
|
+
{
|
|
488
|
+
[type]: Hash.fromString(info[type])
|
|
489
|
+
}
|
|
490
|
+
);
|
|
491
|
+
return [...acc, promise];
|
|
492
|
+
}, []);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
public static async prepareTxArgsSubmitV2(
|
|
496
|
+
resolverUrl: string,
|
|
497
|
+
txData: ContractInvokeTransactionData,
|
|
498
|
+
zkProofResponses: ZeroKnowledgeProofResponse[]
|
|
499
|
+
): Promise<JsonDocumentObjectValue[]> {
|
|
500
|
+
if (txData.method_id.replace('0x', '') !== FunctionSignatures.SubmitZKPResponseV2) {
|
|
501
|
+
throw new Error(
|
|
502
|
+
`submit cross chain doesn't implement requested method id. Only '0x${FunctionSignatures.SubmitZKPResponseV2}' is supported.`
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
const gistUpdatesArr = [];
|
|
507
|
+
const stateUpdatesArr = [];
|
|
508
|
+
const payloadResponses = [];
|
|
509
|
+
const emptyBytes = '0x';
|
|
510
|
+
|
|
511
|
+
for (const zkProof of zkProofResponses) {
|
|
512
|
+
this.checkSupportedCircuit(zkProof.circuitId as CircuitId);
|
|
513
|
+
const { requestId, zkProofEncoded, metadata } = processProofResponse(zkProof);
|
|
514
|
+
|
|
515
|
+
payloadResponses.push({
|
|
516
|
+
requestId: requestId,
|
|
517
|
+
zkProof: zkProofEncoded,
|
|
518
|
+
data: metadata
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
const { gistUpdateResolutions, stateUpdateResolutions } = this.getUpdateResolutions(
|
|
522
|
+
resolverUrl,
|
|
523
|
+
txData.chain_id,
|
|
524
|
+
zkProof.circuitId as OnChainZKPVerifierCircuitId,
|
|
525
|
+
zkProof.pub_signals
|
|
526
|
+
);
|
|
527
|
+
|
|
528
|
+
if (gistUpdateResolutions.length > 0) {
|
|
529
|
+
gistUpdatesArr.push(...((await Promise.all(gistUpdateResolutions)) as GlobalStateUpdate[]));
|
|
530
|
+
}
|
|
531
|
+
if (stateUpdateResolutions.length > 0) {
|
|
532
|
+
stateUpdatesArr.push(
|
|
533
|
+
...((await Promise.all(stateUpdateResolutions)) as IdentityStateUpdate[])
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
const crossChainProofEncoded =
|
|
539
|
+
gistUpdatesArr.length || stateUpdatesArr.length
|
|
540
|
+
? this.packCrossChainProofs(gistUpdatesArr, stateUpdatesArr)
|
|
541
|
+
: emptyBytes;
|
|
542
|
+
return [payloadResponses, crossChainProofEncoded];
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
public async prepareTxArgsSubmitV2(
|
|
546
|
+
txData: ContractInvokeTransactionData,
|
|
547
|
+
zkProofResponses: ZeroKnowledgeProofResponse[]
|
|
548
|
+
): Promise<JsonDocumentObjectValue[]> {
|
|
549
|
+
if (!this._opts?.didResolverUrl) {
|
|
550
|
+
throw new Error(`did resolver url required for crosschain verification`);
|
|
551
|
+
}
|
|
552
|
+
return OnChainZKPVerifier.prepareTxArgsSubmitV2(
|
|
553
|
+
this._opts.didResolverUrl,
|
|
554
|
+
txData,
|
|
555
|
+
zkProofResponses
|
|
556
|
+
);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
private static getUpdateResolutions(
|
|
560
|
+
resolverUrl: string,
|
|
561
|
+
chainId: number,
|
|
562
|
+
proofCircuitId: OnChainZKPVerifierCircuitId,
|
|
563
|
+
inputs: string[]
|
|
564
|
+
) {
|
|
565
|
+
const stateInfo = this.getOnChainGistRootStatePubSignals(proofCircuitId, inputs);
|
|
566
|
+
|
|
567
|
+
const gistUpdateResolutions = this.getCrossChainResolvers(
|
|
568
|
+
stateInfo.gists,
|
|
569
|
+
chainId,
|
|
570
|
+
'gist',
|
|
571
|
+
resolverUrl
|
|
572
|
+
);
|
|
573
|
+
|
|
574
|
+
const stateUpdateResolutions = this.getCrossChainResolvers(
|
|
575
|
+
stateInfo.states,
|
|
576
|
+
chainId,
|
|
577
|
+
'state',
|
|
578
|
+
resolverUrl
|
|
579
|
+
);
|
|
580
|
+
|
|
581
|
+
return { gistUpdateResolutions, stateUpdateResolutions };
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
private static packCrossChainProofs(
|
|
585
|
+
gistUpdateArr: GlobalStateUpdate[],
|
|
586
|
+
stateUpdateArr: IdentityStateUpdate[]
|
|
587
|
+
) {
|
|
588
|
+
const proofs = [];
|
|
589
|
+
for (const globalStateUpdate of gistUpdateArr) {
|
|
590
|
+
proofs.push({
|
|
591
|
+
proofType: 'globalStateProof',
|
|
592
|
+
proof: this.packGlobalStateMsg(globalStateUpdate)
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
for (const stateUpdate of stateUpdateArr) {
|
|
596
|
+
proofs.push({
|
|
597
|
+
proofType: 'stateProof',
|
|
598
|
+
proof: this.packIdentityStateMsg(stateUpdate)
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
return new ethers.AbiCoder().encode(
|
|
602
|
+
['tuple(' + 'string proofType,' + 'bytes proof' + ')[]'],
|
|
603
|
+
[proofs]
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
public static packGlobalStateMsg(msg: GlobalStateUpdate): string {
|
|
608
|
+
return new ethers.AbiCoder().encode(
|
|
609
|
+
[
|
|
610
|
+
'tuple(' +
|
|
611
|
+
'tuple(' +
|
|
612
|
+
'uint256 timestamp,' +
|
|
613
|
+
'bytes2 idType,' +
|
|
614
|
+
'uint256 root,' +
|
|
615
|
+
'uint256 replacedAtTimestamp' +
|
|
616
|
+
') globalStateMsg,' +
|
|
617
|
+
'bytes signature,' +
|
|
618
|
+
')'
|
|
619
|
+
],
|
|
620
|
+
[msg]
|
|
621
|
+
);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
private static packIdentityStateMsg(msg: IdentityStateUpdate): string {
|
|
625
|
+
return new ethers.AbiCoder().encode(
|
|
626
|
+
[
|
|
627
|
+
'tuple(' +
|
|
628
|
+
'tuple(' +
|
|
629
|
+
'uint256 timestamp,' +
|
|
630
|
+
'uint256 id,' +
|
|
631
|
+
'uint256 state,' +
|
|
632
|
+
'uint256 replacedAtTimestamp' +
|
|
633
|
+
') idStateMsg,' +
|
|
634
|
+
'bytes signature,' +
|
|
635
|
+
')'
|
|
636
|
+
],
|
|
637
|
+
[msg]
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
private static getOnChainGistRootStatePubSignals(
|
|
642
|
+
onChainCircuitId: OnChainZKPVerifierCircuitId,
|
|
643
|
+
inputs: string[]
|
|
644
|
+
): StatesInfo {
|
|
645
|
+
const PubSignals = this._supportedCircuitsPubSignalsMap[onChainCircuitId];
|
|
646
|
+
if (!PubSignals) {
|
|
647
|
+
throw new Error(`Circuit ${onChainCircuitId} not supported by OnChainZKPVerifier`);
|
|
648
|
+
}
|
|
649
|
+
const atomicQueryPubSignals = new PubSignals();
|
|
650
|
+
const encodedInputs = byteEncoder.encode(JSON.stringify(inputs));
|
|
651
|
+
atomicQueryPubSignals.pubSignalsUnmarshal(encodedInputs);
|
|
652
|
+
return atomicQueryPubSignals.getStatesInfo();
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
private static async resolveDidDocumentEip712MessageAndSignature(
|
|
656
|
+
did: DID,
|
|
657
|
+
resolverUrl: string,
|
|
658
|
+
opts?: {
|
|
659
|
+
state?: Hash;
|
|
660
|
+
gist?: Hash;
|
|
661
|
+
}
|
|
662
|
+
) {
|
|
663
|
+
const didDoc = await resolveDidDocument(did, resolverUrl, {
|
|
664
|
+
...opts,
|
|
665
|
+
signature: DIDDocumentSignature.EthereumEip712Signature2021
|
|
666
|
+
});
|
|
667
|
+
if (!didDoc.didResolutionMetadata.proof?.length) {
|
|
668
|
+
throw new Error('No proof found in resolved DID document');
|
|
669
|
+
}
|
|
670
|
+
const message = didDoc.didResolutionMetadata.proof[0].eip712.message;
|
|
671
|
+
const signature = didDoc.didResolutionMetadata.proof[0].proofValue;
|
|
672
|
+
const isGistRequest = opts?.gist && !opts.state;
|
|
673
|
+
if (isGistRequest) {
|
|
674
|
+
return {
|
|
675
|
+
globalStateMsg: {
|
|
676
|
+
timestamp: message.timestamp,
|
|
677
|
+
idType: message.idType,
|
|
678
|
+
root: message.root,
|
|
679
|
+
replacedAtTimestamp: message.replacedAtTimestamp
|
|
680
|
+
},
|
|
681
|
+
signature
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
return {
|
|
686
|
+
idStateMsg: {
|
|
687
|
+
timestamp: message.timestamp,
|
|
688
|
+
id: message.id,
|
|
689
|
+
state: message.state,
|
|
690
|
+
replacedAtTimestamp: message.replacedAtTimestamp
|
|
691
|
+
},
|
|
692
|
+
signature
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Packs an Ethereum identity proof from a Decentralized Identifier (DID).
|
|
699
|
+
* @param did - Decentralized Identifier (DID) to pack.
|
|
700
|
+
* @returns A hexadecimal string representing the packed DID identity proof.
|
|
701
|
+
*/
|
|
702
|
+
export const packEthIdentityProof = (did: DID): string => {
|
|
703
|
+
return `0x${bytesToHex(BytesHelper.intToBytes(DID.idFromDID(did).bigInt()))}`;
|
|
704
|
+
};
|