LtHash

class atproto_crypto.lthash.LtHash(state: bytes | None = None)

Bases: object

Homomorphic hash of a set.

Each element expands to 1024 lanes that are added into the state, so the state depends on the elements of the set and not on the order they were added in. An element added twice is in the set twice.

Parameters:

state – State to continue from. The empty set by default.

add(element: str) → None

Add the element to the set.

Parameters:

element – Element of the set.

remove(element: str) → None

Remove the element from the set.

Parameters:

element – Element of the set.

property state: bytes

Get state as 1024 little-endian 16-bit lanes.

digest() → bytes

Get SHA-256 digest of the state.

Returns:

Digest of 32 bytes.

Return type:

bytes