@pezkuwi/util-crypto 14.0.10 → 14.0.11
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/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/address/eq.js +19 -0
- package/address/evmToAddress.d.ts +7 -0
- package/address/evmToAddress.js +14 -0
- package/address/index.d.ts +16 -0
- 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/base32/bs32.js +40 -0
- package/base32/helpers.d.ts +25 -0
- package/base32/helpers.js +61 -0
- package/base32/index.d.ts +4 -0
- package/base32/index.js +4 -0
- package/base58/bs58.d.ts +26 -0
- package/base58/bs58.js +34 -0
- package/base58/index.d.ts +4 -0
- package/base58/index.js +4 -0
- package/base64/bs64.d.ts +26 -0
- package/base64/bs64.js +34 -0
- package/base64/index.d.ts +6 -0
- 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/blake2/asU8a.js +32 -0
- package/blake2/index.d.ts +4 -0
- package/blake2/index.js +4 -0
- package/bn.d.ts +30 -0
- package/bn.js +8 -0
- package/bundle-pezkuwi-util-crypto.js +8251 -0
- package/bundle.d.ts +26 -0
- 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/cjs/ed25519/index.d.ts +10 -0
- 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/cjs/ed25519/pair/fromSecret.js +26 -0
- 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/cjs/ethereum/index.d.ts +3 -0
- 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/cjs/hd/index.d.ts +3 -0
- 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/cjs/json/index.d.ts +4 -0
- 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/cjs/keccak/index.d.ts +4 -0
- 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/cjs/key/index.d.ts +9 -0
- 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/cjs/mnemonic/index.d.ts +8 -0
- 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/cjs/mnemonic/wordlists/index.d.ts +8 -0
- 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/cjs/nacl/index.d.ts +5 -0
- 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/cjs/random/index.d.ts +5 -0
- 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/cjs/scrypt/index.d.ts +3 -0
- 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/cjs/secp256k1/index.d.ts +7 -0
- 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/cjs/sha/index.d.ts +4 -0
- 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/cjs/sr25519/index.d.ts +9 -0
- 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/cjs/xxhash/index.d.ts +4 -0
- 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/ed25519/pair/fromRandom.js +19 -0
- package/ed25519/pair/fromSecret.d.ts +16 -0
- package/ed25519/pair/fromSecret.js +23 -0
- package/ed25519/pair/fromSeed.d.ts +16 -0
- package/ed25519/pair/fromSeed.js +31 -0
- package/ed25519/pair/fromString.d.ts +16 -0
- package/ed25519/pair/fromString.js +20 -0
- 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/hmac/shaAsU8a.js +36 -0
- 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/keccak/asU8a.js +33 -0
- 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/key/hdkdEcdsa.js +4 -0
- package/key/hdkdEd25519.d.ts +1 -0
- package/key/hdkdEd25519.js +3 -0
- 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/mnemonic/generate.js +20 -0
- 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/mnemonic/toLegacySeed.js +34 -0
- package/mnemonic/toMiniSecret.d.ts +1 -0
- package/mnemonic/toMiniSecret.js +17 -0
- package/mnemonic/validate.d.ts +14 -0
- package/mnemonic/validate.js +21 -0
- package/mnemonic/wordlists/en.d.ts +2 -0
- package/mnemonic/wordlists/en.js +1 -0
- package/mnemonic/wordlists/es.d.ts +2 -0
- package/mnemonic/wordlists/es.js +1 -0
- package/mnemonic/wordlists/fr.d.ts +2 -0
- package/mnemonic/wordlists/fr.js +1 -0
- package/mnemonic/wordlists/index.d.ts +8 -0
- package/mnemonic/wordlists/index.js +8 -0
- package/mnemonic/wordlists/it.d.ts +2 -0
- package/mnemonic/wordlists/it.js +1 -0
- package/mnemonic/wordlists/jp.d.ts +2 -0
- package/mnemonic/wordlists/jp.js +1 -0
- package/mnemonic/wordlists/ko.d.ts +2 -0
- package/mnemonic/wordlists/ko.js +1 -0
- package/mnemonic/wordlists/zh-s.d.ts +2 -0
- package/mnemonic/wordlists/zh-s.js +1 -0
- package/mnemonic/wordlists/zh-t.d.ts +2 -0
- package/mnemonic/wordlists/zh-t.js +1 -0
- package/nacl/decrypt.d.ts +15 -0
- package/nacl/decrypt.js +18 -0
- package/nacl/encrypt.d.ts +20 -0
- package/nacl/encrypt.js +22 -0
- 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/packageDetect.js +6 -0
- 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/random/asNumber.js +20 -0
- package/random/asU8a.d.ts +20 -0
- package/random/asU8a.js +24 -0
- 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/sha/asU8a.js +19 -0
- 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/sr25519/deriveHard.js +3 -0
- package/sr25519/derivePublic.d.ts +1 -0
- package/sr25519/derivePublic.js +12 -0
- package/sr25519/deriveSoft.d.ts +1 -0
- package/sr25519/deriveSoft.js +3 -0
- 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/xxhash/asU8a.js +35 -0
- 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
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ed25519PairFromRandom = ed25519PairFromRandom;
|
|
4
|
+
const index_js_1 = require("../../random/index.js");
|
|
5
|
+
const fromSeed_js_1 = require("./fromSeed.js");
|
|
6
|
+
/**
|
|
7
|
+
* @name ed25519PairFromRandom
|
|
8
|
+
* @summary Creates a new public/secret keypair.
|
|
9
|
+
* @description
|
|
10
|
+
* Returns a new generate object containing a `publicKey` & `secretKey`.
|
|
11
|
+
* @example
|
|
12
|
+
* <BR>
|
|
13
|
+
*
|
|
14
|
+
* ```javascript
|
|
15
|
+
* import { ed25519PairFromRandom } from '@pezkuwi/util-crypto';
|
|
16
|
+
*
|
|
17
|
+
* ed25519PairFromRandom(); // => { secretKey: [...], publicKey: [...] }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
function ed25519PairFromRandom() {
|
|
21
|
+
return (0, fromSeed_js_1.ed25519PairFromSeed)((0, index_js_1.randomAsU8a)());
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Keypair } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* @name ed25519PairFromSecret
|
|
4
|
+
* @summary Creates a new public/secret keypair from a secret.
|
|
5
|
+
* @description
|
|
6
|
+
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied secret.
|
|
7
|
+
* @example
|
|
8
|
+
* <BR>
|
|
9
|
+
*
|
|
10
|
+
* ```javascript
|
|
11
|
+
* import { ed25519PairFromSecret } from '@pezkuwi/util-crypto';
|
|
12
|
+
*
|
|
13
|
+
* ed25519PairFromSecret(...); // => { secretKey: [...], publicKey: [...] }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function ed25519PairFromSecret(secretKey: Uint8Array): Keypair;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ed25519PairFromSecret = ed25519PairFromSecret;
|
|
4
|
+
/**
|
|
5
|
+
* @name ed25519PairFromSecret
|
|
6
|
+
* @summary Creates a new public/secret keypair from a secret.
|
|
7
|
+
* @description
|
|
8
|
+
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied secret.
|
|
9
|
+
* @example
|
|
10
|
+
* <BR>
|
|
11
|
+
*
|
|
12
|
+
* ```javascript
|
|
13
|
+
* import { ed25519PairFromSecret } from '@pezkuwi/util-crypto';
|
|
14
|
+
*
|
|
15
|
+
* ed25519PairFromSecret(...); // => { secretKey: [...], publicKey: [...] }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function ed25519PairFromSecret(secretKey) {
|
|
19
|
+
if (secretKey.length !== 64) {
|
|
20
|
+
throw new Error('Invalid secretKey provided');
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
publicKey: secretKey.slice(32),
|
|
24
|
+
secretKey
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Keypair } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* @name ed25519PairFromSeed
|
|
4
|
+
* @summary Creates a new public/secret keypair from a seed.
|
|
5
|
+
* @description
|
|
6
|
+
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
|
|
7
|
+
* @example
|
|
8
|
+
* <BR>
|
|
9
|
+
*
|
|
10
|
+
* ```javascript
|
|
11
|
+
* import { ed25519PairFromSeed } from '@pezkuwi/util-crypto';
|
|
12
|
+
*
|
|
13
|
+
* ed25519PairFromSeed(...); // => { secretKey: [...], publicKey: [...] }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function ed25519PairFromSeed(seed: Uint8Array, onlyJs?: boolean): Keypair;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ed25519PairFromSeed = ed25519PairFromSeed;
|
|
4
|
+
const ed25519_1 = require("@noble/curves/ed25519");
|
|
5
|
+
const util_1 = require("@pezkuwi/util");
|
|
6
|
+
const wasm_crypto_1 = require("@pezkuwi/wasm-crypto");
|
|
7
|
+
/**
|
|
8
|
+
* @name ed25519PairFromSeed
|
|
9
|
+
* @summary Creates a new public/secret keypair from a seed.
|
|
10
|
+
* @description
|
|
11
|
+
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
|
|
12
|
+
* @example
|
|
13
|
+
* <BR>
|
|
14
|
+
*
|
|
15
|
+
* ```javascript
|
|
16
|
+
* import { ed25519PairFromSeed } from '@pezkuwi/util-crypto';
|
|
17
|
+
*
|
|
18
|
+
* ed25519PairFromSeed(...); // => { secretKey: [...], publicKey: [...] }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function ed25519PairFromSeed(seed, onlyJs) {
|
|
22
|
+
if (!util_1.hasBigInt || (!onlyJs && (0, wasm_crypto_1.isReady)())) {
|
|
23
|
+
const full = (0, wasm_crypto_1.ed25519KeypairFromSeed)(seed);
|
|
24
|
+
return {
|
|
25
|
+
publicKey: full.slice(32),
|
|
26
|
+
secretKey: full.slice(0, 64)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const publicKey = ed25519_1.ed25519.getPublicKey(seed);
|
|
30
|
+
return {
|
|
31
|
+
publicKey,
|
|
32
|
+
secretKey: (0, util_1.u8aConcatStrict)([seed, publicKey])
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Keypair } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* @name ed25519PairFromString
|
|
4
|
+
* @summary Creates a new public/secret keypair from a string.
|
|
5
|
+
* @description
|
|
6
|
+
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied string. The string is hashed and the value used as the input seed.
|
|
7
|
+
* @example
|
|
8
|
+
* <BR>
|
|
9
|
+
*
|
|
10
|
+
* ```javascript
|
|
11
|
+
* import { ed25519PairFromString } from '@pezkuwi/util-crypto';
|
|
12
|
+
*
|
|
13
|
+
* ed25519PairFromString('test'); // => { secretKey: [...], publicKey: [...] }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function ed25519PairFromString(value: string): Keypair;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ed25519PairFromString = ed25519PairFromString;
|
|
4
|
+
const util_1 = require("@pezkuwi/util");
|
|
5
|
+
const asU8a_js_1 = require("../../blake2/asU8a.js");
|
|
6
|
+
const fromSeed_js_1 = require("./fromSeed.js");
|
|
7
|
+
/**
|
|
8
|
+
* @name ed25519PairFromString
|
|
9
|
+
* @summary Creates a new public/secret keypair from a string.
|
|
10
|
+
* @description
|
|
11
|
+
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied string. The string is hashed and the value used as the input seed.
|
|
12
|
+
* @example
|
|
13
|
+
* <BR>
|
|
14
|
+
*
|
|
15
|
+
* ```javascript
|
|
16
|
+
* import { ed25519PairFromString } from '@pezkuwi/util-crypto';
|
|
17
|
+
*
|
|
18
|
+
* ed25519PairFromString('test'); // => { secretKey: [...], publicKey: [...] }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function ed25519PairFromString(value) {
|
|
22
|
+
return (0, fromSeed_js_1.ed25519PairFromSeed)((0, asU8a_js_1.blake2AsU8a)((0, util_1.stringToU8a)(value)));
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Keypair } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* @name ed25519Sign
|
|
4
|
+
* @summary Signs a message using the supplied secretKey
|
|
5
|
+
* @description
|
|
6
|
+
* Returns message signature of `message`, using the `secretKey`.
|
|
7
|
+
* @example
|
|
8
|
+
* <BR>
|
|
9
|
+
*
|
|
10
|
+
* ```javascript
|
|
11
|
+
* import { ed25519Sign } from '@pezkuwi/util-crypto';
|
|
12
|
+
*
|
|
13
|
+
* ed25519Sign([...], [...]); // => [...]
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function ed25519Sign(message: string | Uint8Array, { publicKey, secretKey }: Partial<Keypair>, onlyJs?: boolean): Uint8Array;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ed25519Sign = ed25519Sign;
|
|
4
|
+
const ed25519_1 = require("@noble/curves/ed25519");
|
|
5
|
+
const util_1 = require("@pezkuwi/util");
|
|
6
|
+
const wasm_crypto_1 = require("@pezkuwi/wasm-crypto");
|
|
7
|
+
/**
|
|
8
|
+
* @name ed25519Sign
|
|
9
|
+
* @summary Signs a message using the supplied secretKey
|
|
10
|
+
* @description
|
|
11
|
+
* Returns message signature of `message`, using the `secretKey`.
|
|
12
|
+
* @example
|
|
13
|
+
* <BR>
|
|
14
|
+
*
|
|
15
|
+
* ```javascript
|
|
16
|
+
* import { ed25519Sign } from '@pezkuwi/util-crypto';
|
|
17
|
+
*
|
|
18
|
+
* ed25519Sign([...], [...]); // => [...]
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function ed25519Sign(message, { publicKey, secretKey }, onlyJs) {
|
|
22
|
+
if (!secretKey) {
|
|
23
|
+
throw new Error('Expected a valid secretKey');
|
|
24
|
+
}
|
|
25
|
+
else if (!publicKey) {
|
|
26
|
+
throw new Error('Expected a valid publicKey');
|
|
27
|
+
}
|
|
28
|
+
const messageU8a = (0, util_1.u8aToU8a)(message);
|
|
29
|
+
const privateU8a = secretKey.subarray(0, 32);
|
|
30
|
+
return !util_1.hasBigInt || (!onlyJs && (0, wasm_crypto_1.isReady)())
|
|
31
|
+
? (0, wasm_crypto_1.ed25519Sign)(publicKey, privateU8a, messageU8a)
|
|
32
|
+
: ed25519_1.ed25519.sign(messageU8a, privateU8a);
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name ed25519Sign
|
|
3
|
+
* @summary Verifies the signature on the supplied message.
|
|
4
|
+
* @description
|
|
5
|
+
* Verifies the `signature` on `message` with the supplied `publicKey`. Returns `true` on sucess, `false` otherwise.
|
|
6
|
+
* @example
|
|
7
|
+
* <BR>
|
|
8
|
+
*
|
|
9
|
+
* ```javascript
|
|
10
|
+
* import { ed25519Verify } from '@pezkuwi/util-crypto';
|
|
11
|
+
*
|
|
12
|
+
* ed25519Verify([...], [...], [...]); // => true/false
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function ed25519Verify(message: string | Uint8Array, signature: string | Uint8Array, publicKey: string | Uint8Array, onlyJs?: boolean): boolean;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ed25519Verify = ed25519Verify;
|
|
4
|
+
const ed25519_1 = require("@noble/curves/ed25519");
|
|
5
|
+
const util_1 = require("@pezkuwi/util");
|
|
6
|
+
const wasm_crypto_1 = require("@pezkuwi/wasm-crypto");
|
|
7
|
+
/**
|
|
8
|
+
* @name ed25519Sign
|
|
9
|
+
* @summary Verifies the signature on the supplied message.
|
|
10
|
+
* @description
|
|
11
|
+
* Verifies the `signature` on `message` with the supplied `publicKey`. Returns `true` on sucess, `false` otherwise.
|
|
12
|
+
* @example
|
|
13
|
+
* <BR>
|
|
14
|
+
*
|
|
15
|
+
* ```javascript
|
|
16
|
+
* import { ed25519Verify } from '@pezkuwi/util-crypto';
|
|
17
|
+
*
|
|
18
|
+
* ed25519Verify([...], [...], [...]); // => true/false
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function ed25519Verify(message, signature, publicKey, onlyJs) {
|
|
22
|
+
const messageU8a = (0, util_1.u8aToU8a)(message);
|
|
23
|
+
const publicKeyU8a = (0, util_1.u8aToU8a)(publicKey);
|
|
24
|
+
const signatureU8a = (0, util_1.u8aToU8a)(signature);
|
|
25
|
+
if (publicKeyU8a.length !== 32) {
|
|
26
|
+
throw new Error(`Invalid publicKey, received ${publicKeyU8a.length}, expected 32`);
|
|
27
|
+
}
|
|
28
|
+
else if (signatureU8a.length !== 64) {
|
|
29
|
+
throw new Error(`Invalid signature, received ${signatureU8a.length} bytes, expected 64`);
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
return !util_1.hasBigInt || (!onlyJs && (0, wasm_crypto_1.isReady)())
|
|
33
|
+
? (0, wasm_crypto_1.ed25519Verify)(signatureU8a, messageU8a, publicKeyU8a)
|
|
34
|
+
: ed25519_1.ed25519.verify(signatureU8a, messageU8a, publicKeyU8a);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ethereumEncode = ethereumEncode;
|
|
4
|
+
const util_1 = require("@pezkuwi/util");
|
|
5
|
+
const index_js_1 = require("../keccak/index.js");
|
|
6
|
+
const index_js_2 = require("../secp256k1/index.js");
|
|
7
|
+
function getH160(u8a) {
|
|
8
|
+
if ([33, 65].includes(u8a.length)) {
|
|
9
|
+
u8a = (0, index_js_1.keccakAsU8a)((0, index_js_2.secp256k1Expand)(u8a));
|
|
10
|
+
}
|
|
11
|
+
return u8a.slice(-20);
|
|
12
|
+
}
|
|
13
|
+
function ethereumEncode(addressOrPublic) {
|
|
14
|
+
if (!addressOrPublic) {
|
|
15
|
+
return '0x';
|
|
16
|
+
}
|
|
17
|
+
const u8aAddress = (0, util_1.u8aToU8a)(addressOrPublic);
|
|
18
|
+
if (![20, 32, 33, 65].includes(u8aAddress.length)) {
|
|
19
|
+
throw new Error(`Invalid address or publicKey provided, received ${u8aAddress.length} bytes input`);
|
|
20
|
+
}
|
|
21
|
+
const address = (0, util_1.u8aToHex)(getH160(u8aAddress), -1, false);
|
|
22
|
+
const hash = (0, util_1.u8aToHex)((0, index_js_1.keccakAsU8a)(address), -1, false);
|
|
23
|
+
let result = '';
|
|
24
|
+
for (let i = 0; i < 40; i++) {
|
|
25
|
+
result = `${result}${parseInt(hash[i], 16) > 7 ? address[i].toUpperCase() : address[i]}`;
|
|
26
|
+
}
|
|
27
|
+
return `0x${result}`;
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEthereumChecksum = exports.isEthereumAddress = exports.ethereumEncode = void 0;
|
|
4
|
+
var encode_js_1 = require("./encode.js");
|
|
5
|
+
Object.defineProperty(exports, "ethereumEncode", { enumerable: true, get: function () { return encode_js_1.ethereumEncode; } });
|
|
6
|
+
var isAddress_js_1 = require("./isAddress.js");
|
|
7
|
+
Object.defineProperty(exports, "isEthereumAddress", { enumerable: true, get: function () { return isAddress_js_1.isEthereumAddress; } });
|
|
8
|
+
var isChecksum_js_1 = require("./isChecksum.js");
|
|
9
|
+
Object.defineProperty(exports, "isEthereumChecksum", { enumerable: true, get: function () { return isChecksum_js_1.isEthereumChecksum; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isEthereumAddress(address?: string): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEthereumAddress = isEthereumAddress;
|
|
4
|
+
const util_1 = require("@pezkuwi/util");
|
|
5
|
+
const isChecksum_js_1 = require("./isChecksum.js");
|
|
6
|
+
function isEthereumAddress(address) {
|
|
7
|
+
if (!address || address.length !== 42 || !(0, util_1.isHex)(address)) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return (0, isChecksum_js_1.isEthereumChecksum)(address);
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isEthereumChecksum(_address: string): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEthereumChecksum = isEthereumChecksum;
|
|
4
|
+
const util_1 = require("@pezkuwi/util");
|
|
5
|
+
const index_js_1 = require("../keccak/index.js");
|
|
6
|
+
function isInvalidChar(char, byte) {
|
|
7
|
+
return char !== (byte > 7
|
|
8
|
+
? char.toUpperCase()
|
|
9
|
+
: char.toLowerCase());
|
|
10
|
+
}
|
|
11
|
+
function isEthereumChecksum(_address) {
|
|
12
|
+
const address = _address.replace('0x', '');
|
|
13
|
+
const hash = (0, util_1.u8aToHex)((0, index_js_1.keccakAsU8a)(address.toLowerCase()), -1, false);
|
|
14
|
+
for (let i = 0; i < 40; i++) {
|
|
15
|
+
if (isInvalidChar(address[i], parseInt(hash[i], 16))) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hdEthereum = hdEthereum;
|
|
4
|
+
const util_1 = require("@pezkuwi/util");
|
|
5
|
+
const bn_js_1 = require("../../bn.js");
|
|
6
|
+
const index_js_1 = require("../../hmac/index.js");
|
|
7
|
+
const index_js_2 = require("../../secp256k1/index.js");
|
|
8
|
+
const validatePath_js_1 = require("../validatePath.js");
|
|
9
|
+
const MASTER_SECRET = (0, util_1.stringToU8a)('Bitcoin seed');
|
|
10
|
+
function createCoded(secretKey, chainCode) {
|
|
11
|
+
return {
|
|
12
|
+
chainCode,
|
|
13
|
+
publicKey: (0, index_js_2.secp256k1PairFromSeed)(secretKey).publicKey,
|
|
14
|
+
secretKey
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function deriveChild(hd, index) {
|
|
18
|
+
const indexBuffer = (0, util_1.bnToU8a)(index, bn_js_1.BN_BE_32_OPTS);
|
|
19
|
+
const data = index >= validatePath_js_1.HARDENED
|
|
20
|
+
? (0, util_1.u8aConcat)(new Uint8Array(1), hd.secretKey, indexBuffer)
|
|
21
|
+
: (0, util_1.u8aConcat)(hd.publicKey, indexBuffer);
|
|
22
|
+
try {
|
|
23
|
+
const I = (0, index_js_1.hmacShaAsU8a)(hd.chainCode, data, 512);
|
|
24
|
+
return createCoded((0, index_js_2.secp256k1PrivateKeyTweakAdd)(hd.secretKey, I.slice(0, 32)), I.slice(32));
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// In case parse256(IL) >= n or ki == 0, proceed with the next value for i
|
|
28
|
+
return deriveChild(hd, index + 1);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function hdEthereum(seed, path = '') {
|
|
32
|
+
const I = (0, index_js_1.hmacShaAsU8a)(MASTER_SECRET, seed, 512);
|
|
33
|
+
let hd = createCoded(I.slice(0, 32), I.slice(32));
|
|
34
|
+
if (!path || path === 'm' || path === 'M' || path === "m'" || path === "M'") {
|
|
35
|
+
return hd;
|
|
36
|
+
}
|
|
37
|
+
if (!(0, validatePath_js_1.hdValidatePath)(path)) {
|
|
38
|
+
throw new Error('Invalid derivation path');
|
|
39
|
+
}
|
|
40
|
+
const parts = path.split('/').slice(1);
|
|
41
|
+
for (const p of parts) {
|
|
42
|
+
hd = deriveChild(hd, parseInt(p, 10) + ((p.length > 1) && p.endsWith("'")
|
|
43
|
+
? validatePath_js_1.HARDENED
|
|
44
|
+
: 0));
|
|
45
|
+
}
|
|
46
|
+
return hd;
|
|
47
|
+
}
|
package/cjs/hd/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hdValidatePath = exports.hdLedger = exports.hdEthereum = void 0;
|
|
4
|
+
var index_js_1 = require("./ethereum/index.js");
|
|
5
|
+
Object.defineProperty(exports, "hdEthereum", { enumerable: true, get: function () { return index_js_1.hdEthereum; } });
|
|
6
|
+
var index_js_2 = require("./ledger/index.js");
|
|
7
|
+
Object.defineProperty(exports, "hdLedger", { enumerable: true, get: function () { return index_js_2.hdLedger; } });
|
|
8
|
+
var validatePath_js_1 = require("./validatePath.js");
|
|
9
|
+
Object.defineProperty(exports, "hdValidatePath", { enumerable: true, get: function () { return validatePath_js_1.hdValidatePath; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ledgerDerivePrivate(xprv: Uint8Array, index: number): Uint8Array;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ledgerDerivePrivate = ledgerDerivePrivate;
|
|
4
|
+
const util_1 = require("@pezkuwi/util");
|
|
5
|
+
const bn_js_1 = require("../../bn.js");
|
|
6
|
+
const index_js_1 = require("../../hmac/index.js");
|
|
7
|
+
function ledgerDerivePrivate(xprv, index) {
|
|
8
|
+
const kl = xprv.subarray(0, 32);
|
|
9
|
+
const kr = xprv.subarray(32, 64);
|
|
10
|
+
const cc = xprv.subarray(64, 96);
|
|
11
|
+
const data = (0, util_1.u8aConcat)([0], kl, kr, (0, util_1.bnToU8a)(index, bn_js_1.BN_LE_32_OPTS));
|
|
12
|
+
const z = (0, index_js_1.hmacShaAsU8a)(cc, data, 512);
|
|
13
|
+
data[0] = 0x01;
|
|
14
|
+
return (0, util_1.u8aConcat)((0, util_1.bnToU8a)((0, util_1.u8aToBn)(kl, bn_js_1.BN_LE_OPTS).iadd((0, util_1.u8aToBn)(z.subarray(0, 28), bn_js_1.BN_LE_OPTS).imul(util_1.BN_EIGHT)), bn_js_1.BN_LE_512_OPTS).subarray(0, 32), (0, util_1.bnToU8a)((0, util_1.u8aToBn)(kr, bn_js_1.BN_LE_OPTS).iadd((0, util_1.u8aToBn)(z.subarray(32, 64), bn_js_1.BN_LE_OPTS)), bn_js_1.BN_LE_512_OPTS).subarray(0, 32), (0, index_js_1.hmacShaAsU8a)(cc, data, 512).subarray(32, 64));
|
|
15
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hdLedger = hdLedger;
|
|
4
|
+
const index_js_1 = require("../../ed25519/index.js");
|
|
5
|
+
const index_js_2 = require("../../mnemonic/index.js");
|
|
6
|
+
const validatePath_js_1 = require("../validatePath.js");
|
|
7
|
+
const derivePrivate_js_1 = require("./derivePrivate.js");
|
|
8
|
+
const master_js_1 = require("./master.js");
|
|
9
|
+
function hdLedger(_mnemonic, path) {
|
|
10
|
+
const words = _mnemonic
|
|
11
|
+
.split(' ')
|
|
12
|
+
.map((s) => s.trim())
|
|
13
|
+
.filter((s) => s);
|
|
14
|
+
if (![12, 24, 25].includes(words.length)) {
|
|
15
|
+
throw new Error('Expected a mnemonic with 24 words (or 25 including a password)');
|
|
16
|
+
}
|
|
17
|
+
const [mnemonic, password] = words.length === 25
|
|
18
|
+
? [words.slice(0, 24).join(' '), words[24]]
|
|
19
|
+
: [words.join(' '), ''];
|
|
20
|
+
if (!(0, index_js_2.mnemonicValidate)(mnemonic)) {
|
|
21
|
+
throw new Error('Invalid mnemonic passed to ledger derivation');
|
|
22
|
+
}
|
|
23
|
+
else if (!(0, validatePath_js_1.hdValidatePath)(path)) {
|
|
24
|
+
throw new Error('Invalid derivation path');
|
|
25
|
+
}
|
|
26
|
+
const parts = path.split('/').slice(1);
|
|
27
|
+
let seed = (0, master_js_1.ledgerMaster)(mnemonic, password);
|
|
28
|
+
for (const p of parts) {
|
|
29
|
+
const n = parseInt(p.replace(/'$/, ''), 10);
|
|
30
|
+
seed = (0, derivePrivate_js_1.ledgerDerivePrivate)(seed, (n < validatePath_js_1.HARDENED) ? (n + validatePath_js_1.HARDENED) : n);
|
|
31
|
+
}
|
|
32
|
+
return (0, index_js_1.ed25519PairFromSeed)(seed.slice(0, 32));
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ledgerMaster(mnemonic: string, password?: string): Uint8Array;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ledgerMaster = ledgerMaster;
|
|
4
|
+
const util_1 = require("@pezkuwi/util");
|
|
5
|
+
const index_js_1 = require("../../hmac/index.js");
|
|
6
|
+
const bip39_js_1 = require("../../mnemonic/bip39.js");
|
|
7
|
+
const ED25519_CRYPTO = 'ed25519 seed';
|
|
8
|
+
function ledgerMaster(mnemonic, password) {
|
|
9
|
+
const seed = (0, bip39_js_1.mnemonicToSeedSync)(mnemonic, password);
|
|
10
|
+
const chainCode = (0, index_js_1.hmacShaAsU8a)(ED25519_CRYPTO, new Uint8Array([1, ...seed]), 256);
|
|
11
|
+
let priv;
|
|
12
|
+
while (!priv || (priv[31] & 0b0010_0000)) {
|
|
13
|
+
priv = (0, index_js_1.hmacShaAsU8a)(ED25519_CRYPTO, priv || seed, 512);
|
|
14
|
+
}
|
|
15
|
+
priv[0] &= 0b1111_1000;
|
|
16
|
+
priv[31] &= 0b0111_1111;
|
|
17
|
+
priv[31] |= 0b0100_0000;
|
|
18
|
+
return (0, util_1.u8aConcat)(priv, chainCode);
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HARDENED = void 0;
|
|
4
|
+
exports.hdValidatePath = hdValidatePath;
|
|
5
|
+
exports.HARDENED = 0x80000000;
|
|
6
|
+
function hdValidatePath(path) {
|
|
7
|
+
if (!path.startsWith('m/')) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
const parts = path.split('/').slice(1);
|
|
11
|
+
for (const p of parts) {
|
|
12
|
+
const n = /^\d+'?$/.test(p)
|
|
13
|
+
? parseInt(p.replace(/'$/, ''), 10)
|
|
14
|
+
: Number.NaN;
|
|
15
|
+
if (isNaN(n) || (n >= exports.HARDENED) || (n < 0)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
package/cjs/helpers.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HexString } from '@pezkuwi/util/types';
|
|
2
|
+
export type { HexString } from '@pezkuwi/util/types';
|
|
3
|
+
interface DualHash {
|
|
4
|
+
256: (u8a: Uint8Array) => Uint8Array;
|
|
5
|
+
512: (u8a: Uint8Array) => Uint8Array;
|
|
6
|
+
}
|
|
7
|
+
/** @internal */
|
|
8
|
+
export declare function createAsHex<T extends (...args: never[]) => Uint8Array>(fn: T): (...args: Parameters<T>) => HexString;
|
|
9
|
+
/** @internal */
|
|
10
|
+
export declare function createBitHasher(bitLength: 256 | 512, fn: (data: string | Uint8Array, bitLength: 256 | 512, onlyJs?: boolean) => Uint8Array): (data: string | Uint8Array, onlyJs?: boolean) => Uint8Array;
|
|
11
|
+
/** @internal */
|
|
12
|
+
export declare function createDualHasher(wa: DualHash, js: DualHash): (value: string | Uint8Array, bitLength?: 256 | 512, onlyJs?: boolean) => Uint8Array;
|
package/cjs/helpers.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAsHex = createAsHex;
|
|
4
|
+
exports.createBitHasher = createBitHasher;
|
|
5
|
+
exports.createDualHasher = createDualHasher;
|
|
6
|
+
const util_1 = require("@pezkuwi/util");
|
|
7
|
+
const wasm_crypto_1 = require("@pezkuwi/wasm-crypto");
|
|
8
|
+
/** @internal */
|
|
9
|
+
function createAsHex(fn) {
|
|
10
|
+
return (...args) => (0, util_1.u8aToHex)(fn(...args));
|
|
11
|
+
}
|
|
12
|
+
/** @internal */
|
|
13
|
+
function createBitHasher(bitLength, fn) {
|
|
14
|
+
return (data, onlyJs) => fn(data, bitLength, onlyJs);
|
|
15
|
+
}
|
|
16
|
+
/** @internal */
|
|
17
|
+
function createDualHasher(wa, js) {
|
|
18
|
+
return (value, bitLength = 256, onlyJs) => {
|
|
19
|
+
const u8a = (0, util_1.u8aToU8a)(value);
|
|
20
|
+
return !util_1.hasBigInt || (!onlyJs && (0, wasm_crypto_1.isReady)())
|
|
21
|
+
? wa[bitLength](u8a)
|
|
22
|
+
: js[bitLength](u8a);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { hmacSha256AsU8a, hmacSha512AsU8a, hmacShaAsU8a } from './shaAsU8a.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hmacShaAsU8a = exports.hmacSha512AsU8a = exports.hmacSha256AsU8a = void 0;
|
|
4
|
+
var shaAsU8a_js_1 = require("./shaAsU8a.js");
|
|
5
|
+
Object.defineProperty(exports, "hmacSha256AsU8a", { enumerable: true, get: function () { return shaAsU8a_js_1.hmacSha256AsU8a; } });
|
|
6
|
+
Object.defineProperty(exports, "hmacSha512AsU8a", { enumerable: true, get: function () { return shaAsU8a_js_1.hmacSha512AsU8a; } });
|
|
7
|
+
Object.defineProperty(exports, "hmacShaAsU8a", { enumerable: true, get: function () { return shaAsU8a_js_1.hmacShaAsU8a; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name hmacShaAsU8a
|
|
3
|
+
* @description creates a Hmac Sha (256/512) Uint8Array from the key & data
|
|
4
|
+
*/
|
|
5
|
+
export declare function hmacShaAsU8a(key: Uint8Array | string, data: Uint8Array, bitLength?: 256 | 512, onlyJs?: boolean): Uint8Array;
|
|
6
|
+
/**
|
|
7
|
+
* @name hmacSha256AsU8a
|
|
8
|
+
* @description creates a Hmac Sha256 Uint8Array from the key & data
|
|
9
|
+
*/
|
|
10
|
+
export declare const hmacSha256AsU8a: (key: Uint8Array | string, data: Uint8Array, onlyJs?: boolean) => Uint8Array;
|
|
11
|
+
/**
|
|
12
|
+
* @name hmacSha512AsU8a
|
|
13
|
+
* @description creates a Hmac Sha512 Uint8Array from the key & data
|
|
14
|
+
*/
|
|
15
|
+
export declare const hmacSha512AsU8a: (key: Uint8Array | string, data: Uint8Array, onlyJs?: boolean) => Uint8Array;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hmacSha512AsU8a = exports.hmacSha256AsU8a = void 0;
|
|
4
|
+
exports.hmacShaAsU8a = hmacShaAsU8a;
|
|
5
|
+
const hmac_1 = require("@noble/hashes/hmac");
|
|
6
|
+
const sha256_1 = require("@noble/hashes/sha256");
|
|
7
|
+
const sha512_1 = require("@noble/hashes/sha512");
|
|
8
|
+
const util_1 = require("@pezkuwi/util");
|
|
9
|
+
const wasm_crypto_1 = require("@pezkuwi/wasm-crypto");
|
|
10
|
+
const JS_HASH = {
|
|
11
|
+
256: sha256_1.sha256,
|
|
12
|
+
512: sha512_1.sha512
|
|
13
|
+
};
|
|
14
|
+
const WA_MHAC = {
|
|
15
|
+
256: wasm_crypto_1.hmacSha256,
|
|
16
|
+
512: wasm_crypto_1.hmacSha512
|
|
17
|
+
};
|
|
18
|
+
function createSha(bitLength) {
|
|
19
|
+
return (key, data, onlyJs) => hmacShaAsU8a(key, data, bitLength, onlyJs);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @name hmacShaAsU8a
|
|
23
|
+
* @description creates a Hmac Sha (256/512) Uint8Array from the key & data
|
|
24
|
+
*/
|
|
25
|
+
function hmacShaAsU8a(key, data, bitLength = 256, onlyJs) {
|
|
26
|
+
const u8aKey = (0, util_1.u8aToU8a)(key);
|
|
27
|
+
return !util_1.hasBigInt || (!onlyJs && (0, wasm_crypto_1.isReady)())
|
|
28
|
+
? WA_MHAC[bitLength](u8aKey, data)
|
|
29
|
+
: (0, hmac_1.hmac)(JS_HASH[bitLength], u8aKey, data);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @name hmacSha256AsU8a
|
|
33
|
+
* @description creates a Hmac Sha256 Uint8Array from the key & data
|
|
34
|
+
*/
|
|
35
|
+
exports.hmacSha256AsU8a = createSha(256);
|
|
36
|
+
/**
|
|
37
|
+
* @name hmacSha512AsU8a
|
|
38
|
+
* @description creates a Hmac Sha512 Uint8Array from the key & data
|
|
39
|
+
*/
|
|
40
|
+
exports.hmacSha512AsU8a = createSha(512);
|