CIP-008¶
-
cardano_error_t cardano_cip8_sign(const byte_t *message, size_t message_size, const cardano_address_t *address, const cardano_ed25519_private_key_t *signing_key, cardano_buffer_t **cose_sign1_out, cardano_buffer_t **cose_key_out)¶
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
signDataAPI. 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
address
The resulting
cose_sign1_outandcose_key_outbuffers contain CBOR-encoded COSE structures.const byte_t message[] = "Hello, Cardano!"; cardano_address_t* address = // previously constructed cardano_ed25519_private_key_t* sk = // derived key; cardano_buffer_t* cose_sign1 = NULL; cardano_buffer_t* cose_key = NULL; cardano_error_t result = cardano_cip8_sign( message, sizeof(message) - 1, address, sk, &cose_sign1, &cose_key); if (result != CARDANO_SUCCESS) { // handle error... } cardano_buffer_unref(&cose_sign1); cardano_buffer_unref(&cose_key);- Parameters:¶
- const byte_t *message¶
[in] Pointer to the message bytes to sign.
- size_t message_size¶
[in] Size of
messagein bytes.- const cardano_address_t *address¶
[in] Cardano address to bind the signature to. Must not be NULL. If you need to bind the signature to a key hash instead, use cardano_cip8_sign_ex.
- const cardano_ed25519_private_key_t *signing_key¶
[in] Ed25519 private key used to produce the signature. Must not be NULL.
- cardano_buffer_t **cose_sign1_out¶
[out] On success, receives a newly allocated buffer containing the CBOR-encoded COSE_Sign1 structure.
- cardano_buffer_t **cose_key_out¶
[out] On success, receives a newly allocated buffer containing the CBOR-encoded COSE_Key structure corresponding to
signing_key.
- Returns:¶
CARDANO_SUCCESS on success, or an error code on failure.
- Post:¶
On success, the caller owns
cose_sign1_outandcose_key_outand must release them with cardano_buffer_unref().
-
cardano_error_t cardano_cip8_sign_ex(const byte_t *message, size_t message_size, const cardano_blake2b_hash_t *key_hash, const cardano_ed25519_private_key_t *signing_key, cardano_buffer_t **cose_sign1_out, cardano_buffer_t **cose_key_out)¶
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
signDataAPI, 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
key_hash
The resulting
cose_sign1_outandcose_key_outbuffers contain CBOR-encoded COSE structures.const byte_t message[] = "Hello, dRep!"; cardano_blake2b_hash_t* key_hash = // previously computed key hash; cardano_ed25519_private_key_t* sk = // derived key; cardano_buffer_t* cose_sign1 = NULL; cardano_buffer_t* cose_key = NULL; cardano_error_t result = cardano_cip8_sign_ex( message, sizeof(message) - 1, key_hash, sk, &cose_sign1, &cose_key); if (result != CARDANO_SUCCESS) { // handle error... } cardano_buffer_unref(&cose_sign1); cardano_buffer_unref(&cose_key);- Parameters:¶
- const byte_t *message¶
[in] Pointer to the message bytes to sign.
- size_t message_size¶
[in] Size of
messagein bytes.- const cardano_blake2b_hash_t *key_hash¶
[in] Key hash to bind the signature to (typically a Blake2b-224 hash of a public key). Must not be NULL.
- const cardano_ed25519_private_key_t *signing_key¶
[in] Ed25519 private key used to produce the signature. Must not be NULL.
- cardano_buffer_t **cose_sign1_out¶
[out] On success, receives a newly allocated buffer containing the CBOR-encoded COSE_Sign1 structure.
- cardano_buffer_t **cose_key_out¶
[out] On success, receives a newly allocated buffer containing the CBOR-encoded COSE_Key structure corresponding to
signing_key.
- Returns:¶
CARDANO_SUCCESS on success, or an error code on failure.
- Post:¶
On success, the caller owns
cose_sign1_outandcose_key_outand must release them with cardano_buffer_unref().