@validator-lut-sdk/v3
v1.9.11
Published
---
Maintainers
Readme
This package can:
- Compute a digest from strings or Buffers.
- Verify a digest against an expected hash securely.
Installation
npm install jito-validator-sdkor
yarn add jito-validator-sdkUsage
1. Import functions
import { bs58, verifySha256String } from "jito-validator-sdk";2. Compute a hash (Base58)
const hash = await bs58("test");
console.log(hash);
// => Base58 encoded stringThe function accepts both string and Buffer inputs.
3. Verify a SHA256 hash
const input = "test";
const expected = "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08";
const ok = await verifySha256String(input, expected);
console.log(ok); // trueIf the hashes don't match or expected is not valid hex, it returns false.
Verification uses crypto.timingSafeEqual to prevent timing attacks.
API
bs58(input: string | Buffer, encoding?: BufferEncoding): Promise<string>
- input: the string or Buffer to encode.
- encoding: defaults to
"utf8". - returns: Base58 encoded string.
verifySha256String(input: string | Buffer, expectedHex: string, encoding?: BufferEncoding): Promise<boolean>
- input: the string or Buffer to check.
- expectedHex: 64-character hex digest.
- returns:
trueif the hashes match,falseotherwise.
License
MIT
Do you want me to also obfuscate the README a bit (like making it look more mysterious/less straightforward), or keep it developer-friendly like this?
