@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,104 @@
|
|
|
1
|
+
import { verifyGroth16Proof, ZKProof } from '@iden3/js-jwz';
|
|
2
|
+
import { witnessBuilder } from './witness_calculator';
|
|
3
|
+
import * as snarkjs from 'snarkjs';
|
|
4
|
+
import * as ffjavascript from 'ffjavascript';
|
|
5
|
+
import { ICircuitStorage } from '../../storage';
|
|
6
|
+
import { CircuitId } from '../../circuits';
|
|
7
|
+
import { byteDecoder } from '../../utils';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* ZKProver is responsible for proof generation and verification
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
* @interface ZKProver
|
|
14
|
+
*/
|
|
15
|
+
export interface IZKProver {
|
|
16
|
+
/**
|
|
17
|
+
* generates zero knowledge proof
|
|
18
|
+
*
|
|
19
|
+
* @param {Uint8Array} inputs - inputs that will be used for proof generation
|
|
20
|
+
* @param {string} circuitId - circuit id for proof generation
|
|
21
|
+
* @returns `Promise<ZKProof>`
|
|
22
|
+
*/
|
|
23
|
+
generate(inputs: Uint8Array, circuitId: string): Promise<ZKProof>;
|
|
24
|
+
/**
|
|
25
|
+
* verifies zero knowledge proof
|
|
26
|
+
*
|
|
27
|
+
* @param {ZKProof} zkp - zero knowledge proof that will be verified
|
|
28
|
+
* @param {string} circuitId - circuit id for proof verification
|
|
29
|
+
* @returns `Promise<boolean>`
|
|
30
|
+
*/
|
|
31
|
+
verify(zkp: ZKProof, circuitId: string): Promise<boolean>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* NativeProver service responsible for zk generation and verification of groth16 algorithm with bn128 curve
|
|
36
|
+
* @public
|
|
37
|
+
* @class NativeProver
|
|
38
|
+
* @implements implements IZKProver interface
|
|
39
|
+
*/
|
|
40
|
+
export class NativeProver implements IZKProver {
|
|
41
|
+
private static readonly curveName = 'bn128';
|
|
42
|
+
constructor(private readonly _circuitStorage: ICircuitStorage) {}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* verifies zero knowledge proof
|
|
46
|
+
*
|
|
47
|
+
* @param {ZKProof} zkp - zero knowledge proof that will be verified
|
|
48
|
+
* @param {string} circuitId - circuit id for proof verification
|
|
49
|
+
* @returns `Promise<ZKProof>`
|
|
50
|
+
*/
|
|
51
|
+
async verify(zkp: ZKProof, circuitId: CircuitId): Promise<boolean> {
|
|
52
|
+
try {
|
|
53
|
+
const circuitData = await this._circuitStorage.loadCircuitData(circuitId);
|
|
54
|
+
|
|
55
|
+
if (!circuitData.verificationKey) {
|
|
56
|
+
throw new Error(`verification file doesn't exist for circuit ${circuitId}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return verifyGroth16Proof(zkp, JSON.parse(byteDecoder.decode(circuitData.verificationKey)));
|
|
60
|
+
} catch (e) {
|
|
61
|
+
// eslint-disable-next-line no-console
|
|
62
|
+
console.log(e);
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* generates zero knowledge proof
|
|
69
|
+
*
|
|
70
|
+
* @param {Uint8Array} inputs - inputs that will be used for proof generation
|
|
71
|
+
* @param {string} circuitId - circuit id for proof generation
|
|
72
|
+
* @returns `Promise<ZKProof>`
|
|
73
|
+
*/
|
|
74
|
+
async generate(inputs: Uint8Array, circuitId: CircuitId): Promise<ZKProof> {
|
|
75
|
+
const circuitData = await this._circuitStorage.loadCircuitData(circuitId);
|
|
76
|
+
if (!circuitData.wasm) {
|
|
77
|
+
throw new Error(`wasm file doesn't exist for circuit ${circuitId}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const witnessCalculator = await witnessBuilder(circuitData.wasm);
|
|
81
|
+
|
|
82
|
+
const parsedData = JSON.parse(byteDecoder.decode(inputs));
|
|
83
|
+
|
|
84
|
+
const wtnsBytes: Uint8Array = await witnessCalculator.calculateWTNSBin(parsedData, 0);
|
|
85
|
+
|
|
86
|
+
if (!circuitData.provingKey) {
|
|
87
|
+
throw new Error(`proving file doesn't exist for circuit ${circuitId}`);
|
|
88
|
+
}
|
|
89
|
+
const { proof, publicSignals } = await snarkjs.groth16.prove(circuitData.provingKey, wtnsBytes);
|
|
90
|
+
|
|
91
|
+
// we need to terminate curve manually
|
|
92
|
+
await this.terminateCurve();
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
proof,
|
|
96
|
+
pub_signals: publicSignals
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private async terminateCurve(): Promise<void> {
|
|
101
|
+
const curve = await ffjavascript.getCurveFromName(NativeProver.curveName);
|
|
102
|
+
curve.terminate();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/* eslint-disable require-await */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
export async function witnessBuilder(code: BufferSource, options?: any) {
|
|
4
|
+
options = options || {};
|
|
5
|
+
|
|
6
|
+
let wasmModule;
|
|
7
|
+
try {
|
|
8
|
+
wasmModule = await WebAssembly.compile(code);
|
|
9
|
+
} catch (err: any) {
|
|
10
|
+
throw new Error(err);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let errStr = '';
|
|
14
|
+
let msgStr = '';
|
|
15
|
+
|
|
16
|
+
const instance = await WebAssembly.instantiate(wasmModule, {
|
|
17
|
+
runtime: {
|
|
18
|
+
exceptionHandler: function (code: number) {
|
|
19
|
+
let err;
|
|
20
|
+
if (code == 1) {
|
|
21
|
+
err = 'Signal not found.\n';
|
|
22
|
+
} else if (code == 2) {
|
|
23
|
+
err = 'Too many signals set.\n';
|
|
24
|
+
} else if (code == 3) {
|
|
25
|
+
err = 'Signal already set.\n';
|
|
26
|
+
} else if (code == 4) {
|
|
27
|
+
err = 'Assert Failed.\n';
|
|
28
|
+
} else if (code == 5) {
|
|
29
|
+
err = 'Not enough memory.\n';
|
|
30
|
+
} else if (code == 6) {
|
|
31
|
+
err = 'Input signal array access exceeds the size.\n';
|
|
32
|
+
} else {
|
|
33
|
+
err = 'Unknown error.\n';
|
|
34
|
+
}
|
|
35
|
+
throw new Error(err + errStr);
|
|
36
|
+
},
|
|
37
|
+
printErrorMessage: function () {
|
|
38
|
+
errStr += getMessage() + '\n';
|
|
39
|
+
},
|
|
40
|
+
writeBufferMessage: function () {
|
|
41
|
+
const msg = getMessage();
|
|
42
|
+
// Any calls to `log()` will always end with a `\n`, so that's when we print and reset
|
|
43
|
+
if (msg === '\n') {
|
|
44
|
+
msgStr = '';
|
|
45
|
+
} else {
|
|
46
|
+
// If we've buffered other content, put a space in between the items
|
|
47
|
+
if (msgStr !== '') {
|
|
48
|
+
msgStr += ' ';
|
|
49
|
+
}
|
|
50
|
+
// Then append the message to the message we are creating
|
|
51
|
+
msgStr += msg;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
showSharedRWMemory: function () {
|
|
55
|
+
printSharedRWMemory();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const sanityCheck = options;
|
|
61
|
+
|
|
62
|
+
const wc = new WitnessCalculator(instance, sanityCheck);
|
|
63
|
+
return wc;
|
|
64
|
+
|
|
65
|
+
function getMessage() {
|
|
66
|
+
let message = '';
|
|
67
|
+
let c = (instance as any).exports.getMessageChar();
|
|
68
|
+
while (c != 0) {
|
|
69
|
+
message += String.fromCharCode(c);
|
|
70
|
+
c = (instance as any).exports.getMessageChar();
|
|
71
|
+
}
|
|
72
|
+
return message;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function printSharedRWMemory() {
|
|
76
|
+
const shared_rw_memory_size = (instance as any).exports.getFieldNumLen32();
|
|
77
|
+
const arr = new Uint32Array(shared_rw_memory_size);
|
|
78
|
+
for (let j = 0; j < shared_rw_memory_size; j++) {
|
|
79
|
+
arr[shared_rw_memory_size - 1 - j] = (instance as any).exports.readSharedRWMemory(j);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// If we've buffered other content, put a space in between the items
|
|
83
|
+
if (msgStr !== '') {
|
|
84
|
+
msgStr += ' ';
|
|
85
|
+
}
|
|
86
|
+
// Then append the value to the message we are creating
|
|
87
|
+
msgStr += fromArray32(arr).toString();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
class WitnessCalculator {
|
|
92
|
+
version: any;
|
|
93
|
+
n32: any;
|
|
94
|
+
prime: any;
|
|
95
|
+
witnessSize: any;
|
|
96
|
+
sanityCheck: any;
|
|
97
|
+
constructor(private instance: any, sanityCheck: any) {
|
|
98
|
+
this.instance = instance;
|
|
99
|
+
this.version = (this.instance.exports as any).getVersion();
|
|
100
|
+
this.n32 = (this.instance.exports as any).getFieldNumLen32();
|
|
101
|
+
|
|
102
|
+
(this.instance.exports as any).getRawPrime();
|
|
103
|
+
const arr = new Uint32Array(this.n32);
|
|
104
|
+
for (let i = 0; i < this.n32; i++) {
|
|
105
|
+
arr[this.n32 - 1 - i] = (this.instance.exports as any).readSharedRWMemory(i);
|
|
106
|
+
}
|
|
107
|
+
this.prime = fromArray32(arr);
|
|
108
|
+
|
|
109
|
+
this.witnessSize = (this.instance.exports as any).getWitnessSize();
|
|
110
|
+
|
|
111
|
+
this.sanityCheck = sanityCheck;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
circom_version() {
|
|
115
|
+
return (this.instance.exports as any).getVersion();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async _doCalculateWitness(input: any, sanityCheck: any) {
|
|
119
|
+
//input is assumed to be a map from signals to arrays of bigints
|
|
120
|
+
(this.instance.exports as any).init(this.sanityCheck || sanityCheck ? 1 : 0);
|
|
121
|
+
const keys = Object.keys(input);
|
|
122
|
+
let input_counter = 0;
|
|
123
|
+
keys.forEach((k) => {
|
|
124
|
+
const h = fnvHash(k);
|
|
125
|
+
const hMSB = parseInt(h.slice(0, 8), 16);
|
|
126
|
+
const hLSB = parseInt(h.slice(8, 16), 16);
|
|
127
|
+
const fArr = flatArray(input[k]);
|
|
128
|
+
const signalSize = (this.instance.exports as any).getInputSignalSize(hMSB, hLSB);
|
|
129
|
+
if (signalSize < 0) {
|
|
130
|
+
throw new Error(`Signal ${k} not found\n`);
|
|
131
|
+
}
|
|
132
|
+
if (fArr.length < signalSize) {
|
|
133
|
+
throw new Error(`Not enough values for input signal ${k}\n`);
|
|
134
|
+
}
|
|
135
|
+
if (fArr.length > signalSize) {
|
|
136
|
+
throw new Error(`Too many values for input signal ${k}\n`);
|
|
137
|
+
}
|
|
138
|
+
for (let i = 0; i < fArr.length; i++) {
|
|
139
|
+
const arrFr = toArray32(BigInt(fArr[i]) % this.prime, this.n32);
|
|
140
|
+
for (let j = 0; j < this.n32; j++) {
|
|
141
|
+
(this.instance.exports as any).writeSharedRWMemory(j, arrFr[this.n32 - 1 - j]);
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
(this.instance.exports as any).setInputSignal(hMSB, hLSB, i);
|
|
145
|
+
input_counter++;
|
|
146
|
+
} catch (err: any) {
|
|
147
|
+
// console.log(`After adding signal ${i} of ${k}`)
|
|
148
|
+
throw new Error(err);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
if (input_counter < (this.instance.exports as any).getInputSize()) {
|
|
153
|
+
throw new Error(
|
|
154
|
+
`Not all inputs have been set. Only ${input_counter} out of ${(
|
|
155
|
+
this.instance.exports as any
|
|
156
|
+
).getInputSize()}`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async calculateWitness(input: any, sanityCheck: any) {
|
|
162
|
+
const w = [];
|
|
163
|
+
|
|
164
|
+
await this._doCalculateWitness(input, sanityCheck);
|
|
165
|
+
|
|
166
|
+
for (let i = 0; i < this.witnessSize; i++) {
|
|
167
|
+
(this.instance.exports as any).getWitness(i);
|
|
168
|
+
const arr = new Uint32Array(this.n32);
|
|
169
|
+
for (let j = 0; j < this.n32; j++) {
|
|
170
|
+
arr[this.n32 - 1 - j] = (this.instance.exports as any).readSharedRWMemory(j);
|
|
171
|
+
}
|
|
172
|
+
w.push(fromArray32(arr));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return w;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async calculateBinWitness(input: any, sanityCheck: any) {
|
|
179
|
+
const buff32 = new Uint32Array(this.witnessSize * this.n32);
|
|
180
|
+
const buff = new Uint8Array(buff32.buffer);
|
|
181
|
+
await this._doCalculateWitness(input, sanityCheck);
|
|
182
|
+
|
|
183
|
+
for (let i = 0; i < this.witnessSize; i++) {
|
|
184
|
+
(this.instance.exports as any).getWitness(i);
|
|
185
|
+
const pos = i * this.n32;
|
|
186
|
+
for (let j = 0; j < this.n32; j++) {
|
|
187
|
+
buff32[pos + j] = (this.instance.exports as any).readSharedRWMemory(j);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return buff;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async calculateWTNSBin(input: any, sanityCheck: any) {
|
|
195
|
+
const buff32 = new Uint32Array(this.witnessSize * this.n32 + this.n32 + 11);
|
|
196
|
+
const buff = new Uint8Array(buff32.buffer);
|
|
197
|
+
await this._doCalculateWitness(input, sanityCheck);
|
|
198
|
+
|
|
199
|
+
//"wtns"
|
|
200
|
+
buff[0] = 'w'.charCodeAt(0);
|
|
201
|
+
buff[1] = 't'.charCodeAt(0);
|
|
202
|
+
buff[2] = 'n'.charCodeAt(0);
|
|
203
|
+
buff[3] = 's'.charCodeAt(0);
|
|
204
|
+
|
|
205
|
+
//version 2
|
|
206
|
+
buff32[1] = 2;
|
|
207
|
+
|
|
208
|
+
//number of sections: 2
|
|
209
|
+
buff32[2] = 2;
|
|
210
|
+
|
|
211
|
+
//id section 1
|
|
212
|
+
buff32[3] = 1;
|
|
213
|
+
|
|
214
|
+
const n8 = this.n32 * 4;
|
|
215
|
+
//id section 1 length in 64bytes
|
|
216
|
+
const idSection1length = 8 + n8;
|
|
217
|
+
const idSection1lengthHex = idSection1length.toString(16);
|
|
218
|
+
buff32[4] = parseInt(idSection1lengthHex.slice(0, 8), 16);
|
|
219
|
+
buff32[5] = parseInt(idSection1lengthHex.slice(8, 16), 16);
|
|
220
|
+
|
|
221
|
+
//this.n32
|
|
222
|
+
buff32[6] = n8;
|
|
223
|
+
|
|
224
|
+
//prime number
|
|
225
|
+
this.instance.exports.getRawPrime();
|
|
226
|
+
|
|
227
|
+
let pos = 7;
|
|
228
|
+
for (let j = 0; j < this.n32; j++) {
|
|
229
|
+
buff32[pos + j] = this.instance.exports.readSharedRWMemory(j);
|
|
230
|
+
}
|
|
231
|
+
pos += this.n32;
|
|
232
|
+
|
|
233
|
+
// witness size
|
|
234
|
+
buff32[pos] = this.witnessSize;
|
|
235
|
+
pos++;
|
|
236
|
+
|
|
237
|
+
//id section 2
|
|
238
|
+
buff32[pos] = 2;
|
|
239
|
+
pos++;
|
|
240
|
+
|
|
241
|
+
// section 2 length
|
|
242
|
+
const idSection2length = n8 * this.witnessSize;
|
|
243
|
+
const idSection2lengthHex = idSection2length.toString(16);
|
|
244
|
+
buff32[pos] = parseInt(idSection2lengthHex.slice(0, 8), 16);
|
|
245
|
+
buff32[pos + 1] = parseInt(idSection2lengthHex.slice(8, 16), 16);
|
|
246
|
+
|
|
247
|
+
pos += 2;
|
|
248
|
+
for (let i = 0; i < this.witnessSize; i++) {
|
|
249
|
+
this.instance.exports.getWitness(i);
|
|
250
|
+
for (let j = 0; j < this.n32; j++) {
|
|
251
|
+
buff32[pos + j] = this.instance.exports.readSharedRWMemory(j);
|
|
252
|
+
}
|
|
253
|
+
pos += this.n32;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return buff;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function toArray32(rem: bigint, size: number) {
|
|
261
|
+
const res = []; //new Uint32Array(size); //has no unshift
|
|
262
|
+
const radix = BigInt(0x100000000);
|
|
263
|
+
while (rem) {
|
|
264
|
+
res.unshift(Number(rem % radix));
|
|
265
|
+
rem = rem / radix;
|
|
266
|
+
}
|
|
267
|
+
if (size) {
|
|
268
|
+
let i = size - res.length;
|
|
269
|
+
while (i > 0) {
|
|
270
|
+
res.unshift(0);
|
|
271
|
+
i--;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return res;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function fromArray32(arr: Uint32Array) {
|
|
278
|
+
//returns a BigInt
|
|
279
|
+
let res = BigInt(0);
|
|
280
|
+
const radix = BigInt(0x100000000);
|
|
281
|
+
for (let i = 0; i < arr.length; i++) {
|
|
282
|
+
res = res * radix + BigInt(arr[i]);
|
|
283
|
+
}
|
|
284
|
+
return res;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function flatArray(a: any[]) {
|
|
288
|
+
const res: any[] = [];
|
|
289
|
+
fillArray(res, a);
|
|
290
|
+
return res;
|
|
291
|
+
|
|
292
|
+
function fillArray(res: any[], a: any[]) {
|
|
293
|
+
if (Array.isArray(a)) {
|
|
294
|
+
for (let i = 0; i < a.length; i++) {
|
|
295
|
+
fillArray(res, a[i]);
|
|
296
|
+
}
|
|
297
|
+
} else {
|
|
298
|
+
res.push(a);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function fnvHash(str: any) {
|
|
304
|
+
const uint64_max = BigInt(2) ** BigInt(64);
|
|
305
|
+
let hash = BigInt('0xCBF29CE484222325');
|
|
306
|
+
for (let i = 0; i < str.length; i++) {
|
|
307
|
+
hash ^= BigInt(str[i].charCodeAt());
|
|
308
|
+
hash *= BigInt(0x100000001b3);
|
|
309
|
+
hash %= uint64_max;
|
|
310
|
+
}
|
|
311
|
+
let hashHex = hash.toString(16);
|
|
312
|
+
const n = 16 - hashHex.length;
|
|
313
|
+
hashHex = '0'.repeat(n).concat(hashHex);
|
|
314
|
+
return hashHex;
|
|
315
|
+
}
|