@pezkuwi/util-crypto 14.0.10 → 14.0.12
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/build/blake2/asU8a.d.ts +1 -1
- package/build/bundle-pezkuwi-util-crypto.js +8749 -8246
- package/build/cjs/blake2/asU8a.d.ts +1 -1
- package/build/cjs/keccak/asU8a.d.ts +1 -1
- package/build/cjs/packageInfo.js +1 -1
- package/build/cjs/scrypt/encode.d.ts +1 -1
- package/build/cjs/xxhash/asU8a.d.ts +1 -1
- package/build/keccak/asU8a.d.ts +1 -1
- package/build/package.json +9 -9
- package/build/packageInfo.js +1 -1
- package/build/scrypt/encode.d.ts +1 -1
- package/build/xxhash/asU8a.d.ts +1 -1
- package/build-deno/packageInfo.ts +1 -1
- package/build-tsc/blake2/asU8a.d.ts +1 -1
- package/build-tsc/keccak/asU8a.d.ts +1 -1
- package/build-tsc/scrypt/encode.d.ts +1 -1
- package/build-tsc/xxhash/asU8a.d.ts +1 -1
- package/build-tsc-cjs/packageInfo.js +1 -1
- package/build-tsc-esm/packageInfo.js +1 -1
- 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 +2023 -11
- 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/src/packageInfo.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.spec.tsbuildinfo +1 -1
- 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,78 @@
|
|
|
1
|
+
import { u8aIsWrapped, u8aToU8a, u8aUnwrapBytes, u8aWrapBytes } from '@pezkuwi/util';
|
|
2
|
+
import { decodeAddress } from '../address/decode.js';
|
|
3
|
+
import { ed25519Verify } from '../ed25519/verify.js';
|
|
4
|
+
import { secp256k1Verify } from '../secp256k1/verify.js';
|
|
5
|
+
import { sr25519Verify } from '../sr25519/verify.js';
|
|
6
|
+
const secp256k1VerifyHasher = (hashType) => (message, signature, publicKey) => secp256k1Verify(message, signature, publicKey, hashType, true);
|
|
7
|
+
const VERIFIERS_ECDSA = [
|
|
8
|
+
['ecdsa', secp256k1VerifyHasher('blake2')],
|
|
9
|
+
['ethereum', secp256k1VerifyHasher('keccak')]
|
|
10
|
+
];
|
|
11
|
+
const VERIFIERS = [
|
|
12
|
+
['ed25519', ed25519Verify],
|
|
13
|
+
['sr25519', sr25519Verify]
|
|
14
|
+
];
|
|
15
|
+
function verifyDetect(result, { message, publicKey, signature }, verifiers = [...VERIFIERS, ...VERIFIERS_ECDSA]) {
|
|
16
|
+
result.isValid = verifiers.some(([crypto, verify]) => {
|
|
17
|
+
try {
|
|
18
|
+
if (verify(message, signature, publicKey)) {
|
|
19
|
+
result.crypto = crypto;
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// do nothing, result.isValid still set to false
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
});
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
function verifyMultisig(result, { message, publicKey, signature }) {
|
|
31
|
+
if (![0, 1, 2].includes(signature[0]) || ![65, 66].includes(signature.length)) {
|
|
32
|
+
throw new Error(`Unknown crypto type, expected signature prefix [0..2], found ${signature[0]}`);
|
|
33
|
+
}
|
|
34
|
+
// If the signature is 66 bytes it must be an ecdsa signature
|
|
35
|
+
// containing: prefix [1 byte] + signature [65] bytes.
|
|
36
|
+
// Remove the and then verify
|
|
37
|
+
if (signature.length === 66) {
|
|
38
|
+
result = verifyDetect(result, { message, publicKey, signature: signature.subarray(1) }, VERIFIERS_ECDSA);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// The signature contains 65 bytes which is either
|
|
42
|
+
// - A ed25519 or sr25519 signature [1 byte prefix + 64 bytes]
|
|
43
|
+
// - An ecdsa signature [65 bytes]
|
|
44
|
+
result = verifyDetect(result, { message, publicKey, signature: signature.subarray(1) }, VERIFIERS);
|
|
45
|
+
if (!result.isValid) {
|
|
46
|
+
result = verifyDetect(result, { message, publicKey, signature }, VERIFIERS_ECDSA);
|
|
47
|
+
}
|
|
48
|
+
// If both failed, explicitly set crypto to 'none'
|
|
49
|
+
if (!result.isValid) {
|
|
50
|
+
result.crypto = 'none';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
function getVerifyFn(signature) {
|
|
56
|
+
return [0, 1, 2].includes(signature[0]) && [65, 66].includes(signature.length)
|
|
57
|
+
? verifyMultisig
|
|
58
|
+
: verifyDetect;
|
|
59
|
+
}
|
|
60
|
+
export function signatureVerify(message, signature, addressOrPublicKey) {
|
|
61
|
+
const signatureU8a = u8aToU8a(signature);
|
|
62
|
+
if (![64, 65, 66].includes(signatureU8a.length)) {
|
|
63
|
+
throw new Error(`Invalid signature length, expected [64..66] bytes, found ${signatureU8a.length}`);
|
|
64
|
+
}
|
|
65
|
+
const publicKey = decodeAddress(addressOrPublicKey);
|
|
66
|
+
const input = { message: u8aToU8a(message), publicKey, signature: signatureU8a };
|
|
67
|
+
const result = { crypto: 'none', isValid: false, isWrapped: u8aIsWrapped(input.message, true), publicKey };
|
|
68
|
+
const isWrappedBytes = u8aIsWrapped(input.message, false);
|
|
69
|
+
const verifyFn = getVerifyFn(signatureU8a);
|
|
70
|
+
verifyFn(result, input);
|
|
71
|
+
if (result.crypto !== 'none' || (result.isWrapped && !isWrappedBytes)) {
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
input.message = isWrappedBytes
|
|
75
|
+
? u8aUnwrapBytes(input.message)
|
|
76
|
+
: u8aWrapBytes(input.message);
|
|
77
|
+
return verifyFn(result, input);
|
|
78
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getSharedSecret } from '@scure/sr25519';
|
|
2
|
+
import { u8aToU8a } from '@pezkuwi/util';
|
|
3
|
+
/**
|
|
4
|
+
* @name sr25519Agreement
|
|
5
|
+
* @description Key agreement between other's public key and self secret key
|
|
6
|
+
*/
|
|
7
|
+
export function sr25519Agreement(secretKey, publicKey) {
|
|
8
|
+
const secretKeyU8a = u8aToU8a(secretKey);
|
|
9
|
+
const publicKeyU8a = u8aToU8a(publicKey);
|
|
10
|
+
if (publicKeyU8a.length !== 32) {
|
|
11
|
+
throw new Error(`Invalid publicKey, received ${publicKeyU8a.length} bytes, expected 32`);
|
|
12
|
+
}
|
|
13
|
+
else if (secretKeyU8a.length !== 64) {
|
|
14
|
+
throw new Error(`Invalid secretKey, received ${secretKeyU8a.length} bytes, expected 64`);
|
|
15
|
+
}
|
|
16
|
+
return getSharedSecret(secretKeyU8a, publicKeyU8a);
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as sr25519 from '@scure/sr25519';
|
|
2
|
+
import { isU8a } from '@pezkuwi/util';
|
|
3
|
+
export function createDeriveFn(derive) {
|
|
4
|
+
return (keypair, chainCode) => {
|
|
5
|
+
if (!isU8a(chainCode) || chainCode.length !== 32) {
|
|
6
|
+
throw new Error('Invalid chainCode passed to derive');
|
|
7
|
+
}
|
|
8
|
+
const secretKey = derive(keypair.secretKey, chainCode);
|
|
9
|
+
const publicKey = sr25519.getPublicKey(secretKey);
|
|
10
|
+
return { publicKey, secretKey };
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sr25519DeriveHard: (keypair: import("../types.js").Keypair, chainCode: Uint8Array) => import("../types.js").Keypair;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sr25519DerivePublic(publicKey: string | Uint8Array, chainCode: Uint8Array): Uint8Array;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as sr25519 from '@scure/sr25519';
|
|
2
|
+
import { isU8a, u8aToU8a } from '@pezkuwi/util';
|
|
3
|
+
export function sr25519DerivePublic(publicKey, chainCode) {
|
|
4
|
+
const publicKeyU8a = u8aToU8a(publicKey);
|
|
5
|
+
if (!isU8a(chainCode) || chainCode.length !== 32) {
|
|
6
|
+
throw new Error('Invalid chainCode passed to derive');
|
|
7
|
+
}
|
|
8
|
+
else if (publicKeyU8a.length !== 32) {
|
|
9
|
+
throw new Error(`Invalid publicKey, received ${publicKeyU8a.length} bytes, expected 32`);
|
|
10
|
+
}
|
|
11
|
+
return sr25519.HDKD.publicSoft(publicKeyU8a, chainCode);
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sr25519DeriveSoft: (keypair: import("../types.js").Keypair, chainCode: Uint8Array) => import("../types.js").Keypair;
|
|
@@ -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';
|
package/sr25519/index.js
ADDED
|
@@ -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';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Keypair } from '../../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* @name sr25519PairFromSeed
|
|
4
|
+
* @description Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sr25519PairFromSeed(seed: string | Uint8Array): Keypair;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as sr25519 from '@scure/sr25519';
|
|
2
|
+
import { u8aToU8a } from '@pezkuwi/util';
|
|
3
|
+
/**
|
|
4
|
+
* @name sr25519PairFromSeed
|
|
5
|
+
* @description Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
|
|
6
|
+
*/
|
|
7
|
+
export function sr25519PairFromSeed(seed) {
|
|
8
|
+
const seedU8a = u8aToU8a(seed);
|
|
9
|
+
if (seedU8a.length !== 32) {
|
|
10
|
+
throw new Error(`Expected a seed matching 32 bytes, found ${seedU8a.length}`);
|
|
11
|
+
}
|
|
12
|
+
const sec = sr25519.secretFromSeed(seedU8a);
|
|
13
|
+
const pub = sr25519.getPublicKey(sec);
|
|
14
|
+
return {
|
|
15
|
+
publicKey: pub,
|
|
16
|
+
secretKey: sec
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { u8aToU8a } from '@pezkuwi/util';
|
|
2
|
+
const SEC_LEN = 64;
|
|
3
|
+
const PUB_LEN = 32;
|
|
4
|
+
const TOT_LEN = SEC_LEN + PUB_LEN;
|
|
5
|
+
export function sr25519PairFromU8a(full) {
|
|
6
|
+
const fullU8a = u8aToU8a(full);
|
|
7
|
+
if (fullU8a.length !== TOT_LEN) {
|
|
8
|
+
throw new Error(`Expected keypair with ${TOT_LEN} bytes, found ${fullU8a.length}`);
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
publicKey: fullU8a.slice(SEC_LEN, TOT_LEN),
|
|
12
|
+
secretKey: fullU8a.slice(0, SEC_LEN)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Keypair } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* @name sr25519Sign
|
|
4
|
+
* @description Returns message signature of `message`, using the supplied pair
|
|
5
|
+
*/
|
|
6
|
+
export declare function sr25519Sign(message: string | Uint8Array, { publicKey, secretKey }: Partial<Keypair>): Uint8Array;
|
package/sr25519/sign.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as sr25519 from '@scure/sr25519';
|
|
2
|
+
import { u8aToU8a } from '@pezkuwi/util';
|
|
3
|
+
/**
|
|
4
|
+
* @name sr25519Sign
|
|
5
|
+
* @description Returns message signature of `message`, using the supplied pair
|
|
6
|
+
*/
|
|
7
|
+
export function sr25519Sign(message, { publicKey, secretKey }) {
|
|
8
|
+
if (publicKey?.length !== 32) {
|
|
9
|
+
throw new Error('Expected a valid publicKey, 32-bytes');
|
|
10
|
+
}
|
|
11
|
+
else if (secretKey?.length !== 64) {
|
|
12
|
+
throw new Error('Expected a valid secretKey, 64-bytes');
|
|
13
|
+
}
|
|
14
|
+
return sr25519.sign(secretKey, u8aToU8a(message));
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as sr25519 from '@scure/sr25519';
|
|
2
|
+
import { u8aToU8a } from '@pezkuwi/util';
|
|
3
|
+
/**
|
|
4
|
+
* @name sr25519Verify
|
|
5
|
+
* @description Verifies the signature of `message`, using the supplied pair
|
|
6
|
+
*/
|
|
7
|
+
export function sr25519Verify(message, signature, publicKey) {
|
|
8
|
+
const publicKeyU8a = u8aToU8a(publicKey);
|
|
9
|
+
const signatureU8a = u8aToU8a(signature);
|
|
10
|
+
if (publicKeyU8a.length !== 32) {
|
|
11
|
+
throw new Error(`Invalid publicKey, received ${publicKeyU8a.length} bytes, expected 32`);
|
|
12
|
+
}
|
|
13
|
+
else if (signatureU8a.length !== 64) {
|
|
14
|
+
throw new Error(`Invalid signature, received ${signatureU8a.length} bytes, expected 64`);
|
|
15
|
+
}
|
|
16
|
+
return sr25519.verify(u8aToU8a(message), signatureU8a, publicKeyU8a);
|
|
17
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Keypair } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* @name sr25519VrfSign
|
|
4
|
+
* @description Sign with sr25519 vrf signing (deterministic)
|
|
5
|
+
*/
|
|
6
|
+
export declare function sr25519VrfSign(message: string | Uint8Array, { secretKey }: Partial<Keypair>, context?: string | Uint8Array, extra?: string | Uint8Array): Uint8Array;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { randomBytes } from '@noble/hashes/utils';
|
|
2
|
+
import * as sr25519 from '@scure/sr25519';
|
|
3
|
+
import { u8aToU8a } from '@pezkuwi/util';
|
|
4
|
+
const EMPTY_U8A = new Uint8Array();
|
|
5
|
+
/**
|
|
6
|
+
* @name sr25519VrfSign
|
|
7
|
+
* @description Sign with sr25519 vrf signing (deterministic)
|
|
8
|
+
*/
|
|
9
|
+
export function sr25519VrfSign(message, { secretKey }, context = EMPTY_U8A, extra = EMPTY_U8A) {
|
|
10
|
+
if (secretKey?.length !== 64) {
|
|
11
|
+
throw new Error('Invalid secretKey, expected 64-bytes');
|
|
12
|
+
}
|
|
13
|
+
return sr25519.vrf.sign(u8aToU8a(message), secretKey, u8aToU8a(context), u8aToU8a(extra), randomBytes);
|
|
14
|
+
// return vrfSign(secretKey, u8aToU8a(context), u8aToU8a(message), u8aToU8a(extra));
|
|
15
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name sr25519VrfVerify
|
|
3
|
+
* @description Verify with sr25519 vrf verification
|
|
4
|
+
*/
|
|
5
|
+
export declare function sr25519VrfVerify(message: string | Uint8Array, signOutput: string | Uint8Array, publicKey: string | Uint8Array, context?: string | Uint8Array, extra?: string | Uint8Array): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as sr25519 from '@scure/sr25519';
|
|
2
|
+
import { u8aToU8a } from '@pezkuwi/util';
|
|
3
|
+
const EMPTY_U8A = new Uint8Array();
|
|
4
|
+
/**
|
|
5
|
+
* @name sr25519VrfVerify
|
|
6
|
+
* @description Verify with sr25519 vrf verification
|
|
7
|
+
*/
|
|
8
|
+
export function sr25519VrfVerify(message, signOutput, publicKey, context = EMPTY_U8A, extra = EMPTY_U8A) {
|
|
9
|
+
const publicKeyU8a = u8aToU8a(publicKey);
|
|
10
|
+
const proofU8a = u8aToU8a(signOutput);
|
|
11
|
+
if (publicKeyU8a.length !== 32) {
|
|
12
|
+
throw new Error('Invalid publicKey, expected 32-bytes');
|
|
13
|
+
}
|
|
14
|
+
else if (proofU8a.length !== 96) {
|
|
15
|
+
throw new Error('Invalid vrfSign output, expected 96 bytes');
|
|
16
|
+
}
|
|
17
|
+
return sr25519.vrf.verify(u8aToU8a(message), proofU8a, publicKeyU8a, u8aToU8a(context), u8aToU8a(extra));
|
|
18
|
+
}
|
package/src/packageInfo.ts
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
|
|
4
4
|
// Do not edit, auto-generated by @pezkuwi/dev
|
|
5
5
|
|
|
6
|
-
export const packageInfo = { name: '@pezkuwi/util-crypto', path: 'auto', type: 'auto', version: '14.0.
|
|
6
|
+
export const packageInfo = { name: '@pezkuwi/util-crypto', path: 'auto', type: 'auto', version: '14.0.12' };
|