CIP

Implementation of Cardano Improvement Proposals (CIPs)

pycardano.cip.cip8.sign(message: str, signing_key: Union[pycardano.key.ExtendedSigningKey, pycardano.key.SigningKey], attach_cose_key: bool = False, network: pycardano.network.Network = Network.MAINNET) Union[str, dict]

Sign an arbitrary message with a payment or stake key following CIP-0008. Note that a stake key passed in must be of type StakeSigningKey or StakeExtendedSigningKey to be detected.

Parameters
  • message (str) – Message to be signed

  • signing_key (SigningKey) – Key which is used to sign the message

  • attach_cose_key (bool) – Whether or not to attach the Cose key to the output

  • network (Network) – Network to use for the address generation

Returns

A hex-encoded string containing the signed message and verification key. In the case of attach_cose_key=True, a dict containing the signed message and Cose key.

Return type

Union[str, dict]

pycardano.cip.cip8.verify(signed_message: Union[str, dict], attach_cose_key: Optional[bool] = None) dict

Verify the signature of a COSESign1 message and decode its contents following CIP-0008. Supports messages signed by browser wallets or Message.sign().

Parameters
  • signed_message (Union[str, dict]) – Message to be verified

  • attach_cose_key (Optional[bool]) – Whether or not the Cose key is included with the signed_message. This method will try to determine this automatically if not specified. Usually if signed_message is a dict, this should be true.

Returns

A dict containing whether or not the message is verified, the message contents, and an Address which was used to sign the message.

Return type

dict