@pezkuwi/util-crypto 14.0.1 → 14.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +4 -4
- package/address/addressToEvm.d.ts +5 -0
- package/address/addressToEvm.js +8 -0
- package/address/check.d.ts +8 -0
- package/address/check.js +26 -0
- package/address/checksum.d.ts +1 -0
- package/address/checksum.js +16 -0
- package/address/decode.d.ts +2 -0
- package/address/decode.js +29 -0
- package/address/defaults.d.ts +6 -0
- package/address/defaults.js +8 -0
- package/address/derive.d.ts +8 -0
- package/address/derive.js +24 -0
- package/address/encode.d.ts +2 -0
- package/address/encode.js +23 -0
- package/address/encodeDerived.d.ts +9 -0
- package/address/encodeDerived.js +12 -0
- package/address/encodeMulti.d.ts +9 -0
- package/address/encodeMulti.js +11 -0
- package/address/eq.d.ts +15 -0
- package/{src/address/eq.ts → address/eq.js} +2 -7
- package/address/evmToAddress.d.ts +7 -0
- package/address/evmToAddress.js +14 -0
- package/{src/address/index.ts → address/index.d.ts} +0 -5
- package/address/index.js +16 -0
- package/address/is.d.ts +2 -0
- package/address/is.js +9 -0
- package/address/keyDerived.d.ts +2 -0
- package/address/keyDerived.js +8 -0
- package/address/keyMulti.d.ts +2 -0
- package/address/keyMulti.js +8 -0
- package/address/setSS58Format.d.ts +6 -0
- package/address/setSS58Format.js +11 -0
- package/address/sort.d.ts +2 -0
- package/address/sort.js +7 -0
- package/address/sshash.d.ts +1 -0
- package/address/sshash.js +6 -0
- package/address/types.d.ts +1 -0
- package/address/types.js +1 -0
- package/address/util.d.ts +1 -0
- package/address/util.js +4 -0
- package/address/validate.d.ts +2 -0
- package/address/validate.js +4 -0
- package/base32/bs32.d.ts +26 -0
- package/{src/base32/bs32.ts → base32/bs32.js} +8 -21
- package/base32/helpers.d.ts +25 -0
- package/base32/helpers.js +61 -0
- package/{src/base32/index.ts → base32/index.d.ts} +0 -4
- package/base32/index.js +4 -0
- package/base58/bs58.d.ts +26 -0
- package/{src/base58/bs58.ts → base58/bs58.js} +4 -13
- package/{src/base58/index.ts → base58/index.d.ts} +0 -4
- package/base58/index.js +4 -0
- package/base64/bs64.d.ts +26 -0
- package/{src/base64/bs64.ts → base64/bs64.js} +4 -13
- package/{src/base64/index.ts → base64/index.d.ts} +0 -4
- package/base64/index.js +6 -0
- package/base64/pad.d.ts +5 -0
- package/base64/pad.js +7 -0
- package/base64/trim.d.ts +5 -0
- package/base64/trim.js +10 -0
- package/blake2/asU8a.d.ts +20 -0
- package/{src/blake2/asU8a.ts → blake2/asU8a.js} +8 -16
- package/{src/blake2/index.ts → blake2/index.d.ts} +0 -4
- package/blake2/index.js +4 -0
- package/bn.d.ts +30 -0
- package/{src/bn.ts → bn.js} +0 -7
- package/bundle-polkadot-util-crypto.js +11813 -0
- package/{src/bundle.ts → bundle.d.ts} +0 -7
- package/bundle.js +26 -0
- package/bundleInit.d.ts +1 -0
- package/bundleInit.js +5 -0
- package/cjs/address/addressToEvm.d.ts +5 -0
- package/cjs/address/addressToEvm.js +11 -0
- package/cjs/address/check.d.ts +8 -0
- package/cjs/address/check.js +29 -0
- package/cjs/address/checksum.d.ts +1 -0
- package/cjs/address/checksum.js +19 -0
- package/cjs/address/decode.d.ts +2 -0
- package/cjs/address/decode.js +32 -0
- package/cjs/address/defaults.d.ts +6 -0
- package/cjs/address/defaults.js +11 -0
- package/cjs/address/derive.d.ts +8 -0
- package/cjs/address/derive.js +27 -0
- package/cjs/address/encode.d.ts +2 -0
- package/cjs/address/encode.js +26 -0
- package/cjs/address/encodeDerived.d.ts +9 -0
- package/cjs/address/encodeDerived.js +15 -0
- package/cjs/address/encodeMulti.d.ts +9 -0
- package/cjs/address/encodeMulti.js +14 -0
- package/cjs/address/eq.d.ts +15 -0
- package/cjs/address/eq.js +22 -0
- package/cjs/address/evmToAddress.d.ts +7 -0
- package/cjs/address/evmToAddress.js +17 -0
- package/cjs/address/index.d.ts +16 -0
- package/cjs/address/index.js +35 -0
- package/cjs/address/is.d.ts +2 -0
- package/cjs/address/is.js +12 -0
- package/cjs/address/keyDerived.d.ts +2 -0
- package/cjs/address/keyDerived.js +11 -0
- package/cjs/address/keyMulti.d.ts +2 -0
- package/cjs/address/keyMulti.js +11 -0
- package/cjs/address/setSS58Format.d.ts +6 -0
- package/cjs/address/setSS58Format.js +14 -0
- package/cjs/address/sort.d.ts +2 -0
- package/cjs/address/sort.js +10 -0
- package/cjs/address/sshash.d.ts +1 -0
- package/cjs/address/sshash.js +9 -0
- package/cjs/address/types.d.ts +1 -0
- package/cjs/address/types.js +2 -0
- package/cjs/address/util.d.ts +1 -0
- package/cjs/address/util.js +7 -0
- package/cjs/address/validate.d.ts +2 -0
- package/cjs/address/validate.js +7 -0
- package/cjs/base32/bs32.d.ts +26 -0
- package/cjs/base32/bs32.js +43 -0
- package/cjs/base32/helpers.d.ts +25 -0
- package/cjs/base32/helpers.js +67 -0
- package/cjs/base32/index.d.ts +4 -0
- package/cjs/base32/index.js +11 -0
- package/cjs/base58/bs58.d.ts +26 -0
- package/cjs/base58/bs58.js +37 -0
- package/cjs/base58/index.d.ts +4 -0
- package/cjs/base58/index.js +11 -0
- package/cjs/base64/bs64.d.ts +26 -0
- package/cjs/base64/bs64.js +37 -0
- package/cjs/base64/index.d.ts +6 -0
- package/cjs/base64/index.js +15 -0
- package/cjs/base64/pad.d.ts +5 -0
- package/cjs/base64/pad.js +10 -0
- package/cjs/base64/trim.d.ts +5 -0
- package/cjs/base64/trim.js +13 -0
- package/cjs/blake2/asU8a.d.ts +20 -0
- package/cjs/blake2/asU8a.js +36 -0
- package/cjs/blake2/index.d.ts +4 -0
- package/cjs/blake2/index.js +9 -0
- package/cjs/bn.d.ts +30 -0
- package/cjs/bn.js +11 -0
- package/cjs/bundle.d.ts +26 -0
- package/cjs/bundle.js +31 -0
- package/cjs/bundleInit.d.ts +1 -0
- package/cjs/bundleInit.js +7 -0
- package/cjs/crypto.d.ts +3 -0
- package/cjs/crypto.js +16 -0
- package/cjs/ed25519/deriveHard.d.ts +1 -0
- package/cjs/ed25519/deriveHard.js +12 -0
- package/{src/ed25519/index.ts → cjs/ed25519/index.d.ts} +0 -3
- package/cjs/ed25519/index.js +20 -0
- package/cjs/ed25519/pair/fromRandom.d.ts +16 -0
- package/cjs/ed25519/pair/fromRandom.js +22 -0
- package/cjs/ed25519/pair/fromSecret.d.ts +16 -0
- package/{src/ed25519/pair/fromSecret.ts → cjs/ed25519/pair/fromSecret.js} +11 -14
- package/cjs/ed25519/pair/fromSeed.d.ts +16 -0
- package/cjs/ed25519/pair/fromSeed.js +34 -0
- package/cjs/ed25519/pair/fromString.d.ts +16 -0
- package/cjs/ed25519/pair/fromString.js +23 -0
- package/cjs/ed25519/sign.d.ts +16 -0
- package/cjs/ed25519/sign.js +33 -0
- package/cjs/ed25519/verify.d.ts +15 -0
- package/cjs/ed25519/verify.js +39 -0
- package/cjs/ethereum/encode.d.ts +2 -0
- package/cjs/ethereum/encode.js +28 -0
- package/{src/ethereum/index.ts → cjs/ethereum/index.d.ts} +0 -3
- package/cjs/ethereum/index.js +9 -0
- package/cjs/ethereum/isAddress.d.ts +1 -0
- package/cjs/ethereum/isAddress.js +14 -0
- package/cjs/ethereum/isChecksum.d.ts +1 -0
- package/cjs/ethereum/isChecksum.js +20 -0
- package/cjs/hd/ethereum/index.d.ts +2 -0
- package/cjs/hd/ethereum/index.js +47 -0
- package/{src/hd/index.ts → cjs/hd/index.d.ts} +0 -3
- package/cjs/hd/index.js +9 -0
- package/cjs/hd/ledger/derivePrivate.d.ts +1 -0
- package/cjs/hd/ledger/derivePrivate.js +15 -0
- package/cjs/hd/ledger/index.d.ts +2 -0
- package/cjs/hd/ledger/index.js +33 -0
- package/cjs/hd/ledger/master.d.ts +1 -0
- package/cjs/hd/ledger/master.js +19 -0
- package/cjs/hd/validatePath.d.ts +2 -0
- package/cjs/hd/validatePath.js +20 -0
- package/cjs/helpers.d.ts +12 -0
- package/cjs/helpers.js +24 -0
- package/cjs/hmac/index.d.ts +1 -0
- package/cjs/hmac/index.js +7 -0
- package/cjs/hmac/shaAsU8a.d.ts +15 -0
- package/cjs/hmac/shaAsU8a.js +40 -0
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +5 -0
- package/cjs/json/constants.d.ts +6 -0
- package/cjs/json/constants.js +8 -0
- package/cjs/json/decrypt.d.ts +2 -0
- package/cjs/json/decrypt.js +16 -0
- package/cjs/json/decryptData.d.ts +2 -0
- package/cjs/json/decryptData.js +32 -0
- package/cjs/json/encrypt.d.ts +2 -0
- package/cjs/json/encrypt.js +18 -0
- package/cjs/json/encryptFormat.d.ts +2 -0
- package/cjs/json/encryptFormat.js +17 -0
- package/{src/json/index.ts → cjs/json/index.d.ts} +0 -3
- package/cjs/json/index.js +11 -0
- package/cjs/json/types.d.ts +16 -0
- package/cjs/json/types.js +2 -0
- package/cjs/keccak/asU8a.d.ts +30 -0
- package/cjs/keccak/asU8a.js +36 -0
- package/{src/keccak/index.ts → cjs/keccak/index.d.ts} +0 -4
- package/cjs/keccak/index.js +11 -0
- package/cjs/key/DeriveJunction.d.ts +12 -0
- package/cjs/key/DeriveJunction.js +62 -0
- package/cjs/key/extractPath.d.ts +9 -0
- package/cjs/key/extractPath.js +26 -0
- package/cjs/key/extractSuri.d.ts +11 -0
- package/cjs/key/extractSuri.js +25 -0
- package/cjs/key/fromPath.d.ts +3 -0
- package/cjs/key/fromPath.js +21 -0
- package/cjs/key/hdkdDerive.d.ts +3 -0
- package/cjs/key/hdkdDerive.js +11 -0
- package/cjs/key/hdkdEcdsa.d.ts +1 -0
- package/cjs/key/hdkdEcdsa.js +7 -0
- package/cjs/key/hdkdEd25519.d.ts +1 -0
- package/cjs/key/hdkdEd25519.js +6 -0
- package/cjs/key/hdkdSr25519.d.ts +3 -0
- package/cjs/key/hdkdSr25519.js +10 -0
- package/{src/key/index.ts → cjs/key/index.d.ts} +0 -3
- package/cjs/key/index.js +18 -0
- package/cjs/mnemonic/bip39.d.ts +5 -0
- package/cjs/mnemonic/bip39.js +90 -0
- package/cjs/mnemonic/generate.d.ts +13 -0
- package/cjs/mnemonic/generate.js +23 -0
- package/{src/mnemonic/index.ts → cjs/mnemonic/index.d.ts} +0 -3
- package/cjs/mnemonic/index.js +16 -0
- package/cjs/mnemonic/toEntropy.d.ts +1 -0
- package/cjs/mnemonic/toEntropy.js +11 -0
- package/cjs/mnemonic/toLegacySeed.d.ts +18 -0
- package/cjs/mnemonic/toLegacySeed.js +37 -0
- package/cjs/mnemonic/toMiniSecret.d.ts +1 -0
- package/cjs/mnemonic/toMiniSecret.js +20 -0
- package/cjs/mnemonic/validate.d.ts +14 -0
- package/cjs/mnemonic/validate.js +24 -0
- package/cjs/mnemonic/wordlists/en.d.ts +2 -0
- package/cjs/mnemonic/wordlists/en.js +3 -0
- package/cjs/mnemonic/wordlists/es.d.ts +2 -0
- package/cjs/mnemonic/wordlists/es.js +3 -0
- package/cjs/mnemonic/wordlists/fr.d.ts +2 -0
- package/cjs/mnemonic/wordlists/fr.js +3 -0
- package/{src/mnemonic/wordlists/index.ts → cjs/mnemonic/wordlists/index.d.ts} +0 -3
- package/cjs/mnemonic/wordlists/index.js +20 -0
- package/cjs/mnemonic/wordlists/it.d.ts +2 -0
- package/cjs/mnemonic/wordlists/it.js +3 -0
- package/cjs/mnemonic/wordlists/jp.d.ts +2 -0
- package/cjs/mnemonic/wordlists/jp.js +3 -0
- package/cjs/mnemonic/wordlists/ko.d.ts +2 -0
- package/cjs/mnemonic/wordlists/ko.js +3 -0
- package/cjs/mnemonic/wordlists/zh-s.d.ts +2 -0
- package/cjs/mnemonic/wordlists/zh-s.js +3 -0
- package/cjs/mnemonic/wordlists/zh-t.d.ts +2 -0
- package/cjs/mnemonic/wordlists/zh-t.js +3 -0
- package/cjs/nacl/decrypt.d.ts +15 -0
- package/cjs/nacl/decrypt.js +21 -0
- package/cjs/nacl/encrypt.d.ts +20 -0
- package/cjs/nacl/encrypt.js +25 -0
- package/{src/nacl/index.ts → cjs/nacl/index.d.ts} +0 -3
- package/cjs/nacl/index.js +10 -0
- package/cjs/nacl/tweetnacl.d.ts +2 -0
- package/cjs/nacl/tweetnacl.js +238 -0
- package/cjs/networks.d.ts +1 -0
- package/cjs/networks.js +7 -0
- package/cjs/package.json +3 -0
- package/cjs/packageDetect.d.ts +1 -0
- package/cjs/packageDetect.js +8 -0
- package/cjs/packageInfo.d.ts +6 -0
- package/cjs/packageInfo.js +4 -0
- package/cjs/pbkdf2/encode.d.ts +7 -0
- package/cjs/pbkdf2/encode.js +19 -0
- package/cjs/pbkdf2/index.d.ts +1 -0
- package/cjs/pbkdf2/index.js +5 -0
- package/cjs/random/asNumber.d.ts +15 -0
- package/cjs/random/asNumber.js +23 -0
- package/cjs/random/asU8a.d.ts +20 -0
- package/cjs/random/asU8a.js +28 -0
- package/{src/random/index.ts → cjs/random/index.d.ts} +0 -4
- package/cjs/random/index.js +11 -0
- package/cjs/scrypt/defaults.d.ts +3 -0
- package/cjs/scrypt/defaults.js +16 -0
- package/cjs/scrypt/encode.d.ts +8 -0
- package/cjs/scrypt/encode.js +18 -0
- package/cjs/scrypt/fromU8a.d.ts +7 -0
- package/cjs/scrypt/fromU8a.js +27 -0
- package/{src/scrypt/index.ts → cjs/scrypt/index.d.ts} +0 -3
- package/cjs/scrypt/index.js +9 -0
- package/cjs/scrypt/toU8a.d.ts +2 -0
- package/cjs/scrypt/toU8a.js +8 -0
- package/cjs/scrypt/types.d.ts +6 -0
- package/cjs/scrypt/types.js +2 -0
- package/cjs/secp256k1/compress.d.ts +1 -0
- package/cjs/secp256k1/compress.js +17 -0
- package/cjs/secp256k1/deriveHard.d.ts +1 -0
- package/cjs/secp256k1/deriveHard.js +13 -0
- package/cjs/secp256k1/expand.d.ts +1 -0
- package/cjs/secp256k1/expand.js +20 -0
- package/cjs/secp256k1/hasher.d.ts +2 -0
- package/cjs/secp256k1/hasher.js +10 -0
- package/{src/secp256k1/index.ts → cjs/secp256k1/index.d.ts} +0 -3
- package/cjs/secp256k1/index.js +17 -0
- package/cjs/secp256k1/pair/fromSeed.d.ts +6 -0
- package/cjs/secp256k1/pair/fromSeed.js +34 -0
- package/cjs/secp256k1/recover.d.ts +6 -0
- package/cjs/secp256k1/recover.js +29 -0
- package/cjs/secp256k1/sign.d.ts +7 -0
- package/cjs/secp256k1/sign.js +23 -0
- package/cjs/secp256k1/tweakAdd.d.ts +1 -0
- package/cjs/secp256k1/tweakAdd.js +48 -0
- package/cjs/secp256k1/types.d.ts +1 -0
- package/cjs/secp256k1/types.js +2 -0
- package/cjs/secp256k1/verify.d.ts +6 -0
- package/cjs/secp256k1/verify.js +23 -0
- package/cjs/sha/asU8a.d.ts +15 -0
- package/cjs/sha/asU8a.js +22 -0
- package/{src/sha/index.ts → cjs/sha/index.d.ts} +0 -4
- package/cjs/sha/index.js +10 -0
- package/cjs/signature/index.d.ts +4 -0
- package/cjs/signature/index.js +8 -0
- package/cjs/signature/verify.d.ts +2 -0
- package/cjs/signature/verify.js +81 -0
- package/cjs/sr25519/agreement.d.ts +5 -0
- package/cjs/sr25519/agreement.js +20 -0
- package/cjs/sr25519/derive.d.ts +2 -0
- package/cjs/sr25519/derive.js +16 -0
- package/cjs/sr25519/deriveHard.d.ts +1 -0
- package/cjs/sr25519/deriveHard.js +7 -0
- package/cjs/sr25519/derivePublic.d.ts +1 -0
- package/cjs/sr25519/derivePublic.js +16 -0
- package/cjs/sr25519/deriveSoft.d.ts +1 -0
- package/cjs/sr25519/deriveSoft.js +7 -0
- package/{src/sr25519/index.ts → cjs/sr25519/index.d.ts} +0 -3
- package/cjs/sr25519/index.js +21 -0
- package/cjs/sr25519/pair/fromSeed.d.ts +6 -0
- package/cjs/sr25519/pair/fromSeed.js +22 -0
- package/cjs/sr25519/pair/fromU8a.d.ts +2 -0
- package/cjs/sr25519/pair/fromU8a.js +17 -0
- package/cjs/sr25519/pair/toU8a.d.ts +2 -0
- package/cjs/sr25519/pair/toU8a.js +7 -0
- package/cjs/sr25519/sign.d.ts +6 -0
- package/cjs/sr25519/sign.js +19 -0
- package/cjs/sr25519/verify.d.ts +5 -0
- package/cjs/sr25519/verify.js +21 -0
- package/cjs/sr25519/vrfSign.d.ts +6 -0
- package/cjs/sr25519/vrfSign.js +19 -0
- package/cjs/sr25519/vrfVerify.d.ts +5 -0
- package/cjs/sr25519/vrfVerify.js +22 -0
- package/cjs/types.d.ts +26 -0
- package/cjs/types.js +5 -0
- package/cjs/xxhash/asU8a.d.ts +20 -0
- package/cjs/xxhash/asU8a.js +39 -0
- package/{src/xxhash/index.ts → cjs/xxhash/index.d.ts} +0 -4
- package/cjs/xxhash/index.js +9 -0
- package/cjs/xxhash/xxhash64.d.ts +1 -0
- package/cjs/xxhash/xxhash64.js +103 -0
- package/crypto.d.ts +3 -0
- package/crypto.js +12 -0
- package/ed25519/deriveHard.d.ts +1 -0
- package/ed25519/deriveHard.js +9 -0
- package/ed25519/index.d.ts +10 -0
- package/ed25519/index.js +10 -0
- package/ed25519/pair/fromRandom.d.ts +16 -0
- package/{src/ed25519/pair/fromRandom.ts → ed25519/pair/fromRandom.js} +2 -8
- package/ed25519/pair/fromSecret.d.ts +16 -0
- package/ed25519/pair/fromSecret.js +23 -0
- package/ed25519/pair/fromSeed.d.ts +16 -0
- package/{src/ed25519/pair/fromSeed.ts → ed25519/pair/fromSeed.js} +11 -21
- package/ed25519/pair/fromString.d.ts +16 -0
- package/{src/ed25519/pair/fromString.ts → ed25519/pair/fromString.js} +2 -13
- package/ed25519/sign.d.ts +16 -0
- package/ed25519/sign.js +30 -0
- package/ed25519/verify.d.ts +15 -0
- package/ed25519/verify.js +36 -0
- package/ethereum/encode.d.ts +2 -0
- package/ethereum/encode.js +25 -0
- package/ethereum/index.d.ts +3 -0
- package/ethereum/index.js +3 -0
- package/ethereum/isAddress.d.ts +1 -0
- package/ethereum/isAddress.js +11 -0
- package/ethereum/isChecksum.d.ts +1 -0
- package/ethereum/isChecksum.js +17 -0
- package/hd/ethereum/index.d.ts +2 -0
- package/hd/ethereum/index.js +44 -0
- package/hd/index.d.ts +3 -0
- package/hd/index.js +3 -0
- package/hd/ledger/derivePrivate.d.ts +1 -0
- package/hd/ledger/derivePrivate.js +12 -0
- package/hd/ledger/index.d.ts +2 -0
- package/hd/ledger/index.js +30 -0
- package/hd/ledger/master.d.ts +1 -0
- package/hd/ledger/master.js +16 -0
- package/hd/validatePath.d.ts +2 -0
- package/hd/validatePath.js +16 -0
- package/helpers.d.ts +12 -0
- package/helpers.js +19 -0
- package/hmac/index.d.ts +1 -0
- package/hmac/index.js +1 -0
- package/hmac/shaAsU8a.d.ts +15 -0
- package/{src/hmac/shaAsU8a.ts → hmac/shaAsU8a.js} +11 -23
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/json/constants.d.ts +6 -0
- package/json/constants.js +5 -0
- package/json/decrypt.d.ts +2 -0
- package/json/decrypt.js +13 -0
- package/json/decryptData.d.ts +2 -0
- package/json/decryptData.js +29 -0
- package/json/encrypt.d.ts +2 -0
- package/json/encrypt.js +15 -0
- package/json/encryptFormat.d.ts +2 -0
- package/json/encryptFormat.js +14 -0
- package/json/index.d.ts +4 -0
- package/json/index.js +4 -0
- package/json/types.d.ts +16 -0
- package/json/types.js +1 -0
- package/keccak/asU8a.d.ts +30 -0
- package/{src/keccak/asU8a.ts → keccak/asU8a.js} +1 -13
- package/keccak/index.d.ts +4 -0
- package/keccak/index.js +4 -0
- package/key/DeriveJunction.d.ts +12 -0
- package/key/DeriveJunction.js +58 -0
- package/key/extractPath.d.ts +9 -0
- package/key/extractPath.js +23 -0
- package/key/extractSuri.d.ts +11 -0
- package/key/extractSuri.js +22 -0
- package/key/fromPath.d.ts +3 -0
- package/key/fromPath.js +18 -0
- package/key/hdkdDerive.d.ts +3 -0
- package/key/hdkdDerive.js +8 -0
- package/key/hdkdEcdsa.d.ts +1 -0
- package/{src/key/hdkdEcdsa.ts → key/hdkdEcdsa.js} +0 -4
- package/key/hdkdEd25519.d.ts +1 -0
- package/{src/key/hdkdEd25519.ts → key/hdkdEd25519.js} +0 -4
- package/key/hdkdSr25519.d.ts +3 -0
- package/key/hdkdSr25519.js +7 -0
- package/key/index.d.ts +9 -0
- package/key/index.js +9 -0
- package/mnemonic/bip39.d.ts +5 -0
- package/mnemonic/bip39.js +82 -0
- package/mnemonic/generate.d.ts +13 -0
- package/{src/mnemonic/generate.ts → mnemonic/generate.js} +4 -9
- package/mnemonic/index.d.ts +8 -0
- package/mnemonic/index.js +8 -0
- package/mnemonic/toEntropy.d.ts +1 -0
- package/mnemonic/toEntropy.js +8 -0
- package/mnemonic/toLegacySeed.d.ts +18 -0
- package/{src/mnemonic/toLegacySeed.ts → mnemonic/toLegacySeed.js} +12 -17
- package/mnemonic/toMiniSecret.d.ts +1 -0
- package/mnemonic/toMiniSecret.js +17 -0
- package/mnemonic/validate.d.ts +14 -0
- package/{src/mnemonic/validate.ts → mnemonic/validate.js} +4 -9
- package/mnemonic/wordlists/en.d.ts +2 -0
- package/{src/mnemonic/wordlists/en.ts → mnemonic/wordlists/en.js} +0 -6
- package/mnemonic/wordlists/es.d.ts +2 -0
- package/{src/mnemonic/wordlists/es.ts → mnemonic/wordlists/es.js} +0 -6
- package/mnemonic/wordlists/fr.d.ts +2 -0
- package/{src/mnemonic/wordlists/fr.ts → mnemonic/wordlists/fr.js} +0 -6
- package/mnemonic/wordlists/index.d.ts +8 -0
- package/mnemonic/wordlists/index.js +8 -0
- package/mnemonic/wordlists/it.d.ts +2 -0
- package/{src/mnemonic/wordlists/it.ts → mnemonic/wordlists/it.js} +0 -6
- package/mnemonic/wordlists/jp.d.ts +2 -0
- package/{src/mnemonic/wordlists/jp.ts → mnemonic/wordlists/jp.js} +0 -6
- package/mnemonic/wordlists/ko.d.ts +2 -0
- package/{src/mnemonic/wordlists/ko.ts → mnemonic/wordlists/ko.js} +0 -6
- package/mnemonic/wordlists/zh-s.d.ts +2 -0
- package/{src/mnemonic/wordlists/zh-s.ts → mnemonic/wordlists/zh-s.js} +0 -6
- package/mnemonic/wordlists/zh-t.d.ts +2 -0
- package/{src/mnemonic/wordlists/zh-t.ts → mnemonic/wordlists/zh-t.js} +0 -6
- package/nacl/decrypt.d.ts +15 -0
- package/{src/nacl/decrypt.ts → nacl/decrypt.js} +2 -6
- package/nacl/encrypt.d.ts +20 -0
- package/{src/nacl/encrypt.ts → nacl/encrypt.js} +5 -14
- package/nacl/index.d.ts +5 -0
- package/nacl/index.js +5 -0
- package/nacl/tweetnacl.d.ts +2 -0
- package/nacl/tweetnacl.js +234 -0
- package/networks.d.ts +1 -0
- package/networks.js +1 -0
- package/package.json +2020 -8
- package/packageDetect.d.ts +1 -0
- package/{src/packageDetect.ts → packageDetect.js} +0 -8
- package/packageInfo.d.ts +6 -0
- package/packageInfo.js +1 -0
- package/pbkdf2/encode.d.ts +7 -0
- package/pbkdf2/encode.js +16 -0
- package/pbkdf2/index.d.ts +1 -0
- package/pbkdf2/index.js +1 -0
- package/random/asNumber.d.ts +15 -0
- package/{src/random/asNumber.ts → random/asNumber.js} +2 -10
- package/random/asU8a.d.ts +20 -0
- package/{src/random/asU8a.ts → random/asU8a.js} +2 -8
- package/random/index.d.ts +5 -0
- package/random/index.js +5 -0
- package/scrypt/defaults.d.ts +3 -0
- package/scrypt/defaults.js +13 -0
- package/scrypt/encode.d.ts +8 -0
- package/scrypt/encode.js +15 -0
- package/scrypt/fromU8a.d.ts +7 -0
- package/scrypt/fromU8a.js +24 -0
- package/scrypt/index.d.ts +3 -0
- package/scrypt/index.js +3 -0
- package/scrypt/toU8a.d.ts +2 -0
- package/scrypt/toU8a.js +5 -0
- package/scrypt/types.d.ts +6 -0
- package/scrypt/types.js +1 -0
- package/secp256k1/compress.d.ts +1 -0
- package/secp256k1/compress.js +14 -0
- package/secp256k1/deriveHard.d.ts +1 -0
- package/secp256k1/deriveHard.js +10 -0
- package/secp256k1/expand.d.ts +1 -0
- package/secp256k1/expand.js +17 -0
- package/secp256k1/hasher.d.ts +2 -0
- package/secp256k1/hasher.js +7 -0
- package/secp256k1/index.d.ts +7 -0
- package/secp256k1/index.js +7 -0
- package/secp256k1/pair/fromSeed.d.ts +6 -0
- package/secp256k1/pair/fromSeed.js +31 -0
- package/secp256k1/recover.d.ts +6 -0
- package/secp256k1/recover.js +26 -0
- package/secp256k1/sign.d.ts +7 -0
- package/secp256k1/sign.js +20 -0
- package/secp256k1/tweakAdd.d.ts +1 -0
- package/secp256k1/tweakAdd.js +45 -0
- package/secp256k1/types.d.ts +1 -0
- package/secp256k1/types.js +1 -0
- package/secp256k1/verify.d.ts +6 -0
- package/secp256k1/verify.js +20 -0
- package/sha/asU8a.d.ts +15 -0
- package/{src/sha/asU8a.ts → sha/asU8a.js} +1 -12
- package/sha/index.d.ts +4 -0
- package/sha/index.js +4 -0
- package/signature/index.d.ts +4 -0
- package/signature/index.js +4 -0
- package/signature/verify.d.ts +2 -0
- package/signature/verify.js +78 -0
- package/sr25519/agreement.d.ts +5 -0
- package/sr25519/agreement.js +17 -0
- package/sr25519/derive.d.ts +2 -0
- package/sr25519/derive.js +12 -0
- package/sr25519/deriveHard.d.ts +1 -0
- package/{src/sr25519/deriveHard.ts → sr25519/deriveHard.js} +0 -6
- package/sr25519/derivePublic.d.ts +1 -0
- package/sr25519/derivePublic.js +12 -0
- package/sr25519/deriveSoft.d.ts +1 -0
- package/{src/sr25519/deriveSoft.ts → sr25519/deriveSoft.js} +0 -6
- package/sr25519/index.d.ts +9 -0
- package/sr25519/index.js +9 -0
- package/sr25519/pair/fromSeed.d.ts +6 -0
- package/sr25519/pair/fromSeed.js +18 -0
- package/sr25519/pair/fromU8a.d.ts +2 -0
- package/sr25519/pair/fromU8a.js +14 -0
- package/sr25519/pair/toU8a.d.ts +2 -0
- package/sr25519/pair/toU8a.js +4 -0
- package/sr25519/sign.d.ts +6 -0
- package/sr25519/sign.js +15 -0
- package/sr25519/verify.d.ts +5 -0
- package/sr25519/verify.js +17 -0
- package/sr25519/vrfSign.d.ts +6 -0
- package/sr25519/vrfSign.js +15 -0
- package/sr25519/vrfVerify.d.ts +5 -0
- package/sr25519/vrfVerify.js +18 -0
- package/types.d.ts +26 -0
- package/types.js +2 -0
- package/xxhash/asU8a.d.ts +20 -0
- package/{src/xxhash/asU8a.ts → xxhash/asU8a.js} +11 -21
- package/xxhash/index.d.ts +4 -0
- package/xxhash/index.js +4 -0
- package/xxhash/xxhash64.d.ts +1 -0
- package/xxhash/xxhash64.js +100 -0
- package/src/address/addressToEvm.spec.ts +0 -16
- package/src/address/addressToEvm.ts +0 -12
- package/src/address/check.spec.ts +0 -44
- package/src/address/check.ts +0 -34
- package/src/address/checksum.spec.ts +0 -45
- package/src/address/checksum.ts +0 -25
- package/src/address/decode.spec.ts +0 -138
- package/src/address/decode.ts +0 -41
- package/src/address/defaults.ts +0 -12
- package/src/address/derive.spec.ts +0 -26
- package/src/address/derive.ts +0 -36
- package/src/address/encode.spec.ts +0 -177
- package/src/address/encode.ts +0 -43
- package/src/address/encodeDerived.spec.ts +0 -14
- package/src/address/encodeDerived.ts +0 -19
- package/src/address/encodeMulti.spec.ts +0 -18
- package/src/address/encodeMulti.ts +0 -18
- package/src/address/eq.spec.ts +0 -45
- package/src/address/evmToAddress.spec.ts +0 -20
- package/src/address/evmToAddress.ts +0 -24
- package/src/address/is.spec.ts +0 -113
- package/src/address/is.ts +0 -14
- package/src/address/keyDerived.spec.ts +0 -24
- package/src/address/keyDerived.ts +0 -22
- package/src/address/keyMulti.spec.ts +0 -20
- package/src/address/keyMulti.ts +0 -23
- package/src/address/setSS58Format.spec.ts +0 -21
- package/src/address/setSS58Format.ts +0 -20
- package/src/address/sort.spec.ts +0 -22
- package/src/address/sort.ts +0 -17
- package/src/address/sshash.ts +0 -12
- package/src/address/types.ts +0 -6
- package/src/address/util.ts +0 -8
- package/src/address/validate.spec.ts +0 -113
- package/src/address/validate.ts +0 -10
- package/src/base32/decode.spec.ts +0 -34
- package/src/base32/encode.spec.ts +0 -30
- package/src/base32/helpers.ts +0 -93
- package/src/base32/is.spec.ts +0 -32
- package/src/base32/validate.spec.ts +0 -44
- package/src/base58/decode.spec.ts +0 -31
- package/src/base58/encode.spec.ts +0 -26
- package/src/base58/validate.spec.ts +0 -20
- package/src/base64/decode.spec.ts +0 -42
- package/src/base64/encode.spec.ts +0 -14
- package/src/base64/pad.spec.ts +0 -14
- package/src/base64/pad.ts +0 -10
- package/src/base64/trim.spec.ts +0 -14
- package/src/base64/trim.ts +0 -14
- package/src/base64/validate.spec.ts +0 -32
- package/src/blake2/asHex.spec.ts +0 -57
- package/src/blake2/asU8a.spec.ts +0 -74
- package/src/bundleInit.ts +0 -11
- package/src/crypto.spec.ts +0 -18
- package/src/crypto.ts +0 -18
- package/src/ed25519/deriveHard.ts +0 -18
- package/src/ed25519/pair/fromRandom.spec.ts +0 -28
- package/src/ed25519/pair/fromSecret.spec.ts +0 -33
- package/src/ed25519/pair/fromSeed.spec.ts +0 -42
- package/src/ed25519/pair/fromString.spec.ts +0 -17
- package/src/ed25519/sign.spec.ts +0 -40
- package/src/ed25519/sign.ts +0 -38
- package/src/ed25519/verify.spec.ts +0 -84
- package/src/ed25519/verify.ts +0 -41
- package/src/ethereum/encode.spec.ts +0 -59
- package/src/ethereum/encode.ts +0 -39
- package/src/ethereum/isAddress.spec.ts +0 -34
- package/src/ethereum/isAddress.ts +0 -16
- package/src/ethereum/isChecksum.ts +0 -27
- package/src/ethereum/isCheksum.spec.ts +0 -30
- package/src/hd/ethereum/index.spec.ts +0 -54
- package/src/hd/ethereum/index.ts +0 -69
- package/src/hd/ledger/derivePrivate.ts +0 -34
- package/src/hd/ledger/index.spec.ts +0 -64
- package/src/hd/ledger/index.ts +0 -42
- package/src/hd/ledger/master.spec.ts +0 -19
- package/src/hd/ledger/master.ts +0 -26
- package/src/hd/validatePath.spec.ts +0 -30
- package/src/hd/validatePath.ts +0 -24
- package/src/helpers.ts +0 -38
- package/src/hmac/index.ts +0 -4
- package/src/hmac/shaAsU8a.spec.ts +0 -45
- package/src/index.ts +0 -6
- package/src/json/constants.ts +0 -11
- package/src/json/decrypt.ts +0 -25
- package/src/json/decryptData.ts +0 -45
- package/src/json/encrypt.ts +0 -25
- package/src/json/encryptFormat.ts +0 -20
- package/src/json/types.ts +0 -22
- package/src/keccak/asHex.spec.ts +0 -30
- package/src/keccak/asU8a.spec.ts +0 -56
- package/src/key/DeriveJunction.ts +0 -79
- package/src/key/extractPath.spec.ts +0 -51
- package/src/key/extractPath.ts +0 -37
- package/src/key/extractSuri.spec.ts +0 -147
- package/src/key/extractSuri.ts +0 -40
- package/src/key/fromPath.ts +0 -28
- package/src/key/hdkdDerive.ts +0 -17
- package/src/key/hdkdSr25519.ts +0 -14
- package/src/mnemonic/bip39.spec.ts +0 -80
- package/src/mnemonic/bip39.ts +0 -127
- package/src/mnemonic/generate.spec.ts +0 -58
- package/src/mnemonic/toEntropy.spec.ts +0 -36
- package/src/mnemonic/toEntropy.ts +0 -13
- package/src/mnemonic/toLegacySeed.spec.ts +0 -52
- package/src/mnemonic/toMiniSecret.spec.ts +0 -67
- package/src/mnemonic/toMiniSecret.ts +0 -23
- package/src/mnemonic/toMiniSecretCmp.spec.ts +0 -64
- package/src/mnemonic/validate.spec.ts +0 -39
- package/src/mod.ts +0 -4
- package/src/nacl/decrypt.spec.ts +0 -26
- package/src/nacl/encrypt.spec.ts +0 -20
- package/src/nacl/tweetnacl-secretbox-data.spec.ts +0 -4629
- package/src/nacl/tweetnacl-secretbox.spec.ts +0 -161
- package/src/nacl/tweetnacl.ts +0 -1159
- package/src/networks.ts +0 -5
- package/src/packageInfo.ts +0 -6
- package/src/pbkdf2/encode.spec.ts +0 -54
- package/src/pbkdf2/encode.ts +0 -29
- package/src/pbkdf2/index.ts +0 -4
- package/src/random/asHex.spec.ts +0 -38
- package/src/random/asNumber.spec.ts +0 -16
- package/src/random/asU8a.spec.ts +0 -36
- package/src/scrypt/defaults.ts +0 -19
- package/src/scrypt/encode.spec.ts +0 -43
- package/src/scrypt/encode.ts +0 -30
- package/src/scrypt/fromU8a.ts +0 -44
- package/src/scrypt/toU8a.ts +0 -17
- package/src/scrypt/types.ts +0 -9
- package/src/secp256k1/compress.spec.ts +0 -47
- package/src/secp256k1/compress.ts +0 -21
- package/src/secp256k1/deriveHard.ts +0 -17
- package/src/secp256k1/expand.spec.ts +0 -47
- package/src/secp256k1/expand.ts +0 -30
- package/src/secp256k1/hasher.spec.ts +0 -24
- package/src/secp256k1/hasher.ts +0 -13
- package/src/secp256k1/pair/fromSeed.spec.ts +0 -75
- package/src/secp256k1/pair/fromSeed.ts +0 -42
- package/src/secp256k1/recover.spec.ts +0 -35
- package/src/secp256k1/recover.ts +0 -36
- package/src/secp256k1/sign.spec.ts +0 -39
- package/src/secp256k1/sign.ts +0 -37
- package/src/secp256k1/signVerify.spec.ts +0 -94
- package/src/secp256k1/tweakAdd.spec.ts +0 -35
- package/src/secp256k1/tweakAdd.ts +0 -65
- package/src/secp256k1/types.ts +0 -4
- package/src/secp256k1/verify.spec.ts +0 -81
- package/src/secp256k1/verify.ts +0 -32
- package/src/sha/asU8a256.spec.ts +0 -55
- package/src/sha/asU8a512.spec.ts +0 -33
- package/src/signature/index.ts +0 -8
- package/src/signature/verify.spec.ts +0 -230
- package/src/signature/verify.ts +0 -114
- package/src/sr25519/agreement.spec.ts +0 -31
- package/src/sr25519/agreement.ts +0 -23
- package/src/sr25519/derive.ts +0 -21
- package/src/sr25519/derivePublic.ts +0 -18
- package/src/sr25519/pair/fromSeed.spec.ts +0 -35
- package/src/sr25519/pair/fromSeed.ts +0 -28
- package/src/sr25519/pair/fromU8a.ts +0 -23
- package/src/sr25519/pair/testing.spec.ts +0 -161
- package/src/sr25519/pair/toU8a.ts +0 -10
- package/src/sr25519/sign.spec.ts +0 -28
- package/src/sr25519/sign.ts +0 -22
- package/src/sr25519/verify.spec.ts +0 -42
- package/src/sr25519/verify.ts +0 -23
- package/src/sr25519/vrfSign.ts +0 -24
- package/src/sr25519/vrfSignVerify.spec.ts +0 -73
- package/src/sr25519/vrfVerify.ts +0 -25
- package/src/test/index.ts +0 -8
- package/src/test/performance.ts +0 -17
- package/src/types.ts +0 -33
- package/src/xxhash/asHex.spec.ts +0 -36
- package/src/xxhash/asU8a.spec.ts +0 -48
- package/src/xxhash/xxhash64.ts +0 -155
- package/tsconfig.build.json +0 -18
- package/tsconfig.spec.json +0 -20
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { Keypair } from '../../types.js';
|
|
5
|
-
|
|
6
|
-
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
7
|
-
|
|
8
|
-
import { hasBigInt, u8aEmpty } from '@pezkuwi/util';
|
|
9
|
-
import { isReady, secp256k1FromSeed } from '@pezkuwi/wasm-crypto';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @name secp256k1PairFromSeed
|
|
13
|
-
* @description Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
|
|
14
|
-
*/
|
|
15
|
-
export function secp256k1PairFromSeed (seed: Uint8Array, onlyJs?: boolean): Keypair {
|
|
16
|
-
if (seed.length !== 32) {
|
|
17
|
-
throw new Error('Expected valid 32-byte private key as a seed');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (!hasBigInt || (!onlyJs && isReady())) {
|
|
21
|
-
const full = secp256k1FromSeed(seed);
|
|
22
|
-
const publicKey = full.slice(32);
|
|
23
|
-
|
|
24
|
-
// There is an issue with the secp256k1 when running in an ASM.js environment where
|
|
25
|
-
// it seems that the lazy static section yields invalid results on the _first_ run.
|
|
26
|
-
// If this happens, fail outright, we cannot allow invalid return values
|
|
27
|
-
// https://github.com/polkadot-js/wasm/issues/307
|
|
28
|
-
if (u8aEmpty(publicKey)) {
|
|
29
|
-
throw new Error('Invalid publicKey generated from WASM interface');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
publicKey,
|
|
34
|
-
secretKey: full.slice(0, 32)
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
publicKey: secp256k1.getPublicKey(seed, true),
|
|
40
|
-
secretKey: seed
|
|
41
|
-
};
|
|
42
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
|
5
|
-
|
|
6
|
-
import { u8aToHex, u8aToU8a } from '@pezkuwi/util';
|
|
7
|
-
import { waitReady } from '@pezkuwi/wasm-crypto';
|
|
8
|
-
|
|
9
|
-
import { keccakAsU8a } from '../keccak/index.js';
|
|
10
|
-
import { perfWasm } from '../test/index.js';
|
|
11
|
-
import { secp256k1Recover } from './index.js';
|
|
12
|
-
|
|
13
|
-
const sig = u8aToU8a('0x7505f2880114da51b3f5d535f8687953c0ab9af4ab81e592eaebebf53b728d2b6dfd9b5bcd70fee412b1f31360e7c2774009305cb84fc50c1d0ff8034dfa5fff');
|
|
14
|
-
const msg = u8aToU8a('0xa30b64ce1eedf409c8afb801d72c05234e64849ea538c15dd3c8cf4ffcf166c9');
|
|
15
|
-
|
|
16
|
-
describe('secp256k1Recover', (): void => {
|
|
17
|
-
beforeEach(async (): Promise<void> => {
|
|
18
|
-
await waitReady();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
for (const onlyJs of [false, true]) {
|
|
22
|
-
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
|
23
|
-
it('recovers a publicKey', (): void => {
|
|
24
|
-
const pubKey = '0x93a9fc7154c6da3c826415df01eb0e37fb4da4b0';
|
|
25
|
-
const res = keccakAsU8a(secp256k1Recover(msg, sig, 0, undefined, onlyJs));
|
|
26
|
-
|
|
27
|
-
expect(u8aToHex(res.subarray(-20))).toEqual(pubKey);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
perfWasm('secp256k1Recover', 200, (_, onlyJs) =>
|
|
33
|
-
secp256k1Recover(msg, sig, 0, undefined, onlyJs)
|
|
34
|
-
);
|
|
35
|
-
});
|
package/src/secp256k1/recover.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { HashType } from './types.js';
|
|
5
|
-
|
|
6
|
-
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
7
|
-
|
|
8
|
-
import { hasBigInt, u8aToU8a } from '@pezkuwi/util';
|
|
9
|
-
import { isReady, secp256k1Recover as wasm } from '@pezkuwi/wasm-crypto';
|
|
10
|
-
|
|
11
|
-
import { secp256k1Compress } from './compress.js';
|
|
12
|
-
import { secp256k1Expand } from './expand.js';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @name secp256k1Recover
|
|
16
|
-
* @description Recovers a publicKey from the supplied signature
|
|
17
|
-
*/
|
|
18
|
-
export function secp256k1Recover (msgHash: string | Uint8Array, signature: string | Uint8Array, recovery: number, hashType: HashType = 'blake2', onlyJs?: boolean): Uint8Array {
|
|
19
|
-
const sig = u8aToU8a(signature).subarray(0, 64);
|
|
20
|
-
const msg = u8aToU8a(msgHash);
|
|
21
|
-
const publicKey = !hasBigInt || (!onlyJs && isReady())
|
|
22
|
-
? wasm(msg, sig, recovery)
|
|
23
|
-
: secp256k1.Signature
|
|
24
|
-
.fromCompact(sig)
|
|
25
|
-
.addRecoveryBit(recovery)
|
|
26
|
-
.recoverPublicKey(msg)
|
|
27
|
-
.toRawBytes();
|
|
28
|
-
|
|
29
|
-
if (!publicKey) {
|
|
30
|
-
throw new Error('Unable to recover publicKey from signature');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return hashType === 'keccak'
|
|
34
|
-
? secp256k1Expand(publicKey, onlyJs)
|
|
35
|
-
: secp256k1Compress(publicKey, onlyJs);
|
|
36
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
|
5
|
-
|
|
6
|
-
import { hexToU8a } from '@pezkuwi/util';
|
|
7
|
-
import { waitReady } from '@pezkuwi/wasm-crypto';
|
|
8
|
-
|
|
9
|
-
import { perfWasm } from '../test/index.js';
|
|
10
|
-
import { secp256k1PairFromSeed, secp256k1Sign } from './index.js';
|
|
11
|
-
|
|
12
|
-
const pair = secp256k1PairFromSeed(hexToU8a('0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae'));
|
|
13
|
-
const msg = hexToU8a('0xa30b64ce1eedf409c8afb801d72c05234e64849ea538c15dd3c8cf4ffcf166c9');
|
|
14
|
-
|
|
15
|
-
describe('sign', (): void => {
|
|
16
|
-
beforeEach(async (): Promise<void> => {
|
|
17
|
-
await waitReady();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
for (const onlyJs of [false, true]) {
|
|
21
|
-
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
|
22
|
-
it('generates a known signature', (): void => {
|
|
23
|
-
expect(
|
|
24
|
-
secp256k1Sign(msg, pair, undefined, onlyJs)
|
|
25
|
-
).toEqual(hexToU8a(
|
|
26
|
-
// from elliptic, this is - 0xdf92f73d9f060cefacf187b5414491cb992998ace017fa48839b5cda3e264ba8c4efa521361678d9b8582744d77aa4b8d886d7380b7808a683174afad9c4700300
|
|
27
|
-
// libsecp256k1 & @noble/hashes do agree here...
|
|
28
|
-
'0xdf92f73d9f060cefacf187b5414491cb992998ace017fa48839b5cda3e264ba83b105adec9e9872647a7d8bb28855b45e22805aea3d097953cbb1391f671d13e01'
|
|
29
|
-
));
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// since the libsecp256k1 signatures don't match (but can be verified), we
|
|
35
|
-
// do both signing and verification here (checking the extracted key)
|
|
36
|
-
perfWasm('secp256k1Sign', 1000, (_, onlyJs) =>
|
|
37
|
-
secp256k1Sign(msg, pair, undefined, onlyJs)
|
|
38
|
-
);
|
|
39
|
-
});
|
package/src/secp256k1/sign.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { Keypair } from '../types.js';
|
|
5
|
-
import type { HashType } from './types.js';
|
|
6
|
-
|
|
7
|
-
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
8
|
-
|
|
9
|
-
import { bnToU8a, hasBigInt, u8aConcat } from '@pezkuwi/util';
|
|
10
|
-
import { isReady, secp256k1Sign as wasm } from '@pezkuwi/wasm-crypto';
|
|
11
|
-
|
|
12
|
-
import { BN_BE_256_OPTS } from '../bn.js';
|
|
13
|
-
import { hasher } from './hasher.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @name secp256k1Sign
|
|
17
|
-
* @description Returns message signature of `message`, using the supplied pair
|
|
18
|
-
*/
|
|
19
|
-
export function secp256k1Sign (message: Uint8Array | string, { secretKey }: Partial<Keypair>, hashType: HashType = 'blake2', onlyJs?: boolean): Uint8Array {
|
|
20
|
-
if (secretKey?.length !== 32) {
|
|
21
|
-
throw new Error('Expected valid secp256k1 secretKey, 32-bytes');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const data = hasher(hashType, message, onlyJs);
|
|
25
|
-
|
|
26
|
-
if (!hasBigInt || (!onlyJs && isReady())) {
|
|
27
|
-
return wasm(data, secretKey);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const signature = secp256k1.sign(data, secretKey, { lowS: true });
|
|
31
|
-
|
|
32
|
-
return u8aConcat(
|
|
33
|
-
bnToU8a(signature.r, BN_BE_256_OPTS),
|
|
34
|
-
bnToU8a(signature.s, BN_BE_256_OPTS),
|
|
35
|
-
new Uint8Array([signature.recovery || 0])
|
|
36
|
-
);
|
|
37
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
|
5
|
-
|
|
6
|
-
import '../bundleInit.js';
|
|
7
|
-
|
|
8
|
-
import { stringToU8a } from '@pezkuwi/util';
|
|
9
|
-
|
|
10
|
-
import { randomAsU8a } from '../random/asU8a.js';
|
|
11
|
-
import { hasher } from './hasher.js';
|
|
12
|
-
import { secp256k1Expand, secp256k1PairFromSeed, secp256k1Sign, secp256k1Verify } from './index.js';
|
|
13
|
-
|
|
14
|
-
const MESSAGE = stringToU8a('this is a message');
|
|
15
|
-
|
|
16
|
-
describe('sign and verify', (): void => {
|
|
17
|
-
it('verify message signature', (): void => {
|
|
18
|
-
const address = '0x59f587c045d4d4e9aa1016eae43770fc0551df8a385027723342753a876aeef0';
|
|
19
|
-
const sig = '0x92fcacf0946bbd10b31dfe16d567ed1d3014e81007dd9e5256e19c0f07eacc1643b151ca29e449a765e16a7ce59b88d800467d6b3412d30ea8ad22307a59664b00';
|
|
20
|
-
const msg = stringToU8a('secp256k1');
|
|
21
|
-
|
|
22
|
-
expect(secp256k1Verify(msg, sig, address)).toEqual(true);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('has 65-byte signatures', (): void => {
|
|
26
|
-
const pair = secp256k1PairFromSeed(randomAsU8a());
|
|
27
|
-
|
|
28
|
-
expect(secp256k1Sign(MESSAGE, pair)).toHaveLength(65);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('signs/verifies a message by random key (blake2)', (): void => {
|
|
32
|
-
const pair = secp256k1PairFromSeed(randomAsU8a());
|
|
33
|
-
const signature = secp256k1Sign(MESSAGE, pair);
|
|
34
|
-
const address = hasher('blake2', pair.publicKey);
|
|
35
|
-
|
|
36
|
-
expect(secp256k1Verify(MESSAGE, signature, address)).toEqual(true);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('signs/verifies a message by random key (keccak)', (): void => {
|
|
40
|
-
const pair = secp256k1PairFromSeed(randomAsU8a());
|
|
41
|
-
const signature = secp256k1Sign(MESSAGE, pair, 'keccak');
|
|
42
|
-
const address = hasher('keccak', secp256k1Expand(pair.publicKey));
|
|
43
|
-
|
|
44
|
-
expect(secp256k1Verify(MESSAGE, signature, address, 'keccak')).toEqual(true);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('fails verification on hasher mismatches', (): void => {
|
|
48
|
-
const pair = secp256k1PairFromSeed(randomAsU8a());
|
|
49
|
-
const signature = secp256k1Sign(MESSAGE, pair, 'keccak');
|
|
50
|
-
const address = hasher('keccak', secp256k1Expand(pair.publicKey));
|
|
51
|
-
|
|
52
|
-
expect(secp256k1Verify(MESSAGE, signature, address, 'blake2')).toEqual(false);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('works over a range of random keys (blake2)', (): void => {
|
|
56
|
-
for (let i = 0; i < 256; i++) {
|
|
57
|
-
const pair = secp256k1PairFromSeed(randomAsU8a());
|
|
58
|
-
|
|
59
|
-
try {
|
|
60
|
-
expect(
|
|
61
|
-
secp256k1Verify(
|
|
62
|
-
MESSAGE,
|
|
63
|
-
secp256k1Sign(MESSAGE, pair, 'blake2'),
|
|
64
|
-
hasher('blake2', pair.publicKey),
|
|
65
|
-
'blake2'
|
|
66
|
-
)
|
|
67
|
-
).toEqual(true);
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.error(`blake2 failed on #${i}`);
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}, 120000);
|
|
74
|
-
|
|
75
|
-
it('works over a range of random keys (keccak)', (): void => {
|
|
76
|
-
for (let i = 0; i < 256; i++) {
|
|
77
|
-
const pair = secp256k1PairFromSeed(randomAsU8a());
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
expect(
|
|
81
|
-
secp256k1Verify(
|
|
82
|
-
MESSAGE,
|
|
83
|
-
secp256k1Sign(MESSAGE, pair, 'keccak'),
|
|
84
|
-
hasher('keccak', secp256k1Expand(pair.publicKey)),
|
|
85
|
-
'keccak'
|
|
86
|
-
)
|
|
87
|
-
).toEqual(true);
|
|
88
|
-
} catch (error) {
|
|
89
|
-
console.error(`keccak failed on #${i}`);
|
|
90
|
-
throw error;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}, 120000);
|
|
94
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
|
5
|
-
|
|
6
|
-
import { secp256k1PrivateKeyTweakAdd } from './tweakAdd.js';
|
|
7
|
-
|
|
8
|
-
describe('TweakAdd', (): void => {
|
|
9
|
-
it('fails for wrong array length', (): void => {
|
|
10
|
-
const A = new Uint8Array([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]);
|
|
11
|
-
const B = new Uint8Array([3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]);
|
|
12
|
-
|
|
13
|
-
expect(
|
|
14
|
-
() => secp256k1PrivateKeyTweakAdd(A, B)
|
|
15
|
-
).toThrow(/Expected tweak to be an Uint8Array/);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
for (const onlyBn of [false, true]) {
|
|
19
|
-
describe(`onlyBn=${(onlyBn && 'true') || 'false'}`, (): void => {
|
|
20
|
-
it('succeeds for a simple case', (): void => {
|
|
21
|
-
const A = new Uint8Array([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]);
|
|
22
|
-
const B = new Uint8Array([3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]);
|
|
23
|
-
|
|
24
|
-
expect(
|
|
25
|
-
secp256k1PrivateKeyTweakAdd(A, B, onlyBn)
|
|
26
|
-
).toEqual(new Uint8Array([
|
|
27
|
-
3, 4, 3, 4, 3, 4, 3, 4, 3,
|
|
28
|
-
4, 3, 4, 3, 4, 3, 4, 3, 4,
|
|
29
|
-
3, 4, 3, 4, 3, 4, 3, 4, 3,
|
|
30
|
-
4, 3, 4, 3, 4
|
|
31
|
-
]));
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { _0n, BN, bnToU8a, hasBigInt, isU8a, nToU8a, u8aToBigInt } from '@pezkuwi/util';
|
|
5
|
-
import { BigInt } from '@pezkuwi/x-bigint';
|
|
6
|
-
|
|
7
|
-
import { BN_BE_256_OPTS, BN_BE_OPTS } from '../bn.js';
|
|
8
|
-
|
|
9
|
-
// pre-defined curve param as lifted form elliptic
|
|
10
|
-
// https://github.com/indutny/elliptic/blob/e71b2d9359c5fe9437fbf46f1f05096de447de57/lib/elliptic/curves.js#L182
|
|
11
|
-
const N = 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141'.replace(/ /g, '');
|
|
12
|
-
const N_BI = BigInt(`0x${N}`);
|
|
13
|
-
const N_BN = new BN(N, 'hex');
|
|
14
|
-
|
|
15
|
-
function addBi (seckey: Uint8Array, tweak: Uint8Array): Uint8Array {
|
|
16
|
-
let res = u8aToBigInt(tweak, BN_BE_OPTS);
|
|
17
|
-
|
|
18
|
-
if (res >= N_BI) {
|
|
19
|
-
throw new Error('Tweak parameter is out of range');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
res += u8aToBigInt(seckey, BN_BE_OPTS);
|
|
23
|
-
|
|
24
|
-
if (res >= N_BI) {
|
|
25
|
-
res -= N_BI;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (res === _0n) {
|
|
29
|
-
throw new Error('Invalid resulting private key');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return nToU8a(res, BN_BE_256_OPTS);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function addBn (seckey: Uint8Array, tweak: Uint8Array): Uint8Array {
|
|
36
|
-
const res = new BN(tweak);
|
|
37
|
-
|
|
38
|
-
if (res.cmp(N_BN) >= 0) {
|
|
39
|
-
throw new Error('Tweak parameter is out of range');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
res.iadd(new BN(seckey));
|
|
43
|
-
|
|
44
|
-
if (res.cmp(N_BN) >= 0) {
|
|
45
|
-
res.isub(N_BN);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (res.isZero()) {
|
|
49
|
-
throw new Error('Invalid resulting private key');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return bnToU8a(res, BN_BE_256_OPTS);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function secp256k1PrivateKeyTweakAdd (seckey: Uint8Array, tweak: Uint8Array, onlyBn?: boolean): Uint8Array {
|
|
56
|
-
if (!isU8a(seckey) || seckey.length !== 32) {
|
|
57
|
-
throw new Error('Expected seckey to be an Uint8Array with length 32');
|
|
58
|
-
} else if (!isU8a(tweak) || tweak.length !== 32) {
|
|
59
|
-
throw new Error('Expected tweak to be an Uint8Array with length 32');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return !hasBigInt || onlyBn
|
|
63
|
-
? addBn(seckey, tweak)
|
|
64
|
-
: addBi(seckey, tweak);
|
|
65
|
-
}
|
package/src/secp256k1/types.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
|
5
|
-
|
|
6
|
-
import '../bundleInit.js';
|
|
7
|
-
|
|
8
|
-
import { hexToU8a } from '@pezkuwi/util';
|
|
9
|
-
import { waitReady } from '@pezkuwi/wasm-crypto';
|
|
10
|
-
|
|
11
|
-
import { perfWasm } from '../test/index.js';
|
|
12
|
-
import { hasher } from './hasher.js';
|
|
13
|
-
import { secp256k1PairFromSeed, secp256k1Verify } from './index.js';
|
|
14
|
-
|
|
15
|
-
const message = 'Pay KSMs to the Kusama account:88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee';
|
|
16
|
-
|
|
17
|
-
describe('secp256k1Verify', (): void => {
|
|
18
|
-
beforeEach(async (): Promise<void> => {
|
|
19
|
-
await waitReady();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
for (const onlyJs of [true]) {
|
|
23
|
-
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
|
24
|
-
it('validates known ETH against address', (): void => {
|
|
25
|
-
expect(
|
|
26
|
-
secp256k1Verify(
|
|
27
|
-
`\x19Ethereum Signed Message:\n${message.length.toString()}${message}`,
|
|
28
|
-
'0x55bd020bdbbdc02de34e915effc9b18a99002f4c29f64e22e8dcbb69e722ea6c28e1bb53b9484063fbbfd205e49dcc1f620929f520c9c4c3695150f05a28f52a01',
|
|
29
|
-
'0x002309df96687e44280bb72c3818358faeeb699c',
|
|
30
|
-
'keccak',
|
|
31
|
-
onlyJs
|
|
32
|
-
)
|
|
33
|
-
).toEqual(true);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
for (const isPublic of [false, true]) {
|
|
37
|
-
describe(`validation against known, isPublic=${(isPublic && 'true') || 'false'}`, (): void => {
|
|
38
|
-
const pair = secp256k1PairFromSeed(hexToU8a('0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae'));
|
|
39
|
-
const msg = hexToU8a('0xa30b64ce1eedf409c8afb801d72c05234e64849ea538c15dd3c8cf4ffcf166c9');
|
|
40
|
-
const addr = isPublic
|
|
41
|
-
? pair.publicKey
|
|
42
|
-
: hasher('blake2', pair.publicKey, onlyJs);
|
|
43
|
-
|
|
44
|
-
it('signature from JS', (): void => {
|
|
45
|
-
expect(
|
|
46
|
-
secp256k1Verify(
|
|
47
|
-
msg,
|
|
48
|
-
'0xdf92f73d9f060cefacf187b5414491cb992998ace017fa48839b5cda3e264ba8c4efa521361678d9b8582744d77aa4b8d886d7380b7808a683174afad9c4700300',
|
|
49
|
-
addr,
|
|
50
|
-
'blake2',
|
|
51
|
-
onlyJs
|
|
52
|
-
)
|
|
53
|
-
).toEqual(true);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('signature from wasm', (): void => {
|
|
57
|
-
expect(
|
|
58
|
-
secp256k1Verify(
|
|
59
|
-
msg,
|
|
60
|
-
'0xdf92f73d9f060cefacf187b5414491cb992998ace017fa48839b5cda3e264ba83b105adec9e9872647a7d8bb28855b45e22805aea3d097953cbb1391f671d13e01',
|
|
61
|
-
addr,
|
|
62
|
-
'blake2',
|
|
63
|
-
onlyJs
|
|
64
|
-
)
|
|
65
|
-
).toEqual(true);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
perfWasm('secp256k1Verify', 100, (_, onlyJs) =>
|
|
73
|
-
secp256k1Verify(
|
|
74
|
-
`\x19Ethereum Signed Message:\n${message.length.toString()}${message}`,
|
|
75
|
-
'0x55bd020bdbbdc02de34e915effc9b18a99002f4c29f64e22e8dcbb69e722ea6c28e1bb53b9484063fbbfd205e49dcc1f620929f520c9c4c3695150f05a28f52a01',
|
|
76
|
-
'0x002309df96687e44280bb72c3818358faeeb699c',
|
|
77
|
-
'keccak',
|
|
78
|
-
onlyJs
|
|
79
|
-
)
|
|
80
|
-
);
|
|
81
|
-
});
|
package/src/secp256k1/verify.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { HashType } from './types.js';
|
|
5
|
-
|
|
6
|
-
import { u8aEq, u8aToU8a } from '@pezkuwi/util';
|
|
7
|
-
|
|
8
|
-
import { hasher } from './hasher.js';
|
|
9
|
-
import { secp256k1Recover } from './recover.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @name secp256k1Verify
|
|
13
|
-
* @description Verifies the signature of `message`, using the supplied pair
|
|
14
|
-
*/
|
|
15
|
-
export function secp256k1Verify (msgHash: string | Uint8Array, signature: string | Uint8Array, address: string | Uint8Array, hashType: HashType = 'blake2', onlyJs?: boolean): boolean {
|
|
16
|
-
const sig = u8aToU8a(signature);
|
|
17
|
-
|
|
18
|
-
if (sig.length !== 65) {
|
|
19
|
-
throw new Error(`Expected signature with 65 bytes, ${sig.length} found instead`);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const publicKey = secp256k1Recover(hasher(hashType, msgHash), sig, sig[64], hashType, onlyJs);
|
|
23
|
-
const signerAddr = hasher(hashType, publicKey, onlyJs);
|
|
24
|
-
const inputAddr = u8aToU8a(address);
|
|
25
|
-
|
|
26
|
-
// for Ethereum (keccak) the last 20 bytes is the address
|
|
27
|
-
return u8aEq(publicKey, inputAddr) || (
|
|
28
|
-
hashType === 'keccak'
|
|
29
|
-
? u8aEq(signerAddr.slice(-20), inputAddr.slice(-20))
|
|
30
|
-
: u8aEq(signerAddr, inputAddr)
|
|
31
|
-
);
|
|
32
|
-
}
|
package/src/sha/asU8a256.spec.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
|
5
|
-
|
|
6
|
-
import { hexToU8a } from '@pezkuwi/util';
|
|
7
|
-
import { waitReady } from '@pezkuwi/wasm-crypto';
|
|
8
|
-
|
|
9
|
-
import { perfWasm } from '../test/index.js';
|
|
10
|
-
import { sha256AsU8a } from './index.js';
|
|
11
|
-
|
|
12
|
-
const TESTS = [
|
|
13
|
-
{
|
|
14
|
-
input: '0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
|
|
15
|
-
output: '0x5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456'
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
input: '0x7941cb07924fdc7b710e11d98d82850e89566e1c3cb980517ffe4b430f86dfd5',
|
|
19
|
-
output: '0xe668668fa102ccd4d3cf50e4472be8426e7dc52d6d355bee8c5e2177d1de81f7'
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
input: '0x5d9a905bc3ca7c153623af0a05231960eb3f5bdd5b8b7b55ede8b2deac689d65',
|
|
23
|
-
output: '0x6721bc38e80d03f4f45f1544819d17e0c33674eb6efcddf6c6192cd78194dd9f'
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
input: '0xb0cd6528ae4d5baf7c6f0d202e7f372b6488d22b2a5bd72f794f8f1e6031b31f',
|
|
27
|
-
output: '0x353f5a030af27885aed3571cd9e2cac9f4331c51d31cef496a586496aec32256'
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
input: '0x841267bd4110e1b634e17cd019abc6ae4f9a6dd097fb063000c1615a643b5463',
|
|
31
|
-
output: '0x8174a30d921978e7055516189872cca737b49468c6bcf7fdfe59d4a54c489a1f'
|
|
32
|
-
}
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
describe('sha256AsU8a', (): void => {
|
|
36
|
-
beforeEach(async (): Promise<void> => {
|
|
37
|
-
await waitReady();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
for (const onlyJs of [false, true]) {
|
|
41
|
-
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
|
42
|
-
for (const { input, output } of TESTS) {
|
|
43
|
-
it(`creates known sha-256 hash, ${output}`, (): void => {
|
|
44
|
-
expect(
|
|
45
|
-
sha256AsU8a(hexToU8a(input), onlyJs)
|
|
46
|
-
).toEqual(hexToU8a(output));
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
perfWasm('sha256AsU8a', 128000, (input, onlyJs) =>
|
|
53
|
-
sha256AsU8a(input, onlyJs)
|
|
54
|
-
);
|
|
55
|
-
});
|
package/src/sha/asU8a512.spec.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
/// <reference types="@polkadot/dev-test/globals.d.ts" />
|
|
5
|
-
|
|
6
|
-
import { waitReady } from '@pezkuwi/wasm-crypto';
|
|
7
|
-
|
|
8
|
-
import { perfWasm } from '../test/index.js';
|
|
9
|
-
import { sha512AsU8a } from './index.js';
|
|
10
|
-
|
|
11
|
-
describe('sha512AsU8a', (): void => {
|
|
12
|
-
beforeEach(async (): Promise<void> => {
|
|
13
|
-
await waitReady();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
for (const onlyJs of [false, true]) {
|
|
17
|
-
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
|
18
|
-
it('creates a sha-512 hash', (): void => {
|
|
19
|
-
expect(
|
|
20
|
-
sha512AsU8a(Uint8Array.from([0x61, 0x62, 0x63, 0x64]), onlyJs)
|
|
21
|
-
).toEqual(
|
|
22
|
-
Uint8Array.from([
|
|
23
|
-
216, 2, 47, 32, 96, 173, 110, 253, 41, 122, 183, 61, 204, 83, 85, 201, 178, 20, 5, 75, 13, 23, 118, 161, 54, 166, 105, 210, 106, 125, 59, 20, 247, 58, 160, 208, 235, 255, 25, 238, 51, 51, 104, 240, 22, 75, 100, 25, 169, 109, 164, 158, 62, 72, 23, 83, 231, 233, 107, 113, 107, 220, 203, 111
|
|
24
|
-
])
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
perfWasm('sha512AsU8a', 64000, (input, onlyJs) =>
|
|
31
|
-
sha512AsU8a(input, onlyJs)
|
|
32
|
-
);
|
|
33
|
-
});
|