Cip8
- class cometa.message_signing.CIP8SignResult(cose_sign1, cose_key)[source]
Bases:
objectResult of a CIP-8 message signing operation.
Contains the COSE_Sign1 and COSE_Key structures as CBOR-encoded bytes.
- Parameters:
cose_sign1 (bytes)
cose_key (bytes)
- cose_sign1
The CBOR-encoded COSE_Sign1 structure containing the signature.
- cose_key
The CBOR-encoded COSE_Key structure containing the public key.
- cometa.message_signing.cip8.sign(message, address, signing_key)[source]
Signs arbitrary data using CIP-8 / COSE and binds the signature to a Cardano address.
This function creates a COSE_Sign1 and COSE_Key structure compatible with CIP-8 and the CIP-30 signData API. The message is signed directly (no pre-hashing), with the CIP-8 “hashed” flag set to false and an empty external_aad.
- The protected headers include:
alg: EdDSA (-8)
address: raw bytes of the address
- Parameters:
message (bytes) – The message bytes to sign.
address (Address) – Cardano address to bind the signature to.
signing_key (Ed25519PrivateKey) – Ed25519 private key used to produce the signature.
- Returns:
A CIP8SignResult containing the CBOR-encoded COSE_Sign1 and COSE_Key structures.
- Raises:
CardanoError – If signing fails.
- Return type:
Example
>>> from cometa import Ed25519PrivateKey, Address >>> private_key = Ed25519PrivateKey.generate() >>> address = Address.from_bech32("addr1...") >>> result = sign(b"Hello, Cardano!", address, private_key) >>> result.cose_sign1 # CBOR-encoded COSE_Sign1 b'...'
- cometa.message_signing.cip8.sign_with_key_hash(message, key_hash, signing_key)[source]
Signs arbitrary data using CIP-8 / COSE and binds the signature to a key hash.
This function creates a COSE_Sign1 and COSE_Key structure compatible with CIP-8 and the CIP-30 signData API, binding the signature to a key hash rather than a full Cardano address. The message is signed directly (no pre-hashing), with the CIP-8 “hashed” flag set to false and an empty external_aad.
- The protected headers include:
alg: EdDSA (-8)
keyHash: raw bytes of the key hash
- Parameters:
message (bytes) – The message bytes to sign.
key_hash (Blake2bHash) – Key hash to bind the signature to (typically a Blake2b-224 hash of a public key).
signing_key (Ed25519PrivateKey) – Ed25519 private key used to produce the signature.
- Returns:
A CIP8SignResult containing the CBOR-encoded COSE_Sign1 and COSE_Key structures.
- Raises:
CardanoError – If signing fails.
- Return type:
Example
>>> from cometa import Ed25519PrivateKey, Blake2bHash >>> private_key = Ed25519PrivateKey.generate() >>> key_hash = private_key.get_public_key().to_hash() >>> result = sign_with_key_hash(b"Hello, dRep!", key_hash, private_key) >>> result.cose_sign1 # CBOR-encoded COSE_Sign1 b'...'