@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,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scryptToU8a = exports.scryptFromU8a = exports.scryptEncode = void 0;
|
|
4
|
+
var encode_js_1 = require("./encode.js");
|
|
5
|
+
Object.defineProperty(exports, "scryptEncode", { enumerable: true, get: function () { return encode_js_1.scryptEncode; } });
|
|
6
|
+
var fromU8a_js_1 = require("./fromU8a.js");
|
|
7
|
+
Object.defineProperty(exports, "scryptFromU8a", { enumerable: true, get: function () { return fromU8a_js_1.scryptFromU8a; } });
|
|
8
|
+
var toU8a_js_1 = require("./toU8a.js");
|
|
9
|
+
Object.defineProperty(exports, "scryptToU8a", { enumerable: true, get: function () { return toU8a_js_1.scryptToU8a; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scryptToU8a = scryptToU8a;
|
|
4
|
+
const util_1 = require("@pezkuwi/util");
|
|
5
|
+
const bn_js_1 = require("../bn.js");
|
|
6
|
+
function scryptToU8a(salt, { N, p, r }) {
|
|
7
|
+
return (0, util_1.u8aConcat)(salt, (0, util_1.bnToU8a)(N, bn_js_1.BN_LE_32_OPTS), (0, util_1.bnToU8a)(p, bn_js_1.BN_LE_32_OPTS), (0, util_1.bnToU8a)(r, bn_js_1.BN_LE_32_OPTS));
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function secp256k1Compress(publicKey: Uint8Array, onlyJs?: boolean): Uint8Array;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secp256k1Compress = secp256k1Compress;
|
|
4
|
+
const secp256k1_1 = require("@noble/curves/secp256k1");
|
|
5
|
+
const util_1 = require("@pezkuwi/util");
|
|
6
|
+
const wasm_crypto_1 = require("@pezkuwi/wasm-crypto");
|
|
7
|
+
function secp256k1Compress(publicKey, onlyJs) {
|
|
8
|
+
if (![33, 65].includes(publicKey.length)) {
|
|
9
|
+
throw new Error(`Invalid publicKey provided, received ${publicKey.length} bytes input`);
|
|
10
|
+
}
|
|
11
|
+
if (publicKey.length === 33) {
|
|
12
|
+
return publicKey;
|
|
13
|
+
}
|
|
14
|
+
return !util_1.hasBigInt || (!onlyJs && (0, wasm_crypto_1.isReady)())
|
|
15
|
+
? (0, wasm_crypto_1.secp256k1Compress)(publicKey)
|
|
16
|
+
: secp256k1_1.secp256k1.ProjectivePoint.fromHex(publicKey).toRawBytes(true);
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function secp256k1DeriveHard(seed: Uint8Array, chainCode: Uint8Array): Uint8Array;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secp256k1DeriveHard = secp256k1DeriveHard;
|
|
4
|
+
const util_1 = require("@pezkuwi/util");
|
|
5
|
+
const asU8a_js_1 = require("../blake2/asU8a.js");
|
|
6
|
+
const HDKD = (0, util_1.compactAddLength)((0, util_1.stringToU8a)('Secp256k1HDKD'));
|
|
7
|
+
function secp256k1DeriveHard(seed, chainCode) {
|
|
8
|
+
if (!(0, util_1.isU8a)(chainCode) || chainCode.length !== 32) {
|
|
9
|
+
throw new Error('Invalid chainCode passed to derive');
|
|
10
|
+
}
|
|
11
|
+
// NOTE This is specific to the Substrate HDD derivation, so always use the blake2 hasher
|
|
12
|
+
return (0, asU8a_js_1.blake2AsU8a)((0, util_1.u8aConcat)(HDKD, seed, chainCode), 256);
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function secp256k1Expand(publicKey: Uint8Array, onlyJs?: boolean): Uint8Array;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secp256k1Expand = secp256k1Expand;
|
|
4
|
+
const secp256k1_1 = require("@noble/curves/secp256k1");
|
|
5
|
+
const util_1 = require("@pezkuwi/util");
|
|
6
|
+
const wasm_crypto_1 = require("@pezkuwi/wasm-crypto");
|
|
7
|
+
const bn_js_1 = require("../bn.js");
|
|
8
|
+
function secp256k1Expand(publicKey, onlyJs) {
|
|
9
|
+
if (![33, 65].includes(publicKey.length)) {
|
|
10
|
+
throw new Error(`Invalid publicKey provided, received ${publicKey.length} bytes input`);
|
|
11
|
+
}
|
|
12
|
+
if (publicKey.length === 65) {
|
|
13
|
+
return publicKey.subarray(1);
|
|
14
|
+
}
|
|
15
|
+
if (!util_1.hasBigInt || (!onlyJs && (0, wasm_crypto_1.isReady)())) {
|
|
16
|
+
return (0, wasm_crypto_1.secp256k1Expand)(publicKey).subarray(1);
|
|
17
|
+
}
|
|
18
|
+
const { px, py } = secp256k1_1.secp256k1.ProjectivePoint.fromHex(publicKey);
|
|
19
|
+
return (0, util_1.u8aConcat)((0, util_1.bnToU8a)(px, bn_js_1.BN_BE_256_OPTS), (0, util_1.bnToU8a)(py, bn_js_1.BN_BE_256_OPTS));
|
|
20
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasher = hasher;
|
|
4
|
+
const index_js_1 = require("../blake2/index.js");
|
|
5
|
+
const index_js_2 = require("../keccak/index.js");
|
|
6
|
+
function hasher(hashType, data, onlyJs) {
|
|
7
|
+
return hashType === 'keccak'
|
|
8
|
+
? (0, index_js_2.keccakAsU8a)(data, undefined, onlyJs)
|
|
9
|
+
: (0, index_js_1.blake2AsU8a)(data, undefined, undefined, onlyJs);
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { secp256k1Compress } from './compress.js';
|
|
2
|
+
export { secp256k1Expand } from './expand.js';
|
|
3
|
+
export { secp256k1PairFromSeed } from './pair/fromSeed.js';
|
|
4
|
+
export { secp256k1Recover } from './recover.js';
|
|
5
|
+
export { secp256k1Sign } from './sign.js';
|
|
6
|
+
export { secp256k1PrivateKeyTweakAdd } from './tweakAdd.js';
|
|
7
|
+
export { secp256k1Verify } from './verify.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secp256k1Verify = exports.secp256k1PrivateKeyTweakAdd = exports.secp256k1Sign = exports.secp256k1Recover = exports.secp256k1PairFromSeed = exports.secp256k1Expand = exports.secp256k1Compress = void 0;
|
|
4
|
+
var compress_js_1 = require("./compress.js");
|
|
5
|
+
Object.defineProperty(exports, "secp256k1Compress", { enumerable: true, get: function () { return compress_js_1.secp256k1Compress; } });
|
|
6
|
+
var expand_js_1 = require("./expand.js");
|
|
7
|
+
Object.defineProperty(exports, "secp256k1Expand", { enumerable: true, get: function () { return expand_js_1.secp256k1Expand; } });
|
|
8
|
+
var fromSeed_js_1 = require("./pair/fromSeed.js");
|
|
9
|
+
Object.defineProperty(exports, "secp256k1PairFromSeed", { enumerable: true, get: function () { return fromSeed_js_1.secp256k1PairFromSeed; } });
|
|
10
|
+
var recover_js_1 = require("./recover.js");
|
|
11
|
+
Object.defineProperty(exports, "secp256k1Recover", { enumerable: true, get: function () { return recover_js_1.secp256k1Recover; } });
|
|
12
|
+
var sign_js_1 = require("./sign.js");
|
|
13
|
+
Object.defineProperty(exports, "secp256k1Sign", { enumerable: true, get: function () { return sign_js_1.secp256k1Sign; } });
|
|
14
|
+
var tweakAdd_js_1 = require("./tweakAdd.js");
|
|
15
|
+
Object.defineProperty(exports, "secp256k1PrivateKeyTweakAdd", { enumerable: true, get: function () { return tweakAdd_js_1.secp256k1PrivateKeyTweakAdd; } });
|
|
16
|
+
var verify_js_1 = require("./verify.js");
|
|
17
|
+
Object.defineProperty(exports, "secp256k1Verify", { enumerable: true, get: function () { return verify_js_1.secp256k1Verify; } });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Keypair } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* @name secp256k1PairFromSeed
|
|
4
|
+
* @description Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
|
|
5
|
+
*/
|
|
6
|
+
export declare function secp256k1PairFromSeed(seed: Uint8Array, onlyJs?: boolean): Keypair;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secp256k1PairFromSeed = secp256k1PairFromSeed;
|
|
4
|
+
const secp256k1_1 = require("@noble/curves/secp256k1");
|
|
5
|
+
const util_1 = require("@pezkuwi/util");
|
|
6
|
+
const wasm_crypto_1 = require("@pezkuwi/wasm-crypto");
|
|
7
|
+
/**
|
|
8
|
+
* @name secp256k1PairFromSeed
|
|
9
|
+
* @description Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
|
|
10
|
+
*/
|
|
11
|
+
function secp256k1PairFromSeed(seed, onlyJs) {
|
|
12
|
+
if (seed.length !== 32) {
|
|
13
|
+
throw new Error('Expected valid 32-byte private key as a seed');
|
|
14
|
+
}
|
|
15
|
+
if (!util_1.hasBigInt || (!onlyJs && (0, wasm_crypto_1.isReady)())) {
|
|
16
|
+
const full = (0, wasm_crypto_1.secp256k1FromSeed)(seed);
|
|
17
|
+
const publicKey = full.slice(32);
|
|
18
|
+
// There is an issue with the secp256k1 when running in an ASM.js environment where
|
|
19
|
+
// it seems that the lazy static section yields invalid results on the _first_ run.
|
|
20
|
+
// If this happens, fail outright, we cannot allow invalid return values
|
|
21
|
+
// https://github.com/polkadot-js/wasm/issues/307
|
|
22
|
+
if ((0, util_1.u8aEmpty)(publicKey)) {
|
|
23
|
+
throw new Error('Invalid publicKey generated from WASM interface');
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
publicKey,
|
|
27
|
+
secretKey: full.slice(0, 32)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
publicKey: secp256k1_1.secp256k1.getPublicKey(seed, true),
|
|
32
|
+
secretKey: seed
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HashType } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* @name secp256k1Recover
|
|
4
|
+
* @description Recovers a publicKey from the supplied signature
|
|
5
|
+
*/
|
|
6
|
+
export declare function secp256k1Recover(msgHash: string | Uint8Array, signature: string | Uint8Array, recovery: number, hashType?: HashType, onlyJs?: boolean): Uint8Array;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secp256k1Recover = secp256k1Recover;
|
|
4
|
+
const secp256k1_1 = require("@noble/curves/secp256k1");
|
|
5
|
+
const util_1 = require("@pezkuwi/util");
|
|
6
|
+
const wasm_crypto_1 = require("@pezkuwi/wasm-crypto");
|
|
7
|
+
const compress_js_1 = require("./compress.js");
|
|
8
|
+
const expand_js_1 = require("./expand.js");
|
|
9
|
+
/**
|
|
10
|
+
* @name secp256k1Recover
|
|
11
|
+
* @description Recovers a publicKey from the supplied signature
|
|
12
|
+
*/
|
|
13
|
+
function secp256k1Recover(msgHash, signature, recovery, hashType = 'blake2', onlyJs) {
|
|
14
|
+
const sig = (0, util_1.u8aToU8a)(signature).subarray(0, 64);
|
|
15
|
+
const msg = (0, util_1.u8aToU8a)(msgHash);
|
|
16
|
+
const publicKey = !util_1.hasBigInt || (!onlyJs && (0, wasm_crypto_1.isReady)())
|
|
17
|
+
? (0, wasm_crypto_1.secp256k1Recover)(msg, sig, recovery)
|
|
18
|
+
: secp256k1_1.secp256k1.Signature
|
|
19
|
+
.fromCompact(sig)
|
|
20
|
+
.addRecoveryBit(recovery)
|
|
21
|
+
.recoverPublicKey(msg)
|
|
22
|
+
.toRawBytes();
|
|
23
|
+
if (!publicKey) {
|
|
24
|
+
throw new Error('Unable to recover publicKey from signature');
|
|
25
|
+
}
|
|
26
|
+
return hashType === 'keccak'
|
|
27
|
+
? (0, expand_js_1.secp256k1Expand)(publicKey, onlyJs)
|
|
28
|
+
: (0, compress_js_1.secp256k1Compress)(publicKey, onlyJs);
|
|
29
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Keypair } from '../types.js';
|
|
2
|
+
import type { HashType } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* @name secp256k1Sign
|
|
5
|
+
* @description Returns message signature of `message`, using the supplied pair
|
|
6
|
+
*/
|
|
7
|
+
export declare function secp256k1Sign(message: Uint8Array | string, { secretKey }: Partial<Keypair>, hashType?: HashType, onlyJs?: boolean): Uint8Array;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secp256k1Sign = secp256k1Sign;
|
|
4
|
+
const secp256k1_1 = require("@noble/curves/secp256k1");
|
|
5
|
+
const util_1 = require("@pezkuwi/util");
|
|
6
|
+
const wasm_crypto_1 = require("@pezkuwi/wasm-crypto");
|
|
7
|
+
const bn_js_1 = require("../bn.js");
|
|
8
|
+
const hasher_js_1 = require("./hasher.js");
|
|
9
|
+
/**
|
|
10
|
+
* @name secp256k1Sign
|
|
11
|
+
* @description Returns message signature of `message`, using the supplied pair
|
|
12
|
+
*/
|
|
13
|
+
function secp256k1Sign(message, { secretKey }, hashType = 'blake2', onlyJs) {
|
|
14
|
+
if (secretKey?.length !== 32) {
|
|
15
|
+
throw new Error('Expected valid secp256k1 secretKey, 32-bytes');
|
|
16
|
+
}
|
|
17
|
+
const data = (0, hasher_js_1.hasher)(hashType, message, onlyJs);
|
|
18
|
+
if (!util_1.hasBigInt || (!onlyJs && (0, wasm_crypto_1.isReady)())) {
|
|
19
|
+
return (0, wasm_crypto_1.secp256k1Sign)(data, secretKey);
|
|
20
|
+
}
|
|
21
|
+
const signature = secp256k1_1.secp256k1.sign(data, secretKey, { lowS: true });
|
|
22
|
+
return (0, util_1.u8aConcat)((0, util_1.bnToU8a)(signature.r, bn_js_1.BN_BE_256_OPTS), (0, util_1.bnToU8a)(signature.s, bn_js_1.BN_BE_256_OPTS), new Uint8Array([signature.recovery || 0]));
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function secp256k1PrivateKeyTweakAdd(seckey: Uint8Array, tweak: Uint8Array, onlyBn?: boolean): Uint8Array;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secp256k1PrivateKeyTweakAdd = secp256k1PrivateKeyTweakAdd;
|
|
4
|
+
const util_1 = require("@pezkuwi/util");
|
|
5
|
+
const x_bigint_1 = require("@pezkuwi/x-bigint");
|
|
6
|
+
const bn_js_1 = require("../bn.js");
|
|
7
|
+
const N = 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141'.replace(/ /g, '');
|
|
8
|
+
const N_BI = (0, x_bigint_1.BigInt)(`0x${N}`);
|
|
9
|
+
const N_BN = new util_1.BN(N, 'hex');
|
|
10
|
+
function addBi(seckey, tweak) {
|
|
11
|
+
let res = (0, util_1.u8aToBigInt)(tweak, bn_js_1.BN_BE_OPTS);
|
|
12
|
+
if (res >= N_BI) {
|
|
13
|
+
throw new Error('Tweak parameter is out of range');
|
|
14
|
+
}
|
|
15
|
+
res += (0, util_1.u8aToBigInt)(seckey, bn_js_1.BN_BE_OPTS);
|
|
16
|
+
if (res >= N_BI) {
|
|
17
|
+
res -= N_BI;
|
|
18
|
+
}
|
|
19
|
+
if (res === util_1._0n) {
|
|
20
|
+
throw new Error('Invalid resulting private key');
|
|
21
|
+
}
|
|
22
|
+
return (0, util_1.nToU8a)(res, bn_js_1.BN_BE_256_OPTS);
|
|
23
|
+
}
|
|
24
|
+
function addBn(seckey, tweak) {
|
|
25
|
+
const res = new util_1.BN(tweak);
|
|
26
|
+
if (res.cmp(N_BN) >= 0) {
|
|
27
|
+
throw new Error('Tweak parameter is out of range');
|
|
28
|
+
}
|
|
29
|
+
res.iadd(new util_1.BN(seckey));
|
|
30
|
+
if (res.cmp(N_BN) >= 0) {
|
|
31
|
+
res.isub(N_BN);
|
|
32
|
+
}
|
|
33
|
+
if (res.isZero()) {
|
|
34
|
+
throw new Error('Invalid resulting private key');
|
|
35
|
+
}
|
|
36
|
+
return (0, util_1.bnToU8a)(res, bn_js_1.BN_BE_256_OPTS);
|
|
37
|
+
}
|
|
38
|
+
function secp256k1PrivateKeyTweakAdd(seckey, tweak, onlyBn) {
|
|
39
|
+
if (!(0, util_1.isU8a)(seckey) || seckey.length !== 32) {
|
|
40
|
+
throw new Error('Expected seckey to be an Uint8Array with length 32');
|
|
41
|
+
}
|
|
42
|
+
else if (!(0, util_1.isU8a)(tweak) || tweak.length !== 32) {
|
|
43
|
+
throw new Error('Expected tweak to be an Uint8Array with length 32');
|
|
44
|
+
}
|
|
45
|
+
return !util_1.hasBigInt || onlyBn
|
|
46
|
+
? addBn(seckey, tweak)
|
|
47
|
+
: addBi(seckey, tweak);
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type HashType = 'blake2' | 'keccak';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HashType } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* @name secp256k1Verify
|
|
4
|
+
* @description Verifies the signature of `message`, using the supplied pair
|
|
5
|
+
*/
|
|
6
|
+
export declare function secp256k1Verify(msgHash: string | Uint8Array, signature: string | Uint8Array, address: string | Uint8Array, hashType?: HashType, onlyJs?: boolean): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secp256k1Verify = secp256k1Verify;
|
|
4
|
+
const util_1 = require("@pezkuwi/util");
|
|
5
|
+
const hasher_js_1 = require("./hasher.js");
|
|
6
|
+
const recover_js_1 = require("./recover.js");
|
|
7
|
+
/**
|
|
8
|
+
* @name secp256k1Verify
|
|
9
|
+
* @description Verifies the signature of `message`, using the supplied pair
|
|
10
|
+
*/
|
|
11
|
+
function secp256k1Verify(msgHash, signature, address, hashType = 'blake2', onlyJs) {
|
|
12
|
+
const sig = (0, util_1.u8aToU8a)(signature);
|
|
13
|
+
if (sig.length !== 65) {
|
|
14
|
+
throw new Error(`Expected signature with 65 bytes, ${sig.length} found instead`);
|
|
15
|
+
}
|
|
16
|
+
const publicKey = (0, recover_js_1.secp256k1Recover)((0, hasher_js_1.hasher)(hashType, msgHash), sig, sig[64], hashType, onlyJs);
|
|
17
|
+
const signerAddr = (0, hasher_js_1.hasher)(hashType, publicKey, onlyJs);
|
|
18
|
+
const inputAddr = (0, util_1.u8aToU8a)(address);
|
|
19
|
+
// for Ethereum (keccak) the last 20 bytes is the address
|
|
20
|
+
return (0, util_1.u8aEq)(publicKey, inputAddr) || (hashType === 'keccak'
|
|
21
|
+
? (0, util_1.u8aEq)(signerAddr.slice(-20), inputAddr.slice(-20))
|
|
22
|
+
: (0, util_1.u8aEq)(signerAddr, inputAddr));
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name shaAsU8a
|
|
3
|
+
* @summary Creates a sha Uint8Array from the input.
|
|
4
|
+
*/
|
|
5
|
+
export declare const shaAsU8a: (value: string | Uint8Array, bitLength?: 256 | 512, onlyJs?: boolean) => Uint8Array;
|
|
6
|
+
/**
|
|
7
|
+
* @name sha256AsU8a
|
|
8
|
+
* @summary Creates a sha256 Uint8Array from the input.
|
|
9
|
+
*/
|
|
10
|
+
export declare const sha256AsU8a: (data: string | Uint8Array, onlyJs?: boolean) => Uint8Array;
|
|
11
|
+
/**
|
|
12
|
+
* @name sha512AsU8a
|
|
13
|
+
* @summary Creates a sha512 Uint8Array from the input.
|
|
14
|
+
*/
|
|
15
|
+
export declare const sha512AsU8a: (data: string | Uint8Array, onlyJs?: boolean) => Uint8Array;
|
package/cjs/sha/asU8a.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sha512AsU8a = exports.sha256AsU8a = exports.shaAsU8a = void 0;
|
|
4
|
+
const sha256_1 = require("@noble/hashes/sha256");
|
|
5
|
+
const sha512_1 = require("@noble/hashes/sha512");
|
|
6
|
+
const wasm_crypto_1 = require("@pezkuwi/wasm-crypto");
|
|
7
|
+
const helpers_js_1 = require("../helpers.js");
|
|
8
|
+
/**
|
|
9
|
+
* @name shaAsU8a
|
|
10
|
+
* @summary Creates a sha Uint8Array from the input.
|
|
11
|
+
*/
|
|
12
|
+
exports.shaAsU8a = (0, helpers_js_1.createDualHasher)({ 256: wasm_crypto_1.sha256, 512: wasm_crypto_1.sha512 }, { 256: sha256_1.sha256, 512: sha512_1.sha512 });
|
|
13
|
+
/**
|
|
14
|
+
* @name sha256AsU8a
|
|
15
|
+
* @summary Creates a sha256 Uint8Array from the input.
|
|
16
|
+
*/
|
|
17
|
+
exports.sha256AsU8a = (0, helpers_js_1.createBitHasher)(256, exports.shaAsU8a);
|
|
18
|
+
/**
|
|
19
|
+
* @name sha512AsU8a
|
|
20
|
+
* @summary Creates a sha512 Uint8Array from the input.
|
|
21
|
+
*/
|
|
22
|
+
exports.sha512AsU8a = (0, helpers_js_1.createBitHasher)(512, exports.shaAsU8a);
|
package/cjs/sha/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shaAsU8a = exports.sha512AsU8a = exports.sha256AsU8a = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @summary Implements Sha-256/512 hashing functions for a variety of input and outputs
|
|
6
|
+
*/
|
|
7
|
+
var asU8a_js_1 = require("./asU8a.js");
|
|
8
|
+
Object.defineProperty(exports, "sha256AsU8a", { enumerable: true, get: function () { return asU8a_js_1.sha256AsU8a; } });
|
|
9
|
+
Object.defineProperty(exports, "sha512AsU8a", { enumerable: true, get: function () { return asU8a_js_1.sha512AsU8a; } });
|
|
10
|
+
Object.defineProperty(exports, "shaAsU8a", { enumerable: true, get: function () { return asU8a_js_1.shaAsU8a; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signatureVerify = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @summary Utilities for working with signatures
|
|
6
|
+
*/
|
|
7
|
+
var verify_js_1 = require("./verify.js");
|
|
8
|
+
Object.defineProperty(exports, "signatureVerify", { enumerable: true, get: function () { return verify_js_1.signatureVerify; } });
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signatureVerify = signatureVerify;
|
|
4
|
+
const util_1 = require("@pezkuwi/util");
|
|
5
|
+
const decode_js_1 = require("../address/decode.js");
|
|
6
|
+
const verify_js_1 = require("../ed25519/verify.js");
|
|
7
|
+
const verify_js_2 = require("../secp256k1/verify.js");
|
|
8
|
+
const verify_js_3 = require("../sr25519/verify.js");
|
|
9
|
+
const secp256k1VerifyHasher = (hashType) => (message, signature, publicKey) => (0, verify_js_2.secp256k1Verify)(message, signature, publicKey, hashType, true);
|
|
10
|
+
const VERIFIERS_ECDSA = [
|
|
11
|
+
['ecdsa', secp256k1VerifyHasher('blake2')],
|
|
12
|
+
['ethereum', secp256k1VerifyHasher('keccak')]
|
|
13
|
+
];
|
|
14
|
+
const VERIFIERS = [
|
|
15
|
+
['ed25519', verify_js_1.ed25519Verify],
|
|
16
|
+
['sr25519', verify_js_3.sr25519Verify]
|
|
17
|
+
];
|
|
18
|
+
function verifyDetect(result, { message, publicKey, signature }, verifiers = [...VERIFIERS, ...VERIFIERS_ECDSA]) {
|
|
19
|
+
result.isValid = verifiers.some(([crypto, verify]) => {
|
|
20
|
+
try {
|
|
21
|
+
if (verify(message, signature, publicKey)) {
|
|
22
|
+
result.crypto = crypto;
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// do nothing, result.isValid still set to false
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
});
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
function verifyMultisig(result, { message, publicKey, signature }) {
|
|
34
|
+
if (![0, 1, 2].includes(signature[0]) || ![65, 66].includes(signature.length)) {
|
|
35
|
+
throw new Error(`Unknown crypto type, expected signature prefix [0..2], found ${signature[0]}`);
|
|
36
|
+
}
|
|
37
|
+
// If the signature is 66 bytes it must be an ecdsa signature
|
|
38
|
+
// containing: prefix [1 byte] + signature [65] bytes.
|
|
39
|
+
// Remove the and then verify
|
|
40
|
+
if (signature.length === 66) {
|
|
41
|
+
result = verifyDetect(result, { message, publicKey, signature: signature.subarray(1) }, VERIFIERS_ECDSA);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// The signature contains 65 bytes which is either
|
|
45
|
+
// - A ed25519 or sr25519 signature [1 byte prefix + 64 bytes]
|
|
46
|
+
// - An ecdsa signature [65 bytes]
|
|
47
|
+
result = verifyDetect(result, { message, publicKey, signature: signature.subarray(1) }, VERIFIERS);
|
|
48
|
+
if (!result.isValid) {
|
|
49
|
+
result = verifyDetect(result, { message, publicKey, signature }, VERIFIERS_ECDSA);
|
|
50
|
+
}
|
|
51
|
+
// If both failed, explicitly set crypto to 'none'
|
|
52
|
+
if (!result.isValid) {
|
|
53
|
+
result.crypto = 'none';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
function getVerifyFn(signature) {
|
|
59
|
+
return [0, 1, 2].includes(signature[0]) && [65, 66].includes(signature.length)
|
|
60
|
+
? verifyMultisig
|
|
61
|
+
: verifyDetect;
|
|
62
|
+
}
|
|
63
|
+
function signatureVerify(message, signature, addressOrPublicKey) {
|
|
64
|
+
const signatureU8a = (0, util_1.u8aToU8a)(signature);
|
|
65
|
+
if (![64, 65, 66].includes(signatureU8a.length)) {
|
|
66
|
+
throw new Error(`Invalid signature length, expected [64..66] bytes, found ${signatureU8a.length}`);
|
|
67
|
+
}
|
|
68
|
+
const publicKey = (0, decode_js_1.decodeAddress)(addressOrPublicKey);
|
|
69
|
+
const input = { message: (0, util_1.u8aToU8a)(message), publicKey, signature: signatureU8a };
|
|
70
|
+
const result = { crypto: 'none', isValid: false, isWrapped: (0, util_1.u8aIsWrapped)(input.message, true), publicKey };
|
|
71
|
+
const isWrappedBytes = (0, util_1.u8aIsWrapped)(input.message, false);
|
|
72
|
+
const verifyFn = getVerifyFn(signatureU8a);
|
|
73
|
+
verifyFn(result, input);
|
|
74
|
+
if (result.crypto !== 'none' || (result.isWrapped && !isWrappedBytes)) {
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
input.message = isWrappedBytes
|
|
78
|
+
? (0, util_1.u8aUnwrapBytes)(input.message)
|
|
79
|
+
: (0, util_1.u8aWrapBytes)(input.message);
|
|
80
|
+
return verifyFn(result, input);
|
|
81
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sr25519Agreement = sr25519Agreement;
|
|
4
|
+
const sr25519_1 = require("@scure/sr25519");
|
|
5
|
+
const util_1 = require("@pezkuwi/util");
|
|
6
|
+
/**
|
|
7
|
+
* @name sr25519Agreement
|
|
8
|
+
* @description Key agreement between other's public key and self secret key
|
|
9
|
+
*/
|
|
10
|
+
function sr25519Agreement(secretKey, publicKey) {
|
|
11
|
+
const secretKeyU8a = (0, util_1.u8aToU8a)(secretKey);
|
|
12
|
+
const publicKeyU8a = (0, util_1.u8aToU8a)(publicKey);
|
|
13
|
+
if (publicKeyU8a.length !== 32) {
|
|
14
|
+
throw new Error(`Invalid publicKey, received ${publicKeyU8a.length} bytes, expected 32`);
|
|
15
|
+
}
|
|
16
|
+
else if (secretKeyU8a.length !== 64) {
|
|
17
|
+
throw new Error(`Invalid secretKey, received ${secretKeyU8a.length} bytes, expected 64`);
|
|
18
|
+
}
|
|
19
|
+
return (0, sr25519_1.getSharedSecret)(secretKeyU8a, publicKeyU8a);
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDeriveFn = createDeriveFn;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const sr25519 = tslib_1.__importStar(require("@scure/sr25519"));
|
|
6
|
+
const util_1 = require("@pezkuwi/util");
|
|
7
|
+
function createDeriveFn(derive) {
|
|
8
|
+
return (keypair, chainCode) => {
|
|
9
|
+
if (!(0, util_1.isU8a)(chainCode) || chainCode.length !== 32) {
|
|
10
|
+
throw new Error('Invalid chainCode passed to derive');
|
|
11
|
+
}
|
|
12
|
+
const secretKey = derive(keypair.secretKey, chainCode);
|
|
13
|
+
const publicKey = sr25519.getPublicKey(secretKey);
|
|
14
|
+
return { publicKey, secretKey };
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sr25519DeriveHard: (keypair: import("../types.js").Keypair, chainCode: Uint8Array) => import("../types.js").Keypair;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sr25519DeriveHard = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const sr25519 = tslib_1.__importStar(require("@scure/sr25519"));
|
|
6
|
+
const derive_js_1 = require("./derive.js");
|
|
7
|
+
exports.sr25519DeriveHard = (0, derive_js_1.createDeriveFn)(sr25519.HDKD.secretHard);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sr25519DerivePublic(publicKey: string | Uint8Array, chainCode: Uint8Array): Uint8Array;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sr25519DerivePublic = sr25519DerivePublic;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const sr25519 = tslib_1.__importStar(require("@scure/sr25519"));
|
|
6
|
+
const util_1 = require("@pezkuwi/util");
|
|
7
|
+
function sr25519DerivePublic(publicKey, chainCode) {
|
|
8
|
+
const publicKeyU8a = (0, util_1.u8aToU8a)(publicKey);
|
|
9
|
+
if (!(0, util_1.isU8a)(chainCode) || chainCode.length !== 32) {
|
|
10
|
+
throw new Error('Invalid chainCode passed to derive');
|
|
11
|
+
}
|
|
12
|
+
else if (publicKeyU8a.length !== 32) {
|
|
13
|
+
throw new Error(`Invalid publicKey, received ${publicKeyU8a.length} bytes, expected 32`);
|
|
14
|
+
}
|
|
15
|
+
return sr25519.HDKD.publicSoft(publicKeyU8a, chainCode);
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sr25519DeriveSoft: (keypair: import("../types.js").Keypair, chainCode: Uint8Array) => import("../types.js").Keypair;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sr25519DeriveSoft = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const sr25519 = tslib_1.__importStar(require("@scure/sr25519"));
|
|
6
|
+
const derive_js_1 = require("./derive.js");
|
|
7
|
+
exports.sr25519DeriveSoft = (0, derive_js_1.createDeriveFn)(sr25519.HDKD.secretSoft);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { sr25519Agreement } from './agreement.js';
|
|
2
|
+
export { sr25519DeriveHard } from './deriveHard.js';
|
|
3
|
+
export { sr25519DerivePublic } from './derivePublic.js';
|
|
4
|
+
export { sr25519DeriveSoft } from './deriveSoft.js';
|
|
5
|
+
export { sr25519PairFromSeed } from './pair/fromSeed.js';
|
|
6
|
+
export { sr25519Sign } from './sign.js';
|
|
7
|
+
export { sr25519Verify } from './verify.js';
|
|
8
|
+
export { sr25519VrfSign } from './vrfSign.js';
|
|
9
|
+
export { sr25519VrfVerify } from './vrfVerify.js';
|