@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
package/src/networks.ts
DELETED
package/src/packageInfo.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
// Do not edit, auto-generated by @polkadot/dev
|
|
5
|
-
|
|
6
|
-
export const packageInfo = { name: '@polkadot/util-crypto', path: 'auto', type: 'auto', version: '14.0.1' };
|
|
@@ -1,54 +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 { u8aEq, u8aToHex } from '@pezkuwi/util';
|
|
7
|
-
import { waitReady } from '@pezkuwi/wasm-crypto';
|
|
8
|
-
|
|
9
|
-
import { randomAsU8a } from '../random/asU8a.js';
|
|
10
|
-
import { perfWasm } from '../test/index.js';
|
|
11
|
-
import { pbkdf2Encode } from './index.js';
|
|
12
|
-
|
|
13
|
-
const KNOWN_SALT = new Uint8Array([
|
|
14
|
-
1, 2, 3, 4, 5, 6, 7, 8,
|
|
15
|
-
9, 10, 11, 12, 13, 14, 15, 16,
|
|
16
|
-
17, 18, 19, 20, 21, 22, 23, 24,
|
|
17
|
-
25, 26, 27, 28, 29, 30, 31, 32
|
|
18
|
-
]);
|
|
19
|
-
const TEST_PASSWORD = 'test password';
|
|
20
|
-
|
|
21
|
-
describe('pbkdf2Encode', (): void => {
|
|
22
|
-
beforeEach(async (): Promise<void> => {
|
|
23
|
-
await waitReady();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
for (const rounds of [256, 1024, 2048] as const) {
|
|
27
|
-
it(`has equivalent Wasm & JS results (${rounds} rounds)`, (): void => {
|
|
28
|
-
const salt = randomAsU8a();
|
|
29
|
-
|
|
30
|
-
expect(
|
|
31
|
-
u8aEq(
|
|
32
|
-
pbkdf2Encode(TEST_PASSWORD, salt, rounds, false).password,
|
|
33
|
-
pbkdf2Encode(TEST_PASSWORD, salt, rounds, true).password
|
|
34
|
-
)
|
|
35
|
-
).toBe(true);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
for (const onlyJs of [false, true]) {
|
|
40
|
-
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
|
41
|
-
it('creates known iterations', (): void => {
|
|
42
|
-
expect(
|
|
43
|
-
u8aToHex(pbkdf2Encode(TEST_PASSWORD, KNOWN_SALT, 2048, onlyJs).password)
|
|
44
|
-
).toEqual(
|
|
45
|
-
'0x600ba9ad65e4294d112e028fdad5dd8fce0a6a6e6b89fb36ed006785ccc3b3aec46831b3105c24237293e6cfa1a0ef6717c113f87ff9237a3f73d210adfa6634'
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
perfWasm('pbkdf2Encode', 8, (input, onlyJs) =>
|
|
52
|
-
pbkdf2Encode(input, input, undefined, onlyJs)
|
|
53
|
-
);
|
|
54
|
-
});
|
package/src/pbkdf2/encode.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { pbkdf2 as pbkdf2Js } from '@noble/hashes/pbkdf2';
|
|
5
|
-
import { sha512 } from '@noble/hashes/sha512';
|
|
6
|
-
|
|
7
|
-
import { hasBigInt, u8aToU8a } from '@pezkuwi/util';
|
|
8
|
-
import { isReady, pbkdf2 } from '@pezkuwi/wasm-crypto';
|
|
9
|
-
|
|
10
|
-
import { randomAsU8a } from '../random/asU8a.js';
|
|
11
|
-
|
|
12
|
-
interface Result {
|
|
13
|
-
password: Uint8Array;
|
|
14
|
-
rounds: number;
|
|
15
|
-
salt: Uint8Array;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function pbkdf2Encode (passphrase?: string | Uint8Array, salt: Uint8Array = randomAsU8a(), rounds = 2048, onlyJs?: boolean): Result {
|
|
19
|
-
const u8aPass = u8aToU8a(passphrase);
|
|
20
|
-
const u8aSalt = u8aToU8a(salt);
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
password: !hasBigInt || (!onlyJs && isReady())
|
|
24
|
-
? pbkdf2(u8aPass, u8aSalt, rounds)
|
|
25
|
-
: pbkdf2Js(sha512, u8aPass, u8aSalt, { c: rounds, dkLen: 64 }),
|
|
26
|
-
rounds,
|
|
27
|
-
salt
|
|
28
|
-
};
|
|
29
|
-
}
|
package/src/pbkdf2/index.ts
DELETED
package/src/random/asHex.spec.ts
DELETED
|
@@ -1,38 +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 { isHex } from '@pezkuwi/util';
|
|
7
|
-
|
|
8
|
-
import { randomAsHex } from './index.js';
|
|
9
|
-
|
|
10
|
-
describe('randomAsBuffer', (): void => {
|
|
11
|
-
it('generated results does not match', (): void => {
|
|
12
|
-
expect(
|
|
13
|
-
randomAsHex()
|
|
14
|
-
).not.toEqual(
|
|
15
|
-
randomAsHex()
|
|
16
|
-
);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('is a valid hex number', (): void => {
|
|
20
|
-
expect(
|
|
21
|
-
isHex(
|
|
22
|
-
randomAsHex()
|
|
23
|
-
)
|
|
24
|
-
).toEqual(true);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('generates 32 bytes by default', (): void => {
|
|
28
|
-
expect(
|
|
29
|
-
randomAsHex()
|
|
30
|
-
).toHaveLength(32 * 2 + 2);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('generates with the supplied length', (): void => {
|
|
34
|
-
expect(
|
|
35
|
-
randomAsHex(66)
|
|
36
|
-
).toHaveLength(66 * 2 + 2);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1,16 +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 { randomAsNumber } from './index.js';
|
|
7
|
-
|
|
8
|
-
describe('randomAsNumber', (): void => {
|
|
9
|
-
it('generates subsequent non-matching numbers', (): void => {
|
|
10
|
-
expect(
|
|
11
|
-
randomAsNumber()
|
|
12
|
-
).not.toEqual(
|
|
13
|
-
randomAsNumber()
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
});
|
package/src/random/asU8a.spec.ts
DELETED
|
@@ -1,36 +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 { isU8a } from '@pezkuwi/util';
|
|
7
|
-
|
|
8
|
-
import { randomAsU8a } from './index.js';
|
|
9
|
-
|
|
10
|
-
describe('randomAsU8a', (): void => {
|
|
11
|
-
it('generates a Uint8Array', (): void => {
|
|
12
|
-
expect(
|
|
13
|
-
isU8a(randomAsU8a())
|
|
14
|
-
).toEqual(true);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('generated results does not match', (): void => {
|
|
18
|
-
expect(
|
|
19
|
-
randomAsU8a()
|
|
20
|
-
).not.toEqual(
|
|
21
|
-
randomAsU8a()
|
|
22
|
-
);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('generates 32 bytes by default', (): void => {
|
|
26
|
-
expect(
|
|
27
|
-
randomAsU8a()
|
|
28
|
-
).toHaveLength(32);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('generates with the suuplied length', (): void => {
|
|
32
|
-
expect(
|
|
33
|
-
randomAsU8a(66)
|
|
34
|
-
).toHaveLength(66);
|
|
35
|
-
});
|
|
36
|
-
});
|
package/src/scrypt/defaults.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { ScryptParams } from './types.js';
|
|
5
|
-
|
|
6
|
-
export const ALLOWED_PARAMS: ScryptParams[] = [
|
|
7
|
-
{ N: 1 << 13, p: 10, r: 8 },
|
|
8
|
-
{ N: 1 << 14, p: 5, r: 8 },
|
|
9
|
-
{ N: 1 << 15, p: 3, r: 8 },
|
|
10
|
-
{ N: 1 << 15, p: 1, r: 8 },
|
|
11
|
-
{ N: 1 << 16, p: 2, r: 8 },
|
|
12
|
-
{ N: 1 << 17, p: 1, r: 8 }
|
|
13
|
-
];
|
|
14
|
-
|
|
15
|
-
export const DEFAULT_PARAMS: ScryptParams = {
|
|
16
|
-
N: 1 << 17,
|
|
17
|
-
p: 1,
|
|
18
|
-
r: 8
|
|
19
|
-
};
|
|
@@ -1,43 +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 { DEFAULT_PARAMS } from './defaults.js';
|
|
10
|
-
import { scryptEncode } from './index.js';
|
|
11
|
-
|
|
12
|
-
// eslint-disable-next-line jest/no-export
|
|
13
|
-
export const KNOWN_TEST = 'testing, 123';
|
|
14
|
-
|
|
15
|
-
// eslint-disable-next-line jest/no-export
|
|
16
|
-
export const KNOWN_PASS = new Uint8Array([225, 18, 85, 30, 46, 178, 200, 63, 147, 225, 37, 46, 88, 224, 151, 132, 48, 206, 104, 234, 120, 112, 243, 198, 92, 52, 101, 127, 242, 22, 116, 55, 74, 29, 17, 197, 38, 191, 128, 39, 255, 119, 175, 113, 180, 252, 171, 10, 78, 93, 226, 7, 166, 120, 99, 198, 225, 158, 107, 132, 226, 73, 129, 35]);
|
|
17
|
-
|
|
18
|
-
// eslint-disable-next-line jest/no-export
|
|
19
|
-
export const KNOWN_SALT = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8]);
|
|
20
|
-
|
|
21
|
-
describe('scryptEncode', (): void => {
|
|
22
|
-
beforeEach(async (): Promise<void> => {
|
|
23
|
-
await waitReady();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
for (const onlyJs of [false, true]) {
|
|
27
|
-
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
|
28
|
-
it('generates a known output', (): void => {
|
|
29
|
-
expect(
|
|
30
|
-
scryptEncode(KNOWN_TEST, KNOWN_SALT, undefined, onlyJs)
|
|
31
|
-
).toEqual({
|
|
32
|
-
params: DEFAULT_PARAMS,
|
|
33
|
-
password: KNOWN_PASS,
|
|
34
|
-
salt: KNOWN_SALT
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
perfWasm('scryptEncode', 4, (input, onlyJs) =>
|
|
41
|
-
scryptEncode(input, input, undefined, onlyJs)
|
|
42
|
-
);
|
|
43
|
-
});
|
package/src/scrypt/encode.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { ScryptParams } from './types.js';
|
|
5
|
-
|
|
6
|
-
import { scrypt as scryptJs } from '@noble/hashes/scrypt';
|
|
7
|
-
|
|
8
|
-
import { hasBigInt, objectSpread, u8aToU8a } from '@pezkuwi/util';
|
|
9
|
-
import { isReady, scrypt } from '@pezkuwi/wasm-crypto';
|
|
10
|
-
|
|
11
|
-
import { randomAsU8a } from '../random/asU8a.js';
|
|
12
|
-
import { DEFAULT_PARAMS } from './defaults.js';
|
|
13
|
-
|
|
14
|
-
interface Result {
|
|
15
|
-
params: ScryptParams,
|
|
16
|
-
password: Uint8Array;
|
|
17
|
-
salt: Uint8Array;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function scryptEncode (passphrase?: string | Uint8Array, salt = randomAsU8a(), params = DEFAULT_PARAMS, onlyJs?: boolean): Result {
|
|
21
|
-
const u8a = u8aToU8a(passphrase);
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
params,
|
|
25
|
-
password: !hasBigInt || (!onlyJs && isReady())
|
|
26
|
-
? scrypt(u8a, salt, Math.log2(params.N), params.r, params.p)
|
|
27
|
-
: scryptJs(u8a, salt, objectSpread({ dkLen: 64 }, params)),
|
|
28
|
-
salt
|
|
29
|
-
};
|
|
30
|
-
}
|
package/src/scrypt/fromU8a.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { ScryptParams } from './types.js';
|
|
5
|
-
|
|
6
|
-
import { u8aToBn } from '@pezkuwi/util';
|
|
7
|
-
|
|
8
|
-
import { BN_LE_OPTS } from '../bn.js';
|
|
9
|
-
import { ALLOWED_PARAMS } from './defaults.js';
|
|
10
|
-
|
|
11
|
-
interface Result {
|
|
12
|
-
params: ScryptParams,
|
|
13
|
-
salt: Uint8Array;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function scryptFromU8a (data: Uint8Array): Result {
|
|
17
|
-
if (!(data instanceof Uint8Array)) {
|
|
18
|
-
throw new Error('Expected input to be a Uint8Array');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Ensure the input is exactly 44 bytes: 32 for salt + 3 * 4 for N, p, r
|
|
22
|
-
if (data.length < 32 + 12) {
|
|
23
|
-
throw new Error(`Invalid input length: expected 44 bytes, found ${data.length}`);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const salt = data.subarray(0, 32);
|
|
27
|
-
const N = u8aToBn(data.subarray(32, 36), BN_LE_OPTS).toNumber();
|
|
28
|
-
const p = u8aToBn(data.subarray(36, 40), BN_LE_OPTS).toNumber();
|
|
29
|
-
const r = u8aToBn(data.subarray(40, 44), BN_LE_OPTS).toNumber();
|
|
30
|
-
|
|
31
|
-
if (N > (1 << 20) || p > 4 || r > 16) {
|
|
32
|
-
throw new Error('Scrypt parameters exceed safe limits');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const isAllowed = ALLOWED_PARAMS.some((preset) =>
|
|
36
|
-
preset.N === N && preset.p === p && preset.r === r
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
if (!isAllowed) {
|
|
40
|
-
throw new Error('Invalid injected scrypt params found');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return { params: { N, p, r }, salt };
|
|
44
|
-
}
|
package/src/scrypt/toU8a.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { ScryptParams } from './types.js';
|
|
5
|
-
|
|
6
|
-
import { bnToU8a, u8aConcat } from '@pezkuwi/util';
|
|
7
|
-
|
|
8
|
-
import { BN_LE_32_OPTS } from '../bn.js';
|
|
9
|
-
|
|
10
|
-
export function scryptToU8a (salt: Uint8Array, { N, p, r }: ScryptParams): Uint8Array {
|
|
11
|
-
return u8aConcat(
|
|
12
|
-
salt,
|
|
13
|
-
bnToU8a(N, BN_LE_32_OPTS),
|
|
14
|
-
bnToU8a(p, BN_LE_32_OPTS),
|
|
15
|
-
bnToU8a(r, BN_LE_32_OPTS)
|
|
16
|
-
);
|
|
17
|
-
}
|
package/src/scrypt/types.ts
DELETED
|
@@ -1,47 +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 { secp256k1Compress } from './index.js';
|
|
11
|
-
|
|
12
|
-
describe('secp256k1Compress', (): void => {
|
|
13
|
-
beforeEach(async (): Promise<void> => {
|
|
14
|
-
await waitReady();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
for (const onlyJs of [false, true]) {
|
|
18
|
-
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
|
19
|
-
it('returns a compressed key as-is', (): void => {
|
|
20
|
-
expect(
|
|
21
|
-
secp256k1Compress(
|
|
22
|
-
hexToU8a('0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077'),
|
|
23
|
-
onlyJs
|
|
24
|
-
)
|
|
25
|
-
).toEqual(
|
|
26
|
-
hexToU8a('0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077')
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('compresses a known key', (): void => {
|
|
31
|
-
expect(
|
|
32
|
-
secp256k1Compress(
|
|
33
|
-
hexToU8a('0x04b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af'),
|
|
34
|
-
onlyJs
|
|
35
|
-
)
|
|
36
|
-
).toEqual(
|
|
37
|
-
hexToU8a('0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077')
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
perfWasm('secp256k1Compress', 100000, (input, onlyJs) => secp256k1Compress(input, onlyJs), [[
|
|
44
|
-
hexToU8a('0x04b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af')
|
|
45
|
-
]]
|
|
46
|
-
);
|
|
47
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
5
|
-
|
|
6
|
-
import { hasBigInt } from '@pezkuwi/util';
|
|
7
|
-
import { isReady, secp256k1Compress as wasm } from '@pezkuwi/wasm-crypto';
|
|
8
|
-
|
|
9
|
-
export function secp256k1Compress (publicKey: Uint8Array, onlyJs?: boolean): Uint8Array {
|
|
10
|
-
if (![33, 65].includes(publicKey.length)) {
|
|
11
|
-
throw new Error(`Invalid publicKey provided, received ${publicKey.length} bytes input`);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (publicKey.length === 33) {
|
|
15
|
-
return publicKey;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return !hasBigInt || (!onlyJs && isReady())
|
|
19
|
-
? wasm(publicKey)
|
|
20
|
-
: secp256k1.ProjectivePoint.fromHex(publicKey).toRawBytes(true);
|
|
21
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { compactAddLength, isU8a, stringToU8a, u8aConcat } from '@pezkuwi/util';
|
|
5
|
-
|
|
6
|
-
import { blake2AsU8a } from '../blake2/asU8a.js';
|
|
7
|
-
|
|
8
|
-
const HDKD = compactAddLength(stringToU8a('Secp256k1HDKD'));
|
|
9
|
-
|
|
10
|
-
export function secp256k1DeriveHard (seed: Uint8Array, chainCode: Uint8Array): Uint8Array {
|
|
11
|
-
if (!isU8a(chainCode) || chainCode.length !== 32) {
|
|
12
|
-
throw new Error('Invalid chainCode passed to derive');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// NOTE This is specific to the Substrate HDD derivation, so always use the blake2 hasher
|
|
16
|
-
return blake2AsU8a(u8aConcat(HDKD, seed, chainCode), 256);
|
|
17
|
-
}
|
|
@@ -1,47 +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 { secp256k1Expand } from './index.js';
|
|
11
|
-
|
|
12
|
-
describe('secp256k1Expand', (): void => {
|
|
13
|
-
beforeEach(async (): Promise<void> => {
|
|
14
|
-
await waitReady();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
for (const onlyJs of [false, true]) {
|
|
18
|
-
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
|
19
|
-
it('expands a known key', (): void => {
|
|
20
|
-
expect(
|
|
21
|
-
secp256k1Expand(
|
|
22
|
-
hexToU8a('0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077'),
|
|
23
|
-
onlyJs
|
|
24
|
-
)
|
|
25
|
-
).toEqual(
|
|
26
|
-
hexToU8a('0xb9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af')
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('expands a known full key', (): void => {
|
|
31
|
-
expect(
|
|
32
|
-
secp256k1Expand(
|
|
33
|
-
hexToU8a('0x04b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af'),
|
|
34
|
-
onlyJs
|
|
35
|
-
)
|
|
36
|
-
).toEqual(
|
|
37
|
-
hexToU8a('0xb9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb1307763fe926c273235fd979a134076d00fd1683cbd35868cb485d4a3a640e52184af')
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
perfWasm('secp256k1Expand', 2000, (input, onlyJs) => secp256k1Expand(input, onlyJs), [[
|
|
44
|
-
hexToU8a('0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077')
|
|
45
|
-
]]
|
|
46
|
-
);
|
|
47
|
-
});
|
package/src/secp256k1/expand.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import { secp256k1 } from '@noble/curves/secp256k1';
|
|
5
|
-
|
|
6
|
-
import { bnToU8a, hasBigInt, u8aConcat } from '@pezkuwi/util';
|
|
7
|
-
import { isReady, secp256k1Expand as wasm } from '@pezkuwi/wasm-crypto';
|
|
8
|
-
|
|
9
|
-
import { BN_BE_256_OPTS } from '../bn.js';
|
|
10
|
-
|
|
11
|
-
export function secp256k1Expand (publicKey: Uint8Array, onlyJs?: boolean): Uint8Array {
|
|
12
|
-
if (![33, 65].includes(publicKey.length)) {
|
|
13
|
-
throw new Error(`Invalid publicKey provided, received ${publicKey.length} bytes input`);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (publicKey.length === 65) {
|
|
17
|
-
return publicKey.subarray(1);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (!hasBigInt || (!onlyJs && isReady())) {
|
|
21
|
-
return wasm(publicKey).subarray(1);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const { px, py } = secp256k1.ProjectivePoint.fromHex(publicKey);
|
|
25
|
-
|
|
26
|
-
return u8aConcat(
|
|
27
|
-
bnToU8a(px, BN_BE_256_OPTS),
|
|
28
|
-
bnToU8a(py, BN_BE_256_OPTS)
|
|
29
|
-
);
|
|
30
|
-
}
|
|
@@ -1,24 +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 { hasher } from './hasher.js';
|
|
7
|
-
|
|
8
|
-
describe('hasher', (): void => {
|
|
9
|
-
it('creates a blake2 hash', (): void => {
|
|
10
|
-
expect(
|
|
11
|
-
hasher('blake2', 'abc')
|
|
12
|
-
).toEqual(
|
|
13
|
-
new Uint8Array([189, 221, 129, 60, 99, 66, 57, 114, 49, 113, 239, 63, 238, 152, 87, 155, 148, 150, 78, 59, 177, 203, 62, 66, 114, 98, 200, 192, 104, 213, 35, 25])
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('creates a keccak hash', (): void => {
|
|
18
|
-
expect(
|
|
19
|
-
hasher('keccak', 'abc')
|
|
20
|
-
).toEqual(
|
|
21
|
-
new Uint8Array([78, 3, 101, 122, 234, 69, 169, 79, 199, 212, 123, 168, 38, 200, 214, 103, 192, 209, 230, 227, 58, 100, 160, 54, 236, 68, 245, 143, 161, 45, 108, 69])
|
|
22
|
-
);
|
|
23
|
-
});
|
|
24
|
-
});
|
package/src/secp256k1/hasher.ts
DELETED
|
@@ -1,13 +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 { blake2AsU8a } from '../blake2/index.js';
|
|
7
|
-
import { keccakAsU8a } from '../keccak/index.js';
|
|
8
|
-
|
|
9
|
-
export function hasher (hashType: HashType, data: Uint8Array | string, onlyJs?: boolean): Uint8Array {
|
|
10
|
-
return hashType === 'keccak'
|
|
11
|
-
? keccakAsU8a(data, undefined, onlyJs)
|
|
12
|
-
: blake2AsU8a(data, undefined, undefined, onlyJs);
|
|
13
|
-
}
|
|
@@ -1,75 +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, u8aToHex } from '@pezkuwi/util';
|
|
7
|
-
import { waitReady } from '@pezkuwi/wasm-crypto';
|
|
8
|
-
|
|
9
|
-
import { mnemonicToMiniSecret } from '../../mnemonic/index.js';
|
|
10
|
-
import { perfWasm } from '../../test/index.js';
|
|
11
|
-
import { secp256k1PairFromSeed } from '../index.js';
|
|
12
|
-
|
|
13
|
-
// mnemonic, secret, public, account_id
|
|
14
|
-
type Test = [string, string, string, string];
|
|
15
|
-
|
|
16
|
-
const tests: Test[] = [
|
|
17
|
-
[
|
|
18
|
-
'life fee table ahead modify maximum dumb such tobacco boss dry nurse',
|
|
19
|
-
'0xf2360e871c830d397fe221382b503f07ddd8763df81a94bb2504390a2fb91f59',
|
|
20
|
-
'0x036b0aa6beab469dd2b748a0ff5ddbe3d13df1e15c9d28a2aa057212994e127bea',
|
|
21
|
-
'0xae8e8fcacbaeb607bcdf0bbd7e615f2b4ef484ee54f19d68a7393fb6db2dd9cd'
|
|
22
|
-
],
|
|
23
|
-
[
|
|
24
|
-
'tide survey cradle cover column ugly author wait eye state elder blame',
|
|
25
|
-
'0x5385355a5118ec732b9dbcf1668ba21db38b07cf79082dafa9a7cc4b52e4abb0',
|
|
26
|
-
'0x03929e4f93cdad265751ad8f6365185d8e937610d19b510400f5867d542d60a313',
|
|
27
|
-
'0xf80ea815da66c42f870b687e1530770d5a7936ae81a147b009506d85bd6d621c'
|
|
28
|
-
],
|
|
29
|
-
[
|
|
30
|
-
'laugh fish flee cake approve butter april dynamic myth license ticket lobster',
|
|
31
|
-
'0x83ec65cf9a8a7442d808aef6f8987599f1ba3be880769bb3a20621b13adbd476',
|
|
32
|
-
'0x0388299e4cfaa33d180a026bd54a46ad98df129a131320a9d2fd6f80e64bc3db39',
|
|
33
|
-
'0x35036238dd195f4c2169379354bda6cba5746f67bde03ef59a77a4cea80729bc'
|
|
34
|
-
],
|
|
35
|
-
[
|
|
36
|
-
'animal thing fork recipe exotic pilot inquiry pledge obey slab obtain reveal',
|
|
37
|
-
'0x0fd50580eb5a58b0eee60c77656dffa50094b539262366f1227d3babfd7343e5',
|
|
38
|
-
'0x036edc954685ad89f0a23b0fb1eb2b9c3a8600eee9091c758426dfb2bc7889a7c3',
|
|
39
|
-
'0x2a94b10d1f28810dc4628e7e424b2d08bd3d17fb08f9416d112f17e86c8fa77c'
|
|
40
|
-
]
|
|
41
|
-
];
|
|
42
|
-
|
|
43
|
-
describe('secp256k1PairFromSeed', (): void => {
|
|
44
|
-
beforeEach(async (): Promise<void> => {
|
|
45
|
-
await waitReady();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const TEST = hexToU8a('0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae');
|
|
49
|
-
const RESULT = {
|
|
50
|
-
publicKey: hexToU8a('0x03fd8c74f795ced92064b86191cb2772b1e3a0947740aa0a5a6e379592471fd85b'),
|
|
51
|
-
secretKey: hexToU8a('0x4380de832af797688026ce24f85204d508243f201650c1a134929e5458b7fbae')
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
for (const onlyJs of [false, true]) {
|
|
55
|
-
describe(`onlyJs=${(onlyJs && 'true') || 'false'}`, (): void => {
|
|
56
|
-
it('generates a valid publicKey/secretKey pair (u8a)', (): void => {
|
|
57
|
-
expect(secp256k1PairFromSeed(TEST, onlyJs)).toEqual(RESULT);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
tests.forEach(([mnemonic, secretKey, publicKey], index): void => {
|
|
61
|
-
it(`creates valid against known (${index})`, (): void => {
|
|
62
|
-
const seed = mnemonicToMiniSecret(mnemonic);
|
|
63
|
-
const pair = secp256k1PairFromSeed(seed, onlyJs);
|
|
64
|
-
|
|
65
|
-
expect(u8aToHex(pair.secretKey)).toEqual(secretKey);
|
|
66
|
-
expect(u8aToHex(pair.publicKey)).toEqual(publicKey);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
perfWasm('secp256k1PairFromSeed', 500, (input, onlyJs) =>
|
|
73
|
-
secp256k1PairFromSeed(input, onlyJs)
|
|
74
|
-
);
|
|
75
|
-
});
|