@bsv/sdk 1.0.26 → 1.0.29
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/package.json +1 -1
- package/dist/cjs/mod.js +0 -25
- package/dist/cjs/mod.js.map +0 -1
- package/dist/cjs/package.json +0 -49
- package/dist/cjs/src/compat/BSM.js +0 -77
- package/dist/cjs/src/compat/BSM.js.map +0 -1
- package/dist/cjs/src/compat/ECIES.js +0 -512
- package/dist/cjs/src/compat/ECIES.js.map +0 -1
- package/dist/cjs/src/compat/HD.js +0 -344
- package/dist/cjs/src/compat/HD.js.map +0 -1
- package/dist/cjs/src/compat/Mnemonic.js +0 -298
- package/dist/cjs/src/compat/Mnemonic.js.map +0 -1
- package/dist/cjs/src/compat/bip-39-wordlist-en.js +0 -2057
- package/dist/cjs/src/compat/bip-39-wordlist-en.js.map +0 -1
- package/dist/cjs/src/compat/index.js +0 -37
- package/dist/cjs/src/compat/index.js.map +0 -1
- package/dist/cjs/src/messages/EncryptedMessage.js +0 -69
- package/dist/cjs/src/messages/EncryptedMessage.js.map +0 -1
- package/dist/cjs/src/messages/SignedMessage.js +0 -85
- package/dist/cjs/src/messages/SignedMessage.js.map +0 -1
- package/dist/cjs/src/messages/index.js +0 -29
- package/dist/cjs/src/messages/index.js.map +0 -1
- package/dist/cjs/src/primitives/AESGCM.js +0 -384
- package/dist/cjs/src/primitives/AESGCM.js.map +0 -1
- package/dist/cjs/src/primitives/BasePoint.js +0 -19
- package/dist/cjs/src/primitives/BasePoint.js.map +0 -1
- package/dist/cjs/src/primitives/BigNumber.js +0 -4272
- package/dist/cjs/src/primitives/BigNumber.js.map +0 -1
- package/dist/cjs/src/primitives/Curve.js +0 -1126
- package/dist/cjs/src/primitives/Curve.js.map +0 -1
- package/dist/cjs/src/primitives/DRBG.js +0 -99
- package/dist/cjs/src/primitives/DRBG.js.map +0 -1
- package/dist/cjs/src/primitives/ECDSA.js +0 -169
- package/dist/cjs/src/primitives/ECDSA.js.map +0 -1
- package/dist/cjs/src/primitives/Hash.js +0 -1387
- package/dist/cjs/src/primitives/Hash.js.map +0 -1
- package/dist/cjs/src/primitives/JacobianPoint.js +0 -400
- package/dist/cjs/src/primitives/JacobianPoint.js.map +0 -1
- package/dist/cjs/src/primitives/K256.js +0 -111
- package/dist/cjs/src/primitives/K256.js.map +0 -1
- package/dist/cjs/src/primitives/Mersenne.js +0 -118
- package/dist/cjs/src/primitives/Mersenne.js.map +0 -1
- package/dist/cjs/src/primitives/MontgomoryMethod.js +0 -150
- package/dist/cjs/src/primitives/MontgomoryMethod.js.map +0 -1
- package/dist/cjs/src/primitives/Point.js +0 -819
- package/dist/cjs/src/primitives/Point.js.map +0 -1
- package/dist/cjs/src/primitives/PrivateKey.js +0 -246
- package/dist/cjs/src/primitives/PrivateKey.js.map +0 -1
- package/dist/cjs/src/primitives/PublicKey.js +0 -168
- package/dist/cjs/src/primitives/PublicKey.js.map +0 -1
- package/dist/cjs/src/primitives/Random.js +0 -57
- package/dist/cjs/src/primitives/Random.js.map +0 -1
- package/dist/cjs/src/primitives/ReductionContext.js +0 -490
- package/dist/cjs/src/primitives/ReductionContext.js.map +0 -1
- package/dist/cjs/src/primitives/Signature.js +0 -357
- package/dist/cjs/src/primitives/Signature.js.map +0 -1
- package/dist/cjs/src/primitives/SymmetricKey.js +0 -82
- package/dist/cjs/src/primitives/SymmetricKey.js.map +0 -1
- package/dist/cjs/src/primitives/TransactionSignature.js +0 -172
- package/dist/cjs/src/primitives/TransactionSignature.js.map +0 -1
- package/dist/cjs/src/primitives/index.js +0 -51
- package/dist/cjs/src/primitives/index.js.map +0 -1
- package/dist/cjs/src/primitives/utils.js +0 -624
- package/dist/cjs/src/primitives/utils.js.map +0 -1
- package/dist/cjs/src/script/LockingScript.js +0 -35
- package/dist/cjs/src/script/LockingScript.js.map +0 -1
- package/dist/cjs/src/script/OP.js +0 -207
- package/dist/cjs/src/script/OP.js.map +0 -1
- package/dist/cjs/src/script/Script.js +0 -435
- package/dist/cjs/src/script/Script.js.map +0 -1
- package/dist/cjs/src/script/ScriptChunk.js +0 -3
- package/dist/cjs/src/script/ScriptChunk.js.map +0 -1
- package/dist/cjs/src/script/ScriptTemplate.js +0 -3
- package/dist/cjs/src/script/ScriptTemplate.js.map +0 -1
- package/dist/cjs/src/script/Spend.js +0 -1252
- package/dist/cjs/src/script/Spend.js.map +0 -1
- package/dist/cjs/src/script/UnlockingScript.js +0 -35
- package/dist/cjs/src/script/UnlockingScript.js.map +0 -1
- package/dist/cjs/src/script/index.js +0 -32
- package/dist/cjs/src/script/index.js.map +0 -1
- package/dist/cjs/src/script/templates/P2PKH.js +0 -120
- package/dist/cjs/src/script/templates/P2PKH.js.map +0 -1
- package/dist/cjs/src/script/templates/RPuzzle.js +0 -125
- package/dist/cjs/src/script/templates/RPuzzle.js.map +0 -1
- package/dist/cjs/src/script/templates/index.js +0 -11
- package/dist/cjs/src/script/templates/index.js.map +0 -1
- package/dist/cjs/src/transaction/Broadcaster.js +0 -3
- package/dist/cjs/src/transaction/Broadcaster.js.map +0 -1
- package/dist/cjs/src/transaction/ChainTracker.js +0 -3
- package/dist/cjs/src/transaction/ChainTracker.js.map +0 -1
- package/dist/cjs/src/transaction/FeeModel.js +0 -3
- package/dist/cjs/src/transaction/FeeModel.js.map +0 -1
- package/dist/cjs/src/transaction/MerklePath.js +0 -239
- package/dist/cjs/src/transaction/MerklePath.js.map +0 -1
- package/dist/cjs/src/transaction/Transaction.js +0 -616
- package/dist/cjs/src/transaction/Transaction.js.map +0 -1
- package/dist/cjs/src/transaction/TransactionInput.js +0 -3
- package/dist/cjs/src/transaction/TransactionInput.js.map +0 -1
- package/dist/cjs/src/transaction/TransactionOutput.js +0 -3
- package/dist/cjs/src/transaction/TransactionOutput.js.map +0 -1
- package/dist/cjs/src/transaction/broadcasters/ARC.js +0 -112
- package/dist/cjs/src/transaction/broadcasters/ARC.js.map +0 -1
- package/dist/cjs/src/transaction/broadcasters/index.js +0 -9
- package/dist/cjs/src/transaction/broadcasters/index.js.map +0 -1
- package/dist/cjs/src/transaction/fee-models/SatoshisPerKilobyte.js +0 -69
- package/dist/cjs/src/transaction/fee-models/SatoshisPerKilobyte.js.map +0 -1
- package/dist/cjs/src/transaction/fee-models/index.js +0 -9
- package/dist/cjs/src/transaction/fee-models/index.js.map +0 -1
- package/dist/cjs/src/transaction/index.js +0 -11
- package/dist/cjs/src/transaction/index.js.map +0 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +0 -1
- package/dist/esm/mod.js +0 -9
- package/dist/esm/mod.js.map +0 -1
- package/dist/esm/src/compat/BSM.js +0 -45
- package/dist/esm/src/compat/BSM.js.map +0 -1
- package/dist/esm/src/compat/ECIES.js +0 -483
- package/dist/esm/src/compat/ECIES.js.map +0 -1
- package/dist/esm/src/compat/HD.js +0 -322
- package/dist/esm/src/compat/HD.js.map +0 -1
- package/dist/esm/src/compat/Mnemonic.js +0 -272
- package/dist/esm/src/compat/Mnemonic.js.map +0 -1
- package/dist/esm/src/compat/bip-39-wordlist-en.js +0 -2054
- package/dist/esm/src/compat/bip-39-wordlist-en.js.map +0 -1
- package/dist/esm/src/compat/index.js +0 -5
- package/dist/esm/src/compat/index.js.map +0 -1
- package/dist/esm/src/messages/EncryptedMessage.js +0 -61
- package/dist/esm/src/messages/EncryptedMessage.js.map +0 -1
- package/dist/esm/src/messages/SignedMessage.js +0 -77
- package/dist/esm/src/messages/SignedMessage.js.map +0 -1
- package/dist/esm/src/messages/index.js +0 -3
- package/dist/esm/src/messages/index.js.map +0 -1
- package/dist/esm/src/primitives/AESGCM.js +0 -371
- package/dist/esm/src/primitives/AESGCM.js.map +0 -1
- package/dist/esm/src/primitives/BasePoint.js +0 -16
- package/dist/esm/src/primitives/BasePoint.js.map +0 -1
- package/dist/esm/src/primitives/BigNumber.js +0 -4307
- package/dist/esm/src/primitives/BigNumber.js.map +0 -1
- package/dist/esm/src/primitives/Curve.js +0 -1141
- package/dist/esm/src/primitives/Curve.js.map +0 -1
- package/dist/esm/src/primitives/DRBG.js +0 -98
- package/dist/esm/src/primitives/DRBG.js.map +0 -1
- package/dist/esm/src/primitives/ECDSA.js +0 -161
- package/dist/esm/src/primitives/ECDSA.js.map +0 -1
- package/dist/esm/src/primitives/Hash.js +0 -1391
- package/dist/esm/src/primitives/Hash.js.map +0 -1
- package/dist/esm/src/primitives/JacobianPoint.js +0 -398
- package/dist/esm/src/primitives/JacobianPoint.js.map +0 -1
- package/dist/esm/src/primitives/K256.js +0 -105
- package/dist/esm/src/primitives/K256.js.map +0 -1
- package/dist/esm/src/primitives/Mersenne.js +0 -117
- package/dist/esm/src/primitives/Mersenne.js.map +0 -1
- package/dist/esm/src/primitives/MontgomoryMethod.js +0 -149
- package/dist/esm/src/primitives/MontgomoryMethod.js.map +0 -1
- package/dist/esm/src/primitives/Point.js +0 -816
- package/dist/esm/src/primitives/Point.js.map +0 -1
- package/dist/esm/src/primitives/PrivateKey.js +0 -240
- package/dist/esm/src/primitives/PrivateKey.js.map +0 -1
- package/dist/esm/src/primitives/PublicKey.js +0 -162
- package/dist/esm/src/primitives/PublicKey.js.map +0 -1
- package/dist/esm/src/primitives/Random.js +0 -56
- package/dist/esm/src/primitives/Random.js.map +0 -1
- package/dist/esm/src/primitives/ReductionContext.js +0 -486
- package/dist/esm/src/primitives/ReductionContext.js.map +0 -1
- package/dist/esm/src/primitives/Signature.js +0 -360
- package/dist/esm/src/primitives/Signature.js.map +0 -1
- package/dist/esm/src/primitives/SymmetricKey.js +0 -76
- package/dist/esm/src/primitives/SymmetricKey.js.map +0 -1
- package/dist/esm/src/primitives/TransactionSignature.js +0 -144
- package/dist/esm/src/primitives/TransactionSignature.js.map +0 -1
- package/dist/esm/src/primitives/index.js +0 -13
- package/dist/esm/src/primitives/index.js.map +0 -1
- package/dist/esm/src/primitives/utils.js +0 -609
- package/dist/esm/src/primitives/utils.js.map +0 -1
- package/dist/esm/src/script/LockingScript.js +0 -29
- package/dist/esm/src/script/LockingScript.js.map +0 -1
- package/dist/esm/src/script/OP.js +0 -205
- package/dist/esm/src/script/OP.js.map +0 -1
- package/dist/esm/src/script/Script.js +0 -430
- package/dist/esm/src/script/Script.js.map +0 -1
- package/dist/esm/src/script/ScriptChunk.js +0 -2
- package/dist/esm/src/script/ScriptChunk.js.map +0 -1
- package/dist/esm/src/script/ScriptTemplate.js +0 -2
- package/dist/esm/src/script/ScriptTemplate.js.map +0 -1
- package/dist/esm/src/script/Spend.js +0 -1240
- package/dist/esm/src/script/Spend.js.map +0 -1
- package/dist/esm/src/script/UnlockingScript.js +0 -29
- package/dist/esm/src/script/UnlockingScript.js.map +0 -1
- package/dist/esm/src/script/index.js +0 -7
- package/dist/esm/src/script/index.js.map +0 -1
- package/dist/esm/src/script/templates/P2PKH.js +0 -113
- package/dist/esm/src/script/templates/P2PKH.js.map +0 -1
- package/dist/esm/src/script/templates/RPuzzle.js +0 -119
- package/dist/esm/src/script/templates/RPuzzle.js.map +0 -1
- package/dist/esm/src/script/templates/index.js +0 -3
- package/dist/esm/src/script/templates/index.js.map +0 -1
- package/dist/esm/src/transaction/Broadcaster.js +0 -2
- package/dist/esm/src/transaction/Broadcaster.js.map +0 -1
- package/dist/esm/src/transaction/ChainTracker.js +0 -2
- package/dist/esm/src/transaction/ChainTracker.js.map +0 -1
- package/dist/esm/src/transaction/FeeModel.js +0 -2
- package/dist/esm/src/transaction/FeeModel.js.map +0 -1
- package/dist/esm/src/transaction/MerklePath.js +0 -237
- package/dist/esm/src/transaction/MerklePath.js.map +0 -1
- package/dist/esm/src/transaction/Transaction.js +0 -617
- package/dist/esm/src/transaction/Transaction.js.map +0 -1
- package/dist/esm/src/transaction/TransactionInput.js +0 -2
- package/dist/esm/src/transaction/TransactionInput.js.map +0 -1
- package/dist/esm/src/transaction/TransactionOutput.js +0 -2
- package/dist/esm/src/transaction/TransactionOutput.js.map +0 -1
- package/dist/esm/src/transaction/broadcasters/ARC.js +0 -111
- package/dist/esm/src/transaction/broadcasters/ARC.js.map +0 -1
- package/dist/esm/src/transaction/broadcasters/index.js +0 -2
- package/dist/esm/src/transaction/broadcasters/index.js.map +0 -1
- package/dist/esm/src/transaction/fee-models/SatoshisPerKilobyte.js +0 -71
- package/dist/esm/src/transaction/fee-models/SatoshisPerKilobyte.js.map +0 -1
- package/dist/esm/src/transaction/fee-models/index.js +0 -2
- package/dist/esm/src/transaction/fee-models/index.js.map +0 -1
- package/dist/esm/src/transaction/index.js +0 -3
- package/dist/esm/src/transaction/index.js.map +0 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +0 -1
- package/dist/types/mod.d.ts +0 -9
- package/dist/types/mod.d.ts.map +0 -1
- package/dist/types/src/compat/BSM.d.ts +0 -28
- package/dist/types/src/compat/BSM.d.ts.map +0 -1
- package/dist/types/src/compat/ECIES.d.ts +0 -62
- package/dist/types/src/compat/ECIES.d.ts.map +0 -1
- package/dist/types/src/compat/HD.d.ts +0 -131
- package/dist/types/src/compat/HD.d.ts.map +0 -1
- package/dist/types/src/compat/Mnemonic.d.ts +0 -132
- package/dist/types/src/compat/Mnemonic.d.ts.map +0 -1
- package/dist/types/src/compat/bip-39-wordlist-en.d.ts +0 -5
- package/dist/types/src/compat/bip-39-wordlist-en.d.ts.map +0 -1
- package/dist/types/src/compat/index.d.ts +0 -5
- package/dist/types/src/compat/index.d.ts.map +0 -1
- package/dist/types/src/messages/EncryptedMessage.d.ts +0 -20
- package/dist/types/src/messages/EncryptedMessage.d.ts.map +0 -1
- package/dist/types/src/messages/SignedMessage.d.ts +0 -21
- package/dist/types/src/messages/SignedMessage.d.ts.map +0 -1
- package/dist/types/src/messages/index.d.ts +0 -3
- package/dist/types/src/messages/index.d.ts.map +0 -1
- package/dist/types/src/primitives/AESGCM.d.ts +0 -14
- package/dist/types/src/primitives/AESGCM.d.ts.map +0 -1
- package/dist/types/src/primitives/BasePoint.d.ts +0 -22
- package/dist/types/src/primitives/BasePoint.d.ts.map +0 -1
- package/dist/types/src/primitives/BigNumber.d.ts +0 -1895
- package/dist/types/src/primitives/BigNumber.d.ts.map +0 -1
- package/dist/types/src/primitives/Curve.d.ts +0 -55
- package/dist/types/src/primitives/Curve.d.ts.map +0 -1
- package/dist/types/src/primitives/DRBG.d.ts +0 -54
- package/dist/types/src/primitives/DRBG.d.ts.map +0 -1
- package/dist/types/src/primitives/ECDSA.d.ts +0 -39
- package/dist/types/src/primitives/ECDSA.d.ts.map +0 -1
- package/dist/types/src/primitives/Hash.d.ts +0 -450
- package/dist/types/src/primitives/Hash.d.ts.map +0 -1
- package/dist/types/src/primitives/JacobianPoint.d.ts +0 -164
- package/dist/types/src/primitives/JacobianPoint.d.ts.map +0 -1
- package/dist/types/src/primitives/K256.d.ts +0 -53
- package/dist/types/src/primitives/K256.d.ts.map +0 -1
- package/dist/types/src/primitives/Mersenne.d.ts +0 -72
- package/dist/types/src/primitives/Mersenne.d.ts.map +0 -1
- package/dist/types/src/primitives/MontgomoryMethod.d.ts +0 -96
- package/dist/types/src/primitives/MontgomoryMethod.d.ts.map +0 -1
- package/dist/types/src/primitives/Point.d.ts +0 -303
- package/dist/types/src/primitives/Point.d.ts.map +0 -1
- package/dist/types/src/primitives/PrivateKey.d.ts +0 -174
- package/dist/types/src/primitives/PrivateKey.d.ts.map +0 -1
- package/dist/types/src/primitives/PublicKey.d.ts +0 -120
- package/dist/types/src/primitives/PublicKey.d.ts.map +0 -1
- package/dist/types/src/primitives/Random.d.ts +0 -14
- package/dist/types/src/primitives/Random.d.ts.map +0 -1
- package/dist/types/src/primitives/ReductionContext.d.ts +0 -308
- package/dist/types/src/primitives/ReductionContext.d.ts.map +0 -1
- package/dist/types/src/primitives/Signature.d.ts +0 -162
- package/dist/types/src/primitives/Signature.d.ts.map +0 -1
- package/dist/types/src/primitives/SymmetricKey.d.ts +0 -55
- package/dist/types/src/primitives/SymmetricKey.d.ts.map +0 -1
- package/dist/types/src/primitives/TransactionSignature.d.ts +0 -36
- package/dist/types/src/primitives/TransactionSignature.d.ts.map +0 -1
- package/dist/types/src/primitives/index.d.ts +0 -13
- package/dist/types/src/primitives/index.d.ts.map +0 -1
- package/dist/types/src/primitives/utils.d.ts +0 -124
- package/dist/types/src/primitives/utils.d.ts.map +0 -1
- package/dist/types/src/script/LockingScript.d.ts +0 -25
- package/dist/types/src/script/LockingScript.d.ts.map +0 -1
- package/dist/types/src/script/OP.d.ts +0 -193
- package/dist/types/src/script/OP.d.ts.map +0 -1
- package/dist/types/src/script/Script.d.ts +0 -148
- package/dist/types/src/script/Script.d.ts.map +0 -1
- package/dist/types/src/script/ScriptChunk.d.ts +0 -8
- package/dist/types/src/script/ScriptChunk.d.ts.map +0 -1
- package/dist/types/src/script/ScriptTemplate.d.ts +0 -33
- package/dist/types/src/script/ScriptTemplate.d.ts.map +0 -1
- package/dist/types/src/script/Spend.d.ts +0 -103
- package/dist/types/src/script/Spend.d.ts.map +0 -1
- package/dist/types/src/script/UnlockingScript.d.ts +0 -25
- package/dist/types/src/script/UnlockingScript.d.ts.map +0 -1
- package/dist/types/src/script/index.d.ts +0 -8
- package/dist/types/src/script/index.d.ts.map +0 -1
- package/dist/types/src/script/templates/P2PKH.d.ts +0 -40
- package/dist/types/src/script/templates/P2PKH.d.ts.map +0 -1
- package/dist/types/src/script/templates/RPuzzle.d.ts +0 -47
- package/dist/types/src/script/templates/RPuzzle.d.ts.map +0 -1
- package/dist/types/src/script/templates/index.d.ts +0 -3
- package/dist/types/src/script/templates/index.d.ts.map +0 -1
- package/dist/types/src/transaction/Broadcaster.d.ts +0 -39
- package/dist/types/src/transaction/Broadcaster.d.ts.map +0 -1
- package/dist/types/src/transaction/ChainTracker.d.ts +0 -23
- package/dist/types/src/transaction/ChainTracker.d.ts.map +0 -1
- package/dist/types/src/transaction/FeeModel.d.ts +0 -12
- package/dist/types/src/transaction/FeeModel.d.ts.map +0 -1
- package/dist/types/src/transaction/MerklePath.d.ts +0 -91
- package/dist/types/src/transaction/MerklePath.d.ts.map +0 -1
- package/dist/types/src/transaction/Transaction.d.ts +0 -215
- package/dist/types/src/transaction/Transaction.d.ts.map +0 -1
- package/dist/types/src/transaction/TransactionInput.d.ts +0 -63
- package/dist/types/src/transaction/TransactionInput.d.ts.map +0 -1
- package/dist/types/src/transaction/TransactionOutput.d.ts +0 -36
- package/dist/types/src/transaction/TransactionOutput.d.ts.map +0 -1
- package/dist/types/src/transaction/broadcasters/ARC.d.ts +0 -28
- package/dist/types/src/transaction/broadcasters/ARC.d.ts.map +0 -1
- package/dist/types/src/transaction/broadcasters/index.d.ts +0 -2
- package/dist/types/src/transaction/broadcasters/index.d.ts.map +0 -1
- package/dist/types/src/transaction/fee-models/SatoshisPerKilobyte.d.ts +0 -26
- package/dist/types/src/transaction/fee-models/SatoshisPerKilobyte.d.ts.map +0 -1
- package/dist/types/src/transaction/fee-models/index.d.ts +0 -2
- package/dist/types/src/transaction/fee-models/index.d.ts.map +0 -1
- package/dist/types/src/transaction/index.d.ts +0 -7
- package/dist/types/src/transaction/index.d.ts.map +0 -1
- package/dist/types/tsconfig.types.tsbuildinfo +0 -1
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
import BigNumber from './BigNumber.js';
|
|
2
|
-
import Mersenne from './Mersenne.js';
|
|
3
|
-
/**
|
|
4
|
-
* A base reduction engine that provides several arithmetic operations over
|
|
5
|
-
* big numbers under a modulus context. It's particularly suitable for
|
|
6
|
-
* calculations required in cryptography algorithms and encoding schemas.
|
|
7
|
-
*
|
|
8
|
-
* @class ReductionContext
|
|
9
|
-
*
|
|
10
|
-
* @property prime - The prime number utilised in the reduction context, typically an instance of Mersenne class.
|
|
11
|
-
* @property m - The modulus used for reduction operations.
|
|
12
|
-
*/
|
|
13
|
-
export default class ReductionContext {
|
|
14
|
-
prime: Mersenne | null;
|
|
15
|
-
m: BigNumber;
|
|
16
|
-
/**
|
|
17
|
-
* Constructs a new ReductionContext.
|
|
18
|
-
*
|
|
19
|
-
* @constructor
|
|
20
|
-
* @param m - A BigNumber representing the modulus, or 'k256' to create a context for Koblitz curve.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* new ReductionContext(new BigNumber(11));
|
|
24
|
-
* new ReductionContext('k256');
|
|
25
|
-
*/
|
|
26
|
-
constructor(m: BigNumber | 'k256');
|
|
27
|
-
/**
|
|
28
|
-
* Asserts that given value is truthy. Throws an Error with a provided message
|
|
29
|
-
* if the value is falsy.
|
|
30
|
-
*
|
|
31
|
-
* @private
|
|
32
|
-
* @param val - The value to be checked.
|
|
33
|
-
* @param msg - The error message to be thrown if the value is falsy.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* this.assert(1 < 2, '1 is not less than 2');
|
|
37
|
-
* this.assert(2 < 1, '2 is less than 1'); // throws an Error with message '2 is less than 1'
|
|
38
|
-
*/
|
|
39
|
-
private assert;
|
|
40
|
-
/**
|
|
41
|
-
* Verifies that a BigNumber is positive and red. Throws an error if these
|
|
42
|
-
* conditions are not met.
|
|
43
|
-
*
|
|
44
|
-
* @param a - The BigNumber to be verified.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* this.verify1(new BigNumber(10).toRed());
|
|
48
|
-
* this.verify1(new BigNumber(-10).toRed()); //throws an Error
|
|
49
|
-
* this.verify1(new BigNumber(10)); //throws an Error
|
|
50
|
-
*/
|
|
51
|
-
verify1(a: BigNumber): void;
|
|
52
|
-
/**
|
|
53
|
-
* Verifies that two BigNumbers are both positive and red. Also checks
|
|
54
|
-
* that they have the same reduction context. Throws an error if these
|
|
55
|
-
* conditions are not met.
|
|
56
|
-
*
|
|
57
|
-
* @param a - The first BigNumber to be verified.
|
|
58
|
-
* @param b - The second BigNumber to be verified.
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* this.verify2(new BigNumber(10).toRed(this), new BigNumber(20).toRed(this));
|
|
62
|
-
* this.verify2(new BigNumber(-10).toRed(this), new BigNumber(20).toRed(this)); //throws an Error
|
|
63
|
-
* this.verify2(new BigNumber(10).toRed(this), new BigNumber(20)); //throws an Error
|
|
64
|
-
*/
|
|
65
|
-
verify2(a: BigNumber, b: BigNumber): void;
|
|
66
|
-
/**
|
|
67
|
-
* Performs an in-place reduction of the given BigNumber by the modulus of the reduction context, 'm'.
|
|
68
|
-
*
|
|
69
|
-
* @method imod
|
|
70
|
-
*
|
|
71
|
-
* @param a - BigNumber to be reduced.
|
|
72
|
-
*
|
|
73
|
-
* @returns Returns the reduced result.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* const context = new ReductionContext(new BigNumber(7));
|
|
77
|
-
* context.imod(new BigNumber(19)); // Returns 5
|
|
78
|
-
*/
|
|
79
|
-
imod(a: BigNumber): BigNumber;
|
|
80
|
-
/**
|
|
81
|
-
* Negates a BigNumber in the context of the modulus.
|
|
82
|
-
*
|
|
83
|
-
* @method neg
|
|
84
|
-
*
|
|
85
|
-
* @param a - BigNumber to negate.
|
|
86
|
-
*
|
|
87
|
-
* @returns Returns the negation of 'a' in the reduction context.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* const context = new ReductionContext(new BigNumber(7));
|
|
91
|
-
* context.neg(new BigNumber(3)); // Returns 4
|
|
92
|
-
*/
|
|
93
|
-
neg(a: BigNumber): BigNumber;
|
|
94
|
-
/**
|
|
95
|
-
* Performs the addition operation on two BigNumbers in the reduction context.
|
|
96
|
-
*
|
|
97
|
-
* @method add
|
|
98
|
-
*
|
|
99
|
-
* @param a - First BigNumber to add.
|
|
100
|
-
* @param b - Second BigNumber to add.
|
|
101
|
-
*
|
|
102
|
-
* @returns Returns the result of 'a + b' in the reduction context.
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* const context = new ReductionContext(new BigNumber(5));
|
|
106
|
-
* context.add(new BigNumber(2), new BigNumber(4)); // Returns 1
|
|
107
|
-
*/
|
|
108
|
-
add(a: BigNumber, b: BigNumber): BigNumber;
|
|
109
|
-
/**
|
|
110
|
-
* Performs an in-place addition operation on two BigNumbers in the reduction context
|
|
111
|
-
* in order to avoid creating a new BigNumber, it modifies the first one with the result.
|
|
112
|
-
*
|
|
113
|
-
* @method iadd
|
|
114
|
-
*
|
|
115
|
-
* @param a - First BigNumber to add.
|
|
116
|
-
* @param b - Second BigNumber to add.
|
|
117
|
-
*
|
|
118
|
-
* @returns Returns the modified 'a' after addition with 'b' in the reduction context.
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* const context = new ReductionContext(new BigNumber(5));
|
|
122
|
-
* const a = new BigNumber(2);
|
|
123
|
-
* context.iadd(a, new BigNumber(4)); // Modifies 'a' to be 1
|
|
124
|
-
*/
|
|
125
|
-
iadd(a: BigNumber, b: BigNumber): BigNumber;
|
|
126
|
-
/**
|
|
127
|
-
* Subtracts one BigNumber from another BigNumber in the reduction context.
|
|
128
|
-
*
|
|
129
|
-
* @method sub
|
|
130
|
-
*
|
|
131
|
-
* @param a - BigNumber to be subtracted from.
|
|
132
|
-
* @param b - BigNumber to subtract.
|
|
133
|
-
*
|
|
134
|
-
* @returns Returns the result of 'a - b' in the reduction context.
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* const context = new ReductionContext(new BigNumber(7));
|
|
138
|
-
* context.sub(new BigNumber(3), new BigNumber(2)); // Returns 1
|
|
139
|
-
*/
|
|
140
|
-
sub(a: BigNumber, b: BigNumber): BigNumber;
|
|
141
|
-
/**
|
|
142
|
-
* Performs in-place subtraction of one BigNumber from another in the reduction context,
|
|
143
|
-
* it modifies the first BigNumber with the result.
|
|
144
|
-
*
|
|
145
|
-
* @method isub
|
|
146
|
-
*
|
|
147
|
-
* @param a - BigNumber to be subtracted from.
|
|
148
|
-
* @param b - BigNumber to subtract.
|
|
149
|
-
*
|
|
150
|
-
* @returns Returns the modified 'a' after subtraction of 'b' in the reduction context.
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* const context = new ReductionContext(new BigNumber(5));
|
|
154
|
-
* const a = new BigNumber(4);
|
|
155
|
-
* context.isub(a, new BigNumber(2)); // Modifies 'a' to be 2
|
|
156
|
-
*/
|
|
157
|
-
isub(a: BigNumber, b: BigNumber): BigNumber;
|
|
158
|
-
/**
|
|
159
|
-
* Performs bitwise shift left operation on a BigNumber in the reduction context.
|
|
160
|
-
*
|
|
161
|
-
* @method shl
|
|
162
|
-
*
|
|
163
|
-
* @param a - BigNumber to perform shift on.
|
|
164
|
-
* @param num - The number of positions to shift.
|
|
165
|
-
*
|
|
166
|
-
* @returns Returns the result of shifting 'a' left by 'num' positions in the reduction context.
|
|
167
|
-
*
|
|
168
|
-
* @example
|
|
169
|
-
* const context = new ReductionContext(new BigNumber(32));
|
|
170
|
-
* context.shl(new BigNumber(4), 2); // Returns 16
|
|
171
|
-
*/
|
|
172
|
-
shl(a: BigNumber, num: number): BigNumber;
|
|
173
|
-
/**
|
|
174
|
-
* Performs in-place multiplication of two BigNumbers in the reduction context,
|
|
175
|
-
* modifying the first BigNumber with the result.
|
|
176
|
-
*
|
|
177
|
-
* @method imul
|
|
178
|
-
*
|
|
179
|
-
* @param a - First BigNumber to multiply.
|
|
180
|
-
* @param b - Second BigNumber to multiply.
|
|
181
|
-
*
|
|
182
|
-
* @returns Returns the modified 'a' after multiplication with 'b' in the reduction context.
|
|
183
|
-
*
|
|
184
|
-
* @example
|
|
185
|
-
* const context = new ReductionContext(new BigNumber(7));
|
|
186
|
-
* const a = new BigNumber(3);
|
|
187
|
-
* context.imul(a, new BigNumber(2)); // Modifies 'a' to be 6
|
|
188
|
-
*/
|
|
189
|
-
imul(a: BigNumber, b: BigNumber): BigNumber;
|
|
190
|
-
/**
|
|
191
|
-
* Multiplies two BigNumbers in the reduction context.
|
|
192
|
-
*
|
|
193
|
-
* @method mul
|
|
194
|
-
*
|
|
195
|
-
* @param a - First BigNumber to multiply.
|
|
196
|
-
* @param b - Second BigNumber to multiply.
|
|
197
|
-
*
|
|
198
|
-
* @returns Returns the result of 'a * b' in the reduction context.
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* const context = new ReductionContext(new BigNumber(7));
|
|
202
|
-
* context.mul(new BigNumber(3), new BigNumber(2)); // Returns 6
|
|
203
|
-
*/
|
|
204
|
-
mul(a: BigNumber, b: BigNumber): BigNumber;
|
|
205
|
-
/**
|
|
206
|
-
* Calculates the square of a BigNumber in the reduction context,
|
|
207
|
-
* modifying the original BigNumber with the result.
|
|
208
|
-
*
|
|
209
|
-
* @method isqr
|
|
210
|
-
*
|
|
211
|
-
* @param a - BigNumber to be squared.
|
|
212
|
-
*
|
|
213
|
-
* @returns Returns the squared 'a' in the reduction context.
|
|
214
|
-
*
|
|
215
|
-
* @example
|
|
216
|
-
* const context = new ReductionContext(new BigNumber(7));
|
|
217
|
-
* const a = new BigNumber(3);
|
|
218
|
-
* context.isqr(a); // Modifies 'a' to be 2 (9 % 7 = 2)
|
|
219
|
-
*/
|
|
220
|
-
isqr(a: BigNumber): BigNumber;
|
|
221
|
-
/**
|
|
222
|
-
* Calculates the square of a BigNumber in the reduction context.
|
|
223
|
-
*
|
|
224
|
-
* @method sqr
|
|
225
|
-
*
|
|
226
|
-
* @param a - BigNumber to be squared.
|
|
227
|
-
*
|
|
228
|
-
* @returns Returns the result of 'a^2' in the reduction context.
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* const context = new ReductionContext(new BigNumber(7));
|
|
232
|
-
* context.sqr(new BigNumber(3)); // Returns 2 (9 % 7 = 2)
|
|
233
|
-
*/
|
|
234
|
-
sqr(a: BigNumber): BigNumber;
|
|
235
|
-
/**
|
|
236
|
-
* Calculates the square root of a BigNumber in the reduction context.
|
|
237
|
-
*
|
|
238
|
-
* @method sqrt
|
|
239
|
-
*
|
|
240
|
-
* @param a - The BigNumber to calculate the square root of.
|
|
241
|
-
*
|
|
242
|
-
* @returns Returns the square root of 'a' in the reduction context.
|
|
243
|
-
*
|
|
244
|
-
* @example
|
|
245
|
-
* const context = new ReductionContext(new BigNumber(9));
|
|
246
|
-
* context.sqrt(new BigNumber(4)); // Returns 2
|
|
247
|
-
*/
|
|
248
|
-
sqrt(a: BigNumber): BigNumber;
|
|
249
|
-
/**
|
|
250
|
-
* Calculates the multiplicative inverse of a BigNumber in the reduction context.
|
|
251
|
-
*
|
|
252
|
-
* @method invm
|
|
253
|
-
*
|
|
254
|
-
* @param a - The BigNumber to find the multiplicative inverse of.
|
|
255
|
-
*
|
|
256
|
-
* @returns Returns the multiplicative inverse of 'a' in the reduction context.
|
|
257
|
-
*
|
|
258
|
-
* @example
|
|
259
|
-
* const context = new ReductionContext(new BigNumber(11));
|
|
260
|
-
* context.invm(new BigNumber(3)); // Returns 4 (3*4 mod 11 = 1)
|
|
261
|
-
*/
|
|
262
|
-
invm(a: BigNumber): BigNumber;
|
|
263
|
-
/**
|
|
264
|
-
* Raises a BigNumber to a power in the reduction context.
|
|
265
|
-
*
|
|
266
|
-
* @method pow
|
|
267
|
-
*
|
|
268
|
-
* @param a - The BigNumber to be raised to a power.
|
|
269
|
-
* @param num - The power to raise the BigNumber to.
|
|
270
|
-
*
|
|
271
|
-
* @returns Returns the result of 'a' raised to the power of 'num' in the reduction context.
|
|
272
|
-
*
|
|
273
|
-
* @example
|
|
274
|
-
* const context = new ReductionContext(new BigNumber(7));
|
|
275
|
-
* context.pow(new BigNumber(3), new BigNumber(2)); // Returns 2 (3^2 % 7)
|
|
276
|
-
*/
|
|
277
|
-
pow(a: BigNumber, num: BigNumber): BigNumber;
|
|
278
|
-
/**
|
|
279
|
-
* Converts a BigNumber to its equivalent in the reduction context.
|
|
280
|
-
*
|
|
281
|
-
* @method convertTo
|
|
282
|
-
*
|
|
283
|
-
* @param num - The BigNumber to convert to the reduction context.
|
|
284
|
-
*
|
|
285
|
-
* @returns Returns the converted BigNumber compatible with the reduction context.
|
|
286
|
-
*
|
|
287
|
-
* @example
|
|
288
|
-
* const context = new ReductionContext(new BigNumber(7));
|
|
289
|
-
* context.convertTo(new BigNumber(8)); // Returns 1 (8 % 7)
|
|
290
|
-
*/
|
|
291
|
-
convertTo(num: BigNumber): BigNumber;
|
|
292
|
-
/**
|
|
293
|
-
* Converts a BigNumber from reduction context to its regular form.
|
|
294
|
-
*
|
|
295
|
-
* @method convertFrom
|
|
296
|
-
*
|
|
297
|
-
* @param num - The BigNumber to convert from the reduction context.
|
|
298
|
-
*
|
|
299
|
-
* @returns Returns the converted BigNumber in its regular form.
|
|
300
|
-
*
|
|
301
|
-
* @example
|
|
302
|
-
* const context = new ReductionContext(new BigNumber(7));
|
|
303
|
-
* const a = context.convertTo(new BigNumber(8)); // 'a' is now 1 in the reduction context
|
|
304
|
-
* context.convertFrom(a); // Returns 1
|
|
305
|
-
*/
|
|
306
|
-
convertFrom(num: BigNumber): BigNumber;
|
|
307
|
-
}
|
|
308
|
-
//# sourceMappingURL=ReductionContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReductionContext.d.ts","sourceRoot":"","sources":["../../../../src/primitives/ReductionContext.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAA;AAEtC,OAAO,QAAQ,MAAM,eAAe,CAAA;AAEpC;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;IACtB,CAAC,EAAE,SAAS,CAAA;IAEZ;;;;;;;;;OASG;gBACU,CAAC,EAAE,SAAS,GAAG,MAAM;IAYlC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM;IAId;;;;;;;;;;OAUG;IACH,OAAO,CAAE,CAAC,EAAE,SAAS,GAAG,IAAI;IAK5B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,IAAI;IAW1C;;;;;;;;;;;;OAYG;IACH,IAAI,CAAE,CAAC,EAAE,SAAS,GAAG,SAAS;IAO9B;;;;;;;;;;;;OAYG;IACH,GAAG,CAAE,CAAC,EAAE,SAAS,GAAG,SAAS;IAQ7B;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,SAAS;IAU3C;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,SAAS;IAU5C;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,SAAS;IAU3C;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,SAAS;IAU5C;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS;IAK1C;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,SAAS;IAK5C;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,SAAS;IAK3C;;;;;;;;;;;;;;OAcG;IACH,IAAI,CAAE,CAAC,EAAE,SAAS,GAAG,SAAS;IAI9B;;;;;;;;;;;;OAYG;IACH,GAAG,CAAE,CAAC,EAAE,SAAS,GAAG,SAAS;IAI7B;;;;;;;;;;;;OAYG;IACH,IAAI,CAAE,CAAC,EAAE,SAAS,GAAG,SAAS;IA0D9B;;;;;;;;;;;;OAYG;IACH,IAAI,CAAE,CAAC,EAAE,SAAS,GAAG,SAAS;IAU9B;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,GAAG,SAAS;IAiD7C;;;;;;;;;;;;OAYG;IACH,SAAS,CAAE,GAAG,EAAE,SAAS,GAAG,SAAS;IAMrC;;;;;;;;;;;;;OAaG;IACH,WAAW,CAAE,GAAG,EAAE,SAAS,GAAG,SAAS;CAKxC"}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import BigNumber from './BigNumber.js';
|
|
2
|
-
import PublicKey from './PublicKey.js';
|
|
3
|
-
/**
|
|
4
|
-
* Represents a digital signature.
|
|
5
|
-
*
|
|
6
|
-
* A digital signature is a mathematical scheme for verifying the authenticity of
|
|
7
|
-
* digital messages or documents. In many scenarios, it is equivalent to a handwritten signature or stamped seal.
|
|
8
|
-
* The signature pair (R, S) corresponds to the raw ECDSA ([Elliptic Curve Digital Signature Algorithm](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm)) signature.
|
|
9
|
-
* Signatures are often serialized into a format known as '[DER encoding](https://en.wikipedia.org/wiki/X.690#DER_encoding)' for transmission.
|
|
10
|
-
*
|
|
11
|
-
* @class Signature
|
|
12
|
-
*/
|
|
13
|
-
export default class Signature {
|
|
14
|
-
/**
|
|
15
|
-
* @property Represents the "r" component of the digital signature
|
|
16
|
-
*/
|
|
17
|
-
r: BigNumber;
|
|
18
|
-
/**
|
|
19
|
-
* @property Represents the "s" component of the digital signature
|
|
20
|
-
*/
|
|
21
|
-
s: BigNumber;
|
|
22
|
-
/**
|
|
23
|
-
* Takes an array of numbers or a string and returns a new Signature instance.
|
|
24
|
-
* This method will throw an error if the DER encoding is invalid.
|
|
25
|
-
* If a string is provided, it is assumed to represent a hexadecimal sequence.
|
|
26
|
-
*
|
|
27
|
-
* @static
|
|
28
|
-
* @method fromDER
|
|
29
|
-
* @param data - The sequence to decode from DER encoding.
|
|
30
|
-
* @param enc - The encoding of the data string.
|
|
31
|
-
* @returns The decoded data in the form of Signature instance.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* const signature = Signature.fromDER('30440220018c1f5502f8...', 'hex');
|
|
35
|
-
*/
|
|
36
|
-
static fromDER(data: number[] | string, enc?: 'hex' | 'base64'): Signature;
|
|
37
|
-
/**
|
|
38
|
-
* Takes an array of numbers or a string and returns a new Signature instance.
|
|
39
|
-
* This method will throw an error if the Compact encoding is invalid.
|
|
40
|
-
* If a string is provided, it is assumed to represent a hexadecimal sequence.
|
|
41
|
-
* compactByte value 27-31 means compressed public key.
|
|
42
|
-
* 32-35 means uncompressed public key.
|
|
43
|
-
* The range represents the recovery param which can be 0,1,2,3,4.
|
|
44
|
-
* We could support recovery functions in future if there's demand.
|
|
45
|
-
*
|
|
46
|
-
* @static
|
|
47
|
-
* @method fromCompact
|
|
48
|
-
* @param data - The sequence to decode from Compact encoding.
|
|
49
|
-
* @param enc - The encoding of the data string.
|
|
50
|
-
* @returns The decoded data in the form of Signature instance.
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* const signature = Signature.fromCompact('1b18c1f5502f8...', 'hex');
|
|
54
|
-
*/
|
|
55
|
-
static fromCompact(data: number[] | string, enc?: 'hex' | 'base64'): Signature;
|
|
56
|
-
/**
|
|
57
|
-
* Creates an instance of the Signature class.
|
|
58
|
-
*
|
|
59
|
-
* @constructor
|
|
60
|
-
* @param r - The R component of the signature.
|
|
61
|
-
* @param s - The S component of the signature.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* const r = new BigNumber('208755674028...');
|
|
65
|
-
* const s = new BigNumber('564745627577...');
|
|
66
|
-
* const signature = new Signature(r, s);
|
|
67
|
-
*/
|
|
68
|
-
constructor(r: BigNumber, s: BigNumber);
|
|
69
|
-
/**
|
|
70
|
-
* Verifies a digital signature.
|
|
71
|
-
*
|
|
72
|
-
* This method will return true if the signature, key, and message hash match.
|
|
73
|
-
* If the data or key do not match the signature, the function returns false.
|
|
74
|
-
*
|
|
75
|
-
* @method verify
|
|
76
|
-
* @param msg - The message to verify.
|
|
77
|
-
* @param key - The public key used to sign the original message.
|
|
78
|
-
* @param enc - The encoding of the msg string.
|
|
79
|
-
* @returns A boolean representing whether the signature is valid.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* const msg = 'The quick brown fox jumps over the lazy dog';
|
|
83
|
-
* const publicKey = PublicKey.fromString('04188ca1050...');
|
|
84
|
-
* const isVerified = signature.verify(msg, publicKey);
|
|
85
|
-
*/
|
|
86
|
-
verify(msg: number[] | string, key: PublicKey, enc?: 'hex'): boolean;
|
|
87
|
-
/**
|
|
88
|
-
* Converts an instance of Signature into DER encoding.
|
|
89
|
-
* An alias for the toDER method.
|
|
90
|
-
*
|
|
91
|
-
* If the encoding parameter is set to 'hex', the function will return a hex string.
|
|
92
|
-
* If 'base64', it will return a base64 string.
|
|
93
|
-
* Otherwise, it will return an array of numbers.
|
|
94
|
-
*
|
|
95
|
-
* @method toDER
|
|
96
|
-
* @param enc - The encoding to use for the output.
|
|
97
|
-
* @returns The current instance in DER encoding.
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* const der = signature.toString('base64');
|
|
101
|
-
*/
|
|
102
|
-
toString(enc?: 'hex' | 'base64'): string | number[];
|
|
103
|
-
/**
|
|
104
|
-
* Converts an instance of Signature into DER encoding.
|
|
105
|
-
*
|
|
106
|
-
* If the encoding parameter is set to 'hex', the function will return a hex string.
|
|
107
|
-
* If 'base64', it will return a base64 string.
|
|
108
|
-
* Otherwise, it will return an array of numbers.
|
|
109
|
-
*
|
|
110
|
-
* @method toDER
|
|
111
|
-
* @param enc - The encoding to use for the output.
|
|
112
|
-
* @returns The current instance in DER encoding.
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* const der = signature.toDER('hex');
|
|
116
|
-
*/
|
|
117
|
-
toDER(enc?: 'hex' | 'base64'): number[] | string;
|
|
118
|
-
/**
|
|
119
|
-
* Converts an instance of Signature into Compact encoding.
|
|
120
|
-
*
|
|
121
|
-
* If the encoding parameter is set to 'hex', the function will return a hex string.
|
|
122
|
-
* If 'base64', it will return a base64 string.
|
|
123
|
-
* Otherwise, it will return an array of numbers.
|
|
124
|
-
*
|
|
125
|
-
* @method toCompact
|
|
126
|
-
* @param enc - The encoding to use for the output.
|
|
127
|
-
* @returns The current instance in DER encoding.
|
|
128
|
-
*
|
|
129
|
-
* @example
|
|
130
|
-
* const compact = signature.toCompact(3, true, 'base64');
|
|
131
|
-
*/
|
|
132
|
-
toCompact(recovery: number, compressed: boolean, enc?: 'hex' | 'base64'): number[] | string;
|
|
133
|
-
/**
|
|
134
|
-
* Recovers the public key from a signature.
|
|
135
|
-
* This method will return the public key if it finds a valid public key.
|
|
136
|
-
* If it does not find a valid public key, it will throw an error.
|
|
137
|
-
* The recovery factor is a number between 0 and 3.
|
|
138
|
-
* @method RecoverPublicKey
|
|
139
|
-
* @param recovery - The recovery factor.
|
|
140
|
-
* @param e - The message hash.
|
|
141
|
-
* @returns The public key associated with the signature.
|
|
142
|
-
*
|
|
143
|
-
* @example
|
|
144
|
-
* const publicKey = signature.RecoverPublicKey(0, msgHash);
|
|
145
|
-
*/
|
|
146
|
-
RecoverPublicKey(recovery: number, e: BigNumber): PublicKey;
|
|
147
|
-
/**
|
|
148
|
-
* Calculates the recovery factor which will work for a particular public key and message hash.
|
|
149
|
-
* This method will return the recovery factor if it finds a valid recovery factor.
|
|
150
|
-
* If it does not find a valid recovery factor, it will throw an error.
|
|
151
|
-
* The recovery factor is a number between 0 and 3.
|
|
152
|
-
*
|
|
153
|
-
* @method CalculateRecoveryFactor
|
|
154
|
-
* @param msgHash - The message hash.
|
|
155
|
-
* @returns the recovery factor: number
|
|
156
|
-
* /
|
|
157
|
-
* @example
|
|
158
|
-
* const recovery = signature.CalculateRecoveryFactor(publicKey, msgHash);
|
|
159
|
-
*/
|
|
160
|
-
CalculateRecoveryFactor(pubkey: PublicKey, msgHash: BigNumber): number;
|
|
161
|
-
}
|
|
162
|
-
//# sourceMappingURL=Signature.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Signature.d.ts","sourceRoot":"","sources":["../../../../src/primitives/Signature.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,SAAS,MAAM,gBAAgB,CAAA;AAOtC;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B;;OAEG;IACH,CAAC,EAAE,SAAS,CAAA;IAEZ;;OAEG;IACH,CAAC,EAAE,SAAS,CAAA;IAEZ;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,OAAO,CAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS;IA6D3E;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,WAAW,CAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS;IAe/E;;;;;;;;;;;OAWG;gBACU,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS;IAKvC;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,KAAK,GAAG,OAAO;IAKrE;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAE,GAAG,CAAC,EAAE,KAAK,GAAG,QAAQ;IAIhC;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAE,GAAG,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM;IAqDjD;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,EAAE,GAAG,MAAM;IAmB5F;;;;;;;;;;;;OAYG;IACH,gBAAgB,CAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,GAAG,SAAS;IA2C5D;;;;;;;;;;;;OAYG;IACH,uBAAuB,CAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,GAAG,MAAM;CAcxE"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import BigNumber from './BigNumber.js';
|
|
2
|
-
/**
|
|
3
|
-
* `SymmetricKey` is a class that extends the `BigNumber` class and implements symmetric encryption and decryption methods.
|
|
4
|
-
* Symmetric-Key encryption is a form of encryption where the same key is used to encrypt and decrypt the message.
|
|
5
|
-
* It leverages the Advanced Encryption Standard Galois/Counter Mode (AES-GCM) for encryption and decryption of messages.
|
|
6
|
-
*
|
|
7
|
-
* @class SymmetricKey
|
|
8
|
-
* @extends {BigNumber}
|
|
9
|
-
*/
|
|
10
|
-
export default class SymmetricKey extends BigNumber {
|
|
11
|
-
/**
|
|
12
|
-
* Generates a symmetric key randomly.
|
|
13
|
-
*
|
|
14
|
-
* @method fromRandom
|
|
15
|
-
* @static
|
|
16
|
-
* @returns The newly generated Symmetric Key.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* const symmetricKey = SymmetricKey.fromRandom();
|
|
20
|
-
*/
|
|
21
|
-
static fromRandom(): SymmetricKey;
|
|
22
|
-
/**
|
|
23
|
-
* Encrypts a given message using AES-GCM encryption.
|
|
24
|
-
* The generated Initialization Vector (IV) is attached to the encrypted message for decryption purposes.
|
|
25
|
-
* The OpenSSL format of |IV|encryptedContent|authTag| is used.
|
|
26
|
-
*
|
|
27
|
-
* @method encrypt
|
|
28
|
-
* @param msg - The message to be encrypted. It can be a string or an array of numbers.
|
|
29
|
-
* @param enc - optional. The encoding of the message. If hex, the string is assumed to be hex, UTF-8 otherwise.
|
|
30
|
-
* @returns Returns the encrypted message as a string or an array of numbers, depending on `enc` argument.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* const key = new SymmetricKey(1234);
|
|
34
|
-
* const encryptedMessage = key.encrypt('plainText', 'utf8');
|
|
35
|
-
*/
|
|
36
|
-
encrypt(msg: number[] | string, enc?: 'hex'): string | number[];
|
|
37
|
-
/**
|
|
38
|
-
* Decrypts a given AES-GCM encrypted message using the same key that was used for encryption.
|
|
39
|
-
* The method extracts the IV and the authentication tag from the encrypted message, then attempts to decrypt it.
|
|
40
|
-
* If the decryption fails (e.g., due to message tampering), an error is thrown.
|
|
41
|
-
*
|
|
42
|
-
* @method decrypt
|
|
43
|
-
* @param msg - The encrypted message to be decrypted. It can be a string or an array of numbers.
|
|
44
|
-
* @param enc - optional. The encoding of the message (if no encoding is provided, uses utf8 for strings, unless specified as hex).
|
|
45
|
-
* @returns Returns the decrypted message as a string or an array of numbers, depending on `enc` argument. If absent, an array of numbers is returned.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* const key = new SymmetricKey(1234);
|
|
49
|
-
* const decryptedMessage = key.decrypt(encryptedMessage, 'utf8');
|
|
50
|
-
*
|
|
51
|
-
* @throws {Error} Will throw an error if the decryption fails, likely due to message tampering or incorrect decryption key.
|
|
52
|
-
*/
|
|
53
|
-
decrypt(msg: number[] | string, enc?: 'hex' | 'utf8'): string | number[];
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=SymmetricKey.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SymmetricKey.d.ts","sourceRoot":"","sources":["../../../../src/primitives/SymmetricKey.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAA;AAKtC;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,SAAS;IACjD;;;;;;;;;OASG;IACH,MAAM,CAAC,UAAU,IAAK,YAAY;IAIlC;;;;;;;;;;;;;MAaE;IACF,OAAO,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,EAAE;IAYhE;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE;CAkB1E"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import Signature from './Signature.js';
|
|
2
|
-
import BigNumber from './BigNumber.js';
|
|
3
|
-
import Script from '../script/Script.js';
|
|
4
|
-
import TransactionInput from '../transaction/TransactionInput.js';
|
|
5
|
-
import TransactionOutput from '../transaction/TransactionOutput.js';
|
|
6
|
-
export default class TransactionSignature extends Signature {
|
|
7
|
-
static readonly SIGHASH_ALL = 1;
|
|
8
|
-
static readonly SIGHASH_NONE = 2;
|
|
9
|
-
static readonly SIGHASH_SINGLE = 3;
|
|
10
|
-
static readonly SIGHASH_FORKID = 64;
|
|
11
|
-
static readonly SIGHASH_ANYONECANPAY = 128;
|
|
12
|
-
scope: number;
|
|
13
|
-
static format(params: {
|
|
14
|
-
sourceTXID: string;
|
|
15
|
-
sourceOutputIndex: number;
|
|
16
|
-
sourceSatoshis: number;
|
|
17
|
-
transactionVersion: number;
|
|
18
|
-
otherInputs: TransactionInput[];
|
|
19
|
-
outputs: TransactionOutput[];
|
|
20
|
-
inputIndex: number;
|
|
21
|
-
subscript: Script;
|
|
22
|
-
inputSequence: number;
|
|
23
|
-
lockTime: number;
|
|
24
|
-
scope: number;
|
|
25
|
-
}): number[];
|
|
26
|
-
static fromChecksigFormat(buf: number[]): TransactionSignature;
|
|
27
|
-
constructor(r: BigNumber, s: BigNumber, scope: number);
|
|
28
|
-
/**
|
|
29
|
-
* Compares to bitcoind's IsLowDERSignature
|
|
30
|
-
* See also Ecdsa signature algorithm which enforces this.
|
|
31
|
-
* See also Bip 62, "low S values in signatures"
|
|
32
|
-
*/
|
|
33
|
-
hasLowS(): boolean;
|
|
34
|
-
toChecksigFormat(): number[];
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=TransactionSignature.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionSignature.d.ts","sourceRoot":"","sources":["../../../../src/primitives/TransactionSignature.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,SAAS,MAAM,gBAAgB,CAAA;AAGtC,OAAO,MAAM,MAAM,qBAAqB,CAAA;AACxC,OAAO,gBAAgB,MAAM,oCAAoC,CAAA;AACjE,OAAO,iBAAiB,MAAM,qCAAqC,CAAA;AAEnE,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,SAAS;IACzD,gBAAuB,WAAW,KAAa;IAC/C,gBAAuB,YAAY,KAAa;IAChD,gBAAuB,cAAc,KAAa;IAClD,gBAAuB,cAAc,MAAa;IAClD,gBAAuB,oBAAoB,OAAa;IAExD,KAAK,EAAE,MAAM,CAAA;IAEb,MAAM,CAAC,MAAM,CAAE,MAAM,EAAE;QACrB,UAAU,EAAE,MAAM,CAAA;QAClB,iBAAiB,EAAE,MAAM,CAAA;QACzB,cAAc,EAAE,MAAM,CAAA;QACtB,kBAAkB,EAAE,MAAM,CAAA;QAC1B,WAAW,EAAE,gBAAgB,EAAE,CAAA;QAC/B,OAAO,EAAE,iBAAiB,EAAE,CAAA;QAC5B,UAAU,EAAE,MAAM,CAAA;QAClB,SAAS,EAAE,MAAM,CAAA;QACjB,aAAa,EAAE,MAAM,CAAA;QACrB,QAAQ,EAAE,MAAM,CAAA;QAChB,KAAK,EAAE,MAAM,CAAA;KACd,GAAG,MAAM,EAAE;IAuHZ,MAAM,CAAC,kBAAkB,CAAE,GAAG,EAAE,MAAM,EAAE,GAAG,oBAAoB;gBAclD,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM;IAKtD;;;;SAIK;IACE,OAAO,IAAK,OAAO;IAY1B,gBAAgB,IAAK,MAAM,EAAE;CAI9B"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export { default as BigNumber } from './BigNumber.js';
|
|
2
|
-
export { default as Curve } from './Curve.js';
|
|
3
|
-
export { default as Point } from './Point.js';
|
|
4
|
-
export { default as PublicKey } from './PublicKey.js';
|
|
5
|
-
export { default as Signature } from './Signature.js';
|
|
6
|
-
export { default as PrivateKey } from './PrivateKey.js';
|
|
7
|
-
export { default as SymmetricKey } from './SymmetricKey.js';
|
|
8
|
-
export * as ECDSA from './ECDSA.js';
|
|
9
|
-
export * as Utils from './utils.js';
|
|
10
|
-
export * as Hash from './Hash.js';
|
|
11
|
-
export { default as Random } from './Random.js';
|
|
12
|
-
export { default as TransactionSignature } from './TransactionSignature.js';
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,2BAA2B,CAAA"}
|