VkeyWitness

class cometa.witness_set.vkey_witness.VkeyWitness(ptr)[source]

Bases: object

Represents a verification key witness in a Cardano transaction.

A VKey witness consists of a verification key (public key) and a signature that proves the owner of the corresponding private key has authorized the transaction.

This is the standard way to sign transactions in Cardano - the private key signs the transaction body hash, and the witness contains both the public key and the signature for verification.

__init__(ptr)[source]
Return type:

None

__enter__()[source]
Return type:

VkeyWitness

__exit__(exc_type, exc_val, exc_tb)[source]
Return type:

None

__repr__()[source]

Return repr(self).

Return type:

str

classmethod new(vkey, signature)[source]

Creates a new VKey witness from raw bytes.

Parameters:
  • vkey (bytes) – The verification key (32 bytes for Ed25519).

  • signature (bytes) – The signature (64 bytes for Ed25519).

Returns:

A new VkeyWitness instance.

Raises:

CardanoError – If creation fails.

Return type:

VkeyWitness

classmethod from_cbor(reader)[source]

Deserializes a VkeyWitness from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the witness data.

Returns:

A new VkeyWitness deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

VkeyWitness

to_cbor(writer)[source]

Serializes the witness to CBOR format.

Parameters:

writer (CborWriter) – A CborWriter to write the serialized data to.

Raises:

CardanoError – If serialization fails.

Return type:

None

property vkey: bytes

The verification key (public key).

Returns:

The 32-byte Ed25519 public key.

property signature: bytes

The signature.

Returns:

The 64-byte Ed25519 signature.

has_public_key(vkey)[source]

Checks if this witness contains a specific public key.

Parameters:

vkey (bytes) – The 32-byte Ed25519 public key to check for.

Returns:

True if the witness contains this public key, False otherwise.

Raises:

CardanoError – If the check fails.

Return type:

bool

to_cip116_json(writer)[source]

Serializes this object to CIP-116 compliant JSON.

Parameters:

writer (JsonWriter) – The JsonWriter to write the JSON to.

Raises:

CardanoError – If serialization fails.

Return type:

None