4.2.3 • Published 7 months ago

@accumulators/hashers v4.2.3

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
7 months ago

Hashers

@accmulators/hashers library implements the following hashing algorithms:

  • Keccak
  • Poseidon
  • Stark Poseidon
  • Stark Pedersen

Example

import { KeccakHasher } from "@accmulators/hashers";

const hasher = new KeccakHasher();

const hash = hasher.hash([`0x1234`, `0x5678`]);

console.log(hash);

Functions

Every hasher supports the following functions:

constructor(options: HasherOptions) - creates a new hasher instance

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 is false) - if true every outputted hash will have the same length and zeros will be padded at the beginning of the string

hashSingle(data: string)

Hashes a single string. Returns a hexadecimal number as a string (for example 0x1234567890abcdef).

hash(data: string[])

Hashes array of string and returns a hexadecimal number as a string.

4.2.0-alpha.0

8 months ago

3.0.3

9 months ago

3.0.2

9 months ago

4.2.0-alpha.1

8 months ago

3.0.1

9 months ago

3.0.8

8 months ago

4.2.3

7 months ago

2.0.3

9 months ago

4.2.2

8 months ago

2.0.2

10 months ago

2.0.4

9 months ago

4.0.1

8 months ago

4.2.1

8 months ago

4.1.0-alpha.0

8 months ago

2.0.1

10 months ago

2.0.0

11 months ago

1.2.1

11 months ago