@unconfirmed/effect-sui 0.0.0-stage → 0.1.1
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/LICENSE +202 -0
- package/README.md +10 -2
- package/dist/Address.d.ts +18 -0
- package/dist/Address.d.ts.map +1 -0
- package/dist/Address.js +33 -0
- package/dist/Address.js.map +1 -0
- package/dist/AddressAlias.d.ts +107 -0
- package/dist/AddressAlias.d.ts.map +1 -0
- package/dist/AddressAlias.js +104 -0
- package/dist/AddressAlias.js.map +1 -0
- package/dist/Bip32.d.ts +6 -0
- package/dist/Bip32.d.ts.map +1 -0
- package/dist/Bip32.js +34 -0
- package/dist/Bip32.js.map +1 -0
- package/dist/Chain.d.ts +23 -0
- package/dist/Chain.d.ts.map +1 -0
- package/dist/Chain.js +7 -0
- package/dist/Chain.js.map +1 -0
- package/dist/CheckpointData.d.ts +74 -0
- package/dist/CheckpointData.d.ts.map +1 -0
- package/dist/CheckpointData.js +48 -0
- package/dist/CheckpointData.js.map +1 -0
- package/dist/Checkpoints.d.ts +23 -0
- package/dist/Checkpoints.d.ts.map +1 -0
- package/dist/Checkpoints.js +7 -0
- package/dist/Checkpoints.js.map +1 -0
- package/dist/CoinReservation.d.ts +18 -0
- package/dist/CoinReservation.d.ts.map +1 -0
- package/dist/CoinReservation.js +58 -0
- package/dist/CoinReservation.js.map +1 -0
- package/dist/Coins.d.ts +42 -0
- package/dist/Coins.d.ts.map +1 -0
- package/dist/Coins.js +49 -0
- package/dist/Coins.js.map +1 -0
- package/dist/DynamicFields.d.ts +115 -0
- package/dist/DynamicFields.d.ts.map +1 -0
- package/dist/DynamicFields.js +101 -0
- package/dist/DynamicFields.js.map +1 -0
- package/dist/Ecdsa.d.ts +39 -0
- package/dist/Ecdsa.d.ts.map +1 -0
- package/dist/Ecdsa.js +76 -0
- package/dist/Ecdsa.js.map +1 -0
- package/dist/Ed25519.d.ts +22 -0
- package/dist/Ed25519.d.ts.map +1 -0
- package/dist/Ed25519.js +77 -0
- package/dist/Ed25519.js.map +1 -0
- package/dist/Events.d.ts +105 -0
- package/dist/Events.d.ts.map +1 -0
- package/dist/Events.js +51 -0
- package/dist/Events.js.map +1 -0
- package/dist/Hash.d.ts +16 -0
- package/dist/Hash.d.ts.map +1 -0
- package/dist/Hash.js +32 -0
- package/dist/Hash.js.map +1 -0
- package/dist/MlDsa65.d.ts +17 -0
- package/dist/MlDsa65.d.ts.map +1 -0
- package/dist/MlDsa65.js +84 -0
- package/dist/MlDsa65.js.map +1 -0
- package/dist/Mnemonic.d.ts +20 -0
- package/dist/Mnemonic.d.ts.map +1 -0
- package/dist/Mnemonic.js +71 -0
- package/dist/Mnemonic.js.map +1 -0
- package/dist/Move.d.ts +261 -0
- package/dist/Move.d.ts.map +1 -0
- package/dist/Move.js +232 -0
- package/dist/Move.js.map +1 -0
- package/dist/MultiSig.d.ts +106 -0
- package/dist/MultiSig.d.ts.map +1 -0
- package/dist/MultiSig.js +254 -0
- package/dist/MultiSig.js.map +1 -0
- package/dist/Objects.d.ts +95 -0
- package/dist/Objects.d.ts.map +1 -0
- package/dist/Objects.js +57 -0
- package/dist/Objects.js.map +1 -0
- package/dist/Packages.d.ts +49 -0
- package/dist/Packages.d.ts.map +1 -0
- package/dist/Packages.js +16 -0
- package/dist/Packages.js.map +1 -0
- package/dist/Passkey.d.ts +11 -0
- package/dist/Passkey.d.ts.map +1 -0
- package/dist/Passkey.js +11 -0
- package/dist/Passkey.js.map +1 -0
- package/dist/PrivateKey.d.ts +39 -0
- package/dist/PrivateKey.d.ts.map +1 -0
- package/dist/PrivateKey.js +118 -0
- package/dist/PrivateKey.js.map +1 -0
- package/dist/Ptb.d.ts +413 -0
- package/dist/Ptb.d.ts.map +1 -0
- package/dist/Ptb.js +338 -0
- package/dist/Ptb.js.map +1 -0
- package/dist/Resolve.d.ts +502 -0
- package/dist/Resolve.d.ts.map +1 -0
- package/dist/Resolve.js +1188 -0
- package/dist/Resolve.js.map +1 -0
- package/dist/RpcError.d.ts +19 -0
- package/dist/RpcError.d.ts.map +1 -0
- package/dist/RpcError.js +37 -0
- package/dist/RpcError.js.map +1 -0
- package/dist/Secp256k1.d.ts +11 -0
- package/dist/Secp256k1.d.ts.map +1 -0
- package/dist/Secp256k1.js +23 -0
- package/dist/Secp256k1.js.map +1 -0
- package/dist/Secp256r1.d.ts +11 -0
- package/dist/Secp256r1.d.ts.map +1 -0
- package/dist/Secp256r1.js +23 -0
- package/dist/Secp256r1.js.map +1 -0
- package/dist/SignatureScheme.d.ts +103 -0
- package/dist/SignatureScheme.d.ts.map +1 -0
- package/dist/SignatureScheme.js +93 -0
- package/dist/SignatureScheme.js.map +1 -0
- package/dist/Signer.d.ts +54 -0
- package/dist/Signer.d.ts.map +1 -0
- package/dist/Signer.js +31 -0
- package/dist/Signer.js.map +1 -0
- package/dist/Testing.d.ts +171 -0
- package/dist/Testing.d.ts.map +1 -0
- package/dist/Testing.js +531 -0
- package/dist/Testing.js.map +1 -0
- package/dist/TransactionData.d.ts +3218 -0
- package/dist/TransactionData.d.ts.map +1 -0
- package/dist/TransactionData.js +105 -0
- package/dist/TransactionData.js.map +1 -0
- package/dist/TransactionJson.d.ts +1544 -0
- package/dist/TransactionJson.d.ts.map +1 -0
- package/dist/TransactionJson.js +926 -0
- package/dist/TransactionJson.js.map +1 -0
- package/dist/Transactions.d.ts +181 -0
- package/dist/Transactions.d.ts.map +1 -0
- package/dist/Transactions.js +49 -0
- package/dist/Transactions.js.map +1 -0
- package/dist/Tx.d.ts +1419 -0
- package/dist/Tx.d.ts.map +1 -0
- package/dist/Tx.js +266 -0
- package/dist/Tx.js.map +1 -0
- package/dist/TypeTag.d.ts +42 -0
- package/dist/TypeTag.d.ts.map +1 -0
- package/dist/TypeTag.js +110 -0
- package/dist/TypeTag.js.map +1 -0
- package/dist/Verify.d.ts +23 -0
- package/dist/Verify.d.ts.map +1 -0
- package/dist/Verify.js +29 -0
- package/dist/Verify.js.map +1 -0
- package/dist/enoki/EnokiClient.d.ts +184 -0
- package/dist/enoki/EnokiClient.d.ts.map +1 -0
- package/dist/enoki/EnokiClient.js +105 -0
- package/dist/enoki/EnokiClient.js.map +1 -0
- package/dist/enoki/EnokiHttp.d.ts +33 -0
- package/dist/enoki/EnokiHttp.d.ts.map +1 -0
- package/dist/enoki/EnokiHttp.js +160 -0
- package/dist/enoki/EnokiHttp.js.map +1 -0
- package/dist/enoki/Sponsor.d.ts +119 -0
- package/dist/enoki/Sponsor.d.ts.map +1 -0
- package/dist/enoki/Sponsor.js +170 -0
- package/dist/enoki/Sponsor.js.map +1 -0
- package/dist/enoki/ZkLoginFlow.d.ts +84 -0
- package/dist/enoki/ZkLoginFlow.d.ts.map +1 -0
- package/dist/enoki/ZkLoginFlow.js +138 -0
- package/dist/enoki/ZkLoginFlow.js.map +1 -0
- package/dist/enoki/index.d.ts +9 -0
- package/dist/enoki/index.d.ts.map +1 -0
- package/dist/enoki/index.js +9 -0
- package/dist/enoki/index.js.map +1 -0
- package/dist/graphql/ChainGraphQL.d.ts +35 -0
- package/dist/graphql/ChainGraphQL.d.ts.map +1 -0
- package/dist/graphql/ChainGraphQL.js +62 -0
- package/dist/graphql/ChainGraphQL.js.map +1 -0
- package/dist/graphql/CheckpointDataGraphQL.d.ts +785 -0
- package/dist/graphql/CheckpointDataGraphQL.d.ts.map +1 -0
- package/dist/graphql/CheckpointDataGraphQL.js +157 -0
- package/dist/graphql/CheckpointDataGraphQL.js.map +1 -0
- package/dist/graphql/CheckpointsGraphQL.d.ts +91 -0
- package/dist/graphql/CheckpointsGraphQL.d.ts.map +1 -0
- package/dist/graphql/CheckpointsGraphQL.js +80 -0
- package/dist/graphql/CheckpointsGraphQL.js.map +1 -0
- package/dist/graphql/CoinsGraphQL.d.ts +81 -0
- package/dist/graphql/CoinsGraphQL.d.ts.map +1 -0
- package/dist/graphql/CoinsGraphQL.js +63 -0
- package/dist/graphql/CoinsGraphQL.js.map +1 -0
- package/dist/graphql/DynamicFieldsGraphQL.d.ts +94 -0
- package/dist/graphql/DynamicFieldsGraphQL.d.ts.map +1 -0
- package/dist/graphql/DynamicFieldsGraphQL.js +126 -0
- package/dist/graphql/DynamicFieldsGraphQL.js.map +1 -0
- package/dist/graphql/EventsGraphQL.d.ts +266 -0
- package/dist/graphql/EventsGraphQL.d.ts.map +1 -0
- package/dist/graphql/EventsGraphQL.js +249 -0
- package/dist/graphql/EventsGraphQL.js.map +1 -0
- package/dist/graphql/ObjectsGraphQL.d.ts +130 -0
- package/dist/graphql/ObjectsGraphQL.d.ts.map +1 -0
- package/dist/graphql/ObjectsGraphQL.js +79 -0
- package/dist/graphql/ObjectsGraphQL.js.map +1 -0
- package/dist/graphql/PackagesGraphQL.d.ts +82 -0
- package/dist/graphql/PackagesGraphQL.d.ts.map +1 -0
- package/dist/graphql/PackagesGraphQL.js +145 -0
- package/dist/graphql/PackagesGraphQL.js.map +1 -0
- package/dist/graphql/SuiGraphQL.d.ts +37 -0
- package/dist/graphql/SuiGraphQL.d.ts.map +1 -0
- package/dist/graphql/SuiGraphQL.js +47 -0
- package/dist/graphql/SuiGraphQL.js.map +1 -0
- package/dist/graphql/TransactionsGraphQL.d.ts +1309 -0
- package/dist/graphql/TransactionsGraphQL.d.ts.map +1 -0
- package/dist/graphql/TransactionsGraphQL.js +206 -0
- package/dist/graphql/TransactionsGraphQL.js.map +1 -0
- package/dist/graphql/convert.d.ts +505 -0
- package/dist/graphql/convert.d.ts.map +1 -0
- package/dist/graphql/convert.js +384 -0
- package/dist/graphql/convert.js.map +1 -0
- package/dist/graphql/index.d.ts +41 -0
- package/dist/graphql/index.d.ts.map +1 -0
- package/dist/graphql/index.js +20 -0
- package/dist/graphql/index.js.map +1 -0
- package/dist/graphql/merge.d.ts +8 -0
- package/dist/graphql/merge.d.ts.map +1 -0
- package/dist/graphql/merge.js +55 -0
- package/dist/graphql/merge.js.map +1 -0
- package/dist/graphql/paging.d.ts +219 -0
- package/dist/graphql/paging.d.ts.map +1 -0
- package/dist/graphql/paging.js +74 -0
- package/dist/graphql/paging.js.map +1 -0
- package/dist/graphql/subscription.d.ts +27 -0
- package/dist/graphql/subscription.d.ts.map +1 -0
- package/dist/graphql/subscription.js +47 -0
- package/dist/graphql/subscription.js.map +1 -0
- package/dist/graphql/tip.d.ts +31 -0
- package/dist/graphql/tip.d.ts.map +1 -0
- package/dist/graphql/tip.js +29 -0
- package/dist/graphql/tip.js.map +1 -0
- package/dist/grpc/ChainGrpc.d.ts +11 -0
- package/dist/grpc/ChainGrpc.d.ts.map +1 -0
- package/dist/grpc/ChainGrpc.js +40 -0
- package/dist/grpc/ChainGrpc.js.map +1 -0
- package/dist/grpc/CheckpointDataGrpc.d.ts +6 -0
- package/dist/grpc/CheckpointDataGrpc.d.ts.map +1 -0
- package/dist/grpc/CheckpointDataGrpc.js +27 -0
- package/dist/grpc/CheckpointDataGrpc.js.map +1 -0
- package/dist/grpc/CheckpointsGrpc.d.ts +6 -0
- package/dist/grpc/CheckpointsGrpc.d.ts.map +1 -0
- package/dist/grpc/CheckpointsGrpc.js +25 -0
- package/dist/grpc/CheckpointsGrpc.js.map +1 -0
- package/dist/grpc/CoinsGrpc.d.ts +7 -0
- package/dist/grpc/CoinsGrpc.d.ts.map +1 -0
- package/dist/grpc/CoinsGrpc.js +34 -0
- package/dist/grpc/CoinsGrpc.js.map +1 -0
- package/dist/grpc/DynamicFieldsGrpc.d.ts +11 -0
- package/dist/grpc/DynamicFieldsGrpc.d.ts.map +1 -0
- package/dist/grpc/DynamicFieldsGrpc.js +91 -0
- package/dist/grpc/DynamicFieldsGrpc.js.map +1 -0
- package/dist/grpc/EventsGrpc.d.ts +13 -0
- package/dist/grpc/EventsGrpc.d.ts.map +1 -0
- package/dist/grpc/EventsGrpc.js +88 -0
- package/dist/grpc/EventsGrpc.js.map +1 -0
- package/dist/grpc/GrpcWeb.d.ts +71 -0
- package/dist/grpc/GrpcWeb.d.ts.map +1 -0
- package/dist/grpc/GrpcWeb.js +243 -0
- package/dist/grpc/GrpcWeb.js.map +1 -0
- package/dist/grpc/ObjectsGrpc.d.ts +10 -0
- package/dist/grpc/ObjectsGrpc.d.ts.map +1 -0
- package/dist/grpc/ObjectsGrpc.js +72 -0
- package/dist/grpc/ObjectsGrpc.js.map +1 -0
- package/dist/grpc/PackagesGrpc.d.ts +9 -0
- package/dist/grpc/PackagesGrpc.d.ts.map +1 -0
- package/dist/grpc/PackagesGrpc.js +78 -0
- package/dist/grpc/PackagesGrpc.js.map +1 -0
- package/dist/grpc/Rpc.d.ts +46 -0
- package/dist/grpc/Rpc.d.ts.map +1 -0
- package/dist/grpc/Rpc.js +111 -0
- package/dist/grpc/Rpc.js.map +1 -0
- package/dist/grpc/TransactionsGrpc.d.ts +6 -0
- package/dist/grpc/TransactionsGrpc.d.ts.map +1 -0
- package/dist/grpc/TransactionsGrpc.js +56 -0
- package/dist/grpc/TransactionsGrpc.js.map +1 -0
- package/dist/grpc/cache.d.ts +7 -0
- package/dist/grpc/cache.d.ts.map +1 -0
- package/dist/grpc/cache.js +55 -0
- package/dist/grpc/cache.js.map +1 -0
- package/dist/grpc/convert.d.ts +43 -0
- package/dist/grpc/convert.d.ts.map +1 -0
- package/dist/grpc/convert.js +198 -0
- package/dist/grpc/convert.js.map +1 -0
- package/dist/grpc/generated/lean.d.ts +36 -0
- package/dist/grpc/generated/lean.d.ts.map +1 -0
- package/dist/grpc/generated/lean.js +205 -0
- package/dist/grpc/generated/lean.js.map +1 -0
- package/dist/grpc/generated/proto.d.ts +2000 -0
- package/dist/grpc/generated/proto.d.ts.map +1 -0
- package/dist/grpc/generated/proto.js +356 -0
- package/dist/grpc/generated/proto.js.map +1 -0
- package/dist/grpc/generated/rpc.d.ts +62 -0
- package/dist/grpc/generated/rpc.d.ts.map +1 -0
- package/dist/grpc/generated/rpc.js +324 -0
- package/dist/grpc/generated/rpc.js.map +1 -0
- package/dist/grpc/index.d.ts +58 -0
- package/dist/grpc/index.d.ts.map +1 -0
- package/dist/grpc/index.js +43 -0
- package/dist/grpc/index.js.map +1 -0
- package/dist/grpc/scan.d.ts +79 -0
- package/dist/grpc/scan.d.ts.map +1 -0
- package/dist/grpc/scan.js +126 -0
- package/dist/grpc/scan.js.map +1 -0
- package/dist/grpc/transaction.d.ts +9 -0
- package/dist/grpc/transaction.d.ts.map +1 -0
- package/dist/grpc/transaction.js +168 -0
- package/dist/grpc/transaction.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/allowances.d.ts +18 -0
- package/dist/internal/allowances.d.ts.map +1 -0
- package/dist/internal/allowances.js +194 -0
- package/dist/internal/allowances.js.map +1 -0
- package/dist/internal/mnemonic.d.ts +53 -0
- package/dist/internal/mnemonic.d.ts.map +1 -0
- package/dist/internal/mnemonic.js +66 -0
- package/dist/internal/mnemonic.js.map +1 -0
- package/dist/internal/passkey/BrowserProvider.d.ts +10 -0
- package/dist/internal/passkey/BrowserProvider.d.ts.map +1 -0
- package/dist/internal/passkey/BrowserProvider.js +101 -0
- package/dist/internal/passkey/BrowserProvider.js.map +1 -0
- package/dist/internal/passkey/Passkey.d.ts +104 -0
- package/dist/internal/passkey/Passkey.d.ts.map +1 -0
- package/dist/internal/passkey/Passkey.js +333 -0
- package/dist/internal/passkey/Passkey.js.map +1 -0
- package/dist/internal/passkey/SoftwareProvider.d.ts +23 -0
- package/dist/internal/passkey/SoftwareProvider.d.ts.map +1 -0
- package/dist/internal/passkey/SoftwareProvider.js +61 -0
- package/dist/internal/passkey/SoftwareProvider.js.map +1 -0
- package/dist/lifecycle/Evidence.d.ts +62 -0
- package/dist/lifecycle/Evidence.d.ts.map +1 -0
- package/dist/lifecycle/Evidence.js +30 -0
- package/dist/lifecycle/Evidence.js.map +1 -0
- package/dist/lifecycle/EvidenceGraphQL.d.ts +59 -0
- package/dist/lifecycle/EvidenceGraphQL.d.ts.map +1 -0
- package/dist/lifecycle/EvidenceGraphQL.js +53 -0
- package/dist/lifecycle/EvidenceGraphQL.js.map +1 -0
- package/dist/lifecycle/EvidenceGrpc.d.ts +4 -0
- package/dist/lifecycle/EvidenceGrpc.d.ts.map +1 -0
- package/dist/lifecycle/EvidenceGrpc.js +37 -0
- package/dist/lifecycle/EvidenceGrpc.js.map +1 -0
- package/dist/lifecycle/Journal.d.ts +69 -0
- package/dist/lifecycle/Journal.d.ts.map +1 -0
- package/dist/lifecycle/Journal.js +70 -0
- package/dist/lifecycle/Journal.js.map +1 -0
- package/dist/lifecycle/JournalEntry.d.ts +67 -0
- package/dist/lifecycle/JournalEntry.d.ts.map +1 -0
- package/dist/lifecycle/JournalEntry.js +45 -0
- package/dist/lifecycle/JournalEntry.js.map +1 -0
- package/dist/lifecycle/JournalKeyValueStore.d.ts +30 -0
- package/dist/lifecycle/JournalKeyValueStore.d.ts.map +1 -0
- package/dist/lifecycle/JournalKeyValueStore.js +217 -0
- package/dist/lifecycle/JournalKeyValueStore.js.map +1 -0
- package/dist/lifecycle/KeyValueStoreIndexedDb.d.ts +54 -0
- package/dist/lifecycle/KeyValueStoreIndexedDb.d.ts.map +1 -0
- package/dist/lifecycle/KeyValueStoreIndexedDb.js +321 -0
- package/dist/lifecycle/KeyValueStoreIndexedDb.js.map +1 -0
- package/dist/lifecycle/KeyValueStoreOpfs.d.ts +65 -0
- package/dist/lifecycle/KeyValueStoreOpfs.d.ts.map +1 -0
- package/dist/lifecycle/KeyValueStoreOpfs.js +207 -0
- package/dist/lifecycle/KeyValueStoreOpfs.js.map +1 -0
- package/dist/lifecycle/Lifecycle.d.ts +416 -0
- package/dist/lifecycle/Lifecycle.d.ts.map +1 -0
- package/dist/lifecycle/Lifecycle.js +666 -0
- package/dist/lifecycle/Lifecycle.js.map +1 -0
- package/dist/lifecycle/Outcome.d.ts +132 -0
- package/dist/lifecycle/Outcome.d.ts.map +1 -0
- package/dist/lifecycle/Outcome.js +106 -0
- package/dist/lifecycle/Outcome.js.map +1 -0
- package/dist/lifecycle/SenderLock.d.ts +37 -0
- package/dist/lifecycle/SenderLock.d.ts.map +1 -0
- package/dist/lifecycle/SenderLock.js +57 -0
- package/dist/lifecycle/SenderLock.js.map +1 -0
- package/dist/lifecycle/SenderLockWebLocks.d.ts +37 -0
- package/dist/lifecycle/SenderLockWebLocks.d.ts.map +1 -0
- package/dist/lifecycle/SenderLockWebLocks.js +100 -0
- package/dist/lifecycle/SenderLockWebLocks.js.map +1 -0
- package/dist/lifecycle/SignedTransaction.d.ts +55 -0
- package/dist/lifecycle/SignedTransaction.d.ts.map +1 -0
- package/dist/lifecycle/SignedTransaction.js +109 -0
- package/dist/lifecycle/SignedTransaction.js.map +1 -0
- package/dist/lifecycle/SubmitConfig.d.ts +44 -0
- package/dist/lifecycle/SubmitConfig.d.ts.map +1 -0
- package/dist/lifecycle/SubmitConfig.js +39 -0
- package/dist/lifecycle/SubmitConfig.js.map +1 -0
- package/dist/lifecycle/index.d.ts +13 -0
- package/dist/lifecycle/index.d.ts.map +1 -0
- package/dist/lifecycle/index.js +13 -0
- package/dist/lifecycle/index.js.map +1 -0
- package/dist/wallet/Connection.d.ts +119 -0
- package/dist/wallet/Connection.d.ts.map +1 -0
- package/dist/wallet/Connection.js +197 -0
- package/dist/wallet/Connection.js.map +1 -0
- package/dist/wallet/Features.d.ts +91 -0
- package/dist/wallet/Features.d.ts.map +1 -0
- package/dist/wallet/Features.js +14 -0
- package/dist/wallet/Features.js.map +1 -0
- package/dist/wallet/Wallet.d.ts +151 -0
- package/dist/wallet/Wallet.d.ts.map +1 -0
- package/dist/wallet/Wallet.js +399 -0
- package/dist/wallet/Wallet.js.map +1 -0
- package/dist/wallet/index.d.ts +7 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/index.js +7 -0
- package/dist/wallet/index.js.map +1 -0
- package/dist/zklogin/AddressSeed.d.ts +40 -0
- package/dist/zklogin/AddressSeed.d.ts.map +1 -0
- package/dist/zklogin/AddressSeed.js +91 -0
- package/dist/zklogin/AddressSeed.js.map +1 -0
- package/dist/zklogin/Errors.d.ts +24 -0
- package/dist/zklogin/Errors.d.ts.map +1 -0
- package/dist/zklogin/Errors.js +25 -0
- package/dist/zklogin/Errors.js.map +1 -0
- package/dist/zklogin/Jwt.d.ts +51 -0
- package/dist/zklogin/Jwt.d.ts.map +1 -0
- package/dist/zklogin/Jwt.js +159 -0
- package/dist/zklogin/Jwt.js.map +1 -0
- package/dist/zklogin/Nonce.d.ts +9 -0
- package/dist/zklogin/Nonce.d.ts.map +1 -0
- package/dist/zklogin/Nonce.js +34 -0
- package/dist/zklogin/Nonce.js.map +1 -0
- package/dist/zklogin/Poseidon.d.ts +24 -0
- package/dist/zklogin/Poseidon.d.ts.map +1 -0
- package/dist/zklogin/Poseidon.js +54 -0
- package/dist/zklogin/Poseidon.js.map +1 -0
- package/dist/zklogin/PublicIdentifier.d.ts +49 -0
- package/dist/zklogin/PublicIdentifier.d.ts.map +1 -0
- package/dist/zklogin/PublicIdentifier.js +90 -0
- package/dist/zklogin/PublicIdentifier.js.map +1 -0
- package/dist/zklogin/Signature.d.ts +55 -0
- package/dist/zklogin/Signature.d.ts.map +1 -0
- package/dist/zklogin/Signature.js +70 -0
- package/dist/zklogin/Signature.js.map +1 -0
- package/dist/zklogin/ZkLogin.d.ts +41 -0
- package/dist/zklogin/ZkLogin.d.ts.map +1 -0
- package/dist/zklogin/ZkLogin.js +87 -0
- package/dist/zklogin/ZkLogin.js.map +1 -0
- package/dist/zklogin/ZkLoginAddress.d.ts +30 -0
- package/dist/zklogin/ZkLoginAddress.d.ts.map +1 -0
- package/dist/zklogin/ZkLoginAddress.js +31 -0
- package/dist/zklogin/ZkLoginAddress.js.map +1 -0
- package/dist/zklogin/ZkLoginVerifier.d.ts +37 -0
- package/dist/zklogin/ZkLoginVerifier.d.ts.map +1 -0
- package/dist/zklogin/ZkLoginVerifier.js +4 -0
- package/dist/zklogin/ZkLoginVerifier.js.map +1 -0
- package/dist/zklogin/ZkLoginVerifierGrpc.d.ts +12 -0
- package/dist/zklogin/ZkLoginVerifierGrpc.d.ts.map +1 -0
- package/dist/zklogin/ZkLoginVerifierGrpc.js +53 -0
- package/dist/zklogin/ZkLoginVerifierGrpc.js.map +1 -0
- package/dist/zklogin/index.d.ts +17 -0
- package/dist/zklogin/index.d.ts.map +1 -0
- package/dist/zklogin/index.js +17 -0
- package/dist/zklogin/index.js.map +1 -0
- package/dist/zklogin/internal/parse.d.ts +9 -0
- package/dist/zklogin/internal/parse.d.ts.map +1 -0
- package/dist/zklogin/internal/parse.js +33 -0
- package/dist/zklogin/internal/parse.js.map +1 -0
- package/dist/zklogin/internal/poseidon.d.ts +21 -0
- package/dist/zklogin/internal/poseidon.d.ts.map +1 -0
- package/dist/zklogin/internal/poseidon.js +40 -0
- package/dist/zklogin/internal/poseidon.js.map +1 -0
- package/package.json +69 -4
- package/src/Address.ts +45 -0
- package/src/AddressAlias.ts +160 -0
- package/src/Bip32.ts +37 -0
- package/src/Chain.ts +21 -0
- package/src/CheckpointData.ts +106 -0
- package/src/Checkpoints.ts +18 -0
- package/src/CoinReservation.ts +65 -0
- package/src/Coins.ts +86 -0
- package/src/DynamicFields.ts +179 -0
- package/src/Ecdsa.ts +103 -0
- package/src/Ed25519.ts +84 -0
- package/src/Events.ts +133 -0
- package/src/Hash.ts +39 -0
- package/src/MlDsa65.ts +92 -0
- package/src/Mnemonic.ts +109 -0
- package/src/Move.ts +440 -0
- package/src/MultiSig.ts +320 -0
- package/src/Objects.ts +112 -0
- package/src/Packages.ts +52 -0
- package/src/Passkey.ts +10 -0
- package/src/PrivateKey.ts +138 -0
- package/src/Ptb.ts +579 -0
- package/src/Resolve.ts +1367 -0
- package/src/RpcError.ts +41 -0
- package/src/Secp256k1.ts +29 -0
- package/src/Secp256r1.ts +29 -0
- package/src/SignatureScheme.ts +166 -0
- package/src/Signer.ts +62 -0
- package/src/Testing.ts +830 -0
- package/src/TransactionData.ts +134 -0
- package/src/TransactionJson.ts +1002 -0
- package/src/Transactions.ts +211 -0
- package/src/Tx.ts +367 -0
- package/src/TypeTag.ts +123 -0
- package/src/Verify.ts +42 -0
- package/src/enoki/EnokiClient.ts +204 -0
- package/src/enoki/EnokiHttp.ts +222 -0
- package/src/enoki/Sponsor.ts +280 -0
- package/src/enoki/ZkLoginFlow.ts +176 -0
- package/src/enoki/index.ts +8 -0
- package/src/graphql/ChainGraphQL.ts +76 -0
- package/src/graphql/CheckpointDataGraphQL.ts +191 -0
- package/src/graphql/CheckpointsGraphQL.ts +96 -0
- package/src/graphql/CoinsGraphQL.ts +85 -0
- package/src/graphql/DynamicFieldsGraphQL.ts +167 -0
- package/src/graphql/EventsGraphQL.ts +301 -0
- package/src/graphql/ObjectsGraphQL.ts +112 -0
- package/src/graphql/PackagesGraphQL.ts +173 -0
- package/src/graphql/SuiGraphQL.ts +77 -0
- package/src/graphql/TransactionsGraphQL.ts +292 -0
- package/src/graphql/convert.ts +450 -0
- package/src/graphql/index.ts +74 -0
- package/src/graphql/merge.ts +62 -0
- package/src/graphql/paging.ts +110 -0
- package/src/graphql/subscription.ts +58 -0
- package/src/graphql/tip.ts +38 -0
- package/src/grpc/ChainGrpc.ts +51 -0
- package/src/grpc/CheckpointDataGrpc.ts +47 -0
- package/src/grpc/CheckpointsGrpc.ts +37 -0
- package/src/grpc/CoinsGrpc.ts +50 -0
- package/src/grpc/DynamicFieldsGrpc.ts +128 -0
- package/src/grpc/EventsGrpc.ts +101 -0
- package/src/grpc/GrpcWeb.ts +343 -0
- package/src/grpc/ObjectsGrpc.ts +95 -0
- package/src/grpc/PackagesGrpc.ts +98 -0
- package/src/grpc/Rpc.ts +156 -0
- package/src/grpc/TransactionsGrpc.ts +88 -0
- package/src/grpc/cache.ts +68 -0
- package/src/grpc/convert.ts +227 -0
- package/src/grpc/generated/lean.ts +276 -0
- package/src/grpc/generated/proto.ts +2130 -0
- package/src/grpc/generated/rpc.ts +417 -0
- package/src/grpc/index.ts +97 -0
- package/src/grpc/scan.ts +183 -0
- package/src/grpc/transaction.ts +182 -0
- package/src/index.ts +35 -0
- package/src/internal/allowances.ts +238 -0
- package/src/internal/mnemonic.ts +99 -0
- package/src/internal/passkey/BrowserProvider.ts +131 -0
- package/src/internal/passkey/Passkey.ts +408 -0
- package/src/internal/passkey/SoftwareProvider.ts +90 -0
- package/src/lifecycle/Evidence.ts +85 -0
- package/src/lifecycle/EvidenceGraphQL.ts +67 -0
- package/src/lifecycle/EvidenceGrpc.ts +47 -0
- package/src/lifecycle/Journal.ts +117 -0
- package/src/lifecycle/JournalEntry.ts +68 -0
- package/src/lifecycle/JournalKeyValueStore.ts +276 -0
- package/src/lifecycle/KeyValueStoreIndexedDb.ts +361 -0
- package/src/lifecycle/KeyValueStoreOpfs.ts +230 -0
- package/src/lifecycle/Lifecycle.ts +990 -0
- package/src/lifecycle/Outcome.ts +130 -0
- package/src/lifecycle/SenderLock.ts +73 -0
- package/src/lifecycle/SenderLockWebLocks.ts +136 -0
- package/src/lifecycle/SignedTransaction.ts +133 -0
- package/src/lifecycle/SubmitConfig.ts +77 -0
- package/src/lifecycle/index.ts +12 -0
- package/src/wallet/Connection.ts +323 -0
- package/src/wallet/Features.ts +114 -0
- package/src/wallet/Wallet.ts +550 -0
- package/src/wallet/index.ts +6 -0
- package/src/zklogin/AddressSeed.ts +130 -0
- package/src/zklogin/Errors.ts +27 -0
- package/src/zklogin/Jwt.ts +186 -0
- package/src/zklogin/Nonce.ts +46 -0
- package/src/zklogin/Poseidon.ts +62 -0
- package/src/zklogin/PublicIdentifier.ts +111 -0
- package/src/zklogin/Signature.ts +88 -0
- package/src/zklogin/ZkLogin.ts +145 -0
- package/src/zklogin/ZkLoginAddress.ts +72 -0
- package/src/zklogin/ZkLoginVerifier.ts +37 -0
- package/src/zklogin/ZkLoginVerifierGrpc.ts +66 -0
- package/src/zklogin/index.ts +16 -0
- package/src/zklogin/internal/parse.ts +30 -0
- package/src/zklogin/internal/poseidon.ts +47 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic fields: reading a field of a parent by name, the child object of a
|
|
3
|
+
* dynamic object field, and listing a parent's fields as a `Stream`.
|
|
4
|
+
*
|
|
5
|
+
* A name is its Move type plus its BCS bytes. `deriveId` computes a field's
|
|
6
|
+
* object id offline, which is how `get` reads through the batched `Objects.get`.
|
|
7
|
+
*/
|
|
8
|
+
import * as Context from "effect/Context"
|
|
9
|
+
import * as Effect from "effect/Effect"
|
|
10
|
+
import * as Result from "effect/Result"
|
|
11
|
+
import * as Schema from "effect/Schema"
|
|
12
|
+
import type * as Stream from "effect/Stream"
|
|
13
|
+
import * as Bcs from "@unconfirmed/effect-bcs/Bcs"
|
|
14
|
+
import { type Address, fromBytes, normalize, SUI_FRAMEWORK } from "./Address.ts"
|
|
15
|
+
import { blake2b256 } from "./Hash.ts"
|
|
16
|
+
import type { SuiObject } from "./Objects.ts"
|
|
17
|
+
import type { RpcError } from "./RpcError.ts"
|
|
18
|
+
import * as TypeTag from "./TypeTag.ts"
|
|
19
|
+
|
|
20
|
+
export interface Name {
|
|
21
|
+
/** The name's Move type, e.g. `u64`, `0x1::string::String`. */
|
|
22
|
+
readonly type: string
|
|
23
|
+
/** The name's BCS bytes. */
|
|
24
|
+
readonly bcs: Uint8Array
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A dynamic field read by name. */
|
|
28
|
+
export interface DynamicField {
|
|
29
|
+
readonly parent: Address
|
|
30
|
+
readonly fieldId: Address
|
|
31
|
+
readonly name: Name
|
|
32
|
+
/** The value's Move type. */
|
|
33
|
+
readonly valueType: string
|
|
34
|
+
/** The value's BCS bytes. */
|
|
35
|
+
readonly value: Uint8Array
|
|
36
|
+
/** The `0x2::dynamic_field::Field<Name, Value>` object itself. */
|
|
37
|
+
readonly field: SuiObject
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** One entry of a parent's listing. */
|
|
41
|
+
export interface FieldInfo {
|
|
42
|
+
/** `Field` for `0x2::dynamic_field`, `Object` for `0x2::dynamic_object_field`. */
|
|
43
|
+
readonly kind: "Field" | "Object"
|
|
44
|
+
readonly parent: Address
|
|
45
|
+
readonly fieldId: Address
|
|
46
|
+
/** For an object field, the name as added (not its `Wrapper`). */
|
|
47
|
+
readonly name: Name
|
|
48
|
+
/** For an object field, the child object's type. */
|
|
49
|
+
readonly valueType: string
|
|
50
|
+
/** The value's BCS bytes; for an object field, the child's id. */
|
|
51
|
+
readonly value: Uint8Array
|
|
52
|
+
/** The child object's id, for an object field. */
|
|
53
|
+
readonly childId: Address | undefined
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export class DynamicFieldNotFound extends /* @__PURE__ */ Schema.TaggedError<DynamicFieldNotFound>()("DynamicFieldNotFound", {
|
|
57
|
+
parent: Schema.String,
|
|
58
|
+
nameType: Schema.String,
|
|
59
|
+
fieldId: Schema.String
|
|
60
|
+
}) {
|
|
61
|
+
override get message(): string {
|
|
62
|
+
return `dynamic field ${this.fieldId} (${this.nameType}) of ${this.parent} not found`
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The name's type doesn't parse, or its value doesn't encode with the given schema. */
|
|
67
|
+
export class InvalidDynamicFieldName extends /* @__PURE__ */ Schema.TaggedError<InvalidDynamicFieldName>()("InvalidDynamicFieldName", {
|
|
68
|
+
nameType: Schema.String,
|
|
69
|
+
issue: Schema.String
|
|
70
|
+
}) {
|
|
71
|
+
override get message(): string {
|
|
72
|
+
return `invalid dynamic field name of type ${this.nameType}: ${this.issue}`
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export class DynamicFieldDecodeError extends /* @__PURE__ */ Schema.TaggedError<DynamicFieldDecodeError>()("DynamicFieldDecodeError", {
|
|
77
|
+
fieldId: Schema.String,
|
|
78
|
+
valueType: Schema.String,
|
|
79
|
+
issue: Schema.String
|
|
80
|
+
}) {
|
|
81
|
+
override get message(): string {
|
|
82
|
+
return `cannot decode dynamic field ${this.fieldId} as ${this.valueType}: ${this.issue}`
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// -----------------------------------------------------------------------------
|
|
87
|
+
// Pure
|
|
88
|
+
// -----------------------------------------------------------------------------
|
|
89
|
+
|
|
90
|
+
const encodeTypeTag = /* @__PURE__ */ Bcs.encodeSync(TypeTag.TypeTag)
|
|
91
|
+
const encodeU64 = /* @__PURE__ */ Bcs.encodeSync(Bcs.u64)
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A dynamic field's object id:
|
|
95
|
+
* `blake2b256(0xf0 || parent || u64(len(name)) || name || bcs(TypeTag))`.
|
|
96
|
+
* Throws on a malformed type string, like `TypeTag.parse`.
|
|
97
|
+
*/
|
|
98
|
+
export const deriveId = (parent: string, nameType: string | TypeTag.TypeTag, nameBcs: Uint8Array): Address => {
|
|
99
|
+
const tag = encodeTypeTag(typeof nameType === "string" ? TypeTag.parse(nameType) : nameType)
|
|
100
|
+
const parentBytes = Bcs.encodeSync(Bcs.Address)(normalize(parent))
|
|
101
|
+
const len = encodeU64(BigInt(nameBcs.length))
|
|
102
|
+
const input = new Uint8Array(1 + 32 + 8 + nameBcs.length + tag.length)
|
|
103
|
+
let o = 0
|
|
104
|
+
input[o++] = 0xf0
|
|
105
|
+
for (const part of [parentBytes, len, nameBcs, tag]) {
|
|
106
|
+
input.set(part, o)
|
|
107
|
+
o += part.length
|
|
108
|
+
}
|
|
109
|
+
return fromBytes(blake2b256(input))
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The id of an object created with `0x2::derived_object::claim(parent, key)`:
|
|
114
|
+
* the dynamic field id of `DerivedObjectKey<K>(key)` under `parent`, as
|
|
115
|
+
* `@mysten/sui`'s `deriveObjectID`. `keyBcs` is the key's BCS bytes (the
|
|
116
|
+
* wrapper adds none). Throws on a malformed key type, like `deriveId`.
|
|
117
|
+
*/
|
|
118
|
+
export const deriveObjectId = (parent: string, keyType: string | TypeTag.TypeTag, keyBcs: Uint8Array): Address =>
|
|
119
|
+
deriveId(parent, {
|
|
120
|
+
_tag: "struct",
|
|
121
|
+
address: SUI_FRAMEWORK,
|
|
122
|
+
module: "derived_object",
|
|
123
|
+
name: "DerivedObjectKey",
|
|
124
|
+
typeParams: [typeof keyType === "string" ? TypeTag.parse(keyType) : keyType]
|
|
125
|
+
}, keyBcs)
|
|
126
|
+
|
|
127
|
+
/** The name type a dynamic object field is stored under: `0x2::dynamic_object_field::Wrapper<T>`. */
|
|
128
|
+
export const objectFieldNameType = (nameType: string): string =>
|
|
129
|
+
`0x2::dynamic_object_field::Wrapper<${nameType}>`
|
|
130
|
+
|
|
131
|
+
/** Encode a name with its BCS schema. */
|
|
132
|
+
export const name = <T, E>(type: string, schema: Schema.Codec<T, E>, value: T): Result.Result<Name, InvalidDynamicFieldName> =>
|
|
133
|
+
Result.match(Bcs.encode(schema)(value), {
|
|
134
|
+
onSuccess: (bcs) => Result.succeed({ type, bcs }),
|
|
135
|
+
onFailure: (e) => Result.fail(new InvalidDynamicFieldName({ nameType: type, issue: e.message }))
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
/** Decode a field's value with a BCS schema. */
|
|
139
|
+
export const decodeValue = <T, E>(schema: Schema.Codec<T, E>) => {
|
|
140
|
+
const run = Bcs.decode(schema)
|
|
141
|
+
return (f: { readonly fieldId: Address; readonly valueType: string; readonly value: Uint8Array }): Effect.Effect<T, DynamicFieldDecodeError> =>
|
|
142
|
+
Result.match(run(f.value), {
|
|
143
|
+
onSuccess: Effect.succeed,
|
|
144
|
+
onFailure: (e) => Effect.fail(new DynamicFieldDecodeError({ fieldId: f.fieldId, valueType: f.valueType, issue: e.message }))
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// -----------------------------------------------------------------------------
|
|
149
|
+
// Service
|
|
150
|
+
// -----------------------------------------------------------------------------
|
|
151
|
+
|
|
152
|
+
export interface ListOptions {
|
|
153
|
+
/** Only fields whose name type matches (`0xaddr[::module[::Name[<T>]]]`, or an exact non-struct type). */
|
|
154
|
+
readonly nameType?: string
|
|
155
|
+
readonly pageSize?: number
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export class DynamicFields extends /* @__PURE__ */ Context.Service<DynamicFields, {
|
|
159
|
+
readonly get: (parent: Address, name: Name) => Effect.Effect<DynamicField, DynamicFieldNotFound | InvalidDynamicFieldName | RpcError>
|
|
160
|
+
/** The child object of a dynamic object field. */
|
|
161
|
+
readonly getObject: (parent: Address, name: Name) => Effect.Effect<SuiObject, DynamicFieldNotFound | InvalidDynamicFieldName | RpcError>
|
|
162
|
+
readonly list: (parent: Address, options?: ListOptions) => Stream.Stream<FieldInfo, RpcError>
|
|
163
|
+
}>()("@unconfirmed/effect-sui/DynamicFields") {}
|
|
164
|
+
|
|
165
|
+
const withName = <T, E, A, Err, R>(
|
|
166
|
+
type: string,
|
|
167
|
+
schema: Schema.Codec<T, E>,
|
|
168
|
+
value: T,
|
|
169
|
+
f: (n: Name) => Effect.Effect<A, Err, R>
|
|
170
|
+
): Effect.Effect<A, Err | InvalidDynamicFieldName, R> =>
|
|
171
|
+
Result.match(name(type, schema, value), { onSuccess: f, onFailure: Effect.fail })
|
|
172
|
+
|
|
173
|
+
/** `get` with the name given as a BCS schema and value: `getWith(parent, "u64", Bcs.u64, 7n)`. */
|
|
174
|
+
export const getWith = <T, E>(parent: Address, type: string, schema: Schema.Codec<T, E>, value: T) =>
|
|
175
|
+
Effect.flatMap(Effect.service(DynamicFields), (d) => withName(type, schema, value, (n) => d.get(parent, n)))
|
|
176
|
+
|
|
177
|
+
/** `getObject` with the name given as a BCS schema and value. */
|
|
178
|
+
export const getObjectWith = <T, E>(parent: Address, type: string, schema: Schema.Codec<T, E>, value: T) =>
|
|
179
|
+
Effect.flatMap(Effect.service(DynamicFields), (d) => withName(type, schema, value, (n) => d.getObject(parent, n)))
|
package/src/Ecdsa.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ECDSA schemes (Secp256k1, Secp256r1) over a curve passed in, so the
|
|
3
|
+
* core links no curve: `@unconfirmed/effect-sui/Secp256k1` and `-secp256r1` give
|
|
4
|
+
* their noble curve and flag. Signatures are ECDSA over
|
|
5
|
+
* `sha256(blake2b256(intentMessage))`, low-S, 64-byte compact `r || s`;
|
|
6
|
+
* public keys are 33-byte compressed points.
|
|
7
|
+
*/
|
|
8
|
+
import * as Effect from "effect/Effect"
|
|
9
|
+
import * as Result from "effect/Result"
|
|
10
|
+
import * as Address from "./Address.ts"
|
|
11
|
+
import * as Hash from "./Hash.ts"
|
|
12
|
+
import * as SignatureScheme from "./SignatureScheme.ts"
|
|
13
|
+
import * as Signer from "./Signer.ts"
|
|
14
|
+
|
|
15
|
+
/** What the scheme needs from a noble curve (`secp256k1`, `p256`). */
|
|
16
|
+
export interface Curve {
|
|
17
|
+
readonly verify: (signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array, options: { lowS: boolean; prehash: boolean }) => boolean
|
|
18
|
+
readonly sign: (message: Uint8Array, secretKey: Uint8Array, options: { lowS: boolean; prehash: boolean }) => Uint8Array
|
|
19
|
+
readonly getPublicKey: (secretKey: Uint8Array, compressed: boolean) => Uint8Array
|
|
20
|
+
readonly utils: { readonly randomSecretKey: () => Uint8Array }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface Ecdsa {
|
|
24
|
+
readonly scheme: SignatureScheme.SignatureScheme
|
|
25
|
+
/** A signer over a 32-byte secret key. */
|
|
26
|
+
readonly fromSecretKey: (secretKey: Uint8Array) => Effect.Effect<Signer.Signer, Signer.InvalidKey>
|
|
27
|
+
/** `fromSecretKey`, synchronously: a `Result` instead of an `Effect`. */
|
|
28
|
+
readonly fromSecretKeyResult: (secretKey: Uint8Array) => Result.Result<Signer.Signer, Signer.InvalidKey>
|
|
29
|
+
/** A fresh random 32-byte secret key, to keep or export (`PrivateKey.encode({ flag, secretKey })`). */
|
|
30
|
+
readonly generateSecretKey: Effect.Effect<Uint8Array>
|
|
31
|
+
/** A signer over a fresh random key. Use `generateSecretKey` to keep the key. */
|
|
32
|
+
readonly generate: Effect.Effect<Signer.Signer>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const SIG = 64
|
|
36
|
+
const PK = 33
|
|
37
|
+
// Explicit, not noble's defaults: Sui refuses high-S signatures, and the curve hashes with SHA-256.
|
|
38
|
+
const OPTIONS = { lowS: true, prehash: true }
|
|
39
|
+
|
|
40
|
+
export const make = (curve: Curve, flag: number, name: string): Ecdsa => {
|
|
41
|
+
const check = (publicKey: Uint8Array, signature: Uint8Array, intentMessage: Uint8Array) => {
|
|
42
|
+
let ok = false
|
|
43
|
+
try {
|
|
44
|
+
ok = curve.verify(signature, Hash.blake2b256(intentMessage), publicKey, OPTIONS)
|
|
45
|
+
} catch {
|
|
46
|
+
ok = false
|
|
47
|
+
}
|
|
48
|
+
return ok
|
|
49
|
+
? Effect.void
|
|
50
|
+
: Effect.fail(new SignatureScheme.InvalidSignature({ scheme: name, reason: "signature does not verify" }))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const scheme: SignatureScheme.SignatureScheme = {
|
|
54
|
+
name,
|
|
55
|
+
flag,
|
|
56
|
+
verify: (body, intentMessage) => {
|
|
57
|
+
if (body.length !== SIG + PK) {
|
|
58
|
+
return Effect.fail(
|
|
59
|
+
new SignatureScheme.InvalidSignature({ scheme: name, reason: `expected ${SIG + PK} bytes, got ${body.length}` })
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
const publicKey = body.subarray(SIG)
|
|
63
|
+
return Effect.as(check(publicKey, body.subarray(0, SIG), intentMessage), { flag, bytes: publicKey.slice() })
|
|
64
|
+
},
|
|
65
|
+
verifyMember: (publicKey, signature, intentMessage) => check(publicKey, signature, intentMessage)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const fromSecretKeyResult = (secretKey: Uint8Array): Result.Result<Signer.Signer, Signer.InvalidKey> => {
|
|
69
|
+
let pk: Uint8Array
|
|
70
|
+
try {
|
|
71
|
+
pk = curve.getPublicKey(secretKey, true)
|
|
72
|
+
} catch {
|
|
73
|
+
// A fixed reason: the curve library's message is not ours to vouch for (it must never carry key bytes).
|
|
74
|
+
return Result.fail(
|
|
75
|
+
new Signer.InvalidKey({ scheme: name, reason: "invalid secret key (expected 32 bytes, a non-zero scalar below the curve order)" })
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
const sk = secretKey.slice()
|
|
79
|
+
return Result.succeed({
|
|
80
|
+
address: Address.fromPublicKey(flag, pk),
|
|
81
|
+
publicKey: { flag, bytes: pk },
|
|
82
|
+
sign: (intentMessage) =>
|
|
83
|
+
Effect.sync(() => {
|
|
84
|
+
const sig = curve.sign(Hash.blake2b256(intentMessage), sk, OPTIONS)
|
|
85
|
+
const out = new Uint8Array(1 + SIG + PK)
|
|
86
|
+
out[0] = flag
|
|
87
|
+
out.set(sig, 1)
|
|
88
|
+
out.set(pk, 1 + SIG)
|
|
89
|
+
return out
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const fromSecretKey = (secretKey: Uint8Array) => Effect.fromResult(fromSecretKeyResult(secretKey))
|
|
95
|
+
const generateSecretKey = Effect.sync(() => curve.utils.randomSecretKey())
|
|
96
|
+
return {
|
|
97
|
+
scheme,
|
|
98
|
+
fromSecretKey,
|
|
99
|
+
fromSecretKeyResult,
|
|
100
|
+
generateSecretKey,
|
|
101
|
+
generate: Effect.flatMap(generateSecretKey, (sk) => Effect.orDie(fromSecretKey(sk)))
|
|
102
|
+
}
|
|
103
|
+
}
|
package/src/Ed25519.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ed25519: the default scheme, and the only one the core ships. It is still
|
|
3
|
+
* just a `SignatureScheme` value: nothing in the core special-cases it.
|
|
4
|
+
*/
|
|
5
|
+
import { ed25519 } from "@noble/curves/ed25519.js"
|
|
6
|
+
import * as Effect from "effect/Effect"
|
|
7
|
+
import * as Result from "effect/Result"
|
|
8
|
+
import * as Address from "./Address.ts"
|
|
9
|
+
import * as Hash from "./Hash.ts"
|
|
10
|
+
import { InvalidSignature, type SignatureScheme } from "./SignatureScheme.ts"
|
|
11
|
+
import { InvalidKey, type Signer } from "./Signer.ts"
|
|
12
|
+
|
|
13
|
+
export const FLAG = 0x00
|
|
14
|
+
const SIG = 64
|
|
15
|
+
const PK = 32
|
|
16
|
+
|
|
17
|
+
const check = (publicKey: Uint8Array, signature: Uint8Array, intentMessage: Uint8Array) => {
|
|
18
|
+
let ok = false
|
|
19
|
+
try {
|
|
20
|
+
ok = ed25519.verify(signature, Hash.blake2b256(intentMessage), publicKey)
|
|
21
|
+
} catch {
|
|
22
|
+
ok = false
|
|
23
|
+
}
|
|
24
|
+
return ok ? Effect.void : Effect.fail(new InvalidSignature({ scheme: "ED25519", reason: "signature does not verify" }))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const scheme: SignatureScheme = {
|
|
28
|
+
name: "ED25519",
|
|
29
|
+
flag: FLAG,
|
|
30
|
+
verify: (body, intentMessage) => {
|
|
31
|
+
if (body.length !== SIG + PK) {
|
|
32
|
+
return Effect.fail(new InvalidSignature({ scheme: "ED25519", reason: `expected ${SIG + PK} bytes, got ${body.length}` }))
|
|
33
|
+
}
|
|
34
|
+
const publicKey = body.subarray(SIG)
|
|
35
|
+
return Effect.as(check(publicKey, body.subarray(0, SIG), intentMessage), { flag: FLAG, bytes: publicKey.slice() })
|
|
36
|
+
},
|
|
37
|
+
verifyMember: (publicKey, signature, intentMessage) => check(publicKey, signature, intentMessage)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Whether `signature` is `publicKey`'s Ed25519 signature over `message` itself, not over an intent
|
|
42
|
+
* message: what Move's `sui::ed25519::ed25519_verify` checks (e.g. a Nautilus enclave's
|
|
43
|
+
* signatures). Malformed keys or signatures are `false`. Sui transactions and personal messages
|
|
44
|
+
* are verified through `scheme` instead.
|
|
45
|
+
*/
|
|
46
|
+
export const verifyRaw = (publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean => {
|
|
47
|
+
try {
|
|
48
|
+
return ed25519.verify(signature, message, publicKey)
|
|
49
|
+
} catch {
|
|
50
|
+
return false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** `fromSecretKey`, synchronously: a `Result` instead of an `Effect`. */
|
|
55
|
+
export const fromSecretKeyResult = (secretKey: Uint8Array): Result.Result<Signer, InvalidKey> => {
|
|
56
|
+
if (secretKey.length !== 32) {
|
|
57
|
+
return Result.fail(new InvalidKey({ scheme: "ED25519", reason: `expected 32 bytes, got ${secretKey.length}` }))
|
|
58
|
+
}
|
|
59
|
+
const sk = secretKey.slice()
|
|
60
|
+
const pk = ed25519.getPublicKey(sk)
|
|
61
|
+
return Result.succeed({
|
|
62
|
+
address: Address.fromPublicKey(FLAG, pk),
|
|
63
|
+
publicKey: { flag: FLAG, bytes: pk },
|
|
64
|
+
sign: (intentMessage) =>
|
|
65
|
+
Effect.sync(() => {
|
|
66
|
+
const sig = ed25519.sign(Hash.blake2b256(intentMessage), sk)
|
|
67
|
+
const out = new Uint8Array(1 + SIG + PK)
|
|
68
|
+
out[0] = FLAG
|
|
69
|
+
out.set(sig, 1)
|
|
70
|
+
out.set(pk, 1 + SIG)
|
|
71
|
+
return out
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** A signer over a 32-byte secret key (seed). */
|
|
77
|
+
export const fromSecretKey = (secretKey: Uint8Array): Effect.Effect<Signer, InvalidKey> =>
|
|
78
|
+
Effect.fromResult(fromSecretKeyResult(secretKey))
|
|
79
|
+
|
|
80
|
+
/** A fresh random 32-byte secret key, to keep or export (`PrivateKey.encode({ flag: FLAG, secretKey })`). */
|
|
81
|
+
export const generateSecretKey: Effect.Effect<Uint8Array> = /* @__PURE__ */ Effect.sync(() => crypto.getRandomValues(new Uint8Array(32)))
|
|
82
|
+
|
|
83
|
+
/** A signer over a fresh random key. Use `generateSecretKey` to keep the key. */
|
|
84
|
+
export const generate: Effect.Effect<Signer> = /* @__PURE__ */ Effect.flatMap(generateSecretKey, (sk) => Effect.orDie(fromSecretKey(sk)))
|
package/src/Events.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Move events: history as a `Stream` (`list`) and live (`subscribe`), with a
|
|
3
|
+
* closed filter algebra that every transport lowers to its own query form.
|
|
4
|
+
*/
|
|
5
|
+
import * as Context from "effect/Context"
|
|
6
|
+
import * as Effect from "effect/Effect"
|
|
7
|
+
import * as Result from "effect/Result"
|
|
8
|
+
import * as Schema from "effect/Schema"
|
|
9
|
+
import type * as Stream from "effect/Stream"
|
|
10
|
+
import * as Bcs from "@unconfirmed/effect-bcs/Bcs"
|
|
11
|
+
import type { Address } from "./Address.ts"
|
|
12
|
+
import type { RpcError } from "./RpcError.ts"
|
|
13
|
+
import * as TypeTag from "./TypeTag.ts"
|
|
14
|
+
|
|
15
|
+
export interface Event {
|
|
16
|
+
/** The event struct's full type, e.g. `0x2::coin::CoinCreated<0x2::sui::SUI>`. */
|
|
17
|
+
readonly type: string
|
|
18
|
+
readonly sender: Address
|
|
19
|
+
/** The package and module of the top-level Move call that emitted it. */
|
|
20
|
+
readonly packageId: Address
|
|
21
|
+
readonly module: string
|
|
22
|
+
/** The event struct's BCS bytes. */
|
|
23
|
+
readonly contents: Uint8Array
|
|
24
|
+
readonly transactionDigest: string
|
|
25
|
+
readonly checkpoint: bigint
|
|
26
|
+
/** Position of the emitting transaction within its checkpoint. */
|
|
27
|
+
readonly transactionIndex: bigint
|
|
28
|
+
/** Position of the event within its transaction's events (the event sequence number). */
|
|
29
|
+
readonly eventIndex: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* An event as its transaction reports it (`Transactions.get` / `execute` with
|
|
34
|
+
* `include: ["events"]`): an `Event` without the ledger position, which a
|
|
35
|
+
* transaction read by digest doesn't carry. Its checkpoint is on `Effects`.
|
|
36
|
+
*/
|
|
37
|
+
export type TransactionEvent = Omit<Event, "checkpoint" | "transactionIndex">
|
|
38
|
+
|
|
39
|
+
export class EventDecodeError extends /* @__PURE__ */ Schema.TaggedError<EventDecodeError>()("EventDecodeError", {
|
|
40
|
+
transactionDigest: Schema.String,
|
|
41
|
+
eventIndex: Schema.Number,
|
|
42
|
+
type: Schema.String,
|
|
43
|
+
issue: Schema.String
|
|
44
|
+
}) {
|
|
45
|
+
override get message(): string {
|
|
46
|
+
return `cannot decode event ${this.eventIndex} of ${this.transactionDigest} as ${this.type}: ${this.issue}`
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Decode an event's contents with a BCS schema. */
|
|
51
|
+
export const decode = <T, E>(schema: Schema.Codec<T, E>) => {
|
|
52
|
+
const run = Bcs.decode(schema)
|
|
53
|
+
return (e: TransactionEvent): Effect.Effect<T, EventDecodeError> =>
|
|
54
|
+
Result.match(run(e.contents), {
|
|
55
|
+
onSuccess: Effect.succeed,
|
|
56
|
+
onFailure: (x) =>
|
|
57
|
+
Effect.fail(
|
|
58
|
+
new EventDecodeError({ transactionDigest: e.transactionDigest, eventIndex: e.eventIndex, type: e.type, issue: x.message })
|
|
59
|
+
)
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// -----------------------------------------------------------------------------
|
|
64
|
+
// Filters
|
|
65
|
+
// -----------------------------------------------------------------------------
|
|
66
|
+
|
|
67
|
+
export type Predicate =
|
|
68
|
+
/** Every event of transactions sent by `address`. */
|
|
69
|
+
| { readonly _tag: "Sender"; readonly address: Address }
|
|
70
|
+
/** Events whose emitting Move call is in `0xpkg` or `0xpkg::module`. */
|
|
71
|
+
| { readonly _tag: "EmitModule"; readonly module: string }
|
|
72
|
+
/** Events whose type is at `0xaddr`, `0xaddr::module`, `0xaddr::module::Name` (any instantiation) or an exact `Name<T>`. */
|
|
73
|
+
| { readonly _tag: "EventType"; readonly type: string }
|
|
74
|
+
/** Events committed to an authenticated event stream. */
|
|
75
|
+
| { readonly _tag: "StreamHead"; readonly streamId: Address }
|
|
76
|
+
|
|
77
|
+
export interface Literal {
|
|
78
|
+
readonly _tag: "Literal"
|
|
79
|
+
readonly negated: boolean
|
|
80
|
+
readonly predicate: Predicate
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type EventFilter =
|
|
84
|
+
| Literal
|
|
85
|
+
| { readonly _tag: "All"; readonly filters: ReadonlyArray<EventFilter> }
|
|
86
|
+
| { readonly _tag: "Any"; readonly filters: ReadonlyArray<EventFilter> }
|
|
87
|
+
|
|
88
|
+
const lit = (predicate: Predicate): Literal => ({ _tag: "Literal", negated: false, predicate })
|
|
89
|
+
|
|
90
|
+
export const sender = (address: Address): Literal => lit({ _tag: "Sender", address })
|
|
91
|
+
export const emitModule = (module: string): Literal => lit({ _tag: "EmitModule", module: TypeTag.normalizePath(module) })
|
|
92
|
+
export const eventType = (type: string): Literal => lit({ _tag: "EventType", type: TypeTag.normalizePath(type) })
|
|
93
|
+
export const streamHead = (streamId: Address): Literal => lit({ _tag: "StreamHead", streamId })
|
|
94
|
+
/** Negation applies to single predicates, as in the node's index. */
|
|
95
|
+
export const not = (l: Literal): Literal => ({ ...l, negated: !l.negated })
|
|
96
|
+
export const all = (...filters: ReadonlyArray<EventFilter>): EventFilter => ({ _tag: "All", filters })
|
|
97
|
+
export const any = (...filters: ReadonlyArray<EventFilter>): EventFilter => ({ _tag: "Any", filters })
|
|
98
|
+
|
|
99
|
+
/** Disjunctive normal form: OR of ANDs of literals, the shape the indexes take. */
|
|
100
|
+
export const toDnf = (f: EventFilter): ReadonlyArray<ReadonlyArray<Literal>> => {
|
|
101
|
+
switch (f._tag) {
|
|
102
|
+
case "Literal":
|
|
103
|
+
return [[f]]
|
|
104
|
+
case "Any":
|
|
105
|
+
return f.filters.flatMap(toDnf)
|
|
106
|
+
case "All":
|
|
107
|
+
return f.filters.reduce<ReadonlyArray<ReadonlyArray<Literal>>>(
|
|
108
|
+
(acc, g) => acc.flatMap((term) => toDnf(g).map((t) => [...term, ...t])),
|
|
109
|
+
[[]]
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// -----------------------------------------------------------------------------
|
|
115
|
+
// Service
|
|
116
|
+
// -----------------------------------------------------------------------------
|
|
117
|
+
|
|
118
|
+
export interface ListOptions {
|
|
119
|
+
readonly filter?: EventFilter
|
|
120
|
+
/** First checkpoint, inclusive. Default: the oldest the node keeps (a descending scan ends there). */
|
|
121
|
+
readonly start?: bigint
|
|
122
|
+
/** Last checkpoint, exclusive. Default: the tip at the time of the call, pinned for the whole scan. */
|
|
123
|
+
readonly end?: bigint
|
|
124
|
+
/** Newest first. */
|
|
125
|
+
readonly descending?: boolean
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export class Events extends /* @__PURE__ */ Context.Service<Events, {
|
|
129
|
+
/** Matching events in ledger order, across as many requests as it takes. An empty `any()` matches nothing. */
|
|
130
|
+
readonly list: (options?: ListOptions) => Stream.Stream<Event, RpcError>
|
|
131
|
+
/** Matching events as they are emitted, from the node's current tip. Ends cleanly if the server closes the stream (resubscribe to continue); a cut-off stream fails. */
|
|
132
|
+
readonly subscribe: (filter?: EventFilter) => Stream.Stream<Event, RpcError>
|
|
133
|
+
}>()("@unconfirmed/effect-sui/Events") {}
|
package/src/Hash.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hashing and intent messages: what every signature scheme ultimately signs.
|
|
3
|
+
*/
|
|
4
|
+
import { blake2b } from "@noble/hashes/blake2.js"
|
|
5
|
+
import { base58 } from "@scure/base"
|
|
6
|
+
import * as Bcs from "@unconfirmed/effect-bcs/Bcs"
|
|
7
|
+
|
|
8
|
+
export const blake2b256 = (bytes: Uint8Array): Uint8Array => blake2b(bytes, { dkLen: 32 })
|
|
9
|
+
|
|
10
|
+
export const IntentScope = {
|
|
11
|
+
TransactionData: 0,
|
|
12
|
+
TransactionEffects: 1,
|
|
13
|
+
CheckpointSummary: 2,
|
|
14
|
+
PersonalMessage: 3
|
|
15
|
+
} as const
|
|
16
|
+
export type IntentScope = (typeof IntentScope)[keyof typeof IntentScope]
|
|
17
|
+
|
|
18
|
+
/** `[scope, version=0, appId=Sui(0)] || bytes`. */
|
|
19
|
+
export const intentMessage = (scope: IntentScope, bytes: Uint8Array): Uint8Array => {
|
|
20
|
+
const out = new Uint8Array(3 + bytes.length)
|
|
21
|
+
out[0] = scope
|
|
22
|
+
out.set(bytes, 3)
|
|
23
|
+
return out
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const transactionIntent = (txBytes: Uint8Array) => intentMessage(IntentScope.TransactionData, txBytes)
|
|
27
|
+
|
|
28
|
+
/** A personal message is signed as BCS `vector<u8>`, so it can never be mistaken for a transaction. */
|
|
29
|
+
export const personalMessageIntent = (message: Uint8Array) =>
|
|
30
|
+
intentMessage(IntentScope.PersonalMessage, Bcs.encodeSync(Bcs.byteVector)(message))
|
|
31
|
+
|
|
32
|
+
/** The transaction digest: `base58(blake2b256("TransactionData::" || bcs))`. */
|
|
33
|
+
export const transactionDigest = (txBytes: Uint8Array): string => {
|
|
34
|
+
const prefix = new TextEncoder().encode("TransactionData::")
|
|
35
|
+
const input = new Uint8Array(prefix.length + txBytes.length)
|
|
36
|
+
input.set(prefix)
|
|
37
|
+
input.set(txBytes, prefix.length)
|
|
38
|
+
return base58.encode(blake2b256(input))
|
|
39
|
+
}
|
package/src/MlDsa65.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ML-DSA-65 (FIPS 204, post-quantum) for `@unconfirmed/effect-sui`: a
|
|
3
|
+
* `SignatureScheme` to install in the registry, and signer constructors.
|
|
4
|
+
*
|
|
5
|
+
* As in Sui and `@mysten/sui`: flag `0x07`, 1952-byte public keys, 3309-byte
|
|
6
|
+
* signatures, pure ML-DSA-65 with an empty context over
|
|
7
|
+
* `blake2b256(intentMessage)`. The secret key is the 32-byte keygen seed (what
|
|
8
|
+
* `suiprivkey` stores). Signing is hedged: each signature mixes in fresh
|
|
9
|
+
* randomness, so signing twice gives two different valid signatures.
|
|
10
|
+
*
|
|
11
|
+
* SignatureSchemes.layer(Ed25519.scheme, MlDsa65.scheme)
|
|
12
|
+
* const signer = yield* MlDsa65.fromSecretKey(seed)
|
|
13
|
+
*/
|
|
14
|
+
import { ml_dsa65 } from "@noble/post-quantum/ml-dsa.js"
|
|
15
|
+
import * as Address from "./Address.ts"
|
|
16
|
+
import * as Hash from "./Hash.ts"
|
|
17
|
+
import * as SignatureScheme from "./SignatureScheme.ts"
|
|
18
|
+
import * as Signer from "./Signer.ts"
|
|
19
|
+
import * as Effect from "effect/Effect"
|
|
20
|
+
|
|
21
|
+
export const FLAG = 0x07
|
|
22
|
+
export const PUBLIC_KEY_SIZE = 1952
|
|
23
|
+
export const SIGNATURE_SIZE = 3309
|
|
24
|
+
export const SECRET_KEY_SIZE = 32
|
|
25
|
+
const NAME = "MLDSA65"
|
|
26
|
+
|
|
27
|
+
const check = (publicKey: Uint8Array, signature: Uint8Array, intentMessage: Uint8Array) => {
|
|
28
|
+
let ok = false
|
|
29
|
+
if (publicKey.length === PUBLIC_KEY_SIZE && signature.length === SIGNATURE_SIZE) {
|
|
30
|
+
try {
|
|
31
|
+
ok = ml_dsa65.verify(signature, Hash.blake2b256(intentMessage), publicKey)
|
|
32
|
+
} catch {
|
|
33
|
+
ok = false
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return ok
|
|
37
|
+
? Effect.void
|
|
38
|
+
: Effect.fail(new SignatureScheme.InvalidSignature({ scheme: NAME, reason: "signature does not verify" }))
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const scheme: SignatureScheme.SignatureScheme = {
|
|
42
|
+
name: NAME,
|
|
43
|
+
flag: FLAG,
|
|
44
|
+
verify: (body, intentMessage) => {
|
|
45
|
+
if (body.length !== SIGNATURE_SIZE + PUBLIC_KEY_SIZE) {
|
|
46
|
+
return Effect.fail(
|
|
47
|
+
new SignatureScheme.InvalidSignature({
|
|
48
|
+
scheme: NAME,
|
|
49
|
+
reason: `expected ${SIGNATURE_SIZE + PUBLIC_KEY_SIZE} bytes, got ${body.length}`
|
|
50
|
+
})
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
const publicKey = body.subarray(SIGNATURE_SIZE)
|
|
54
|
+
return Effect.as(check(publicKey, body.subarray(0, SIGNATURE_SIZE), intentMessage), {
|
|
55
|
+
flag: FLAG,
|
|
56
|
+
bytes: publicKey.slice()
|
|
57
|
+
})
|
|
58
|
+
},
|
|
59
|
+
verifyMember: (publicKey, signature, intentMessage) => check(publicKey, signature, intentMessage)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A signer over a 32-byte secret key (the FIPS 204 keygen seed). */
|
|
63
|
+
export const fromSecretKey = (secretKey: Uint8Array): Effect.Effect<Signer.Signer, Signer.InvalidKey> => {
|
|
64
|
+
if (secretKey.length !== SECRET_KEY_SIZE) {
|
|
65
|
+
return Effect.fail(new Signer.InvalidKey({ scheme: NAME, reason: `expected a ${SECRET_KEY_SIZE}-byte seed, got ${secretKey.length}` }))
|
|
66
|
+
}
|
|
67
|
+
return Effect.sync(() => {
|
|
68
|
+
const { publicKey: pk, secretKey: expanded } = ml_dsa65.keygen(secretKey.slice())
|
|
69
|
+
return {
|
|
70
|
+
address: Address.fromPublicKey(FLAG, pk),
|
|
71
|
+
publicKey: { flag: FLAG, bytes: pk },
|
|
72
|
+
sign: (intentMessage) =>
|
|
73
|
+
Effect.sync(() => {
|
|
74
|
+
const sig = ml_dsa65.sign(Hash.blake2b256(intentMessage), expanded)
|
|
75
|
+
const out = new Uint8Array(1 + SIGNATURE_SIZE + PUBLIC_KEY_SIZE)
|
|
76
|
+
out[0] = FLAG
|
|
77
|
+
out.set(sig, 1)
|
|
78
|
+
out.set(pk, 1 + SIGNATURE_SIZE)
|
|
79
|
+
return out
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** For ML-DSA-65 the seed is the secret key: same as `fromSecretKey`. */
|
|
86
|
+
export const fromSeed = fromSecretKey
|
|
87
|
+
|
|
88
|
+
/** A fresh random 32-byte secret key, to keep or export (`PrivateKey.encode({ flag: FLAG, secretKey })`). */
|
|
89
|
+
export const generateSecretKey: Effect.Effect<Uint8Array> = Effect.sync(() => crypto.getRandomValues(new Uint8Array(SECRET_KEY_SIZE)))
|
|
90
|
+
|
|
91
|
+
/** A signer over a fresh random key. Use `generateSecretKey` to keep the key. */
|
|
92
|
+
export const generate: Effect.Effect<Signer.Signer> = Effect.flatMap(generateSecretKey, (sk) => Effect.orDie(fromSecretKey(sk)))
|