@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
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './identity';
|
|
2
|
+
export * from './credentials';
|
|
3
|
+
export * from './kms';
|
|
4
|
+
export * from './storage';
|
|
5
|
+
export * from './verifiable';
|
|
6
|
+
export * from './schema-processor';
|
|
7
|
+
export * from './proof';
|
|
8
|
+
export * from './iden3comm';
|
|
9
|
+
export * from './circuits';
|
|
10
|
+
export * from './iden3comm';
|
|
11
|
+
export * from './utils';
|
|
12
|
+
export * from './blockchain';
|
|
13
|
+
import * as core from '@mocanetwork/moca-iden3';
|
|
14
|
+
import * as jsonLDMerklizer from '@iden3/js-jsonld-merklization';
|
|
15
|
+
export { core };
|
|
16
|
+
export { jsonLDMerklizer };
|
package/src/kms/index.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Hex, PrivateKey, PublicKey, Signature } from '@iden3/js-crypto';
|
|
2
|
+
import { BytesHelper, checkBigIntInField } from '@mocanetwork/moca-iden3';
|
|
3
|
+
import { IKeyProvider } from '../kms';
|
|
4
|
+
import { AbstractPrivateKeyStore, KmsKeyId, KmsKeyType } from '../store';
|
|
5
|
+
|
|
6
|
+
import * as providerHelpers from '../provider-helpers';
|
|
7
|
+
import { hexToBytes } from '../../utils';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Provider for Baby Jub Jub keys
|
|
11
|
+
* @public
|
|
12
|
+
* @class BjjProvider
|
|
13
|
+
* @implements implements IKeyProvider interface
|
|
14
|
+
*/
|
|
15
|
+
export class BjjProvider implements IKeyProvider {
|
|
16
|
+
/**
|
|
17
|
+
* key type that is handled by BJJ Provider
|
|
18
|
+
* @type {KmsKeyType}
|
|
19
|
+
*/
|
|
20
|
+
keyType: KmsKeyType;
|
|
21
|
+
private keyStore: AbstractPrivateKeyStore;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an instance of BjjProvider.
|
|
24
|
+
* @param {KmsKeyType} keyType - kms key type
|
|
25
|
+
* @param {AbstractPrivateKeyStore} keyStore - key store for kms
|
|
26
|
+
*/
|
|
27
|
+
constructor(keyType: KmsKeyType, keyStore: AbstractPrivateKeyStore) {
|
|
28
|
+
if (keyType !== KmsKeyType.BabyJubJub) {
|
|
29
|
+
throw new Error('Key type must be BabyJubJub');
|
|
30
|
+
}
|
|
31
|
+
this.keyType = keyType;
|
|
32
|
+
this.keyStore = keyStore;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* get all keys
|
|
36
|
+
* @returns list of keys
|
|
37
|
+
*/
|
|
38
|
+
async list(): Promise<
|
|
39
|
+
{
|
|
40
|
+
alias: string;
|
|
41
|
+
key: string;
|
|
42
|
+
}[]
|
|
43
|
+
> {
|
|
44
|
+
const allKeysFromKeyStore = await this.keyStore.list();
|
|
45
|
+
return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* generates a baby jub jub key from a seed phrase
|
|
50
|
+
* @param {Uint8Array} seed - byte array seed
|
|
51
|
+
* @returns kms key identifier
|
|
52
|
+
*/
|
|
53
|
+
async newPrivateKeyFromSeed(seed: Uint8Array): Promise<KmsKeyId> {
|
|
54
|
+
const newKey: Uint8Array = new Uint8Array(32);
|
|
55
|
+
newKey.set(Uint8Array.from(seed), 0);
|
|
56
|
+
newKey.fill(seed.length, 32, 0);
|
|
57
|
+
const privateKey: PrivateKey = new PrivateKey(seed);
|
|
58
|
+
|
|
59
|
+
const publicKey = privateKey.public();
|
|
60
|
+
|
|
61
|
+
const kmsId = {
|
|
62
|
+
type: this.keyType,
|
|
63
|
+
id: providerHelpers.keyPath(this.keyType, publicKey.hex())
|
|
64
|
+
};
|
|
65
|
+
await this.keyStore.importKey({ alias: kmsId.id, key: privateKey.hex() });
|
|
66
|
+
|
|
67
|
+
return kmsId;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Gets public key by kmsKeyId
|
|
72
|
+
*
|
|
73
|
+
* @param {KmsKeyId} keyId - key identifier
|
|
74
|
+
*/
|
|
75
|
+
async publicKey(keyId: KmsKeyId): Promise<string> {
|
|
76
|
+
const privateKey: PrivateKey = await this.privateKey(keyId);
|
|
77
|
+
return privateKey.public().hex();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* signs prepared payload of size,
|
|
82
|
+
* with a key id
|
|
83
|
+
*
|
|
84
|
+
* @param {KmsKeyId} keyId - key identifier
|
|
85
|
+
* @param {Uint8Array} data - data to sign (32 bytes)
|
|
86
|
+
* @returns Uint8Array signature
|
|
87
|
+
*/
|
|
88
|
+
async sign(keyId: KmsKeyId, data: Uint8Array): Promise<Uint8Array> {
|
|
89
|
+
if (data.length != 32) {
|
|
90
|
+
throw new Error('data to sign is too large');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const i = BytesHelper.bytesToInt(data);
|
|
94
|
+
if (!checkBigIntInField(i)) {
|
|
95
|
+
throw new Error('data to sign is too large');
|
|
96
|
+
}
|
|
97
|
+
const privateKey = await this.privateKey(keyId);
|
|
98
|
+
|
|
99
|
+
const signature = privateKey.signPoseidon(i);
|
|
100
|
+
|
|
101
|
+
return signature.compress();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private async privateKey(keyId: KmsKeyId): Promise<PrivateKey> {
|
|
105
|
+
const privateKeyHex = await this.keyStore.get({ alias: keyId.id });
|
|
106
|
+
|
|
107
|
+
return new PrivateKey(Hex.decodeString(privateKeyHex));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async verify(message: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise<boolean> {
|
|
111
|
+
const publicKey = await this.publicKey(keyId);
|
|
112
|
+
|
|
113
|
+
return PublicKey.newFromCompressed(hexToBytes(publicKey)).verifyPoseidon(
|
|
114
|
+
BytesHelper.bytesToInt(message),
|
|
115
|
+
Signature.newFromCompressed(hexToBytes(signatureHex))
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { IKeyProvider } from '../kms';
|
|
2
|
+
import { AbstractPrivateKeyStore, KmsKeyId, KmsKeyType } from '../store';
|
|
3
|
+
import * as providerHelpers from '../provider-helpers';
|
|
4
|
+
import { ed25519 } from '@noble/curves/ed25519';
|
|
5
|
+
import { bytesToHex } from '../../utils';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Provider for Ed25519 keys
|
|
9
|
+
* @public
|
|
10
|
+
* @class Ed25519Provider
|
|
11
|
+
* @implements IKeyProvider interface
|
|
12
|
+
*/
|
|
13
|
+
export class Ed25519Provider implements IKeyProvider {
|
|
14
|
+
/**
|
|
15
|
+
* Creates an instance of Ed25519Provider.
|
|
16
|
+
* @param {KmsKeyType} keyType - kms key type
|
|
17
|
+
* @param {AbstractPrivateKeyStore} keyStore - key store for kms
|
|
18
|
+
*/
|
|
19
|
+
constructor(
|
|
20
|
+
public readonly keyType: KmsKeyType,
|
|
21
|
+
private readonly _keyStore: AbstractPrivateKeyStore
|
|
22
|
+
) {}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* get all keys
|
|
26
|
+
* @returns list of keys
|
|
27
|
+
*/
|
|
28
|
+
async list(): Promise<
|
|
29
|
+
{
|
|
30
|
+
alias: string;
|
|
31
|
+
key: string;
|
|
32
|
+
}[]
|
|
33
|
+
> {
|
|
34
|
+
const allKeysFromKeyStore = await this._keyStore.list();
|
|
35
|
+
return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* generates a ed25519 key from a seed phrase
|
|
40
|
+
* @param {Uint8Array} seed - byte array seed
|
|
41
|
+
* @returns {Promise<KmsKeyId>} kms key identifier
|
|
42
|
+
*/
|
|
43
|
+
async newPrivateKeyFromSeed(seed: Uint8Array): Promise<KmsKeyId> {
|
|
44
|
+
if (seed.length !== 32) {
|
|
45
|
+
throw new Error('Seed should be 32 bytes');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const publicKey = ed25519.getPublicKey(seed);
|
|
49
|
+
const kmsId = {
|
|
50
|
+
type: this.keyType,
|
|
51
|
+
id: providerHelpers.keyPath(this.keyType, bytesToHex(publicKey))
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
await this._keyStore.importKey({
|
|
55
|
+
alias: kmsId.id,
|
|
56
|
+
key: bytesToHex(seed)
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return kmsId;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Gets public key by kmsKeyId
|
|
64
|
+
* @param {KmsKeyId} keyId - key identifier
|
|
65
|
+
* @returns {Promise<string>} Public key as a hex string
|
|
66
|
+
*/
|
|
67
|
+
async publicKey(keyId: KmsKeyId): Promise<string> {
|
|
68
|
+
const privateKeyHex = await this.privateKey(keyId);
|
|
69
|
+
const publicKey = ed25519.getPublicKey(privateKeyHex);
|
|
70
|
+
return bytesToHex(publicKey);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* signs prepared payload of size,
|
|
75
|
+
* with a key id
|
|
76
|
+
* @param {KmsKeyId} keyId - key identifier
|
|
77
|
+
* @param {Uint8Array} digest - data to sign (32 bytes)
|
|
78
|
+
* @returns {Promise<Uint8Array>} signature
|
|
79
|
+
*/
|
|
80
|
+
async sign(keyId: KmsKeyId, digest: Uint8Array): Promise<Uint8Array> {
|
|
81
|
+
const privateKeyHex = await this.privateKey(keyId);
|
|
82
|
+
return ed25519.sign(digest, privateKeyHex);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Verifies a signature for the given message and key identifier.
|
|
87
|
+
* @param digest - The message to verify the signature against.
|
|
88
|
+
* @param signatureHex - The signature to verify, as a hexadecimal string.
|
|
89
|
+
* @param keyId - The key identifier to use for verification.
|
|
90
|
+
* @returns A Promise that resolves to a boolean indicating whether the signature is valid.
|
|
91
|
+
*/
|
|
92
|
+
async verify(digest: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise<boolean> {
|
|
93
|
+
const publicKeyHex = await this.publicKey(keyId);
|
|
94
|
+
return ed25519.verify(signatureHex, digest, publicKeyHex);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Retrieves the private key for a given keyId from the key store.
|
|
99
|
+
* @param {KmsKeyId} keyId - The identifier of the key to retrieve.
|
|
100
|
+
* @returns {Promise<string>} The private key associated with the keyId.
|
|
101
|
+
*/
|
|
102
|
+
private async privateKey(keyId: KmsKeyId): Promise<string> {
|
|
103
|
+
return this._keyStore.get({ alias: keyId.id });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { IKeyProvider } from '../kms';
|
|
2
|
+
import { AbstractPrivateKeyStore, KmsKeyId, KmsKeyType } from '../store';
|
|
3
|
+
import * as providerHelpers from '../provider-helpers';
|
|
4
|
+
import { base64UrlToBytes, bytesToHex } from '../../utils';
|
|
5
|
+
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
6
|
+
import { sha256 } from '@iden3/js-crypto';
|
|
7
|
+
import { ES256KSigner, hexToBytes } from 'did-jwt';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Provider for Secp256k1
|
|
11
|
+
* @public
|
|
12
|
+
* @class Secp256k1Provider
|
|
13
|
+
* @implements implements IKeyProvider interface
|
|
14
|
+
*/
|
|
15
|
+
export class Sec256k1Provider implements IKeyProvider {
|
|
16
|
+
/**
|
|
17
|
+
* key type that is handled by BJJ Provider
|
|
18
|
+
* @type {KmsKeyType}
|
|
19
|
+
*/
|
|
20
|
+
keyType: KmsKeyType;
|
|
21
|
+
private _keyStore: AbstractPrivateKeyStore;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates an instance of BjjProvider.
|
|
25
|
+
* @param {KmsKeyType} keyType - kms key type
|
|
26
|
+
* @param {AbstractPrivateKeyStore} keyStore - key store for kms
|
|
27
|
+
*/
|
|
28
|
+
constructor(keyType: KmsKeyType, keyStore: AbstractPrivateKeyStore) {
|
|
29
|
+
if (keyType !== KmsKeyType.Secp256k1) {
|
|
30
|
+
throw new Error('Key type must be Secp256k1');
|
|
31
|
+
}
|
|
32
|
+
this.keyType = keyType;
|
|
33
|
+
this._keyStore = keyStore;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* get all keys
|
|
38
|
+
* @returns list of keys
|
|
39
|
+
*/
|
|
40
|
+
async list(): Promise<
|
|
41
|
+
{
|
|
42
|
+
alias: string;
|
|
43
|
+
key: string;
|
|
44
|
+
}[]
|
|
45
|
+
> {
|
|
46
|
+
const allKeysFromKeyStore = await this._keyStore.list();
|
|
47
|
+
return allKeysFromKeyStore.filter((key) => key.alias.startsWith(this.keyType));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* generates a baby jub jub key from a seed phrase
|
|
52
|
+
* @param {Uint8Array} seed - byte array seed
|
|
53
|
+
* @returns kms key identifier
|
|
54
|
+
*/
|
|
55
|
+
async newPrivateKeyFromSeed(seed: Uint8Array): Promise<KmsKeyId> {
|
|
56
|
+
if (seed.length !== 32) {
|
|
57
|
+
throw new Error('Seed should be 32 bytes');
|
|
58
|
+
}
|
|
59
|
+
const publicKey = secp256k1.getPublicKey(seed);
|
|
60
|
+
const kmsId = {
|
|
61
|
+
type: this.keyType,
|
|
62
|
+
id: providerHelpers.keyPath(this.keyType, bytesToHex(publicKey))
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
await this._keyStore.importKey({
|
|
66
|
+
alias: kmsId.id,
|
|
67
|
+
key: bytesToHex(seed).padStart(64, '0')
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return kmsId;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets public key by kmsKeyId
|
|
75
|
+
*
|
|
76
|
+
* @param {KmsKeyId} keyId - key identifier
|
|
77
|
+
*/
|
|
78
|
+
async publicKey(keyId: KmsKeyId): Promise<string> {
|
|
79
|
+
const privateKeyHex = await this.privateKey(keyId);
|
|
80
|
+
const publicKey = secp256k1.getPublicKey(privateKeyHex, false); // 04 + x + y (uncompressed key)
|
|
81
|
+
return bytesToHex(publicKey);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Signs the given data using the private key associated with the specified key identifier.
|
|
86
|
+
* @param keyId - The key identifier to use for signing.
|
|
87
|
+
* @param data - The data to sign.
|
|
88
|
+
* @param opts - Signing options, such as the algorithm to use.
|
|
89
|
+
* @returns A Promise that resolves to the signature as a Uint8Array.
|
|
90
|
+
*/
|
|
91
|
+
async sign(
|
|
92
|
+
keyId: KmsKeyId,
|
|
93
|
+
data: Uint8Array,
|
|
94
|
+
opts: { [key: string]: unknown } = { alg: 'ES256K' }
|
|
95
|
+
): Promise<Uint8Array> {
|
|
96
|
+
const privateKeyHex = await this.privateKey(keyId);
|
|
97
|
+
|
|
98
|
+
const signatureBase64 = await ES256KSigner(
|
|
99
|
+
hexToBytes(privateKeyHex),
|
|
100
|
+
opts.alg === 'ES256K-R'
|
|
101
|
+
)(data);
|
|
102
|
+
|
|
103
|
+
if (typeof signatureBase64 !== 'string') {
|
|
104
|
+
throw new Error('signatureBase64 must be a string');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return base64UrlToBytes(signatureBase64);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Verifies a signature for the given message and key identifier.
|
|
112
|
+
* @param message - The message to verify the signature against.
|
|
113
|
+
* @param signatureHex - The signature to verify, as a hexadecimal string.
|
|
114
|
+
* @param keyId - The key identifier to use for verification.
|
|
115
|
+
* @returns A Promise that resolves to a boolean indicating whether the signature is valid.
|
|
116
|
+
*/
|
|
117
|
+
async verify(message: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise<boolean> {
|
|
118
|
+
const publicKeyHex = await this.publicKey(keyId);
|
|
119
|
+
return secp256k1.verify(signatureHex, sha256(message), publicKeyHex);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private async privateKey(keyId: KmsKeyId): Promise<string> {
|
|
123
|
+
return this._keyStore.get({ alias: keyId.id });
|
|
124
|
+
}
|
|
125
|
+
}
|
package/src/kms/kms.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { KmsKeyId, KmsKeyType } from './store';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* KeyProvider is responsible for signing and creation of the keys
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
* @interface IKeyProvider
|
|
8
|
+
*/
|
|
9
|
+
export interface IKeyProvider {
|
|
10
|
+
/**
|
|
11
|
+
* property to store key type
|
|
12
|
+
*
|
|
13
|
+
* @type {KmsKeyType}
|
|
14
|
+
*/
|
|
15
|
+
keyType: KmsKeyType;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* get all keys
|
|
19
|
+
*
|
|
20
|
+
* @returns list of keys
|
|
21
|
+
*/
|
|
22
|
+
list(): Promise<
|
|
23
|
+
{
|
|
24
|
+
alias: string;
|
|
25
|
+
key: string;
|
|
26
|
+
}[]
|
|
27
|
+
>;
|
|
28
|
+
/**
|
|
29
|
+
* gets public key by key id
|
|
30
|
+
*
|
|
31
|
+
* @param {KmsKeyId} keyID - kms key identifier
|
|
32
|
+
* @returns `Promise<PublicKey>`
|
|
33
|
+
*/
|
|
34
|
+
publicKey(keyID: KmsKeyId): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* sign data with kms key
|
|
37
|
+
*
|
|
38
|
+
* @param {KmsKeyId} keyId - key identifier
|
|
39
|
+
* @param {Uint8Array} data - bytes payload
|
|
40
|
+
* @param {{ [key: string]: unknown }} opts - additional options for signing
|
|
41
|
+
* @returns `Promise<Uint8Array>`
|
|
42
|
+
*/
|
|
43
|
+
sign(keyId: KmsKeyId, data: Uint8Array, opts?: { [key: string]: unknown }): Promise<Uint8Array>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* creates new key pair from given seed
|
|
47
|
+
*
|
|
48
|
+
* @param {Uint8Array} seed - seed
|
|
49
|
+
* @returns `Promise<KmsKeyId>`
|
|
50
|
+
*/
|
|
51
|
+
newPrivateKeyFromSeed(seed: Uint8Array): Promise<KmsKeyId>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Verifies a message signature using the provided key ID.
|
|
55
|
+
*
|
|
56
|
+
* @param message - The message bytes to verify.
|
|
57
|
+
* @param signatureHex - The signature in hexadecimal format.
|
|
58
|
+
* @param keyId - The KMS key ID used to verify the signature.
|
|
59
|
+
* @returns A promise that resolves to a boolean indicating whether the signature is valid.
|
|
60
|
+
*/
|
|
61
|
+
verify(message: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise<boolean>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Key management system class contains different key providers.
|
|
65
|
+
* allows to register custom provider, create key, get public key and sign
|
|
66
|
+
*
|
|
67
|
+
* @public
|
|
68
|
+
* @class KMS - class
|
|
69
|
+
*/
|
|
70
|
+
export class KMS {
|
|
71
|
+
private readonly _registry = new Map<KmsKeyType, IKeyProvider>();
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* register key provider in the KMS
|
|
75
|
+
*
|
|
76
|
+
* @param {KmsKeyType} keyType - kms key type
|
|
77
|
+
* @param {IKeyProvider} keyProvider - key provider implementation
|
|
78
|
+
*/
|
|
79
|
+
registerKeyProvider(keyType: KmsKeyType, keyProvider: IKeyProvider): void {
|
|
80
|
+
if (this._registry.get(keyType)) {
|
|
81
|
+
throw new Error('present keyType');
|
|
82
|
+
}
|
|
83
|
+
this._registry.set(keyType, keyProvider);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* generates a new key and returns it kms key id
|
|
88
|
+
*
|
|
89
|
+
* @param {KmsKeyType} keyType
|
|
90
|
+
* @param {Uint8Array} bytes
|
|
91
|
+
* @returns kms key id
|
|
92
|
+
*/
|
|
93
|
+
async createKeyFromSeed(keyType: KmsKeyType, bytes: Uint8Array): Promise<KmsKeyId> {
|
|
94
|
+
const keyProvider = this._registry.get(keyType);
|
|
95
|
+
if (!keyProvider) {
|
|
96
|
+
throw new Error(`keyProvider not found for: ${keyType}`);
|
|
97
|
+
}
|
|
98
|
+
return keyProvider.newPrivateKeyFromSeed(bytes);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* gets public key for key id
|
|
103
|
+
*
|
|
104
|
+
* @param {KmsKeyId} keyId -- key id
|
|
105
|
+
* @returns public key
|
|
106
|
+
*/
|
|
107
|
+
async publicKey(keyId: KmsKeyId): Promise<string> {
|
|
108
|
+
const keyProvider = this._registry.get(keyId.type);
|
|
109
|
+
if (!keyProvider) {
|
|
110
|
+
throw new Error(`keyProvider not found for: ${keyId.type}`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return keyProvider.publicKey(keyId);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* sign Uint8Array with giv KmsKeyIden
|
|
118
|
+
*
|
|
119
|
+
* @param {KmsKeyId} keyId - key id
|
|
120
|
+
* @param {Uint8Array} data - prepared data bytes
|
|
121
|
+
* @returns `Promise<Uint8Array>` - return signature
|
|
122
|
+
*/
|
|
123
|
+
async sign(
|
|
124
|
+
keyId: KmsKeyId,
|
|
125
|
+
data: Uint8Array,
|
|
126
|
+
opts?: {
|
|
127
|
+
[key: string]: unknown;
|
|
128
|
+
}
|
|
129
|
+
): Promise<Uint8Array> {
|
|
130
|
+
const keyProvider = this._registry.get(keyId.type);
|
|
131
|
+
if (!keyProvider) {
|
|
132
|
+
throw new Error(`keyProvider not found for: ${keyId.type}`);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return keyProvider.sign(keyId, data, opts);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Verifies a signature against the provided data and key ID.
|
|
140
|
+
*
|
|
141
|
+
* @param data - The data to verify the signature against.
|
|
142
|
+
* @param signatureHex - The signature to verify, in hexadecimal format.
|
|
143
|
+
* @param keyId - The key ID to use for verification.
|
|
144
|
+
* @returns A promise that resolves to a boolean indicating whether the signature is valid.
|
|
145
|
+
*/
|
|
146
|
+
verify(data: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise<boolean> {
|
|
147
|
+
const keyProvider = this._registry.get(keyId.type);
|
|
148
|
+
if (!keyProvider) {
|
|
149
|
+
throw new Error(`keyProvider not found for: ${keyId.type}`);
|
|
150
|
+
}
|
|
151
|
+
return keyProvider.verify(data, signatureHex, keyId);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* get all keys by key type
|
|
156
|
+
*
|
|
157
|
+
* @param keyType - Key type
|
|
158
|
+
* @returns list of keys
|
|
159
|
+
*/
|
|
160
|
+
list(keyType: KmsKeyType): Promise<
|
|
161
|
+
{
|
|
162
|
+
alias: string;
|
|
163
|
+
key: string;
|
|
164
|
+
}[]
|
|
165
|
+
> {
|
|
166
|
+
const keyProvider = this._registry.get(keyType);
|
|
167
|
+
if (!keyProvider) {
|
|
168
|
+
throw new Error(`keyProvider not found for: ${keyType}`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return keyProvider.list();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { KmsKeyType } from './store';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* builds key path
|
|
5
|
+
*
|
|
6
|
+
* @param {KmsKeyType} keyType - key type
|
|
7
|
+
* @param {string} keyID - key id
|
|
8
|
+
* @returns string path
|
|
9
|
+
*/
|
|
10
|
+
export function keyPath(keyType: KmsKeyType, keyID: string): string {
|
|
11
|
+
const basePath = '';
|
|
12
|
+
return basePath + String(keyType) + ':' + keyID;
|
|
13
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KeyStore that allows to import and get keys by alias.
|
|
3
|
+
*
|
|
4
|
+
* @abstract
|
|
5
|
+
* @public
|
|
6
|
+
* @class AbstractPrivateKeyStore
|
|
7
|
+
*/
|
|
8
|
+
export abstract class AbstractPrivateKeyStore {
|
|
9
|
+
/**
|
|
10
|
+
* imports key by alias
|
|
11
|
+
*
|
|
12
|
+
* @abstract
|
|
13
|
+
* @param {{ alias: string; key: string }} args - key alias and hex representation
|
|
14
|
+
* @returns `Promise<void>`
|
|
15
|
+
*/
|
|
16
|
+
abstract importKey(args: { alias: string; key: string }): Promise<void>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* get key by alias
|
|
20
|
+
*
|
|
21
|
+
* @abstract
|
|
22
|
+
* @param {{ alias: string }} args -key alias
|
|
23
|
+
* @returns `Promise<string>`
|
|
24
|
+
*/
|
|
25
|
+
abstract get(args: { alias: string }): Promise<string>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* get all keys
|
|
29
|
+
*
|
|
30
|
+
* @abstract
|
|
31
|
+
* @returns `Promise<{ alias: string; key: string }[]>`
|
|
32
|
+
*/
|
|
33
|
+
abstract list(): Promise<{ alias: string; key: string }[]>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { UseStore, createStore, get, set, entries } from 'idb-keyval';
|
|
2
|
+
import { AbstractPrivateKeyStore } from './abstract-key-store';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Allows storing keys in the indexed db storage of the browser
|
|
6
|
+
* (NOT ENCRYPTED: DO NOT USE IN THE PRODUCTION)
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @class IndexedDBPrivateKeyStore
|
|
10
|
+
* @implements implements AbstractPrivateKeyStore interface
|
|
11
|
+
*/
|
|
12
|
+
export class IndexedDBPrivateKeyStore implements AbstractPrivateKeyStore {
|
|
13
|
+
static readonly storageKey = 'keystore';
|
|
14
|
+
private readonly _store: UseStore;
|
|
15
|
+
|
|
16
|
+
constructor() {
|
|
17
|
+
this._store = createStore(
|
|
18
|
+
`${IndexedDBPrivateKeyStore.storageKey}-db`,
|
|
19
|
+
IndexedDBPrivateKeyStore.storageKey
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* get all keys
|
|
25
|
+
*
|
|
26
|
+
* @abstract
|
|
27
|
+
* @returns `Promise<{ alias: string; key: string }[]>`
|
|
28
|
+
*/
|
|
29
|
+
async list(): Promise<{ alias: string; key: string }[]> {
|
|
30
|
+
const allEntries = await entries(this._store);
|
|
31
|
+
return allEntries.map(([alias, key]) => ({ alias, key: key.value })) as unknown as {
|
|
32
|
+
alias: string;
|
|
33
|
+
key: string;
|
|
34
|
+
}[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Gets key from the indexed db storage
|
|
39
|
+
*
|
|
40
|
+
* @param {{ alias: string }} args
|
|
41
|
+
* @returns hex string
|
|
42
|
+
*/
|
|
43
|
+
async get(args: { alias: string }): Promise<string> {
|
|
44
|
+
const key = await get(args.alias, this._store);
|
|
45
|
+
if (!key) {
|
|
46
|
+
throw new Error('no key under given alias');
|
|
47
|
+
}
|
|
48
|
+
return key.value;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Import key to the indexed db storage
|
|
53
|
+
*
|
|
54
|
+
* @param {{ alias: string; key: string }} args - alias and private key in the hex
|
|
55
|
+
* @returns void
|
|
56
|
+
*/
|
|
57
|
+
async importKey(args: { alias: string; key: string }): Promise<void> {
|
|
58
|
+
await set(args.alias, { value: args.key }, this._store);
|
|
59
|
+
}
|
|
60
|
+
}
|