@pezkuwi/util-crypto 14.0.2 → 14.0.4
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/bridge.d.ts +82 -0
- package/bridge.js +168 -0
- 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/bridge.d.ts +82 -0
- package/cjs/bridge.js +172 -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/init.d.ts +10 -0
- package/cjs/init.js +43 -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/wbg.d.ts +36 -0
- package/cjs/wbg.js +65 -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/init.d.ts +10 -0
- package/init.js +40 -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 +2022 -10
- 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/wbg.d.ts +36 -0
- package/wbg.js +61 -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,177 +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 { encodeAddress } from './index.js';
|
|
7
|
-
|
|
8
|
-
// eslint-disable-next-line jest/no-export
|
|
9
|
-
export const ALICE_PUBLIC_SR = new Uint8Array([212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125]);
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line jest/no-export
|
|
12
|
-
export const ALICE_PUBLIC_ED = new Uint8Array([209, 114, 167, 76, 218, 76, 134, 89, 18, 195, 43, 160, 168, 10, 87, 174, 105, 171, 174, 65, 14, 92, 203, 89, 222, 232, 78, 47, 68, 50, 219, 79]);
|
|
13
|
-
|
|
14
|
-
const SUBKEY = [
|
|
15
|
-
{
|
|
16
|
-
// substrate default
|
|
17
|
-
address: '5DA4D4GL5iakrn22h5uKoevgvo18Pqj5BcdEUv8etEDPdijA',
|
|
18
|
-
publicKey: '0x3050f8456519829fe03302da802d22d3233a5f4037b9a3e2bcc403ccfcb2d735',
|
|
19
|
-
ss58Format: 42
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
// aventus
|
|
23
|
-
address: 'cLtA6nCDyvwKcEHH4QkZDSHMhS9s78BvUJUsKUbUAn1Jc2SCF',
|
|
24
|
-
publicKey: '0x08e8969768fc14399930d4b8d693f68a2ff6c6a597325d6946095e5e9d9d1b0e',
|
|
25
|
-
ss58Format: 65
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
// crust
|
|
29
|
-
address: 'cTGShekJ1L1UKFZR9xmv9UTJod7vqjFAPo4sDhXih2c3y1yLS',
|
|
30
|
-
publicKey: '0x04a047d52fe542484c69bc528990cfeaf3a663dded0638ee1b51cf78bacd1072',
|
|
31
|
-
ss58Format: 66
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
// sora
|
|
35
|
-
address: 'cnVRwXfAnz3RSVQyBUC8f8McrK3YBX2QYd4WoctpeSC6VTJYm',
|
|
36
|
-
publicKey: '0xae640d53cfa815f4a6a50ae70235cd7d9d134d0f1c3a4ccd118e321dfb6ab51f',
|
|
37
|
-
ss58Format: 69
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
// ecdsa
|
|
41
|
-
address: '4pbsSkWcBaYoFHrKJZp5fDVUKbqSYD9dhZZGvpp3vQ5ysVs5ybV',
|
|
42
|
-
publicKey: '0x035676109c54b9a16d271abeb4954316a40a32bcce023ac14c8e26e958aa68fba9',
|
|
43
|
-
ss58Format: 200
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
// social-network
|
|
47
|
-
address: 'xw5g1Eec8LT99pZLZMaTWwrwvNtfM6vrSuZeVbtEszCDUwByg',
|
|
48
|
-
publicKey: '0x5c64f1151f0ce4358c27238fb20c88e7c899825436f565410724c8c2c5add869',
|
|
49
|
-
ss58Format: 252
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
address: 'yGF4JP7q5AK46d1FPCEm9sYQ4KooSjHMpyVAjLnsCSWVafPnf',
|
|
53
|
-
publicKey: '0x66cd6cf085627d6c85af1aaf2bd10cf843033e929b4e3b1c2ba8e4aa46fe111b',
|
|
54
|
-
ss58Format: 255
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
address: 'yGDYxQatQwuxqT39Zs4LtcTnpzE12vXb7ZJ6xpdiHv6gTu1hF',
|
|
58
|
-
publicKey: '0x242fd5a078ac6b7c3c2531e9bcf1314343782aeb58e7bc6880794589e701db55',
|
|
59
|
-
ss58Format: 255
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
address: 'mHm8k9Emsvyfp3piCauSH684iA6NakctF8dySQcX94GDdrJrE',
|
|
63
|
-
publicKey: '0x44d5a3ac156335ea99d33a83c57c7146c40c8e2260a8a4adf4e7a86256454651',
|
|
64
|
-
ss58Format: 4242
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
address: 'r6Gr4gaMP8TsjhFbqvZhv3YvnasugLiRJpzpRHifsqqG18UXa',
|
|
68
|
-
publicKey: '0x88f01441682a17b52d6ae12d1a5670cf675fd254897efabaa5069eb3a701ab73',
|
|
69
|
-
ss58Format: 14269
|
|
70
|
-
}
|
|
71
|
-
];
|
|
72
|
-
|
|
73
|
-
describe('encode', (): void => {
|
|
74
|
-
it('encodes an address to a valid value', (): void => {
|
|
75
|
-
expect(
|
|
76
|
-
encodeAddress(ALICE_PUBLIC_ED)
|
|
77
|
-
).toEqual('5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaQua');
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('can re-encode an address', (): void => {
|
|
81
|
-
expect(
|
|
82
|
-
encodeAddress('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', 2)
|
|
83
|
-
).toEqual('HNZata7iMYWmk5RvZRTiAsSDhV8366zq2YGb3tLH5Upf74F');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('can re-encode an address to Polkadot live', (): void => {
|
|
87
|
-
expect(
|
|
88
|
-
encodeAddress('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', 0)
|
|
89
|
-
).toEqual('15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5');
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('fails when non-valid publicKey provided', (): void => {
|
|
93
|
-
expect(
|
|
94
|
-
(): string => encodeAddress(
|
|
95
|
-
ALICE_PUBLIC_ED.slice(0, 30)
|
|
96
|
-
)
|
|
97
|
-
).toThrow(/Expected a valid key/);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('encodes a 1-byte address', (): void => {
|
|
101
|
-
expect(
|
|
102
|
-
encodeAddress(
|
|
103
|
-
new Uint8Array([1])
|
|
104
|
-
)
|
|
105
|
-
).toEqual('F7NZ');
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('encodes a 1-byte address (with prefix)', (): void => {
|
|
109
|
-
expect(
|
|
110
|
-
encodeAddress(
|
|
111
|
-
new Uint8Array([1]), 2
|
|
112
|
-
)
|
|
113
|
-
).toEqual('g4b');
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('encodes a 2-byte address', (): void => {
|
|
117
|
-
expect(
|
|
118
|
-
encodeAddress(
|
|
119
|
-
new Uint8Array([0, 1]), 2
|
|
120
|
-
)
|
|
121
|
-
).toEqual('3xygo');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('encodes a 4-byte address', (): void => {
|
|
125
|
-
expect(
|
|
126
|
-
encodeAddress(
|
|
127
|
-
new Uint8Array([1, 2, 3, 4]), 2
|
|
128
|
-
)
|
|
129
|
-
).toEqual('zswfoZa');
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('encodes a 8-byte address', (): void => {
|
|
133
|
-
expect(
|
|
134
|
-
encodeAddress(
|
|
135
|
-
new Uint8Array([42, 44, 10, 0, 0, 0, 0, 0]), 2
|
|
136
|
-
)
|
|
137
|
-
).toEqual('848Gh2GcGaZia');
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('encodes an 33-byte address', (): void => {
|
|
141
|
-
expect(
|
|
142
|
-
encodeAddress('0x03b9dc646dd71118e5f7fda681ad9eca36eb3ee96f344f582fbe7b5bcdebb13077')
|
|
143
|
-
).toEqual('KWCv1L3QX9LDPwY4VzvLmarEmXjVJidUzZcinvVnmxAJJCBou');
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('encodes with 2 byte prefix', (): void => {
|
|
147
|
-
expect(
|
|
148
|
-
encodeAddress(ALICE_PUBLIC_ED, 255)
|
|
149
|
-
).toEqual('yGHU8YKprxHbHdEv7oUK4rzMZXtsdhcXVG2CAMyC9WhzhjH2k');
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
SUBKEY.forEach(({ address, publicKey, ss58Format }, index): void => {
|
|
153
|
-
it(`encodes with Subkey equality (${index} - ${ss58Format})`, (): void => {
|
|
154
|
-
expect(
|
|
155
|
-
encodeAddress(publicKey, ss58Format)
|
|
156
|
-
).toEqual(address);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('does not encode for > 16,383, < 0', (): void => {
|
|
161
|
-
expect(
|
|
162
|
-
() => encodeAddress(ALICE_PUBLIC_ED, -1)
|
|
163
|
-
).toThrow(/range ss58Format specified/);
|
|
164
|
-
expect(
|
|
165
|
-
() => encodeAddress(ALICE_PUBLIC_ED, 16384)
|
|
166
|
-
).toThrow(/range ss58Format specified/);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('does not encode reserved', (): void => {
|
|
170
|
-
expect(
|
|
171
|
-
() => encodeAddress(ALICE_PUBLIC_ED, 46)
|
|
172
|
-
).toThrow(/range ss58Format specified/);
|
|
173
|
-
expect(
|
|
174
|
-
() => encodeAddress(ALICE_PUBLIC_ED, 47)
|
|
175
|
-
).toThrow(/range ss58Format specified/);
|
|
176
|
-
});
|
|
177
|
-
});
|
package/src/address/encode.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { Prefix } from './types.js';
|
|
5
|
-
|
|
6
|
-
// Original implementation: https://github.com/paritytech/polka-ui/blob/4858c094684769080f5811f32b081dd7780b0880/src/polkadot.js#L34
|
|
7
|
-
import { u8aConcat } from '@pezkuwi/util';
|
|
8
|
-
|
|
9
|
-
import { base58Encode } from '../base58/index.js';
|
|
10
|
-
import { decodeAddress } from './decode.js';
|
|
11
|
-
import { defaults } from './defaults.js';
|
|
12
|
-
import { sshash } from './sshash.js';
|
|
13
|
-
|
|
14
|
-
export function encodeAddress (key: string | Uint8Array, ss58Format: Prefix = defaults.prefix): string {
|
|
15
|
-
// decode it, this means we can re-encode an address
|
|
16
|
-
const u8a = decodeAddress(key);
|
|
17
|
-
|
|
18
|
-
if ((ss58Format < 0) || (ss58Format > 16383 && !ss58Exceptions.includes(ss58Format)) || [46, 47].includes(ss58Format)) {
|
|
19
|
-
throw new Error('Out of range ss58Format specified');
|
|
20
|
-
} else if (!defaults.allowedDecodedLengths.includes(u8a.length)) {
|
|
21
|
-
throw new Error(`Expected a valid key to convert, with length ${defaults.allowedDecodedLengths.join(', ')}`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const input = u8aConcat(
|
|
25
|
-
ss58Format < 64
|
|
26
|
-
? [ss58Format]
|
|
27
|
-
: [
|
|
28
|
-
((ss58Format & 0b0000_0000_1111_1100) >> 2) | 0b0100_0000,
|
|
29
|
-
(ss58Format >> 8) | ((ss58Format & 0b0000_0000_0000_0011) << 6)
|
|
30
|
-
],
|
|
31
|
-
u8a
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
return base58Encode(
|
|
35
|
-
u8aConcat(
|
|
36
|
-
input,
|
|
37
|
-
sshash(input).subarray(0, [32, 33].includes(u8a.length) ? 2 : 1)
|
|
38
|
-
)
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Exceptions like 29972 (Mythos chain) which uses Ethereum style account (not ss58 Encoded)
|
|
43
|
-
const ss58Exceptions = [29972];
|
|
@@ -1,14 +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 { encodeDerivedAddress } from './index.js';
|
|
7
|
-
|
|
8
|
-
describe('encodeDerivedAddress', (): void => {
|
|
9
|
-
it('creates a valid known derived address', (): void => {
|
|
10
|
-
expect(
|
|
11
|
-
encodeDerivedAddress('5GvUh7fGKsdBEh5XpypkfkGuf7j3vXLxH9BdxjxnJNVXRYi1', 0)
|
|
12
|
-
).toEqual('5E5XxqPxm7QbEs6twYfp3tyjXidn4kqRrNPH4o6JK9JSLUeD');
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { BN } from '@pezkuwi/util';
|
|
5
|
-
import type { Prefix } from './types.js';
|
|
6
|
-
|
|
7
|
-
import { decodeAddress } from './decode.js';
|
|
8
|
-
import { encodeAddress } from './encode.js';
|
|
9
|
-
import { createKeyDerived } from './keyDerived.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @name encodeDerivedAddress
|
|
13
|
-
* @summary Creates a derived address as used in Substrate utility.
|
|
14
|
-
* @description
|
|
15
|
-
* Creates a Substrate derived address based on the input address/publicKey and the index supplied.
|
|
16
|
-
*/
|
|
17
|
-
export function encodeDerivedAddress (who: string | Uint8Array, index: bigint | BN | number, ss58Format?: Prefix): string {
|
|
18
|
-
return encodeAddress(createKeyDerived(decodeAddress(who), index), ss58Format);
|
|
19
|
-
}
|
|
@@ -1,18 +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 { encodeMultiAddress } from './index.js';
|
|
7
|
-
|
|
8
|
-
describe('encodeMultiAddress', (): void => {
|
|
9
|
-
it('creates a valid known multi address', (): void => {
|
|
10
|
-
expect(
|
|
11
|
-
encodeMultiAddress([
|
|
12
|
-
'5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
|
|
13
|
-
'5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty',
|
|
14
|
-
'5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y'
|
|
15
|
-
], 2)
|
|
16
|
-
).toEqual('5DjYJStmdZ2rcqXbXGX7TW85JsrW6uG4y9MUcLq2BoPMpRA7');
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { BN } from '@pezkuwi/util';
|
|
5
|
-
import type { Prefix } from './types.js';
|
|
6
|
-
|
|
7
|
-
import { encodeAddress } from './encode.js';
|
|
8
|
-
import { createKeyMulti } from './keyMulti.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @name encodeMultiAddress
|
|
12
|
-
* @summary Creates a multisig address.
|
|
13
|
-
* @description
|
|
14
|
-
* Creates a Substrate multisig address based on the input address and the required threshold.
|
|
15
|
-
*/
|
|
16
|
-
export function encodeMultiAddress (who: (string | Uint8Array)[], threshold: bigint | BN | number, ss58Format?: Prefix): string {
|
|
17
|
-
return encodeAddress(createKeyMulti(who, threshold), ss58Format);
|
|
18
|
-
}
|
package/src/address/eq.spec.ts
DELETED
|
@@ -1,45 +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 { ALICE_PUBLIC_SR } from './encode.spec.js';
|
|
7
|
-
import { addressEq } from './index.js';
|
|
8
|
-
|
|
9
|
-
describe('addressEq', (): void => {
|
|
10
|
-
it('returns false with non-equal', (): void => {
|
|
11
|
-
expect(
|
|
12
|
-
addressEq(
|
|
13
|
-
'5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
|
|
14
|
-
'5EnxxUmEbw8DkENKiYuZ1DwQuMoB2UWEQJZZXrTsxoz7SpgG'
|
|
15
|
-
)
|
|
16
|
-
).toEqual(false);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('returns true for equal, matching prefix', (): void => {
|
|
20
|
-
expect(
|
|
21
|
-
addressEq(
|
|
22
|
-
'5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
|
|
23
|
-
'5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'
|
|
24
|
-
)
|
|
25
|
-
).toEqual(true);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('returns true for equal, non-matching prefix', (): void => {
|
|
29
|
-
expect(
|
|
30
|
-
addressEq(
|
|
31
|
-
'5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
|
|
32
|
-
'15oF4uVJwmo4TdGW7VfQxNLavjCXviqxT9S1MgbjMNHr6Sp5'
|
|
33
|
-
)
|
|
34
|
-
).toEqual(true);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('returns true for equal, address vs publicKey', (): void => {
|
|
38
|
-
expect(
|
|
39
|
-
addressEq(
|
|
40
|
-
'5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
|
|
41
|
-
ALICE_PUBLIC_SR
|
|
42
|
-
)
|
|
43
|
-
).toEqual(true);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
@@ -1,20 +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 { evmToAddress } from './index.js';
|
|
7
|
-
|
|
8
|
-
describe('evmToAddress', (): void => {
|
|
9
|
-
it('creates a valid known SS58 address', (): void => {
|
|
10
|
-
expect(
|
|
11
|
-
evmToAddress('0xd43593c715fdd31c61141abd04a99fd6822c8558', 42, 'blake2')
|
|
12
|
-
).toEqual('5FrLxJsyJ5x9n2rmxFwosFraxFCKcXZDngRLNectCn64UjtZ');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('fails when length is invalid', (): void => {
|
|
16
|
-
expect(
|
|
17
|
-
() => evmToAddress('0x1234567890ABCDEF1234567890ABCDEF')
|
|
18
|
-
).toThrow(/address length/);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { HashType } from '../secp256k1/types.js';
|
|
5
|
-
import type { Prefix } from './types.js';
|
|
6
|
-
|
|
7
|
-
import { u8aConcat } from '@pezkuwi/util';
|
|
8
|
-
|
|
9
|
-
import { hasher } from '../secp256k1/hasher.js';
|
|
10
|
-
import { encodeAddress } from './encode.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @name evmToAddress
|
|
14
|
-
* @summary Converts an EVM address to its corresponding SS58 address.
|
|
15
|
-
*/
|
|
16
|
-
export function evmToAddress (evmAddress: string | Uint8Array, ss58Format?: Prefix, hashType: HashType = 'blake2'): string {
|
|
17
|
-
const message = u8aConcat('evm:', evmAddress);
|
|
18
|
-
|
|
19
|
-
if (message.length !== 24) {
|
|
20
|
-
throw new Error(`Converting ${evmAddress as string}: Invalid evm address length`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return encodeAddress(hasher(hashType, message), ss58Format);
|
|
24
|
-
}
|
package/src/address/is.spec.ts
DELETED
|
@@ -1,113 +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 { isAddress } from './index.js';
|
|
7
|
-
|
|
8
|
-
describe('isAddress', (): void => {
|
|
9
|
-
it('decodes an address', (): void => {
|
|
10
|
-
expect(
|
|
11
|
-
isAddress('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
|
|
12
|
-
).toEqual(true);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('decodes the council address', (): void => {
|
|
16
|
-
expect(
|
|
17
|
-
isAddress('F3opxRbN5ZbjJNU511Kj2TLuzFcDq9BGduA9TgiECafpg29')
|
|
18
|
-
).toEqual(true);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('converts a publicKey (hex) as-is', (): void => {
|
|
22
|
-
expect(
|
|
23
|
-
isAddress('0x01020304')
|
|
24
|
-
).toEqual(true);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('decodes a short address', (): void => {
|
|
28
|
-
expect(
|
|
29
|
-
isAddress('F7NZ')
|
|
30
|
-
).toEqual(true);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('decodes a 1-byte accountId (with prefix)', (): void => {
|
|
34
|
-
expect(
|
|
35
|
-
isAddress('g4b', false, 2)
|
|
36
|
-
).toEqual(true);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('decodes a 2-byte accountId', (): void => {
|
|
40
|
-
expect(
|
|
41
|
-
isAddress('3xygo', false, 2)
|
|
42
|
-
).toEqual(true);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('encodes a 4-byte address', (): void => {
|
|
46
|
-
expect(
|
|
47
|
-
isAddress('zswfoZa', false, 2)
|
|
48
|
-
).toEqual(true);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('decodes a 8-byte address', (): void => {
|
|
52
|
-
expect(
|
|
53
|
-
isAddress('848Gh2GcGaZia', false, 2)
|
|
54
|
-
).toEqual(true);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('decodes a 33-byte address', (): void => {
|
|
58
|
-
expect(
|
|
59
|
-
isAddress('KWCv1L3QX9LDPwY4VzvLmarEmXjVJidUzZcinvVnmxAJJCBou')
|
|
60
|
-
).toEqual(true);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('decodes a 2-byte prefix (65)', (): void => {
|
|
64
|
-
expect(
|
|
65
|
-
isAddress('cLtA6nCDyvwKcEHH4QkZDSHMhS9s78BvUJUsKUbUAn1Jc2SCF')
|
|
66
|
-
).toEqual(true);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('decodes a 2-byte prefix (69)', (): void => {
|
|
70
|
-
expect(
|
|
71
|
-
isAddress('cnUaoo5wodnTVA4bnr4woSweto8hWZADUvLFXkR9Q6U7BRsbF')
|
|
72
|
-
).toEqual(true);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('decodes a 2-byte prefix (252)', (): void => {
|
|
76
|
-
expect(
|
|
77
|
-
isAddress('xw9Hca4RJTmBRgzJT4ieJBh7XCK9gE3NXBDSEmgGHd4TCrbnG')
|
|
78
|
-
).toEqual(true);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('decodes a 2-byte prefix (255)', (): void => {
|
|
82
|
-
expect(
|
|
83
|
-
isAddress('yGHU8YKprxHbHdEv7oUK4rzMZXtsdhcXVG2CAMyC9WhzhjH2k')
|
|
84
|
-
).toEqual(true);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('decodes a 2-byte prefix (ecdsa, from Substrate)', (): void => {
|
|
88
|
-
expect(
|
|
89
|
-
isAddress('4pbsSkWcBaYoFHrKJZp5fDVUKbqSYD9dhZZGvpp3vQ5ysVs5ybV')
|
|
90
|
-
).toEqual(true);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('fails when length is invalid', (): void => {
|
|
94
|
-
expect(
|
|
95
|
-
isAddress('y9EMHt34JJo4rWLSaxoLGdYXvjgSXEd4zHUnQgfNzwES8b')
|
|
96
|
-
).toEqual(false);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('fails when the checksum does not match', (): void => {
|
|
100
|
-
expect(
|
|
101
|
-
isAddress('5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMa9cj')
|
|
102
|
-
).toEqual(false);
|
|
103
|
-
expect(
|
|
104
|
-
isAddress('5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDwU')
|
|
105
|
-
).toEqual(false);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('fails when invalid base58 encoded address is found', (): void => {
|
|
109
|
-
expect(
|
|
110
|
-
isAddress('F3opIRbN5ZbjJNU511Kj2TLuzFcDq9BGduA9TgiECafpg29')
|
|
111
|
-
).toEqual(false);
|
|
112
|
-
});
|
|
113
|
-
});
|
package/src/address/is.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { Prefix } from './types.js';
|
|
5
|
-
|
|
6
|
-
import { validateAddress } from './validate.js';
|
|
7
|
-
|
|
8
|
-
export function isAddress (address?: string | null, ignoreChecksum?: boolean, ss58Format?: Prefix): address is string {
|
|
9
|
-
try {
|
|
10
|
-
return validateAddress(address, ignoreChecksum, ss58Format);
|
|
11
|
-
} catch {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -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 { createKeyDerived } from './index.js';
|
|
7
|
-
|
|
8
|
-
describe('createKeyDerived', (): void => {
|
|
9
|
-
it('matches sub accounts with Rust', (): void => {
|
|
10
|
-
expect(
|
|
11
|
-
createKeyDerived(new Uint8Array([1, 0, 0, 0, 0, 0, 0, 0]), 0)
|
|
12
|
-
).toEqual(
|
|
13
|
-
new Uint8Array([234, 236, 28, 96, 177, 168, 152, 193, 71, 179, 226, 102, 179, 155, 188, 240, 90, 182, 21, 175, 47, 47, 250, 179, 178, 0, 81, 222, 70, 56, 52, 234])
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('creates a valid subkey', (): void => {
|
|
18
|
-
expect(
|
|
19
|
-
createKeyDerived('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY', 1)
|
|
20
|
-
).toEqual(
|
|
21
|
-
new Uint8Array([248, 19, 86, 209, 254, 89, 84, 48, 54, 128, 166, 239, 153, 212, 143, 34, 191, 60, 210, 50, 39, 77, 122, 71, 29, 60, 247, 198, 95, 101, 246, 83])
|
|
22
|
-
);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { BN } from '@pezkuwi/util';
|
|
5
|
-
|
|
6
|
-
import { bnToU8a, stringToU8a, u8aConcat } from '@pezkuwi/util';
|
|
7
|
-
|
|
8
|
-
import { blake2AsU8a } from '../blake2/asU8a.js';
|
|
9
|
-
import { BN_LE_16_OPTS } from '../bn.js';
|
|
10
|
-
import { decodeAddress } from './decode.js';
|
|
11
|
-
|
|
12
|
-
const PREFIX = stringToU8a('modlpy/utilisuba');
|
|
13
|
-
|
|
14
|
-
export function createKeyDerived (who: string | Uint8Array, index: bigint | BN | number): Uint8Array {
|
|
15
|
-
return blake2AsU8a(
|
|
16
|
-
u8aConcat(
|
|
17
|
-
PREFIX,
|
|
18
|
-
decodeAddress(who),
|
|
19
|
-
bnToU8a(index, BN_LE_16_OPTS)
|
|
20
|
-
)
|
|
21
|
-
);
|
|
22
|
-
}
|
|
@@ -1,20 +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 { createKeyMulti } from './index.js';
|
|
7
|
-
|
|
8
|
-
describe('createKeyMulti', (): void => {
|
|
9
|
-
it('creates a valid multikey (aligning with Rust, needs sorting)', (): void => {
|
|
10
|
-
expect(
|
|
11
|
-
createKeyMulti([
|
|
12
|
-
new Uint8Array([1, 0, 0, 0, 0, 0, 0, 0]),
|
|
13
|
-
new Uint8Array([3, 0, 0, 0, 0, 0, 0, 0]),
|
|
14
|
-
new Uint8Array([2, 0, 0, 0, 0, 0, 0, 0])
|
|
15
|
-
], 2)
|
|
16
|
-
).toEqual(
|
|
17
|
-
new Uint8Array([67, 151, 196, 155, 179, 207, 47, 123, 90, 2, 35, 54, 162, 111, 241, 226, 88, 148, 54, 193, 252, 195, 93, 101, 16, 5, 93, 101, 186, 186, 254, 79])
|
|
18
|
-
);
|
|
19
|
-
});
|
|
20
|
-
});
|
package/src/address/keyMulti.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { BN } from '@pezkuwi/util';
|
|
5
|
-
|
|
6
|
-
import { bnToU8a, compactToU8a, stringToU8a, u8aConcat, u8aSorted } from '@pezkuwi/util';
|
|
7
|
-
|
|
8
|
-
import { blake2AsU8a } from '../blake2/asU8a.js';
|
|
9
|
-
import { BN_LE_16_OPTS } from '../bn.js';
|
|
10
|
-
import { addressToU8a } from './util.js';
|
|
11
|
-
|
|
12
|
-
const PREFIX = stringToU8a('modlpy/utilisuba');
|
|
13
|
-
|
|
14
|
-
export function createKeyMulti (who: (string | Uint8Array)[], threshold: bigint | BN | number): Uint8Array {
|
|
15
|
-
return blake2AsU8a(
|
|
16
|
-
u8aConcat(
|
|
17
|
-
PREFIX,
|
|
18
|
-
compactToU8a(who.length),
|
|
19
|
-
...u8aSorted(who.map(addressToU8a)),
|
|
20
|
-
bnToU8a(threshold, BN_LE_16_OPTS)
|
|
21
|
-
)
|
|
22
|
-
);
|
|
23
|
-
}
|
|
@@ -1,21 +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 { encodeAddress, setSS58Format } from './index.js';
|
|
7
|
-
|
|
8
|
-
describe('setSS58Format', (): void => {
|
|
9
|
-
beforeEach((): void => {
|
|
10
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
11
|
-
setSS58Format(2);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('sets and allows encoding using', (): void => {
|
|
15
|
-
expect(
|
|
16
|
-
encodeAddress(
|
|
17
|
-
new Uint8Array([1])
|
|
18
|
-
)
|
|
19
|
-
).toEqual('g4b');
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Copyright 2017-2025 @polkadot/util-crypto authors & contributors
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import type { Prefix } from './types.js';
|
|
5
|
-
|
|
6
|
-
import { logger } from '@pezkuwi/util';
|
|
7
|
-
|
|
8
|
-
import { defaults } from './defaults.js';
|
|
9
|
-
|
|
10
|
-
const l = logger('setSS58Format');
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @description Sets the global SS58 format to use for address encoding
|
|
14
|
-
* @deprecated Use keyring.setSS58Format
|
|
15
|
-
*/
|
|
16
|
-
export function setSS58Format (prefix: Prefix): void {
|
|
17
|
-
l.warn('Global setting of the ss58Format is deprecated and not recommended. Set format on the keyring (if used) or as part of the address encode function');
|
|
18
|
-
|
|
19
|
-
defaults.prefix = prefix;
|
|
20
|
-
}
|
package/src/address/sort.spec.ts
DELETED
|
@@ -1,22 +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 { sortAddresses } from './index.js';
|
|
7
|
-
|
|
8
|
-
describe('sortAddresses', (): void => {
|
|
9
|
-
it('sorts addresses by the publicKeys', (): void => {
|
|
10
|
-
expect(
|
|
11
|
-
sortAddresses([
|
|
12
|
-
'5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
|
|
13
|
-
'5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty',
|
|
14
|
-
'5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y'
|
|
15
|
-
])
|
|
16
|
-
).toEqual([
|
|
17
|
-
'5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty',
|
|
18
|
-
'5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y',
|
|
19
|
-
'5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'
|
|
20
|
-
]);
|
|
21
|
-
});
|
|
22
|
-
});
|