Blake2bHashSet
- class cometa.cryptography.blake2b_hash_set.Blake2bHashSet(ptr=None)[source]
Bases:
Set[Blake2bHash]Represents a set of Blake2b hashes.
This collection type is used throughout Cardano for storing sets of transaction IDs, key hashes, and other Blake2b hash values.
Example
>>> hash_set = Blake2bHashSet() >>> hash_set.add(Blake2bHash.from_hex("00" * 32)) >>> len(hash_set) 1
- __init__(ptr=None)[source]
Initializes a new Blake2bHashSet.
- Parameters:
ptr – Optional FFI pointer to an existing hash set. If None, creates a new empty set.
- Raises:
CardanoError – If creation fails or if ptr is an invalid handle.
- Return type:
None
- classmethod from_cbor(reader)[source]
Deserializes a Blake2bHashSet from CBOR data.
- Parameters:
reader (CborReader) – A CborReader positioned at the hash set data.
- Returns:
A new Blake2bHashSet deserialized from the CBOR data.
- Raises:
CardanoError – If deserialization fails.
- Return type:
- classmethod from_list(hashes)[source]
Creates a Blake2bHashSet from an iterable of Blake2bHash objects.
- Parameters:
hashes (Iterable[Blake2bHash]) – An iterable of Blake2bHash objects.
- Returns:
A new Blake2bHashSet containing all the hashes.
- Raises:
CardanoError – If creation fails.
- Return type:
- add(hash_value)[source]
Adds a hash to the set.
- Parameters:
hash_value (Blake2bHash) – The Blake2bHash to add.
- Raises:
CardanoError – If addition fails.
- Return type:
None
- get(index)[source]
Retrieves a hash at the specified index.
- Parameters:
index (int) – The index of the hash to retrieve.
- Returns:
The Blake2bHash at the specified index.
- Raises:
CardanoError – If retrieval fails.
IndexError – If index is out of bounds.
- Return type:
- to_cbor(writer)[source]
Serializes the hash set to CBOR format.
- Parameters:
writer (CborWriter) – A CborWriter to write the serialized data to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None
- __getitem__(index)[source]
Retrieves a hash at the specified index.
- Parameters:
index (int)
- Return type:
- __iter__()[source]
Iterates over all hashes in the set.
- Return type:
Iterator[Blake2bHash]
- __contains__(item)[source]
Checks if a hash is in the set.
- Parameters:
item (Blake2bHash)
- Return type:
bool
- __eq__(other)[source]
Checks equality with another Blake2bHashSet.
- Parameters:
other (object)
- Return type:
bool
- __hash__ = None
- isdisjoint(other)[source]
Returns True if the set has no elements in common with other.
- Parameters:
other (Iterable[Blake2bHash]) – Another iterable to compare with.
- Returns:
True if the sets are disjoint.
- Return type:
bool