@bsv/sdk 2.1.0 → 2.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/README.md +7 -7
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/auth/Peer.js +8 -13
- package/dist/cjs/src/auth/Peer.js.map +1 -1
- package/dist/cjs/src/auth/SessionManager.js +4 -7
- package/dist/cjs/src/auth/SessionManager.js.map +1 -1
- package/dist/cjs/src/auth/certificates/MasterCertificate.js +1 -1
- package/dist/cjs/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js +1 -1
- package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
- package/dist/cjs/src/auth/clients/AuthFetch.js +32 -32
- package/dist/cjs/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js +4 -4
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/cjs/src/compat/ECIES.js +29 -34
- package/dist/cjs/src/compat/ECIES.js.map +1 -1
- package/dist/cjs/src/compat/HD.js +9 -4
- package/dist/cjs/src/compat/HD.js.map +1 -1
- package/dist/cjs/src/compat/Mnemonic.js +12 -12
- package/dist/cjs/src/compat/Mnemonic.js.map +1 -1
- package/dist/cjs/src/identity/ContactsManager.js +172 -232
- package/dist/cjs/src/identity/ContactsManager.js.map +1 -1
- package/dist/cjs/src/identity/IdentityClient.js +122 -55
- package/dist/cjs/src/identity/IdentityClient.js.map +1 -1
- package/dist/cjs/src/kvstore/GlobalKVStore.js +30 -31
- package/dist/cjs/src/kvstore/GlobalKVStore.js.map +1 -1
- package/dist/cjs/src/kvstore/LocalKVStore.js +9 -9
- package/dist/cjs/src/kvstore/LocalKVStore.js.map +1 -1
- package/dist/cjs/src/kvstore/kvStoreInterpreter.js +2 -2
- package/dist/cjs/src/kvstore/kvStoreInterpreter.js.map +1 -1
- package/dist/cjs/src/messages/SignedMessage.js +1 -1
- package/dist/cjs/src/messages/SignedMessage.js.map +1 -1
- package/dist/cjs/src/overlay-tools/Historian.js +1 -1
- package/dist/cjs/src/overlay-tools/Historian.js.map +1 -1
- package/dist/cjs/src/overlay-tools/LookupResolver.js +139 -46
- package/dist/cjs/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/cjs/src/overlay-tools/SHIPBroadcaster.js +75 -146
- package/dist/cjs/src/overlay-tools/SHIPBroadcaster.js.map +1 -1
- package/dist/cjs/src/primitives/AESGCM.js +2 -2
- package/dist/cjs/src/primitives/AESGCM.js.map +1 -1
- package/dist/cjs/src/primitives/BigNumber.js +164 -148
- package/dist/cjs/src/primitives/BigNumber.js.map +1 -1
- package/dist/cjs/src/primitives/Curve.js +17 -15
- package/dist/cjs/src/primitives/Curve.js.map +1 -1
- package/dist/cjs/src/primitives/ECDSA.js +12 -7
- package/dist/cjs/src/primitives/ECDSA.js.map +1 -1
- package/dist/cjs/src/primitives/Hash.js +140 -56
- package/dist/cjs/src/primitives/Hash.js.map +1 -1
- package/dist/cjs/src/primitives/JacobianPoint.js +8 -8
- package/dist/cjs/src/primitives/JacobianPoint.js.map +1 -1
- package/dist/cjs/src/primitives/K256.js +3 -3
- package/dist/cjs/src/primitives/K256.js.map +1 -1
- package/dist/cjs/src/primitives/Point.js +36 -40
- package/dist/cjs/src/primitives/Point.js.map +1 -1
- package/dist/cjs/src/primitives/PrivateKey.js +4 -4
- package/dist/cjs/src/primitives/PrivateKey.js.map +1 -1
- package/dist/cjs/src/primitives/PublicKey.js +4 -4
- package/dist/cjs/src/primitives/PublicKey.js.map +1 -1
- package/dist/cjs/src/primitives/Random.js +10 -14
- package/dist/cjs/src/primitives/Random.js.map +1 -1
- package/dist/cjs/src/primitives/ReaderUint8Array.js +6 -6
- package/dist/cjs/src/primitives/ReaderUint8Array.js.map +1 -1
- package/dist/cjs/src/primitives/Schnorr.js +2 -2
- package/dist/cjs/src/primitives/Schnorr.js.map +1 -1
- package/dist/cjs/src/primitives/Secp256r1.js +2 -1
- package/dist/cjs/src/primitives/Secp256r1.js.map +1 -1
- package/dist/cjs/src/primitives/Signature.js +8 -8
- package/dist/cjs/src/primitives/Signature.js.map +1 -1
- package/dist/cjs/src/primitives/TransactionSignature.js +20 -21
- package/dist/cjs/src/primitives/TransactionSignature.js.map +1 -1
- package/dist/cjs/src/primitives/utils.js +39 -46
- package/dist/cjs/src/primitives/utils.js.map +1 -1
- package/dist/cjs/src/registry/RegistryClient.js +31 -23
- package/dist/cjs/src/registry/RegistryClient.js.map +1 -1
- package/dist/cjs/src/remittance/RemittanceManager.js +19 -18
- package/dist/cjs/src/remittance/RemittanceManager.js.map +1 -1
- package/dist/cjs/src/remittance/modules/BasicBRC29.js.map +1 -1
- package/dist/cjs/src/script/Script.js +93 -170
- package/dist/cjs/src/script/Script.js.map +1 -1
- package/dist/cjs/src/script/ScriptEvaluationError.js +2 -2
- package/dist/cjs/src/script/ScriptEvaluationError.js.map +1 -1
- package/dist/cjs/src/script/Spend.js +14 -12
- package/dist/cjs/src/script/Spend.js.map +1 -1
- package/dist/cjs/src/script/templates/PushDrop.js +22 -18
- package/dist/cjs/src/script/templates/PushDrop.js.map +1 -1
- package/dist/cjs/src/script/templates/RPuzzle.js +2 -4
- package/dist/cjs/src/script/templates/RPuzzle.js.map +1 -1
- package/dist/cjs/src/storage/StorageDownloader.js +42 -9
- package/dist/cjs/src/storage/StorageDownloader.js.map +1 -1
- package/dist/cjs/src/totp/totp.js +1 -1
- package/dist/cjs/src/totp/totp.js.map +1 -1
- package/dist/cjs/src/transaction/Beef.js +239 -192
- package/dist/cjs/src/transaction/Beef.js.map +1 -1
- package/dist/cjs/src/transaction/BeefConstants.js +19 -0
- package/dist/cjs/src/transaction/BeefConstants.js.map +1 -0
- package/dist/cjs/src/transaction/BeefTx.js +12 -12
- package/dist/cjs/src/transaction/BeefTx.js.map +1 -1
- package/dist/cjs/src/transaction/MerklePath.js +4 -4
- package/dist/cjs/src/transaction/MerklePath.js.map +1 -1
- package/dist/cjs/src/transaction/Transaction.js +49 -52
- package/dist/cjs/src/transaction/Transaction.js.map +1 -1
- package/dist/cjs/src/transaction/fee-models/SatoshisPerKilobyte.js +1 -1
- package/dist/cjs/src/transaction/fee-models/SatoshisPerKilobyte.js.map +1 -1
- package/dist/cjs/src/transaction/http/BinaryFetchClient.js +9 -9
- package/dist/cjs/src/transaction/http/BinaryFetchClient.js.map +1 -1
- package/dist/cjs/src/transaction/http/DefaultHttpClient.js +9 -9
- package/dist/cjs/src/transaction/http/DefaultHttpClient.js.map +1 -1
- package/dist/cjs/src/wallet/CachedKeyDeriver.js +1 -1
- package/dist/cjs/src/wallet/CachedKeyDeriver.js.map +1 -1
- package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
- package/dist/cjs/src/wallet/WalletError.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js +5 -4
- package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/ReactNativeWebView.js +9 -9
- package/dist/cjs/src/wallet/substrates/ReactNativeWebView.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +92 -92
- package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js +387 -711
- package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/XDM.js +4 -4
- package/dist/cjs/src/wallet/substrates/XDM.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/window.CWI.js +2 -2
- package/dist/cjs/src/wallet/substrates/window.CWI.js.map +1 -1
- package/dist/cjs/src/wallet/validationHelpers.js +9 -9
- package/dist/cjs/src/wallet/validationHelpers.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/auth/Peer.js +25 -13
- package/dist/esm/src/auth/Peer.js.map +1 -1
- package/dist/esm/src/auth/SessionManager.js +4 -7
- package/dist/esm/src/auth/SessionManager.js.map +1 -1
- package/dist/esm/src/auth/certificates/MasterCertificate.js +1 -1
- package/dist/esm/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js +1 -1
- package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
- package/dist/esm/src/auth/clients/AuthFetch.js +32 -32
- package/dist/esm/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js +4 -4
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/esm/src/compat/ECIES.js +29 -34
- package/dist/esm/src/compat/ECIES.js.map +1 -1
- package/dist/esm/src/compat/HD.js +9 -4
- package/dist/esm/src/compat/HD.js.map +1 -1
- package/dist/esm/src/compat/Mnemonic.js +12 -12
- package/dist/esm/src/compat/Mnemonic.js.map +1 -1
- package/dist/esm/src/identity/ContactsManager.js +172 -232
- package/dist/esm/src/identity/ContactsManager.js.map +1 -1
- package/dist/esm/src/identity/IdentityClient.js +122 -55
- package/dist/esm/src/identity/IdentityClient.js.map +1 -1
- package/dist/esm/src/kvstore/GlobalKVStore.js +30 -31
- package/dist/esm/src/kvstore/GlobalKVStore.js.map +1 -1
- package/dist/esm/src/kvstore/LocalKVStore.js +9 -9
- package/dist/esm/src/kvstore/LocalKVStore.js.map +1 -1
- package/dist/esm/src/kvstore/kvStoreInterpreter.js +2 -2
- package/dist/esm/src/kvstore/kvStoreInterpreter.js.map +1 -1
- package/dist/esm/src/messages/SignedMessage.js +1 -1
- package/dist/esm/src/messages/SignedMessage.js.map +1 -1
- package/dist/esm/src/overlay-tools/Historian.js +1 -1
- package/dist/esm/src/overlay-tools/Historian.js.map +1 -1
- package/dist/esm/src/overlay-tools/LookupResolver.js +139 -46
- package/dist/esm/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/esm/src/overlay-tools/SHIPBroadcaster.js +74 -146
- package/dist/esm/src/overlay-tools/SHIPBroadcaster.js.map +1 -1
- package/dist/esm/src/primitives/AESGCM.js +2 -2
- package/dist/esm/src/primitives/AESGCM.js.map +1 -1
- package/dist/esm/src/primitives/BigNumber.js +167 -154
- package/dist/esm/src/primitives/BigNumber.js.map +1 -1
- package/dist/esm/src/primitives/Curve.js +17 -15
- package/dist/esm/src/primitives/Curve.js.map +1 -1
- package/dist/esm/src/primitives/ECDSA.js +12 -7
- package/dist/esm/src/primitives/ECDSA.js.map +1 -1
- package/dist/esm/src/primitives/Hash.js +140 -56
- package/dist/esm/src/primitives/Hash.js.map +1 -1
- package/dist/esm/src/primitives/JacobianPoint.js +8 -8
- package/dist/esm/src/primitives/JacobianPoint.js.map +1 -1
- package/dist/esm/src/primitives/K256.js +3 -3
- package/dist/esm/src/primitives/K256.js.map +1 -1
- package/dist/esm/src/primitives/Point.js +36 -40
- package/dist/esm/src/primitives/Point.js.map +1 -1
- package/dist/esm/src/primitives/PrivateKey.js +4 -4
- package/dist/esm/src/primitives/PrivateKey.js.map +1 -1
- package/dist/esm/src/primitives/PublicKey.js +4 -4
- package/dist/esm/src/primitives/PublicKey.js.map +1 -1
- package/dist/esm/src/primitives/Random.js +10 -14
- package/dist/esm/src/primitives/Random.js.map +1 -1
- package/dist/esm/src/primitives/ReaderUint8Array.js +6 -6
- package/dist/esm/src/primitives/ReaderUint8Array.js.map +1 -1
- package/dist/esm/src/primitives/Schnorr.js +1 -1
- package/dist/esm/src/primitives/Schnorr.js.map +1 -1
- package/dist/esm/src/primitives/Secp256r1.js +2 -1
- package/dist/esm/src/primitives/Secp256r1.js.map +1 -1
- package/dist/esm/src/primitives/Signature.js +8 -8
- package/dist/esm/src/primitives/Signature.js.map +1 -1
- package/dist/esm/src/primitives/TransactionSignature.js +20 -21
- package/dist/esm/src/primitives/TransactionSignature.js.map +1 -1
- package/dist/esm/src/primitives/utils.js +39 -48
- package/dist/esm/src/primitives/utils.js.map +1 -1
- package/dist/esm/src/registry/RegistryClient.js +31 -23
- package/dist/esm/src/registry/RegistryClient.js.map +1 -1
- package/dist/esm/src/remittance/RemittanceManager.js +19 -18
- package/dist/esm/src/remittance/RemittanceManager.js.map +1 -1
- package/dist/esm/src/remittance/modules/BasicBRC29.js.map +1 -1
- package/dist/esm/src/script/Script.js +93 -170
- package/dist/esm/src/script/Script.js.map +1 -1
- package/dist/esm/src/script/ScriptEvaluationError.js +2 -2
- package/dist/esm/src/script/ScriptEvaluationError.js.map +1 -1
- package/dist/esm/src/script/Spend.js +14 -12
- package/dist/esm/src/script/Spend.js.map +1 -1
- package/dist/esm/src/script/templates/PushDrop.js +4 -3
- package/dist/esm/src/script/templates/PushDrop.js.map +1 -1
- package/dist/esm/src/script/templates/RPuzzle.js +2 -4
- package/dist/esm/src/script/templates/RPuzzle.js.map +1 -1
- package/dist/esm/src/storage/StorageDownloader.js +1 -1
- package/dist/esm/src/storage/StorageDownloader.js.map +1 -1
- package/dist/esm/src/totp/totp.js +1 -1
- package/dist/esm/src/totp/totp.js.map +1 -1
- package/dist/esm/src/transaction/Beef.js +229 -186
- package/dist/esm/src/transaction/Beef.js.map +1 -1
- package/dist/esm/src/transaction/BeefConstants.js +16 -0
- package/dist/esm/src/transaction/BeefConstants.js.map +1 -0
- package/dist/esm/src/transaction/BeefTx.js +3 -3
- package/dist/esm/src/transaction/BeefTx.js.map +1 -1
- package/dist/esm/src/transaction/MerklePath.js +4 -4
- package/dist/esm/src/transaction/MerklePath.js.map +1 -1
- package/dist/esm/src/transaction/Transaction.js +49 -52
- package/dist/esm/src/transaction/Transaction.js.map +1 -1
- package/dist/esm/src/transaction/fee-models/SatoshisPerKilobyte.js +1 -1
- package/dist/esm/src/transaction/fee-models/SatoshisPerKilobyte.js.map +1 -1
- package/dist/esm/src/transaction/http/BinaryFetchClient.js +9 -9
- package/dist/esm/src/transaction/http/BinaryFetchClient.js.map +1 -1
- package/dist/esm/src/transaction/http/DefaultHttpClient.js +9 -9
- package/dist/esm/src/transaction/http/DefaultHttpClient.js.map +1 -1
- package/dist/esm/src/wallet/CachedKeyDeriver.js +1 -1
- package/dist/esm/src/wallet/CachedKeyDeriver.js.map +1 -1
- package/dist/esm/src/wallet/WalletClient.js.map +1 -1
- package/dist/esm/src/wallet/WalletError.js.map +1 -1
- package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js +5 -4
- package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
- package/dist/esm/src/wallet/substrates/ReactNativeWebView.js +9 -9
- package/dist/esm/src/wallet/substrates/ReactNativeWebView.js.map +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +92 -92
- package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js +387 -711
- package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
- package/dist/esm/src/wallet/substrates/XDM.js +4 -4
- package/dist/esm/src/wallet/substrates/XDM.js.map +1 -1
- package/dist/esm/src/wallet/substrates/window.CWI.js +2 -2
- package/dist/esm/src/wallet/substrates/window.CWI.js.map +1 -1
- package/dist/esm/src/wallet/validationHelpers.js +9 -9
- package/dist/esm/src/wallet/validationHelpers.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/auth/Peer.d.ts +13 -0
- package/dist/types/src/auth/Peer.d.ts.map +1 -1
- package/dist/types/src/auth/SessionManager.d.ts.map +1 -1
- package/dist/types/src/auth/clients/AuthFetch.d.ts.map +1 -1
- package/dist/types/src/compat/ECIES.d.ts.map +1 -1
- package/dist/types/src/compat/HD.d.ts.map +1 -1
- package/dist/types/src/identity/ContactsManager.d.ts +18 -0
- package/dist/types/src/identity/ContactsManager.d.ts.map +1 -1
- package/dist/types/src/identity/IdentityClient.d.ts +47 -8
- package/dist/types/src/identity/IdentityClient.d.ts.map +1 -1
- package/dist/types/src/kvstore/GlobalKVStore.d.ts.map +1 -1
- package/dist/types/src/overlay-tools/LookupResolver.d.ts +59 -1
- package/dist/types/src/overlay-tools/LookupResolver.d.ts.map +1 -1
- package/dist/types/src/overlay-tools/SHIPBroadcaster.d.ts +18 -3
- package/dist/types/src/overlay-tools/SHIPBroadcaster.d.ts.map +1 -1
- package/dist/types/src/primitives/BigNumber.d.ts +13 -3
- package/dist/types/src/primitives/BigNumber.d.ts.map +1 -1
- package/dist/types/src/primitives/Curve.d.ts.map +1 -1
- package/dist/types/src/primitives/ECDSA.d.ts.map +1 -1
- package/dist/types/src/primitives/Hash.d.ts +3 -3
- package/dist/types/src/primitives/Hash.d.ts.map +1 -1
- package/dist/types/src/primitives/JacobianPoint.d.ts +3 -1
- package/dist/types/src/primitives/JacobianPoint.d.ts.map +1 -1
- package/dist/types/src/primitives/Point.d.ts.map +1 -1
- package/dist/types/src/primitives/Random.d.ts +2 -2
- package/dist/types/src/primitives/Random.d.ts.map +1 -1
- package/dist/types/src/primitives/ReaderUint8Array.d.ts.map +1 -1
- package/dist/types/src/primitives/Schnorr.d.ts +2 -1
- package/dist/types/src/primitives/Schnorr.d.ts.map +1 -1
- package/dist/types/src/primitives/Secp256r1.d.ts.map +1 -1
- package/dist/types/src/primitives/utils.d.ts +2 -4
- package/dist/types/src/primitives/utils.d.ts.map +1 -1
- package/dist/types/src/registry/RegistryClient.d.ts.map +1 -1
- package/dist/types/src/remittance/RemittanceManager.d.ts.map +1 -1
- package/dist/types/src/remittance/modules/BasicBRC29.d.ts.map +1 -1
- package/dist/types/src/script/Script.d.ts +15 -8
- package/dist/types/src/script/Script.d.ts.map +1 -1
- package/dist/types/src/script/Spend.d.ts.map +1 -1
- package/dist/types/src/script/templates/PushDrop.d.ts +3 -1
- package/dist/types/src/script/templates/PushDrop.d.ts.map +1 -1
- package/dist/types/src/script/templates/RPuzzle.d.ts.map +1 -1
- package/dist/types/src/transaction/Beef.d.ts +46 -8
- package/dist/types/src/transaction/Beef.d.ts.map +1 -1
- package/dist/types/src/transaction/BeefConstants.d.ts +15 -0
- package/dist/types/src/transaction/BeefConstants.d.ts.map +1 -0
- package/dist/types/src/transaction/Transaction.d.ts.map +1 -1
- package/dist/types/src/wallet/CachedKeyDeriver.d.ts.map +1 -1
- package/dist/types/src/wallet/KeyDeriver.d.ts +1 -1
- package/dist/types/src/wallet/KeyDeriver.d.ts.map +1 -1
- package/dist/types/src/wallet/Wallet.interfaces.d.ts +2 -2
- package/dist/types/src/wallet/Wallet.interfaces.d.ts.map +1 -1
- package/dist/types/src/wallet/WalletClient.d.ts +7 -7
- package/dist/types/src/wallet/WalletClient.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts +7 -7
- package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/WalletWireTransceiver.d.ts +36 -7
- package/dist/types/src/wallet/substrates/WalletWireTransceiver.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/window.CWI.d.ts +8 -8
- package/dist/types/src/wallet/substrates/window.CWI.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +3 -3
- package/package.json +1 -1
- package/src/auth/Peer.ts +26 -13
- package/src/auth/SessionManager.ts +4 -7
- package/src/auth/certificates/MasterCertificate.ts +1 -1
- package/src/auth/certificates/__tests/CompletedProtoWallet.ts +1 -1
- package/src/auth/clients/AuthFetch.ts +41 -41
- package/src/auth/transports/SimplifiedFetchTransport.ts +4 -4
- package/src/compat/ECIES.ts +29 -34
- package/src/compat/HD.ts +10 -5
- package/src/compat/Mnemonic.ts +11 -11
- package/src/compat/__tests/HD.test.ts +19 -0
- package/src/identity/ContactsManager.ts +194 -257
- package/src/identity/IdentityClient.ts +155 -66
- package/src/identity/__tests/IdentityClient.test.ts +25 -1
- package/src/kvstore/GlobalKVStore.ts +31 -32
- package/src/kvstore/LocalKVStore.ts +8 -8
- package/src/kvstore/kvStoreInterpreter.ts +2 -2
- package/src/messages/SignedMessage.ts +1 -1
- package/src/overlay-tools/Historian.ts +1 -1
- package/src/overlay-tools/LookupResolver.ts +182 -45
- package/src/overlay-tools/SHIPBroadcaster.ts +92 -168
- package/src/primitives/AESGCM.ts +2 -2
- package/src/primitives/BigNumber.ts +122 -113
- package/src/primitives/Curve.ts +16 -15
- package/src/primitives/ECDSA.ts +10 -8
- package/src/primitives/Hash.ts +152 -53
- package/src/primitives/JacobianPoint.ts +13 -11
- package/src/primitives/K256.ts +3 -3
- package/src/primitives/Point.ts +35 -38
- package/src/primitives/PrivateKey.ts +3 -3
- package/src/primitives/PublicKey.ts +3 -3
- package/src/primitives/Random.ts +11 -14
- package/src/primitives/ReaderUint8Array.ts +7 -7
- package/src/primitives/Schnorr.ts +2 -1
- package/src/primitives/Secp256r1.ts +2 -1
- package/src/primitives/Signature.ts +8 -8
- package/src/primitives/TransactionSignature.ts +16 -16
- package/src/primitives/utils.ts +37 -47
- package/src/registry/RegistryClient.ts +25 -25
- package/src/remittance/RemittanceManager.ts +17 -18
- package/src/remittance/modules/BasicBRC29.ts +2 -5
- package/src/script/Script.ts +114 -170
- package/src/script/ScriptEvaluationError.ts +2 -2
- package/src/script/Spend.ts +14 -15
- package/src/script/templates/PushDrop.ts +5 -3
- package/src/script/templates/RPuzzle.ts +2 -4
- package/src/storage/StorageDownloader.ts +1 -1
- package/src/totp/totp.ts +1 -1
- package/src/transaction/Beef.ts +241 -203
- package/src/transaction/BeefConstants.ts +16 -0
- package/src/transaction/BeefTx.ts +3 -3
- package/src/transaction/MerklePath.ts +4 -4
- package/src/transaction/Transaction.ts +48 -51
- package/src/transaction/fee-models/SatoshisPerKilobyte.ts +1 -1
- package/src/transaction/http/BinaryFetchClient.ts +8 -8
- package/src/transaction/http/DefaultHttpClient.ts +8 -8
- package/src/wallet/CachedKeyDeriver.ts +8 -6
- package/src/wallet/KeyDeriver.ts +1 -1
- package/src/wallet/Wallet.interfaces.ts +2 -4
- package/src/wallet/WalletClient.ts +8 -8
- package/src/wallet/WalletError.ts +1 -1
- package/src/wallet/__tests/WalletClient.substrate.test.ts +10 -6
- package/src/wallet/substrates/HTTPWalletJSON.ts +22 -21
- package/src/wallet/substrates/ReactNativeWebView.ts +9 -9
- package/src/wallet/substrates/WalletWireProcessor.ts +83 -83
- package/src/wallet/substrates/WalletWireTransceiver.ts +528 -938
- package/src/wallet/substrates/XDM.ts +4 -4
- package/src/wallet/substrates/__tests/HTTPWalletJSON.test.ts +38 -25
- package/src/wallet/substrates/__tests/ReactNativeWebView.test.ts +174 -0
- package/src/wallet/substrates/__tests/window.CWI.test.ts +256 -0
- package/src/wallet/substrates/window.CWI.ts +10 -10
- package/src/wallet/validationHelpers.ts +9 -9
package/src/primitives/Hash.ts
CHANGED
|
@@ -223,6 +223,68 @@ function isSurrogatePair (msg: string, i: number): boolean {
|
|
|
223
223
|
return (msg.charCodeAt(i + 1) & 0xfc00) === 0xdc00
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Encode a single UTF-16 code unit (and possibly its surrogate partner)
|
|
228
|
+
* into UTF-8 bytes, appending them to `out`.
|
|
229
|
+
*
|
|
230
|
+
* Returns the index of the last consumed code unit so the caller can
|
|
231
|
+
* advance its loop variable when a surrogate pair is consumed.
|
|
232
|
+
*
|
|
233
|
+
* Inspired by stringToUtf8ByteArray() in closure-library by Google
|
|
234
|
+
* https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt#L117-L143
|
|
235
|
+
* Apache License 2.0
|
|
236
|
+
* https://github.com/google/closure-library/blob/master/LICENSE
|
|
237
|
+
*/
|
|
238
|
+
function appendUtf8CodeUnit (msg: string, i: number, out: number[]): number {
|
|
239
|
+
let c = msg.charCodeAt(i)
|
|
240
|
+
if (c < 128) {
|
|
241
|
+
out.push(c)
|
|
242
|
+
return i
|
|
243
|
+
}
|
|
244
|
+
if (c < 2048) {
|
|
245
|
+
out.push((c >> 6) | 192, (c & 63) | 128)
|
|
246
|
+
return i
|
|
247
|
+
}
|
|
248
|
+
if (isSurrogatePair(msg, i)) {
|
|
249
|
+
c = 0x10000 + ((c & 0x03ff) << 10) + (msg.charCodeAt(i + 1) & 0x03ff)
|
|
250
|
+
out.push(
|
|
251
|
+
(c >> 18) | 240,
|
|
252
|
+
((c >> 12) & 63) | 128,
|
|
253
|
+
((c >> 6) & 63) | 128,
|
|
254
|
+
(c & 63) | 128
|
|
255
|
+
)
|
|
256
|
+
return i + 1
|
|
257
|
+
}
|
|
258
|
+
out.push((c >> 12) | 224, ((c >> 6) & 63) | 128, (c & 63) | 128)
|
|
259
|
+
return i
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function utf8StringToArray (msg: string): number[] {
|
|
263
|
+
const res: number[] = []
|
|
264
|
+
for (let i = 0; i < msg.length; i++) {
|
|
265
|
+
i = appendUtf8CodeUnit(msg, i, res)
|
|
266
|
+
}
|
|
267
|
+
return res
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function hexStringToArray (msg: string): number[] {
|
|
271
|
+
assertValidHex(msg)
|
|
272
|
+
const normalized = normalizeHex(msg)
|
|
273
|
+
const res: number[] = []
|
|
274
|
+
for (let i = 0; i < normalized.length; i += 2) {
|
|
275
|
+
res.push(Number.parseInt(normalized[i] + normalized[i + 1], 16))
|
|
276
|
+
}
|
|
277
|
+
return res
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function numberArrayToByteArray (msg: number[]): number[] {
|
|
281
|
+
const res: number[] = []
|
|
282
|
+
for (let i = 0; i < msg.length; i++) {
|
|
283
|
+
res[i] = Math.trunc(msg[i])
|
|
284
|
+
}
|
|
285
|
+
return res
|
|
286
|
+
}
|
|
287
|
+
|
|
226
288
|
/**
|
|
227
289
|
*
|
|
228
290
|
* @param msg
|
|
@@ -239,47 +301,10 @@ export function toArray (
|
|
|
239
301
|
if (!(msg as unknown as boolean)) {
|
|
240
302
|
return []
|
|
241
303
|
}
|
|
242
|
-
const res: number[] = []
|
|
243
304
|
if (typeof msg === 'string') {
|
|
244
|
-
|
|
245
|
-
// Inspired by stringToUtf8ByteArray() in closure-library by Google
|
|
246
|
-
// https://github.com/google/closure-library/blob/8598d87242af59aac233270742c8984e2b2bdbe0/closure/goog/crypt/crypt#L117-L143
|
|
247
|
-
// Apache License 2.0
|
|
248
|
-
// https://github.com/google/closure-library/blob/master/LICENSE
|
|
249
|
-
let p = 0
|
|
250
|
-
for (let i = 0; i < msg.length; i++) {
|
|
251
|
-
let c = msg.charCodeAt(i)
|
|
252
|
-
if (c < 128) {
|
|
253
|
-
res[p++] = c
|
|
254
|
-
} else if (c < 2048) {
|
|
255
|
-
res[p++] = (c >> 6) | 192
|
|
256
|
-
res[p++] = (c & 63) | 128
|
|
257
|
-
} else if (isSurrogatePair(msg, i)) {
|
|
258
|
-
c = 0x10000 + ((c & 0x03ff) << 10) + (msg.charCodeAt(++i) & 0x03ff)
|
|
259
|
-
res[p++] = (c >> 18) | 240
|
|
260
|
-
res[p++] = ((c >> 12) & 63) | 128
|
|
261
|
-
res[p++] = ((c >> 6) & 63) | 128
|
|
262
|
-
res[p++] = (c & 63) | 128
|
|
263
|
-
} else {
|
|
264
|
-
res[p++] = (c >> 12) | 224
|
|
265
|
-
res[p++] = ((c >> 6) & 63) | 128
|
|
266
|
-
res[p++] = (c & 63) | 128
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
} else {
|
|
270
|
-
assertValidHex(msg)
|
|
271
|
-
msg = normalizeHex(msg)
|
|
272
|
-
for (let i = 0; i < msg.length; i += 2) {
|
|
273
|
-
res.push(parseInt(msg[i] + msg[i + 1], 16))
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
} else {
|
|
277
|
-
msg = msg as number[]
|
|
278
|
-
for (let i = 0; i < msg.length; i++) {
|
|
279
|
-
res[i] = msg[i] | 0
|
|
280
|
-
}
|
|
305
|
+
return enc === 'hex' ? hexStringToArray(msg) : utf8StringToArray(msg)
|
|
281
306
|
}
|
|
282
|
-
return
|
|
307
|
+
return numberArrayToByteArray(msg as number[])
|
|
283
308
|
}
|
|
284
309
|
|
|
285
310
|
/**
|
|
@@ -295,8 +320,7 @@ export function htonl (w: number): number {
|
|
|
295
320
|
|
|
296
321
|
function toHex32 (msg: number[], endian?: 'little' | 'big'): string {
|
|
297
322
|
let res = ''
|
|
298
|
-
for (let
|
|
299
|
-
let w = msg[i]
|
|
323
|
+
for (let w of msg) {
|
|
300
324
|
if (endian === 'little') {
|
|
301
325
|
w = htonl(w)
|
|
302
326
|
}
|
|
@@ -686,7 +710,7 @@ export class SHA1 extends BaseHash {
|
|
|
686
710
|
let e = this.h[4]
|
|
687
711
|
|
|
688
712
|
for (i = 0; i < W.length; i++) {
|
|
689
|
-
const s =
|
|
713
|
+
const s = Math.trunc(i / 20)
|
|
690
714
|
const t = SUM32_5(rotl32(a, 5), FT_1(s, b, c, d), e, W[i], this.k[s])
|
|
691
715
|
e = d
|
|
692
716
|
d = c
|
|
@@ -805,7 +829,7 @@ export class SHA256HMAC {
|
|
|
805
829
|
* @example
|
|
806
830
|
* myHMAC.update('deadbeef', 'hex');
|
|
807
831
|
*/
|
|
808
|
-
update (msg: Uint8Array | number[] | string, enc?: 'hex'):
|
|
832
|
+
update (msg: Uint8Array | number[] | string, enc?: 'hex'): this {
|
|
809
833
|
const data =
|
|
810
834
|
msg instanceof Uint8Array ? msg : Uint8Array.from(toArray(msg, enc))
|
|
811
835
|
this.h.update(data)
|
|
@@ -869,7 +893,7 @@ export class SHA1HMAC {
|
|
|
869
893
|
this.outer = new SHA1().update(key)
|
|
870
894
|
}
|
|
871
895
|
|
|
872
|
-
update (msg: number[] | string, enc?: 'hex'):
|
|
896
|
+
update (msg: number[] | string, enc?: 'hex'): this {
|
|
873
897
|
this.inner.update(msg, enc)
|
|
874
898
|
return this
|
|
875
899
|
}
|
|
@@ -939,7 +963,7 @@ export class SHA512HMAC {
|
|
|
939
963
|
* @example
|
|
940
964
|
* myHMAC.update('deadbeef', 'hex');
|
|
941
965
|
*/
|
|
942
|
-
update (msg: Uint8Array | number[] | string, enc?: 'hex' | 'utf8'):
|
|
966
|
+
update (msg: Uint8Array | number[] | string, enc?: 'hex' | 'utf8'): this {
|
|
943
967
|
const data =
|
|
944
968
|
msg instanceof Uint8Array ? msg : Uint8Array.from(toArray(msg, enc))
|
|
945
969
|
this.h.update(data)
|
|
@@ -1144,7 +1168,7 @@ function abytes (b: Uint8Array | undefined, ...lengths: number[]): void {
|
|
|
1144
1168
|
}
|
|
1145
1169
|
}
|
|
1146
1170
|
function ahash (h: IHash): void {
|
|
1147
|
-
if (typeof h !== 'function' || typeof h.create !== 'function') { throw new
|
|
1171
|
+
if (typeof h !== 'function' || typeof h.create !== 'function') { throw new TypeError('Hash should be wrapped by utils.createHasher') }
|
|
1148
1172
|
anumber(h.outputLen)
|
|
1149
1173
|
anumber(h.blockLen)
|
|
1150
1174
|
}
|
|
@@ -1171,7 +1195,7 @@ type TypedArray =
|
|
|
1171
1195
|
| Int32Array
|
|
1172
1196
|
|
|
1173
1197
|
function clean (...arrays: TypedArray[]): void {
|
|
1174
|
-
for (
|
|
1198
|
+
for (const arr of arrays) arr.fill(0)
|
|
1175
1199
|
}
|
|
1176
1200
|
function createView (arr: TypedArray): DataView {
|
|
1177
1201
|
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength)
|
|
@@ -1229,6 +1253,7 @@ const U32_MASK64 = BigInt(2 ** 32 - 1)
|
|
|
1229
1253
|
const _32n = BigInt(32)
|
|
1230
1254
|
function fromBig (n: bigint, le = false): { h: number, l: number } {
|
|
1231
1255
|
if (le) return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) }
|
|
1256
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1232
1257
|
return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 }
|
|
1233
1258
|
}
|
|
1234
1259
|
function split (lst: bigint[], le = false): Uint32Array[] {
|
|
@@ -1250,14 +1275,18 @@ const rotrBH = (h: number, l: number, s: number): number => (h << (64 - s)) | (l
|
|
|
1250
1275
|
const rotrBL = (h: number, l: number, s: number): number => (h >>> (s - 32)) | (l << (64 - s))
|
|
1251
1276
|
function add (Ah: number, Al: number, Bh: number, Bl: number): { h: number, l: number } {
|
|
1252
1277
|
const l = (Al >>> 0) + (Bl >>> 0)
|
|
1278
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1253
1279
|
return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 }
|
|
1254
1280
|
}
|
|
1255
1281
|
const add3L = (Al: number, Bl: number, Cl: number): number => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0)
|
|
1282
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1256
1283
|
const add3H = (low: number, Ah: number, Bh: number, Ch: number): number => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0
|
|
1257
1284
|
const add4L = (Al: number, Bl: number, Cl: number, Dl: number): number => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0)
|
|
1285
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1258
1286
|
const add4H = (low: number, Ah: number, Bh: number, Ch: number, Dh: number): number => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0
|
|
1259
1287
|
const add5L = (Al: number, Bl: number, Cl: number, Dl: number, El: number): number =>
|
|
1260
1288
|
(Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0)
|
|
1289
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1261
1290
|
const add5H = (low: number, Ah: number, Bh: number, Ch: number, Dh: number, Eh: number): number =>
|
|
1262
1291
|
(Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0
|
|
1263
1292
|
|
|
@@ -1395,13 +1424,21 @@ const K256 = Uint32Array.from([
|
|
|
1395
1424
|
const SHA256_W = new Uint32Array(64)
|
|
1396
1425
|
|
|
1397
1426
|
class FastSHA256 extends HashMD<FastSHA256> {
|
|
1427
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1398
1428
|
protected A = SHA256_IV[0] | 0
|
|
1429
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1399
1430
|
protected B = SHA256_IV[1] | 0
|
|
1431
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1400
1432
|
protected C = SHA256_IV[2] | 0
|
|
1433
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1401
1434
|
protected D = SHA256_IV[3] | 0
|
|
1435
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1402
1436
|
protected E = SHA256_IV[4] | 0
|
|
1437
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1403
1438
|
protected F = SHA256_IV[5] | 0
|
|
1439
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1404
1440
|
protected G = SHA256_IV[6] | 0
|
|
1441
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1405
1442
|
protected H = SHA256_IV[7] | 0
|
|
1406
1443
|
constructor (outputLen = 32) {
|
|
1407
1444
|
super(64, outputLen, 8, false)
|
|
@@ -1422,13 +1459,21 @@ class FastSHA256 extends HashMD<FastSHA256> {
|
|
|
1422
1459
|
G: number,
|
|
1423
1460
|
H: number
|
|
1424
1461
|
): void {
|
|
1462
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1425
1463
|
this.A = A | 0
|
|
1464
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1426
1465
|
this.B = B | 0
|
|
1466
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1427
1467
|
this.C = C | 0
|
|
1468
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1428
1469
|
this.D = D | 0
|
|
1470
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1429
1471
|
this.E = E | 0
|
|
1472
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1430
1473
|
this.F = F | 0
|
|
1474
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1431
1475
|
this.G = G | 0
|
|
1476
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1432
1477
|
this.H = H | 0
|
|
1433
1478
|
}
|
|
1434
1479
|
|
|
@@ -1565,7 +1610,7 @@ const K512 = (() =>
|
|
|
1565
1610
|
'0x597f299cfc657e2a',
|
|
1566
1611
|
'0x5fcb6fab3ad6faec',
|
|
1567
1612
|
'0x6c44198c4a475817'
|
|
1568
|
-
].map(
|
|
1613
|
+
].map(BigInt))
|
|
1569
1614
|
)()
|
|
1570
1615
|
const SHA512_Kh = (() => K512[0])()
|
|
1571
1616
|
const SHA512_Kl = (() => K512[1])()
|
|
@@ -1573,21 +1618,37 @@ const SHA512_W_H = new Uint32Array(80)
|
|
|
1573
1618
|
const SHA512_W_L = new Uint32Array(80)
|
|
1574
1619
|
|
|
1575
1620
|
class FastSHA512 extends HashMD<FastSHA512> {
|
|
1621
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1576
1622
|
protected Ah = SHA512_IV[0] | 0
|
|
1623
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1577
1624
|
protected Al = SHA512_IV[1] | 0
|
|
1625
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1578
1626
|
protected Bh = SHA512_IV[2] | 0
|
|
1627
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1579
1628
|
protected Bl = SHA512_IV[3] | 0
|
|
1629
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1580
1630
|
protected Ch = SHA512_IV[4] | 0
|
|
1631
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1581
1632
|
protected Cl = SHA512_IV[5] | 0
|
|
1633
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1582
1634
|
protected Dh = SHA512_IV[6] | 0
|
|
1635
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1583
1636
|
protected Dl = SHA512_IV[7] | 0
|
|
1637
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1584
1638
|
protected Eh = SHA512_IV[8] | 0
|
|
1639
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1585
1640
|
protected El = SHA512_IV[9] | 0
|
|
1641
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1586
1642
|
protected Fh = SHA512_IV[10] | 0
|
|
1643
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1587
1644
|
protected Fl = SHA512_IV[11] | 0
|
|
1645
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1588
1646
|
protected Gh = SHA512_IV[12] | 0
|
|
1647
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1589
1648
|
protected Gl = SHA512_IV[13] | 0
|
|
1649
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1590
1650
|
protected Hh = SHA512_IV[14] | 0
|
|
1651
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1591
1652
|
protected Hl = SHA512_IV[15] | 0
|
|
1592
1653
|
constructor (outputLen = 64) {
|
|
1593
1654
|
super(128, outputLen, 16, false)
|
|
@@ -1616,41 +1677,63 @@ class FastSHA512 extends HashMD<FastSHA512> {
|
|
|
1616
1677
|
Hh: number,
|
|
1617
1678
|
Hl: number
|
|
1618
1679
|
): void {
|
|
1680
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1619
1681
|
this.Ah = Ah | 0
|
|
1682
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1620
1683
|
this.Al = Al | 0
|
|
1684
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1621
1685
|
this.Bh = Bh | 0
|
|
1686
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1622
1687
|
this.Bl = Bl | 0
|
|
1688
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1623
1689
|
this.Ch = Ch | 0
|
|
1690
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1624
1691
|
this.Cl = Cl | 0
|
|
1692
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1625
1693
|
this.Dh = Dh | 0
|
|
1694
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1626
1695
|
this.Dl = Dl | 0
|
|
1696
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1627
1697
|
this.Eh = Eh | 0
|
|
1698
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1628
1699
|
this.El = El | 0
|
|
1700
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1629
1701
|
this.Fh = Fh | 0
|
|
1702
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1630
1703
|
this.Fl = Fl | 0
|
|
1704
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1631
1705
|
this.Gh = Gh | 0
|
|
1706
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1632
1707
|
this.Gl = Gl | 0
|
|
1708
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1633
1709
|
this.Hh = Hh | 0
|
|
1710
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1634
1711
|
this.Hl = Hl | 0
|
|
1635
1712
|
}
|
|
1636
1713
|
|
|
1637
1714
|
protected process (view: DataView, offset: number): void {
|
|
1638
|
-
for (let i = 0; i < 16; i++, offset +=
|
|
1715
|
+
for (let i = 0; i < 16; i++, offset += 8) {
|
|
1639
1716
|
SHA512_W_H[i] = view.getUint32(offset)
|
|
1640
|
-
SHA512_W_L[i] = view.getUint32(
|
|
1717
|
+
SHA512_W_L[i] = view.getUint32(offset + 4)
|
|
1641
1718
|
}
|
|
1642
1719
|
for (let i = 16; i < 80; i++) {
|
|
1720
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1643
1721
|
const W15h = SHA512_W_H[i - 15] | 0
|
|
1722
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1644
1723
|
const W15l = SHA512_W_L[i - 15] | 0
|
|
1645
1724
|
const s0h = rotrSH(W15h, W15l, 1) ^ rotrSH(W15h, W15l, 8) ^ shrSH(W15h, W15l, 7)
|
|
1646
1725
|
const s0l = rotrSL(W15h, W15l, 1) ^ rotrSL(W15h, W15l, 8) ^ shrSL(W15h, W15l, 7)
|
|
1726
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1647
1727
|
const W2h = SHA512_W_H[i - 2] | 0
|
|
1728
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1648
1729
|
const W2l = SHA512_W_L[i - 2] | 0
|
|
1649
1730
|
const s1h = rotrSH(W2h, W2l, 19) ^ rotrBH(W2h, W2l, 61) ^ shrSH(W2h, W2l, 6)
|
|
1650
1731
|
const s1l = rotrSL(W2h, W2l, 19) ^ rotrBL(W2h, W2l, 61) ^ shrSL(W2h, W2l, 6)
|
|
1651
1732
|
const SUMl = add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16])
|
|
1652
1733
|
const SUMh = add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16])
|
|
1734
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1653
1735
|
SHA512_W_H[i] = SUMh | 0
|
|
1736
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1654
1737
|
SHA512_W_L[i] = SUMl | 0
|
|
1655
1738
|
}
|
|
1656
1739
|
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this
|
|
@@ -1661,26 +1744,41 @@ class FastSHA512 extends HashMD<FastSHA512> {
|
|
|
1661
1744
|
const CHIl = (El & Fl) ^ (~El & Gl)
|
|
1662
1745
|
const T1ll = add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i])
|
|
1663
1746
|
const T1h = add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i])
|
|
1747
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1664
1748
|
const T1l = T1ll | 0
|
|
1665
1749
|
const sigma0h = rotrSH(Ah, Al, 28) ^ rotrBH(Ah, Al, 34) ^ rotrBH(Ah, Al, 39)
|
|
1666
1750
|
const sigma0l = rotrSL(Ah, Al, 28) ^ rotrBL(Ah, Al, 34) ^ rotrBL(Ah, Al, 39)
|
|
1667
1751
|
const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch)
|
|
1668
1752
|
const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl)
|
|
1753
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1669
1754
|
Hh = Gh | 0
|
|
1755
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1670
1756
|
Hl = Gl | 0
|
|
1757
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1671
1758
|
Gh = Fh | 0
|
|
1759
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1672
1760
|
Gl = Fl | 0
|
|
1761
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1673
1762
|
Fh = Eh | 0
|
|
1763
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1674
1764
|
Fl = El | 0
|
|
1765
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1675
1766
|
;({ h: Eh, l: El } = add(Dh | 0, Dl | 0, T1h | 0, T1l | 0))
|
|
1767
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1676
1768
|
Dh = Ch | 0
|
|
1769
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1677
1770
|
Dl = Cl | 0
|
|
1771
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1678
1772
|
Ch = Bh | 0
|
|
1773
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1679
1774
|
Cl = Bl | 0
|
|
1775
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1680
1776
|
Bh = Ah | 0
|
|
1777
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1681
1778
|
Bl = Al | 0
|
|
1682
1779
|
const T2l = add3L(sigma0l, MAJl, T1l)
|
|
1683
1780
|
Ah = add3H(T2l, sigma0h, MAJh, T1h)
|
|
1781
|
+
// eslint-disable-next-line no-bitwise -- ToInt32 (ECMA-262); not truncation. Required for SHA arithmetic.
|
|
1684
1782
|
Al = T2l | 0
|
|
1685
1783
|
}
|
|
1686
1784
|
;({ h: Ah, l: Al } = add(Ah, Al, this.Ah, this.Al))
|
|
@@ -1717,7 +1815,7 @@ class HMAC<T extends Hash<T>> extends Hash<HMAC<T>> {
|
|
|
1717
1815
|
ahash(hash)
|
|
1718
1816
|
const key = toBytes(_key)
|
|
1719
1817
|
this.iHash = hash.create() as T
|
|
1720
|
-
if (typeof (this.iHash as any).update !== 'function') { throw new
|
|
1818
|
+
if (typeof (this.iHash as any).update !== 'function') { throw new TypeError('Expected instance of class which extends utils.Hash') }
|
|
1721
1819
|
this.blockLen = this.iHash.blockLen
|
|
1722
1820
|
this.outputLen = this.iHash.outputLen
|
|
1723
1821
|
const blockLen = this.blockLen
|
|
@@ -1795,7 +1893,8 @@ function pbkdf2Core (hash: (msg: Input) => Uint8Array & { create: () => FastSHA5
|
|
|
1795
1893
|
for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) {
|
|
1796
1894
|
const Ti = DK.subarray(pos, pos + PRF.outputLen)
|
|
1797
1895
|
view.setInt32(0, ti, false)
|
|
1798
|
-
|
|
1896
|
+
prfW = PRFSalt._cloneInto(prfW)
|
|
1897
|
+
prfW.update(arr).digestInto(u)
|
|
1799
1898
|
Ti.set(u.subarray(0, Ti.length))
|
|
1800
1899
|
for (let ui = 1; ui < c; ui++) {
|
|
1801
1900
|
PRF._cloneInto(prfW).update(u).digestInto(u)
|
|
@@ -1845,7 +1944,7 @@ export function pbkdf2 (
|
|
|
1845
1944
|
// back to the original implementation.
|
|
1846
1945
|
try {
|
|
1847
1946
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
1848
|
-
const nodeCrypto = require('crypto')
|
|
1947
|
+
const nodeCrypto = require('node:crypto')
|
|
1849
1948
|
if (typeof nodeCrypto.pbkdf2Sync === 'function') {
|
|
1850
1949
|
const p = Buffer.from(password)
|
|
1851
1950
|
const s = Buffer.from(salt)
|
|
@@ -2,6 +2,8 @@ import BasePoint from './BasePoint.js'
|
|
|
2
2
|
import BigNumber from './BigNumber.js'
|
|
3
3
|
import Point from './Point.js'
|
|
4
4
|
|
|
5
|
+
type JacobianCoord = string | BigNumber | null
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* The `JacobianPoint` class extends the `BasePoint` class for handling Jacobian coordinates on an Elliptic Curve.
|
|
7
9
|
* This class defines the properties and the methods needed to work with points in Jacobian coordinates.
|
|
@@ -39,9 +41,9 @@ export default class JacobianPoint extends BasePoint {
|
|
|
39
41
|
* const pointJ2 = new JacobianPoint('3', '4', '1'); // creates point (3, 4, 1)
|
|
40
42
|
*/
|
|
41
43
|
constructor (
|
|
42
|
-
x:
|
|
43
|
-
y:
|
|
44
|
-
z:
|
|
44
|
+
x: JacobianCoord,
|
|
45
|
+
y: JacobianCoord,
|
|
46
|
+
z: JacobianCoord
|
|
45
47
|
) {
|
|
46
48
|
super('jacobian')
|
|
47
49
|
if (x === null && y === null && z === null) {
|
|
@@ -157,10 +159,10 @@ export default class JacobianPoint extends BasePoint {
|
|
|
157
159
|
const h = u1.redSub(u2)
|
|
158
160
|
const r = s1.redSub(s2)
|
|
159
161
|
if (h.cmpn(0) === 0) {
|
|
160
|
-
if (r.cmpn(0)
|
|
161
|
-
return new JacobianPoint(null, null, null)
|
|
162
|
-
} else {
|
|
162
|
+
if (r.cmpn(0) === 0) {
|
|
163
163
|
return this.dbl()
|
|
164
|
+
} else {
|
|
165
|
+
return new JacobianPoint(null, null, null)
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
168
|
|
|
@@ -215,10 +217,10 @@ export default class JacobianPoint extends BasePoint {
|
|
|
215
217
|
const h = u1.redSub(u2)
|
|
216
218
|
const r = s1.redSub(s2)
|
|
217
219
|
if (h.cmpn(0) === 0) {
|
|
218
|
-
if (r.cmpn(0)
|
|
219
|
-
return new JacobianPoint(null, null, null)
|
|
220
|
-
} else {
|
|
220
|
+
if (r.cmpn(0) === 0) {
|
|
221
221
|
return this.dbl()
|
|
222
|
+
} else {
|
|
223
|
+
return new JacobianPoint(null, null, null)
|
|
222
224
|
}
|
|
223
225
|
}
|
|
224
226
|
|
|
@@ -251,7 +253,7 @@ export default class JacobianPoint extends BasePoint {
|
|
|
251
253
|
if (this.isInfinity()) {
|
|
252
254
|
return this
|
|
253
255
|
}
|
|
254
|
-
if (
|
|
256
|
+
if (pow === undefined) {
|
|
255
257
|
return this.dbl()
|
|
256
258
|
}
|
|
257
259
|
|
|
@@ -414,7 +416,7 @@ export default class JacobianPoint extends BasePoint {
|
|
|
414
416
|
}
|
|
415
417
|
|
|
416
418
|
const xc = x.clone()
|
|
417
|
-
if (this.curve
|
|
419
|
+
if (this.curve?.redN == null) {
|
|
418
420
|
throw new Error('Curve or redN is not initialized.')
|
|
419
421
|
}
|
|
420
422
|
|
package/src/primitives/K256.ts
CHANGED
|
@@ -77,7 +77,7 @@ export default class K256 extends Mersenne {
|
|
|
77
77
|
let currentInputNewWordCount = 0
|
|
78
78
|
|
|
79
79
|
for (let i = 10; i < inputNominalLength; i++) {
|
|
80
|
-
const next = inputWords[i]
|
|
80
|
+
const next = Math.trunc(inputWords[i])
|
|
81
81
|
if (currentInputNewWordCount < tempInputNewWords.length) { // Boundary check
|
|
82
82
|
tempInputNewWords[currentInputNewWordCount++] = ((next & mask) << 4) | (prev >>> 22)
|
|
83
83
|
}
|
|
@@ -123,10 +123,10 @@ export default class K256 extends Mersenne {
|
|
|
123
123
|
|
|
124
124
|
let lo = 0
|
|
125
125
|
for (let i = 0; i < newNominalLength; i++) { // Iterate up to new expanded length
|
|
126
|
-
const w = tempWords[i]
|
|
126
|
+
const w = Math.trunc(tempWords[i])
|
|
127
127
|
lo += w * 0x3d1 // 0x3d1 = 977
|
|
128
128
|
tempWords[i] = lo & 0x3ffffff // 26-bit mask
|
|
129
|
-
lo = w * 0x40 + (
|
|
129
|
+
lo = w * 0x40 + Math.trunc(lo / 0x4000000) // 0x40 = 64. 0x4000000 = 2^26
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
num.words = tempWords // Use setter to re-initialize from tempWords
|