@accmulators/hashers
library implements the following hashing algorithms:
- Keccak
- Poseidon
- Stark Poseidon
- Stark Pedersen
import { KeccakHasher } from "@accmulators/hashers";
const hasher = new KeccakHasher();
const hash = hasher.hash([`0x1234`, `0x5678`]);
console.log(hash);
Every hasher supports the following functions:
Imporant: Don't use constructor for PoseidonHasher
, use async create()
function instead.
HasherOptions
has the following interface:
interface HasherOptions {
blockSizeBits: number;
shouldPad?: boolean;
}
blockSizeBits
(default is 256)shouldPad
(defaults isfalse
) - iftrue
every outputted hash will have the same length and zeros will be padded at the beginning of the string
Hashes a single string. Returns a hexadecimal number as a string (for example 0x1234567890abcdef
).
Hashes array of string and returns a hexadecimal number as a string.