latest.ipv8.attestation.signed_object

Module Contents

Classes

AbstractSignedObject

To reach immutability different objects will have to be signed to reach non-repudiation.

Attributes

T

latest.ipv8.attestation.signed_object.T
class latest.ipv8.attestation.signed_object.AbstractSignedObject(private_key: latest.ipv8.types.PrivateKey | None = None, signature: bytes | None = None)

To reach immutability different objects will have to be signed to reach non-repudiation. Examples are Tokens, Metadata and Attestation objects.

This class handles many of the commonly required interactions for this type of signed data.

get_hash() bytes

Return the hash of this object itself.

verify(public_key: latest.ipv8.types.PublicKey) bool

Verify if a public key belongs to this object.

Returns:

whether the given public key has signed for this object.

_sign(private_key: latest.ipv8.types.PrivateKey | None = None, signature: bytes | None = None) None

Add a signature to this data. Supply either your private key for signing or pass an existing signature.

Parameters:
  • private_key – the private key to sign with.

  • signature – the signature to adapt.

abstract get_plaintext() bytes

Retrieve the content that needs to be signed, in serialized form (bytes).

get_plaintext_signed() bytes

Concatenate the signature to the plaintext.

abstract classmethod unserialize(data: bytes, public_key: latest.ipv8.types.PublicKey, offset: int = 0) T

Read this signed object from its serialized form.

__hash__() int

The hash of this signed object.

__eq__(other: object) bool

Signed objects are equal if their signed plaintext is equal.

__ne__(other: object) bool

Signed objects are not equal if their signed plaintext is not equal.