@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,57 @@
|
|
|
1
|
+
import { poseidon } from '@iden3/js-crypto';
|
|
2
|
+
import { SchemaHash } from '@mocanetwork/moca-iden3';
|
|
3
|
+
import { defaultValueArraySize, prepareCircuitArrayValues } from '../../circuits';
|
|
4
|
+
|
|
5
|
+
export function calculateQueryHashV2(
|
|
6
|
+
values: bigint[],
|
|
7
|
+
schema: SchemaHash,
|
|
8
|
+
slotIndex: string | number,
|
|
9
|
+
operator: string | number,
|
|
10
|
+
claimPathKey: string | number,
|
|
11
|
+
claimPathNotExists: string | number
|
|
12
|
+
): bigint {
|
|
13
|
+
const expValue = prepareCircuitArrayValues(values, 64);
|
|
14
|
+
const valueHash = poseidon.spongeHashX(expValue, 6);
|
|
15
|
+
return poseidon.hash([
|
|
16
|
+
schema.bigInt(),
|
|
17
|
+
BigInt(slotIndex),
|
|
18
|
+
BigInt(operator),
|
|
19
|
+
BigInt(claimPathKey),
|
|
20
|
+
BigInt(claimPathNotExists),
|
|
21
|
+
valueHash
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function calculateQueryHashV3(
|
|
26
|
+
values: bigint[],
|
|
27
|
+
schema: SchemaHash,
|
|
28
|
+
slotIndex: string | number,
|
|
29
|
+
operator: string | number,
|
|
30
|
+
claimPathKey: string | number,
|
|
31
|
+
valueArraySize: string | number,
|
|
32
|
+
merklized: string | number,
|
|
33
|
+
isRevocationChecked: string | number,
|
|
34
|
+
verifierID: string | number,
|
|
35
|
+
nullifierSessionID: string | number
|
|
36
|
+
): bigint {
|
|
37
|
+
const expValue = prepareCircuitArrayValues(values, defaultValueArraySize);
|
|
38
|
+
const valueHash = poseidon.spongeHashX(expValue, 6);
|
|
39
|
+
const firstPartQueryHash = poseidon.hash([
|
|
40
|
+
schema.bigInt(),
|
|
41
|
+
BigInt(slotIndex),
|
|
42
|
+
BigInt(operator),
|
|
43
|
+
BigInt(claimPathKey),
|
|
44
|
+
BigInt(merklized),
|
|
45
|
+
valueHash
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
const queryHash = poseidon.hash([
|
|
49
|
+
firstPartQueryHash,
|
|
50
|
+
BigInt(valueArraySize),
|
|
51
|
+
BigInt(isRevocationChecked),
|
|
52
|
+
BigInt(verifierID),
|
|
53
|
+
BigInt(nullifierSessionID),
|
|
54
|
+
0n
|
|
55
|
+
]);
|
|
56
|
+
return queryHash;
|
|
57
|
+
}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { DID, getDateFromUnixTimestamp, Id, SchemaHash } from '@mocanetwork/moca-iden3';
|
|
2
|
+
import { DocumentLoader, Merklizer, MtValue, Path } from '@iden3/js-jsonld-merklization';
|
|
3
|
+
import { Proof } from '@iden3/js-merkletree';
|
|
4
|
+
import { byteEncoder } from '../../utils';
|
|
5
|
+
import { getOperatorNameByValue, Operators, QueryOperators } from '../../circuits/comparer';
|
|
6
|
+
import { CircuitId } from '../../circuits/models';
|
|
7
|
+
import { calculateCoreSchemaHash, ProofQuery, VerifiableConstants } from '../../verifiable';
|
|
8
|
+
import { QueryMetadata } from '../common';
|
|
9
|
+
import { circuitValidator } from '../provers';
|
|
10
|
+
import { JsonLd } from 'jsonld/jsonld-spec';
|
|
11
|
+
import { VerifiablePresentation } from '../../iden3comm';
|
|
12
|
+
import { ethers } from 'ethers';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Options to verify state
|
|
16
|
+
*/
|
|
17
|
+
export type VerifyOpts = {
|
|
18
|
+
// acceptedStateTransitionDelay is the period of time in milliseconds that a revoked state remains valid.
|
|
19
|
+
acceptedStateTransitionDelay?: number;
|
|
20
|
+
// acceptedProofGenerationDelay is the period of time in milliseconds that a generated proof remains valid.
|
|
21
|
+
acceptedProofGenerationDelay?: number;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const defaultProofGenerationDelayOpts = 24 * 60 * 60 * 1000; // 24 hours
|
|
25
|
+
|
|
26
|
+
// ClaimOutputs fields that are used in proof generation
|
|
27
|
+
export interface ClaimOutputs {
|
|
28
|
+
issuerId: Id;
|
|
29
|
+
schemaHash: SchemaHash;
|
|
30
|
+
slotIndex?: number;
|
|
31
|
+
operator: number;
|
|
32
|
+
operatorOutput?: bigint;
|
|
33
|
+
value: bigint[];
|
|
34
|
+
timestamp: number;
|
|
35
|
+
merklized: number;
|
|
36
|
+
claimPathKey?: bigint;
|
|
37
|
+
claimPathNotExists?: number;
|
|
38
|
+
valueArraySize: number;
|
|
39
|
+
isRevocationChecked: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function checkQueryRequest(
|
|
43
|
+
query: ProofQuery,
|
|
44
|
+
queriesMetadata: QueryMetadata[],
|
|
45
|
+
ldContext: JsonLd,
|
|
46
|
+
outputs: ClaimOutputs,
|
|
47
|
+
circuitId: CircuitId,
|
|
48
|
+
schemaLoader?: DocumentLoader,
|
|
49
|
+
opts?: VerifyOpts
|
|
50
|
+
): Promise<void> {
|
|
51
|
+
// validate issuer
|
|
52
|
+
const userDID = DID.parseFromId(outputs.issuerId);
|
|
53
|
+
const issuerAllowed =
|
|
54
|
+
!query.allowedIssuers ||
|
|
55
|
+
query.allowedIssuers?.some((issuer) => issuer === '*' || issuer === userDID.string());
|
|
56
|
+
if (!issuerAllowed) {
|
|
57
|
+
throw new Error('issuer is not in allowed list');
|
|
58
|
+
}
|
|
59
|
+
if (!query.type) {
|
|
60
|
+
throw new Error('query type is missing');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const schemaId: string = await Path.getTypeIDFromContext(JSON.stringify(ldContext), query.type, {
|
|
64
|
+
documentLoader: schemaLoader
|
|
65
|
+
});
|
|
66
|
+
const schemaHash = calculateCoreSchemaHash(byteEncoder.encode(schemaId));
|
|
67
|
+
|
|
68
|
+
if (schemaHash.bigInt() !== outputs.schemaHash.bigInt()) {
|
|
69
|
+
throw new Error(`schema that was used is not equal to requested in query`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!query.skipClaimRevocationCheck && outputs.isRevocationChecked === 0) {
|
|
73
|
+
throw new Error(`check revocation is required`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
checkCircuitQueriesLength(circuitId, queriesMetadata);
|
|
77
|
+
|
|
78
|
+
// verify timestamp
|
|
79
|
+
let acceptedProofGenerationDelay = defaultProofGenerationDelayOpts;
|
|
80
|
+
if (opts?.acceptedProofGenerationDelay) {
|
|
81
|
+
acceptedProofGenerationDelay = opts.acceptedProofGenerationDelay;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const timeDiff = Date.now() - getDateFromUnixTimestamp(Number(outputs.timestamp)).getTime();
|
|
85
|
+
if (timeDiff > acceptedProofGenerationDelay) {
|
|
86
|
+
throw new Error('generated proof is outdated');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function checkCircuitQueriesLength(circuitId: CircuitId, queriesMetadata: QueryMetadata[]) {
|
|
93
|
+
const circuitValidationData = circuitValidator[circuitId];
|
|
94
|
+
|
|
95
|
+
if (queriesMetadata.length > circuitValidationData.maxQueriesCount) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
`circuit ${circuitId} supports only ${
|
|
98
|
+
circuitValidator[circuitId as CircuitId].maxQueriesCount
|
|
99
|
+
} queries`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function checkCircuitOperator(circuitId: CircuitId, operator: number) {
|
|
105
|
+
const circuitValidationData = circuitValidator[circuitId];
|
|
106
|
+
|
|
107
|
+
if (!circuitValidationData.supportedOperations.includes(operator)) {
|
|
108
|
+
throw new Error(
|
|
109
|
+
`circuit ${circuitId} not support ${getOperatorNameByValue(operator)} operator`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function verifyFieldValueInclusionV2(outputs: ClaimOutputs, metadata: QueryMetadata) {
|
|
115
|
+
if (outputs.operator == QueryOperators.$noop) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (outputs.merklized === 1) {
|
|
119
|
+
if (outputs.claimPathNotExists === 1) {
|
|
120
|
+
throw new Error(`proof doesn't contains target query key`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (outputs.claimPathKey !== metadata.claimPathKey) {
|
|
124
|
+
throw new Error(`proof was generated for another path`);
|
|
125
|
+
}
|
|
126
|
+
} else {
|
|
127
|
+
if (outputs.slotIndex !== metadata.slotIndex) {
|
|
128
|
+
throw new Error(`wrong claim slot was used in claim`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export function verifyFieldValueInclusionNativeExistsSupport(
|
|
133
|
+
outputs: ClaimOutputs,
|
|
134
|
+
metadata: QueryMetadata
|
|
135
|
+
) {
|
|
136
|
+
if (outputs.operator == Operators.NOOP) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (outputs.operator === Operators.EXISTS && !outputs.merklized) {
|
|
140
|
+
throw new Error('$exists operator is not supported for non-merklized credential');
|
|
141
|
+
}
|
|
142
|
+
if (outputs.merklized === 1) {
|
|
143
|
+
if (outputs.claimPathKey !== metadata.claimPathKey) {
|
|
144
|
+
throw new Error(`proof was generated for another path`);
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
if (outputs.slotIndex !== metadata.slotIndex) {
|
|
148
|
+
throw new Error(`wrong claim slot was used in claim`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export async function validateEmptyCredentialSubjectV2Circuit(
|
|
154
|
+
cq: QueryMetadata,
|
|
155
|
+
outputs: ClaimOutputs
|
|
156
|
+
) {
|
|
157
|
+
if (outputs.operator !== Operators.EQ) {
|
|
158
|
+
throw new Error('empty credentialSubject request available only for equal operation');
|
|
159
|
+
}
|
|
160
|
+
for (let index = 1; index < outputs.value.length; index++) {
|
|
161
|
+
if (outputs.value[index] !== 0n) {
|
|
162
|
+
throw new Error(`empty credentialSubject request not available for array of values`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const path = Path.newPath([VerifiableConstants.CREDENTIAL_SUBJECT_PATH]);
|
|
166
|
+
const subjectEntry = await path.mtEntry();
|
|
167
|
+
if (outputs.claimPathKey !== subjectEntry) {
|
|
168
|
+
throw new Error(`proof doesn't contain credentialSubject in claimPathKey`);
|
|
169
|
+
}
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
export async function validateOperators(cq: QueryMetadata, outputs: ClaimOutputs) {
|
|
173
|
+
if (outputs.operator !== cq.operator) {
|
|
174
|
+
throw new Error(`operator that was used is not equal to request`);
|
|
175
|
+
}
|
|
176
|
+
if (outputs.operator === Operators.NOOP) {
|
|
177
|
+
// for noop operator slot and value are not used in this case
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
for (let index = 0; index < outputs.value.length; index++) {
|
|
182
|
+
if (outputs.value[index] !== cq.values[index]) {
|
|
183
|
+
if (outputs.value[index] === 0n && cq.values[index] === undefined) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
throw new Error(`comparison value that was used is not equal to requested in query`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export async function validateDisclosureV2Circuit(
|
|
192
|
+
cq: QueryMetadata,
|
|
193
|
+
outputs: ClaimOutputs,
|
|
194
|
+
verifiablePresentation?: VerifiablePresentation,
|
|
195
|
+
ldLoader?: DocumentLoader
|
|
196
|
+
) {
|
|
197
|
+
const bi = await fieldValueFromVerifiablePresentation(
|
|
198
|
+
cq.fieldName,
|
|
199
|
+
verifiablePresentation,
|
|
200
|
+
ldLoader
|
|
201
|
+
);
|
|
202
|
+
if (bi !== outputs.value[0]) {
|
|
203
|
+
throw new Error(`value that was used is not equal to requested in query`);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (outputs.operator !== Operators.EQ) {
|
|
207
|
+
throw new Error(`operator for selective disclosure must be $eq`);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
for (let index = 1; index < outputs.value.length; index++) {
|
|
211
|
+
if (outputs.value[index] !== 0n) {
|
|
212
|
+
throw new Error(`selective disclosure not available for array of values`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export async function validateDisclosureNativeSDSupport(
|
|
218
|
+
cq: QueryMetadata,
|
|
219
|
+
outputs: ClaimOutputs,
|
|
220
|
+
verifiablePresentation?: VerifiablePresentation,
|
|
221
|
+
ldLoader?: DocumentLoader
|
|
222
|
+
) {
|
|
223
|
+
const bi = await fieldValueFromVerifiablePresentation(
|
|
224
|
+
cq.fieldName,
|
|
225
|
+
verifiablePresentation,
|
|
226
|
+
ldLoader
|
|
227
|
+
);
|
|
228
|
+
if (bi !== outputs.operatorOutput) {
|
|
229
|
+
throw new Error(`operator output should be equal to disclosed value`);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (outputs.operator !== Operators.SD) {
|
|
233
|
+
throw new Error(`operator for selective disclosure must be $sd`);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
for (let index = 0; index < outputs.value.length; index++) {
|
|
237
|
+
if (outputs.value[index] !== 0n) {
|
|
238
|
+
throw new Error(`public signal values must be zero`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
export async function validateEmptyCredentialSubjectNoopNativeSupport(outputs: ClaimOutputs) {
|
|
243
|
+
if (outputs.operator !== Operators.NOOP) {
|
|
244
|
+
throw new Error('empty credentialSubject request available only for $noop operation');
|
|
245
|
+
}
|
|
246
|
+
for (let index = 1; index < outputs.value.length; index++) {
|
|
247
|
+
if (outputs.value[index] !== 0n) {
|
|
248
|
+
throw new Error(`empty credentialSubject request not available for array of values`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export const fieldValueFromVerifiablePresentation = async (
|
|
254
|
+
fieldName: string,
|
|
255
|
+
verifiablePresentation?: VerifiablePresentation,
|
|
256
|
+
ldLoader?: DocumentLoader
|
|
257
|
+
): Promise<bigint> => {
|
|
258
|
+
if (!verifiablePresentation) {
|
|
259
|
+
throw new Error(`verifiablePresentation is required for selective disclosure request`);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
let mz: Merklizer;
|
|
263
|
+
const strVerifiablePresentation: string = JSON.stringify(verifiablePresentation);
|
|
264
|
+
try {
|
|
265
|
+
mz = await Merklizer.merklizeJSONLD(strVerifiablePresentation, {
|
|
266
|
+
documentLoader: ldLoader
|
|
267
|
+
});
|
|
268
|
+
} catch (e) {
|
|
269
|
+
throw new Error(`can't merklize verifiablePresentation`);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
let merklizedPath: Path;
|
|
273
|
+
try {
|
|
274
|
+
const p = `verifiableCredential.credentialSubject.${fieldName}`;
|
|
275
|
+
merklizedPath = await Path.fromDocument(null, strVerifiablePresentation, p, {
|
|
276
|
+
documentLoader: ldLoader
|
|
277
|
+
});
|
|
278
|
+
} catch (e) {
|
|
279
|
+
throw new Error(`can't build path to '${fieldName}' key`);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
let proof: Proof;
|
|
283
|
+
let value: MtValue | undefined;
|
|
284
|
+
try {
|
|
285
|
+
({ proof, value } = await mz.proof(merklizedPath));
|
|
286
|
+
} catch (e) {
|
|
287
|
+
throw new Error(`can't get value by path '${fieldName}'`);
|
|
288
|
+
}
|
|
289
|
+
if (!value) {
|
|
290
|
+
throw new Error(`can't get merkle value for field '${fieldName}'`);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (!proof.existence) {
|
|
294
|
+
throw new Error(
|
|
295
|
+
`path [${merklizedPath.parts}] doesn't exist in verifiablePresentation document`
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return await value.mtEntry();
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
export function calculateGroupId(requestIds: bigint[]): bigint {
|
|
303
|
+
const types = Array(requestIds.length).fill('uint256');
|
|
304
|
+
|
|
305
|
+
const groupID =
|
|
306
|
+
BigInt(ethers.keccak256(ethers.solidityPacked(types, requestIds))) &
|
|
307
|
+
// It should fit in a field number in the circuit (max 253 bits). With this we truncate to 252 bits for the group ID
|
|
308
|
+
BigInt('0x0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF');
|
|
309
|
+
|
|
310
|
+
return groupID;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export function calculateRequestId(requestParams: string, creatorAddress: string): bigint {
|
|
314
|
+
// 0x0000000000000000FFFF...FF. Reserved first 8 bytes for the request Id type and future use
|
|
315
|
+
// 0x00010000000000000000...00. First 2 bytes for the request Id type
|
|
316
|
+
// - 0x0000... for old request Ids with uint64
|
|
317
|
+
// - 0x0001... for new request Ids with uint256
|
|
318
|
+
const requestId =
|
|
319
|
+
(BigInt(
|
|
320
|
+
ethers.keccak256(ethers.solidityPacked(['bytes', 'address'], [requestParams, creatorAddress]))
|
|
321
|
+
) &
|
|
322
|
+
BigInt('0x0000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) +
|
|
323
|
+
BigInt('0x0001000000000000000000000000000000000000000000000000000000000000');
|
|
324
|
+
return requestId;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export function calculateMultiRequestId(
|
|
328
|
+
requestIds: bigint[],
|
|
329
|
+
groupIds: bigint[],
|
|
330
|
+
creatorAddress: string
|
|
331
|
+
): bigint {
|
|
332
|
+
return BigInt(
|
|
333
|
+
ethers.keccak256(
|
|
334
|
+
ethers.solidityPacked(
|
|
335
|
+
['uint256[]', 'uint256[]', 'address'],
|
|
336
|
+
[requestIds, groupIds, creatorAddress]
|
|
337
|
+
)
|
|
338
|
+
)
|
|
339
|
+
);
|
|
340
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import {
|
|
2
|
+
W3CCredential,
|
|
3
|
+
getSerializationAttrFromContext,
|
|
4
|
+
parseSerializationAttr,
|
|
5
|
+
getFieldSlotIndex,
|
|
6
|
+
findCredentialType,
|
|
7
|
+
CoreClaimCreationOptions,
|
|
8
|
+
CoreClaimParsedSlots,
|
|
9
|
+
CoreClaimSlotsPaths,
|
|
10
|
+
getSerializationAttrFromParsedContext,
|
|
11
|
+
parseCoreClaimSlots
|
|
12
|
+
} from '../../verifiable';
|
|
13
|
+
import { Claim as CoreClaim } from '@mocanetwork/moca-iden3';
|
|
14
|
+
import { Merklizer, Options } from '@iden3/js-jsonld-merklization';
|
|
15
|
+
import jsonld from 'jsonld';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @deprecated The interface should not be used. Use CoreClaimParsingOptions from verifiable package instead.
|
|
20
|
+
* CoreClaimOptions is params for core claim parsing
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
* @interface CoreClaimOptions
|
|
24
|
+
*/
|
|
25
|
+
export type CoreClaimOptions = CoreClaimCreationOptions;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated The interface should not be used. Use CoreClaimParsedSlots from verifiable package instead.
|
|
29
|
+
* Parsed slots of core.Claim
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
* @interface ParsedSlots
|
|
33
|
+
*/
|
|
34
|
+
export type ParsedSlots = CoreClaimParsedSlots;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated The interface should not be used. Use CoreClaimSlotsPaths from verifiable package instead.
|
|
38
|
+
*/
|
|
39
|
+
export type SlotsPaths = CoreClaimSlotsPaths;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Serialization of data slots for the fields non-merklized claims
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
* @interface SerializationSchema
|
|
46
|
+
*/
|
|
47
|
+
export interface SerializationSchema {
|
|
48
|
+
indexDataSlotA: string;
|
|
49
|
+
indexDataSlotB: string;
|
|
50
|
+
valueDataSlotA: string;
|
|
51
|
+
valueDataSlotB: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* schema metadata in the json credential schema
|
|
56
|
+
*
|
|
57
|
+
* @public
|
|
58
|
+
* @interface SchemaMetadata
|
|
59
|
+
*/
|
|
60
|
+
export interface SchemaMetadata {
|
|
61
|
+
uris: { [key: string]: string };
|
|
62
|
+
serialization?: SerializationSchema;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* JSON credential Schema
|
|
67
|
+
*
|
|
68
|
+
* @public
|
|
69
|
+
* @interface Schema
|
|
70
|
+
*/
|
|
71
|
+
export interface JSONSchema {
|
|
72
|
+
$metadata: SchemaMetadata;
|
|
73
|
+
$schema: string;
|
|
74
|
+
type: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Parser can parse claim and schema data according to specification
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
* @class Parser
|
|
82
|
+
*/
|
|
83
|
+
export class Parser {
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated The method should not be used. Use credential.toCoreClaim instead.
|
|
86
|
+
* ParseClaim creates core.Claim object from W3CCredential
|
|
87
|
+
*
|
|
88
|
+
* @param {W3CCredential} credential - Verifiable Credential
|
|
89
|
+
* @param {CoreClaimOptions} [opts] - options to parse core claim
|
|
90
|
+
* @returns `Promise<CoreClaim>`
|
|
91
|
+
*/
|
|
92
|
+
static async parseClaim(credential: W3CCredential, opts?: CoreClaimOptions): Promise<CoreClaim> {
|
|
93
|
+
return credential.toCoreClaim(opts);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated The method should not be used. Use findCredentialType from verifiable.
|
|
98
|
+
*/
|
|
99
|
+
static findCredentialType(mz: Merklizer): string {
|
|
100
|
+
return findCredentialType(mz);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated The method should not be used. Use credential.getSerializationAttr instead.
|
|
105
|
+
*
|
|
106
|
+
* Get `iden3_serialization` attr definition from context document either using
|
|
107
|
+
* type name like DeliverAddressMultiTestForked or by type id like
|
|
108
|
+
* urn:uuid:ac2ede19-b3b9-454d-b1a9-a7b3d5763100.
|
|
109
|
+
* */
|
|
110
|
+
static async getSerializationAttr(
|
|
111
|
+
credential: W3CCredential,
|
|
112
|
+
opts: Options,
|
|
113
|
+
tp: string
|
|
114
|
+
): Promise<string> {
|
|
115
|
+
const ldCtx = await jsonld.processContext(
|
|
116
|
+
await jsonld.processContext(null, null, {}),
|
|
117
|
+
credential['@context'] as jsonld.JsonLdDocument,
|
|
118
|
+
opts
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
return getSerializationAttrFromParsedContext(
|
|
122
|
+
ldCtx as unknown as { mappings: Map<string, Record<string, unknown>> },
|
|
123
|
+
tp
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @deprecated The method should not be used. Use getSerializationAttrFromContext from verifiable.
|
|
129
|
+
*
|
|
130
|
+
* Get `iden3_serialization` attr definition from context document either using
|
|
131
|
+
* type name like DeliverAddressMultiTestForked or by type id like
|
|
132
|
+
* urn:uuid:ac2ede19-b3b9-454d-b1a9-a7b3d5763100.
|
|
133
|
+
*
|
|
134
|
+
*/
|
|
135
|
+
static async getSerializationAttrFromContext(
|
|
136
|
+
context: object,
|
|
137
|
+
opts: Options,
|
|
138
|
+
tp: string
|
|
139
|
+
): Promise<string> {
|
|
140
|
+
return getSerializationAttrFromContext(context, opts, tp);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @deprecated The method should not be used. Use getSerializationAttrFromParsedContext from verifiable.
|
|
145
|
+
*
|
|
146
|
+
* */
|
|
147
|
+
static async getSerializationAttrFromParsedContext(
|
|
148
|
+
ldCtx: { mappings: Map<string, Record<string, unknown>> },
|
|
149
|
+
tp: string
|
|
150
|
+
): Promise<string> {
|
|
151
|
+
return getSerializationAttrFromParsedContext(ldCtx, tp);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated The method should not be used. Use parseSerializationAttr from verifiable.
|
|
156
|
+
*
|
|
157
|
+
*/
|
|
158
|
+
static parseSerializationAttr(serAttr: string): SlotsPaths {
|
|
159
|
+
return parseSerializationAttr(serAttr);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
*
|
|
164
|
+
* @deprecated The method should not be used. Use credential.parseSlots instead.
|
|
165
|
+
* ParseSlots converts payload to claim slots using provided schema
|
|
166
|
+
*
|
|
167
|
+
* @param {Merklizer} mz - Merklizer
|
|
168
|
+
* @param {W3CCredential} credential - Verifiable Credential
|
|
169
|
+
* @param {string} credentialType - credential type
|
|
170
|
+
* @returns `ParsedSlots`
|
|
171
|
+
*/
|
|
172
|
+
static async parseSlots(
|
|
173
|
+
mz: Merklizer,
|
|
174
|
+
credential: W3CCredential,
|
|
175
|
+
credentialType: string
|
|
176
|
+
): Promise<{ slots: ParsedSlots; nonMerklized: boolean }> {
|
|
177
|
+
const ldCtx = await jsonld.processContext(
|
|
178
|
+
await jsonld.processContext(null, null, {}),
|
|
179
|
+
credential['@context'] as jsonld.JsonLdDocument,
|
|
180
|
+
mz.options
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
return parseCoreClaimSlots(
|
|
184
|
+
ldCtx as unknown as { mappings: Map<string, Record<string, unknown>> },
|
|
185
|
+
mz,
|
|
186
|
+
credentialType
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @deprecated The method should not be used. Use getFieldSlotIndex from verifiable.
|
|
192
|
+
*
|
|
193
|
+
* GetFieldSlotIndex return index of slot from 0 to 7 (each claim has by default 8 slots) for non-merklized claims
|
|
194
|
+
*
|
|
195
|
+
* @param {string} field - field name
|
|
196
|
+
* @param {Uint8Array} schemaBytes -json schema bytes
|
|
197
|
+
* @returns `number`
|
|
198
|
+
*/
|
|
199
|
+
static async getFieldSlotIndex(
|
|
200
|
+
field: string,
|
|
201
|
+
typeName: string,
|
|
202
|
+
schemaBytes: Uint8Array
|
|
203
|
+
): Promise<number> {
|
|
204
|
+
return getFieldSlotIndex(field, typeName, schemaBytes);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* ExtractCredentialSubjectProperties return credential subject types from JSON schema
|
|
209
|
+
*
|
|
210
|
+
* @param {string | JSON} schema - JSON schema
|
|
211
|
+
* @returns `Promise<Array<string>>`
|
|
212
|
+
*/
|
|
213
|
+
static async extractCredentialSubjectProperties(schema: string): Promise<Array<string>> {
|
|
214
|
+
const parsedSchema = typeof schema === 'string' ? JSON.parse(schema) : schema;
|
|
215
|
+
const props = parsedSchema.properties?.credentialSubject?.properties;
|
|
216
|
+
if (!props) {
|
|
217
|
+
throw new Error('properties.credentialSubject.properties is not set');
|
|
218
|
+
}
|
|
219
|
+
// drop @id field
|
|
220
|
+
delete props['id'];
|
|
221
|
+
return Object.keys(props);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// /**
|
|
225
|
+
// * GetLdPrefixesByJSONSchema return possible credential types for JSON schema
|
|
226
|
+
// *
|
|
227
|
+
// * @param {string} schema - JSON schema
|
|
228
|
+
// * @returns `Promise<Map<string, string>>`
|
|
229
|
+
// */
|
|
230
|
+
// public static async getLdPrefixesByJSONSchema(schema: string): Promise<Map<string, string>> {
|
|
231
|
+
// const metadata = Parser.extractMetadata(schema);
|
|
232
|
+
// const ldURL = metadata.uris['jsonLdContext'];
|
|
233
|
+
// if (!ldURL) {
|
|
234
|
+
// throw new Error('jsonLdContext is not set');
|
|
235
|
+
// }
|
|
236
|
+
|
|
237
|
+
// const props = await Parser.extractCredentialSubjectProperties(schema);
|
|
238
|
+
|
|
239
|
+
// let jsonLdContext;
|
|
240
|
+
// try {
|
|
241
|
+
// const response = await fetch(ldURL);
|
|
242
|
+
// jsonLdContext = await response.json();
|
|
243
|
+
// } catch (e) {
|
|
244
|
+
// throw new Error(`failed to fetch jsonLdContext ${e}`);
|
|
245
|
+
// }
|
|
246
|
+
|
|
247
|
+
// let prefixes;
|
|
248
|
+
// try {
|
|
249
|
+
// prefixes = await LDParser.getPrefixes(jsonLdContext, false, props);
|
|
250
|
+
// } catch (e) {
|
|
251
|
+
// throw new Error(`failed to extract terms from jsonLdContext ${e}`);
|
|
252
|
+
// }
|
|
253
|
+
|
|
254
|
+
// return prefixes;
|
|
255
|
+
// }
|
|
256
|
+
}
|