@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,623 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BytesHelper,
|
|
3
|
+
DID,
|
|
4
|
+
MerklizedRootPosition,
|
|
5
|
+
getDateFromUnixTimestamp
|
|
6
|
+
} from '@mocanetwork/moca-iden3';
|
|
7
|
+
import {
|
|
8
|
+
AuthV2Inputs,
|
|
9
|
+
AuthV2PubSignals,
|
|
10
|
+
CircuitId,
|
|
11
|
+
Operators,
|
|
12
|
+
Query,
|
|
13
|
+
TreeState,
|
|
14
|
+
ValueProof
|
|
15
|
+
} from '../circuits';
|
|
16
|
+
import { ICredentialWallet } from '../credentials';
|
|
17
|
+
import { IIdentityWallet } from '../identity';
|
|
18
|
+
import {
|
|
19
|
+
createVerifiablePresentation,
|
|
20
|
+
ProofQuery,
|
|
21
|
+
RevocationStatus,
|
|
22
|
+
VerifiableConstants,
|
|
23
|
+
W3CCredential
|
|
24
|
+
} from '../verifiable';
|
|
25
|
+
import {
|
|
26
|
+
PreparedCredential,
|
|
27
|
+
QueryMetadata,
|
|
28
|
+
parseCredentialSubject,
|
|
29
|
+
parseQueryMetadata,
|
|
30
|
+
toGISTProof,
|
|
31
|
+
transformQueryValueToBigInts
|
|
32
|
+
} from './common';
|
|
33
|
+
import { IZKProver, NativeProver } from './provers/prover';
|
|
34
|
+
|
|
35
|
+
import { Merklizer, Options, getDocumentLoader } from '@iden3/js-jsonld-merklization';
|
|
36
|
+
import { ZKProof } from '@iden3/js-jwz';
|
|
37
|
+
import { Signer } from 'ethers';
|
|
38
|
+
import {
|
|
39
|
+
StateVerificationOpts,
|
|
40
|
+
JSONObject,
|
|
41
|
+
ZeroKnowledgeProofRequest,
|
|
42
|
+
ZeroKnowledgeProofResponse,
|
|
43
|
+
PROTOCOL_CONSTANTS,
|
|
44
|
+
VerifiablePresentation,
|
|
45
|
+
JsonDocumentObject,
|
|
46
|
+
ZeroKnowledgeProofAuthResponse
|
|
47
|
+
} from '../iden3comm';
|
|
48
|
+
import { cacheLoader } from '../schema-processor';
|
|
49
|
+
import { ICircuitStorage, IStateStorage } from '../storage';
|
|
50
|
+
import { byteDecoder, byteEncoder } from '../utils/encoding';
|
|
51
|
+
import {
|
|
52
|
+
AuthProofGenerationOptions,
|
|
53
|
+
InputGenerator,
|
|
54
|
+
ProofGenerationOptions,
|
|
55
|
+
ProofInputsParams
|
|
56
|
+
} from './provers/inputs-generator';
|
|
57
|
+
import { PubSignalsVerifier, VerifyContext } from './verifiers/pub-signals-verifier';
|
|
58
|
+
import { VerifyOpts } from './verifiers';
|
|
59
|
+
|
|
60
|
+
export interface QueryWithFieldName {
|
|
61
|
+
query: Query;
|
|
62
|
+
fieldName: string;
|
|
63
|
+
rawValue?: unknown;
|
|
64
|
+
isSelectiveDisclosure?: boolean;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Metadata that returns on verification
|
|
69
|
+
* @type VerificationResultMetadata
|
|
70
|
+
*/
|
|
71
|
+
export type VerificationResultMetadata = {
|
|
72
|
+
linkID?: number;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* List of options to customize ProofService
|
|
77
|
+
*/
|
|
78
|
+
export type ProofServiceOptions = Options & {
|
|
79
|
+
prover?: IZKProver;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export interface ProofVerifyOpts {
|
|
83
|
+
query: ProofQuery;
|
|
84
|
+
sender: string;
|
|
85
|
+
opts?: VerifyOpts;
|
|
86
|
+
params?: JSONObject;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface IProofService {
|
|
90
|
+
/**
|
|
91
|
+
* Verification of zkp proof for given circuit id
|
|
92
|
+
*
|
|
93
|
+
* @param {ZKProof} zkp - proof to verify
|
|
94
|
+
* @param {CircuitId} circuitId - circuit id
|
|
95
|
+
* @returns `{Promise<boolean>}`
|
|
96
|
+
*/
|
|
97
|
+
verifyProof(zkp: ZKProof, circuitName: CircuitId): Promise<boolean>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Verification of zkp proof and pub signals for given circuit id
|
|
101
|
+
*
|
|
102
|
+
* @param {ZeroKnowledgeProofResponse} response - zero knowledge proof response
|
|
103
|
+
* @param {ProofVerifyOpts} opts - proof verification options
|
|
104
|
+
* @returns `{Promise<VerificationResultMetadata>}`
|
|
105
|
+
*/
|
|
106
|
+
verifyZKPResponse(
|
|
107
|
+
proofResp: ZeroKnowledgeProofResponse,
|
|
108
|
+
opts: ProofVerifyOpts
|
|
109
|
+
): Promise<VerificationResultMetadata>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Generate proof from given identity and credential for protocol proof request
|
|
113
|
+
*
|
|
114
|
+
* @param {ZeroKnowledgeProofRequest} proofReq - protocol zkp request
|
|
115
|
+
* @param {DID} identifier - did that will generate proof
|
|
116
|
+
* @param {W3CCredential} credential - credential that will be used for proof generation
|
|
117
|
+
* @param {ProofGenerationOptions} opts - options that will be used for proof generation
|
|
118
|
+
*
|
|
119
|
+
* @returns `Promise<ZeroKnowledgeProofResponse>`
|
|
120
|
+
*/
|
|
121
|
+
generateProof(
|
|
122
|
+
proofReq: ZeroKnowledgeProofRequest,
|
|
123
|
+
identifier: DID,
|
|
124
|
+
opts?: ProofGenerationOptions
|
|
125
|
+
): Promise<ZeroKnowledgeProofResponse>;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* generates auth inputs
|
|
129
|
+
*
|
|
130
|
+
* @param {Uint8Array} hash - challenge that will be signed
|
|
131
|
+
* @param {DID} did - identity that will generate a proof
|
|
132
|
+
* @param {CircuitId} circuitId - circuit id for authentication
|
|
133
|
+
* @returns `Promise<Uint8Array>`
|
|
134
|
+
*/
|
|
135
|
+
generateAuthV2Inputs(hash: Uint8Array, did: DID, circuitId: CircuitId): Promise<Uint8Array>;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* generates auth v2 proof from given identity
|
|
139
|
+
*
|
|
140
|
+
* @param {Uint8Array} hash - challenge that will be signed
|
|
141
|
+
* @param {DID} did - identity that will generate a proof
|
|
142
|
+
* @returns `Promise<ZKProof>`
|
|
143
|
+
*/
|
|
144
|
+
generateAuthV2Proof(hash: Uint8Array, did: DID): Promise<ZKProof>;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Generate auth proof from given identity with generic params
|
|
148
|
+
*
|
|
149
|
+
* @param {CircuitId} circuitId - circuitId for the proof generation
|
|
150
|
+
* @param {DID} identifier - did that will generate proof
|
|
151
|
+
* @param {ProofGenerationOptions} opts - options that will be used for proof generation
|
|
152
|
+
*
|
|
153
|
+
* @returns `Promise<ZeroKnowledgeProofResponse>`
|
|
154
|
+
*/
|
|
155
|
+
generateAuthProof(
|
|
156
|
+
circuitId: CircuitId,
|
|
157
|
+
identifier: DID,
|
|
158
|
+
opts?: AuthProofGenerationOptions
|
|
159
|
+
): Promise<ZeroKnowledgeProofAuthResponse>;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* state verification function
|
|
163
|
+
*
|
|
164
|
+
* @param {string} circuitId - id of authentication circuit
|
|
165
|
+
* @param {Array<string>} pubSignals - public signals of authentication circuit
|
|
166
|
+
* @returns `Promise<boolean>`
|
|
167
|
+
*/
|
|
168
|
+
verifyState(circuitId: string, pubSignals: Array<string>): Promise<boolean>;
|
|
169
|
+
/**
|
|
170
|
+
* transitState is done always to the latest state
|
|
171
|
+
*
|
|
172
|
+
* Generates a state transition proof and publishes state to the blockchain
|
|
173
|
+
*
|
|
174
|
+
* @param {DID} did - identity that will transit state
|
|
175
|
+
* @param {TreeState} oldTreeState - previous tree state
|
|
176
|
+
* @param {boolean} isOldStateGenesis - is a transition state is done from genesis state
|
|
177
|
+
* @param {Signer} ethSigner - signer for transaction
|
|
178
|
+
* @returns `{Promise<string>}` - transaction hash is returned
|
|
179
|
+
*/
|
|
180
|
+
transitState(
|
|
181
|
+
did: DID,
|
|
182
|
+
oldTreeState: TreeState,
|
|
183
|
+
isOldStateGenesis: boolean,
|
|
184
|
+
stateStorage: IStateStorage,
|
|
185
|
+
ethSigner: Signer
|
|
186
|
+
): Promise<string>;
|
|
187
|
+
|
|
188
|
+
findCredentialByProofQuery(
|
|
189
|
+
did: DID,
|
|
190
|
+
query: ProofQuery,
|
|
191
|
+
opts?: { skipClaimRevocationCheck: boolean }
|
|
192
|
+
): Promise<{ cred: W3CCredential; revStatus: RevocationStatus | undefined }>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Proof service is an implementation of IProofService
|
|
196
|
+
* that works with a native groth16 prover
|
|
197
|
+
*
|
|
198
|
+
* @public
|
|
199
|
+
* @class ProofService
|
|
200
|
+
* @implements implements IProofService interface
|
|
201
|
+
*/
|
|
202
|
+
export class ProofService implements IProofService {
|
|
203
|
+
private readonly _prover: IZKProver;
|
|
204
|
+
private readonly _ldOptions: Options;
|
|
205
|
+
private readonly _inputsGenerator: InputGenerator;
|
|
206
|
+
private readonly _pubSignalsVerifier: PubSignalsVerifier;
|
|
207
|
+
/**
|
|
208
|
+
* Creates an instance of ProofService.
|
|
209
|
+
* @param {IIdentityWallet} _identityWallet - identity wallet
|
|
210
|
+
* @param {ICredentialWallet} _credentialWallet - credential wallet
|
|
211
|
+
* @param {ICircuitStorage} _circuitStorage - circuit storage to load proving / verification files
|
|
212
|
+
* @param {IStateStorage} _stateStorage - state storage to get GIST proof / publish state
|
|
213
|
+
*/
|
|
214
|
+
constructor(
|
|
215
|
+
private readonly _identityWallet: IIdentityWallet,
|
|
216
|
+
private readonly _credentialWallet: ICredentialWallet,
|
|
217
|
+
_circuitStorage: ICircuitStorage,
|
|
218
|
+
private readonly _stateStorage: IStateStorage,
|
|
219
|
+
opts?: ProofServiceOptions
|
|
220
|
+
) {
|
|
221
|
+
this._prover = opts?.prover ?? new NativeProver(_circuitStorage);
|
|
222
|
+
this._ldOptions = { ...opts, documentLoader: opts?.documentLoader ?? cacheLoader(opts) };
|
|
223
|
+
this._inputsGenerator = new InputGenerator(_identityWallet, _credentialWallet, _stateStorage);
|
|
224
|
+
this._pubSignalsVerifier = new PubSignalsVerifier(
|
|
225
|
+
opts?.documentLoader ?? cacheLoader(opts),
|
|
226
|
+
_stateStorage
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** {@inheritdoc IProofService.verifyProof} */
|
|
231
|
+
async verifyProof(zkp: ZKProof, circuitId: CircuitId): Promise<boolean> {
|
|
232
|
+
return this._prover.verify(zkp, circuitId);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** {@inheritdoc IProofService.verify} */
|
|
236
|
+
async verifyZKPResponse(
|
|
237
|
+
proofResp: ZeroKnowledgeProofResponse,
|
|
238
|
+
opts: ProofVerifyOpts
|
|
239
|
+
): Promise<VerificationResultMetadata> {
|
|
240
|
+
const proofValid = await this._prover.verify(proofResp, proofResp.circuitId);
|
|
241
|
+
if (!proofValid) {
|
|
242
|
+
throw Error(
|
|
243
|
+
`Proof with circuit id ${proofResp.circuitId} and request id ${proofResp.id} is not valid`
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const verifyContext: VerifyContext = {
|
|
248
|
+
pubSignals: proofResp.pub_signals,
|
|
249
|
+
query: opts.query,
|
|
250
|
+
verifiablePresentation: proofResp.vp,
|
|
251
|
+
sender: opts.sender,
|
|
252
|
+
challenge: BigInt(proofResp.id),
|
|
253
|
+
opts: opts.opts,
|
|
254
|
+
params: opts.params
|
|
255
|
+
};
|
|
256
|
+
const pubSignals = await this._pubSignalsVerifier.verify(proofResp.circuitId, verifyContext);
|
|
257
|
+
|
|
258
|
+
return { linkID: (pubSignals as unknown as { linkID?: number }).linkID };
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** {@inheritdoc IProofService.generateProof} */
|
|
262
|
+
async generateProof(
|
|
263
|
+
proofReq: ZeroKnowledgeProofRequest,
|
|
264
|
+
identifier: DID,
|
|
265
|
+
opts?: ProofGenerationOptions
|
|
266
|
+
): Promise<ZeroKnowledgeProofResponse> {
|
|
267
|
+
if (!opts) {
|
|
268
|
+
opts = {
|
|
269
|
+
skipRevocation: false,
|
|
270
|
+
challenge: 0n
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
let credentialWithRevStatus: {
|
|
275
|
+
cred: W3CCredential | undefined;
|
|
276
|
+
revStatus: RevocationStatus | undefined;
|
|
277
|
+
} = { cred: opts.credential, revStatus: opts.credentialRevocationStatus };
|
|
278
|
+
|
|
279
|
+
if (!opts.credential) {
|
|
280
|
+
credentialWithRevStatus = await this.findCredentialByProofQuery(identifier, proofReq.query);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (opts.credential && !opts.credentialRevocationStatus && !opts.skipRevocation) {
|
|
284
|
+
const revStatus = await this._credentialWallet.getRevocationStatusFromCredential(
|
|
285
|
+
opts.credential
|
|
286
|
+
);
|
|
287
|
+
credentialWithRevStatus = { cred: opts.credential, revStatus };
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (!credentialWithRevStatus.cred) {
|
|
291
|
+
throw new Error(
|
|
292
|
+
VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_QUERY +
|
|
293
|
+
` ${JSON.stringify(proofReq.query)}`
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const credentialCoreClaim = await this._identityWallet.getCoreClaimFromCredential(
|
|
298
|
+
credentialWithRevStatus.cred
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
const { nonce: authProfileNonce, genesisDID } =
|
|
302
|
+
await this._identityWallet.getGenesisDIDMetadata(identifier);
|
|
303
|
+
|
|
304
|
+
const preparedCredential: PreparedCredential = {
|
|
305
|
+
credential: credentialWithRevStatus.cred,
|
|
306
|
+
credentialCoreClaim,
|
|
307
|
+
revStatus: credentialWithRevStatus.revStatus
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
const subjectDID = DID.parse(preparedCredential.credential.credentialSubject['id'] as string);
|
|
311
|
+
|
|
312
|
+
const { nonce: credentialSubjectProfileNonce, genesisDID: subjectGenesisDID } =
|
|
313
|
+
await this._identityWallet.getGenesisDIDMetadata(subjectDID);
|
|
314
|
+
|
|
315
|
+
if (subjectGenesisDID.string() !== genesisDID.string()) {
|
|
316
|
+
throw new Error(VerifiableConstants.ERRORS.PROOF_SERVICE_PROFILE_GENESIS_DID_MISMATCH);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const propertiesMetadata = parseCredentialSubject(
|
|
320
|
+
proofReq.query.credentialSubject as JsonDocumentObject
|
|
321
|
+
);
|
|
322
|
+
if (!propertiesMetadata.length) {
|
|
323
|
+
throw new Error(VerifiableConstants.ERRORS.PROOF_SERVICE_NO_QUERIES_IN_ZKP_REQUEST);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const mtPosition = preparedCredential.credentialCoreClaim.getMerklizedPosition();
|
|
327
|
+
|
|
328
|
+
let mk: Merklizer | undefined;
|
|
329
|
+
if (mtPosition !== MerklizedRootPosition.None) {
|
|
330
|
+
mk = await preparedCredential.credential.merklize(this._ldOptions);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const context = proofReq.query['context'] as string;
|
|
334
|
+
const groupId = proofReq.query['groupId'] as number;
|
|
335
|
+
|
|
336
|
+
const ldContext = await this.loadLdContext(context);
|
|
337
|
+
|
|
338
|
+
const credentialType = proofReq.query['type'] as string;
|
|
339
|
+
const queriesMetadata: QueryMetadata[] = [];
|
|
340
|
+
const circuitQueries: Query[] = [];
|
|
341
|
+
|
|
342
|
+
for (const propertyMetadata of propertiesMetadata) {
|
|
343
|
+
const queryMetadata = await parseQueryMetadata(
|
|
344
|
+
propertyMetadata,
|
|
345
|
+
byteDecoder.decode(ldContext),
|
|
346
|
+
credentialType,
|
|
347
|
+
this._ldOptions
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
queriesMetadata.push(queryMetadata);
|
|
351
|
+
const circuitQuery = await this.toCircuitsQuery(
|
|
352
|
+
preparedCredential.credential,
|
|
353
|
+
queryMetadata,
|
|
354
|
+
mk
|
|
355
|
+
);
|
|
356
|
+
circuitQueries.push(circuitQuery);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const inputs = await this.generateInputs(
|
|
360
|
+
preparedCredential,
|
|
361
|
+
genesisDID,
|
|
362
|
+
proofReq,
|
|
363
|
+
{
|
|
364
|
+
...opts,
|
|
365
|
+
authProfileNonce,
|
|
366
|
+
credentialSubjectProfileNonce,
|
|
367
|
+
linkNonce: groupId ? opts.linkNonce : 0n
|
|
368
|
+
},
|
|
369
|
+
circuitQueries
|
|
370
|
+
);
|
|
371
|
+
|
|
372
|
+
const sdQueries = queriesMetadata.filter((q) => q.operator === Operators.SD);
|
|
373
|
+
let vp: VerifiablePresentation | undefined;
|
|
374
|
+
if (sdQueries.length) {
|
|
375
|
+
vp = createVerifiablePresentation(
|
|
376
|
+
context,
|
|
377
|
+
credentialType,
|
|
378
|
+
preparedCredential.credential,
|
|
379
|
+
sdQueries
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
const { proof, pub_signals } = await this._prover.generate(inputs, proofReq.circuitId);
|
|
384
|
+
|
|
385
|
+
return {
|
|
386
|
+
id: proofReq.id,
|
|
387
|
+
circuitId: proofReq.circuitId,
|
|
388
|
+
vp,
|
|
389
|
+
proof,
|
|
390
|
+
pub_signals
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** {@inheritdoc IProofService.generateAuthProof} */
|
|
395
|
+
async generateAuthProof(
|
|
396
|
+
circuitId: CircuitId,
|
|
397
|
+
identifier: DID,
|
|
398
|
+
opts?: AuthProofGenerationOptions
|
|
399
|
+
): Promise<ZeroKnowledgeProofAuthResponse> {
|
|
400
|
+
if (!opts) {
|
|
401
|
+
opts = {
|
|
402
|
+
challenge: 0n
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
let zkProof;
|
|
407
|
+
|
|
408
|
+
switch (circuitId) {
|
|
409
|
+
case CircuitId.AuthV2:
|
|
410
|
+
{
|
|
411
|
+
const challenge = opts.challenge
|
|
412
|
+
? BytesHelper.intToBytes(opts.challenge).reverse()
|
|
413
|
+
: new Uint8Array(32);
|
|
414
|
+
zkProof = await this.generateAuthV2Proof(challenge, identifier);
|
|
415
|
+
}
|
|
416
|
+
return {
|
|
417
|
+
circuitId: circuitId,
|
|
418
|
+
proof: zkProof.proof,
|
|
419
|
+
pub_signals: zkProof.pub_signals
|
|
420
|
+
};
|
|
421
|
+
default:
|
|
422
|
+
throw new Error(`CircuitId ${circuitId} is not supported`);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** {@inheritdoc IProofService.transitState} */
|
|
427
|
+
async transitState(
|
|
428
|
+
did: DID,
|
|
429
|
+
oldTreeState: TreeState,
|
|
430
|
+
isOldStateGenesis: boolean,
|
|
431
|
+
stateStorage: IStateStorage, // for compatibility with previous versions we leave this parameter
|
|
432
|
+
ethSigner: Signer
|
|
433
|
+
): Promise<string> {
|
|
434
|
+
return this._identityWallet.transitState(
|
|
435
|
+
did,
|
|
436
|
+
oldTreeState,
|
|
437
|
+
isOldStateGenesis,
|
|
438
|
+
ethSigner,
|
|
439
|
+
this._prover
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
private async generateInputs(
|
|
444
|
+
preparedCredential: PreparedCredential,
|
|
445
|
+
identifier: DID,
|
|
446
|
+
proofReq: ZeroKnowledgeProofRequest,
|
|
447
|
+
params: ProofInputsParams,
|
|
448
|
+
circuitQueries: Query[]
|
|
449
|
+
): Promise<Uint8Array> {
|
|
450
|
+
return this._inputsGenerator.generateInputs({
|
|
451
|
+
preparedCredential,
|
|
452
|
+
identifier,
|
|
453
|
+
proofReq,
|
|
454
|
+
params,
|
|
455
|
+
circuitQueries
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
private async toCircuitsQuery(
|
|
460
|
+
credential: W3CCredential,
|
|
461
|
+
queryMetadata: QueryMetadata,
|
|
462
|
+
merklizedCredential?: Merklizer
|
|
463
|
+
): Promise<Query> {
|
|
464
|
+
if (queryMetadata.merklizedSchema && !merklizedCredential) {
|
|
465
|
+
throw new Error('merklized root position is set to None for merklized schema');
|
|
466
|
+
}
|
|
467
|
+
if (!queryMetadata.merklizedSchema && merklizedCredential) {
|
|
468
|
+
throw new Error('merklized root position is not set to None for non-merklized schema');
|
|
469
|
+
}
|
|
470
|
+
const query = new Query();
|
|
471
|
+
|
|
472
|
+
query.slotIndex = queryMetadata.slotIndex;
|
|
473
|
+
query.operator = queryMetadata.operator;
|
|
474
|
+
query.values = queryMetadata.values;
|
|
475
|
+
|
|
476
|
+
if (queryMetadata.merklizedSchema && merklizedCredential) {
|
|
477
|
+
const { proof, value: mtValue } = await merklizedCredential.proof(queryMetadata.path);
|
|
478
|
+
query.valueProof = new ValueProof();
|
|
479
|
+
query.valueProof.mtp = proof;
|
|
480
|
+
query.valueProof.path = queryMetadata.claimPathKey;
|
|
481
|
+
|
|
482
|
+
const mtEntry = (await mtValue?.mtEntry()) ?? 0n;
|
|
483
|
+
query.valueProof.value = mtEntry;
|
|
484
|
+
if (!queryMetadata.fieldName) {
|
|
485
|
+
query.values = [mtEntry];
|
|
486
|
+
return query;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (queryMetadata.operator === Operators.SD) {
|
|
491
|
+
const [first, ...rest] = queryMetadata.fieldName.split('.');
|
|
492
|
+
let v = credential.credentialSubject[first];
|
|
493
|
+
for (const part of rest) {
|
|
494
|
+
v = (v as JsonDocumentObject)[part];
|
|
495
|
+
}
|
|
496
|
+
if (typeof v === 'undefined') {
|
|
497
|
+
throw new Error(`credential doesn't contain value for field ${queryMetadata.fieldName}`);
|
|
498
|
+
}
|
|
499
|
+
query.values = await transformQueryValueToBigInts(v, queryMetadata.datatype);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
return query;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
private async loadLdContext(context: string): Promise<Uint8Array> {
|
|
506
|
+
const loader = getDocumentLoader(this._ldOptions);
|
|
507
|
+
let ldSchema: object;
|
|
508
|
+
try {
|
|
509
|
+
ldSchema = (await loader(context)).document;
|
|
510
|
+
} catch (e) {
|
|
511
|
+
throw new Error(`can't load ld context from url ${context}`);
|
|
512
|
+
}
|
|
513
|
+
return byteEncoder.encode(JSON.stringify(ldSchema));
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/** {@inheritdoc IProofService.generateAuthV2Inputs} */
|
|
517
|
+
async generateAuthV2Inputs(
|
|
518
|
+
hash: Uint8Array,
|
|
519
|
+
did: DID,
|
|
520
|
+
circuitId: CircuitId
|
|
521
|
+
): Promise<Uint8Array> {
|
|
522
|
+
if (circuitId !== CircuitId.AuthV2) {
|
|
523
|
+
throw new Error('CircuitId is not supported');
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const { nonce: authProfileNonce, genesisDID } =
|
|
527
|
+
await this._identityWallet.getGenesisDIDMetadata(did);
|
|
528
|
+
|
|
529
|
+
const challenge = BytesHelper.bytesToInt(hash.reverse());
|
|
530
|
+
|
|
531
|
+
const authPrepared = await this._inputsGenerator.prepareAuthBJJCredential(genesisDID);
|
|
532
|
+
|
|
533
|
+
const signature = await this._identityWallet.signChallenge(challenge, authPrepared.credential);
|
|
534
|
+
const id = DID.idFromDID(genesisDID);
|
|
535
|
+
const stateProof = await this._stateStorage.getGISTProof(id.bigInt());
|
|
536
|
+
|
|
537
|
+
const gistProof = toGISTProof(stateProof);
|
|
538
|
+
|
|
539
|
+
const authInputs = new AuthV2Inputs();
|
|
540
|
+
|
|
541
|
+
authInputs.genesisID = id;
|
|
542
|
+
authInputs.profileNonce = BigInt(authProfileNonce);
|
|
543
|
+
authInputs.authClaim = authPrepared.coreClaim;
|
|
544
|
+
authInputs.authClaimIncMtp = authPrepared.incProof.proof;
|
|
545
|
+
authInputs.authClaimNonRevMtp = authPrepared.nonRevProof.proof;
|
|
546
|
+
authInputs.treeState = authPrepared.incProof.treeState;
|
|
547
|
+
authInputs.signature = signature;
|
|
548
|
+
authInputs.challenge = challenge;
|
|
549
|
+
authInputs.gistProof = gistProof;
|
|
550
|
+
return authInputs.inputsMarshal();
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/** {@inheritdoc IProofService.generateAuthV2Proof} */
|
|
554
|
+
async generateAuthV2Proof(challenge: Uint8Array, did: DID): Promise<ZKProof> {
|
|
555
|
+
const authInputs = await this.generateAuthV2Inputs(challenge, did, CircuitId.AuthV2);
|
|
556
|
+
|
|
557
|
+
const zkProof = await this._prover.generate(authInputs, CircuitId.AuthV2);
|
|
558
|
+
return zkProof;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
async verifyState(
|
|
562
|
+
circuitId: string,
|
|
563
|
+
pubSignals: string[],
|
|
564
|
+
opts: StateVerificationOpts = {
|
|
565
|
+
acceptedStateTransitionDelay: PROTOCOL_CONSTANTS.DEFAULT_AUTH_VERIFY_DELAY
|
|
566
|
+
}
|
|
567
|
+
): Promise<boolean> {
|
|
568
|
+
if (circuitId !== CircuitId.AuthV2) {
|
|
569
|
+
throw new Error(`CircuitId is not supported ${circuitId}`);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
const authV2PubSignals = new AuthV2PubSignals().pubSignalsUnmarshal(
|
|
573
|
+
byteEncoder.encode(JSON.stringify(pubSignals))
|
|
574
|
+
);
|
|
575
|
+
const gistRoot = authV2PubSignals.GISTRoot.bigInt();
|
|
576
|
+
const userId = authV2PubSignals.userID.bigInt();
|
|
577
|
+
const globalStateInfo = await this._stateStorage.getGISTRootInfo(gistRoot, userId);
|
|
578
|
+
|
|
579
|
+
if (globalStateInfo.root !== gistRoot) {
|
|
580
|
+
throw new Error(`gist info contains invalid state`);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
if (globalStateInfo.replacedByRoot !== 0n) {
|
|
584
|
+
if (globalStateInfo.replacedAtTimestamp === 0n) {
|
|
585
|
+
throw new Error(`state was replaced, but replaced time unknown`);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
const timeDiff =
|
|
589
|
+
Date.now() -
|
|
590
|
+
getDateFromUnixTimestamp(Number(globalStateInfo.replacedAtTimestamp)).getTime();
|
|
591
|
+
|
|
592
|
+
if (
|
|
593
|
+
timeDiff >
|
|
594
|
+
(opts?.acceptedStateTransitionDelay ?? PROTOCOL_CONSTANTS.DEFAULT_AUTH_VERIFY_DELAY)
|
|
595
|
+
) {
|
|
596
|
+
throw new Error('global state is outdated');
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
return true;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
async findCredentialByProofQuery(
|
|
604
|
+
did: DID,
|
|
605
|
+
query: ProofQuery
|
|
606
|
+
): Promise<{ cred: W3CCredential; revStatus: RevocationStatus | undefined }> {
|
|
607
|
+
const credentials = await this._identityWallet.findOwnedCredentialsByDID(did, query);
|
|
608
|
+
|
|
609
|
+
if (!credentials.length) {
|
|
610
|
+
throw new Error(
|
|
611
|
+
VerifiableConstants.ERRORS.PROOF_SERVICE_NO_CREDENTIAL_FOR_IDENTITY_OR_PROFILE
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
// For EQ / IN / NIN / LT / GT operations selective if credential satisfies query - we can get any.
|
|
616
|
+
// TODO: choose credential for selective credentials
|
|
617
|
+
const credential = query.skipClaimRevocationCheck
|
|
618
|
+
? { cred: credentials[0], revStatus: undefined }
|
|
619
|
+
: await this._credentialWallet.findNonRevokedCredential(credentials);
|
|
620
|
+
|
|
621
|
+
return credential;
|
|
622
|
+
}
|
|
623
|
+
}
|