Hash

All type of hashes in Cardano ledger spec.

class pycardano.hash.ConstrainedBytes(payload: bytes)

Bases: pycardano.serialization.CBORSerializable

A wrapped class of bytes with constrained size.

Parameters

payload (bytes) – Hash in bytes.

MAX_SIZE = 32
MIN_SIZE = 0
property payload: bytes
to_primitive() bytes

Convert the instance and its elements to CBOR primitives recursively.

Returns

A CBOR primitive.

Return type

Primitive

Raises

SerializeException – When the object or its elements could not be converted to CBOR primitive types.

classmethod from_primitive(value: Union[bytes, str]) pycardano.hash.T

Turn a CBOR primitive to its original class type.

Parameters
  • cls (CBORBase) – The original class type.

  • value (Primitive) – A CBOR primitive.

Returns

A CBOR serializable object.

Return type

CBORBase

Raises

DeserializeException – When the object could not be restored from primitives.

class pycardano.hash.VerificationKeyHash(payload: bytes)

Bases: pycardano.hash.ConstrainedBytes

Hash of a Cardano verification key.

MAX_SIZE = 28
MIN_SIZE = 28
class pycardano.hash.ScriptHash(payload: bytes)

Bases: pycardano.hash.ConstrainedBytes

Hash of a policy/plutus script.

MAX_SIZE = 28
MIN_SIZE = 28
class pycardano.hash.ScriptDataHash(payload: bytes)

Bases: pycardano.hash.ConstrainedBytes

Hash of script data. See https://github.com/input-output-hk/cardano-ledger/blob/525844be05adae151e82069dcd0000f3301ca0d0/eras/alonzo/ test-suite/cddl-files/alonzo.cddl#L79-L86

MAX_SIZE = 32
MIN_SIZE = 32
class pycardano.hash.TransactionId(payload: bytes)

Bases: pycardano.hash.ConstrainedBytes

Hash of a transaction.

MAX_SIZE = 32
MIN_SIZE = 32
class pycardano.hash.DatumHash(payload: bytes)

Bases: pycardano.hash.ConstrainedBytes

Hash of a datum

MAX_SIZE = 32
MIN_SIZE = 32
class pycardano.hash.AuxiliaryDataHash(payload: bytes)

Bases: pycardano.hash.ConstrainedBytes

Hash of auxiliary data

MAX_SIZE = 32
MIN_SIZE = 32
class pycardano.hash.PoolKeyHash(payload: bytes)

Bases: pycardano.hash.ConstrainedBytes

Hash of a stake pool

MAX_SIZE = 28
MIN_SIZE = 28