Cardano: Sign message
Asks device to sign given message. User is presented with the first few bytes of the message and the hash of the whole message. User is asked to confirm details on Trezor.
const result = await TrezorConnect.cardanoSignMessage(params);Params
path
String | Array<Number>
minimum length is 5. read more
payload
String
message bytes in hex
preferHexDisplay
Boolean
if true, device will always decode payload as hex bytes
networkId
Number
network identifier. Required if addressParameters are set
protocolMagic
Number
protocol magic. Required if addressParameters are set
addressParameters
Object
CardanoAddressParameters object. read more Used to derive address for message header. If not set then the key hash given by path will be used instead.
path
String | Array<Number>
minimum length is 5. read more
stakingPath
String | Array<Number>
Derivation Path (BIP32).
derivationType
Enum: LEDGER (0) | ICARUS (1) | ICARUS_TREZOR (2)
enum. determines used derivation type. Default is set to ICARUS_TREZOR=2
Displaying payload
By default, the payload is decoded as ASCII given the conditions below are satisfied. If they are not satisfied or preferHexDisplay is true, the payload is displayed as hex bytes. The ASCII conditions are:
- The payload is a valid ASCII string.
- It must be clear to the user what the contents of the payload are, specifically there is:
- At least one character
- No control characters
- No leading, trailing nor multiple consecutive spaces
Example
Sign hash of "Hello Trezor!":
TrezorConnect.cardanoSignMessage({
path: "m/1852'/1815'/0'/0/0",
payload: '48656c6c6f205472657a6f7221', // "Hello Trezor!" in hex
preferHexDisplay: false,
});Sign hash of "Hello Trezor!" using address parameters for header:
TrezorConnect.cardanoSignMessage({
path: "m/1852'/1815'/0'/0/0",
payload: '48656c6c6f205472657a6f7221', // "Hello Trezor!" in hex
preferHexDisplay: false,
networkId: 1,
protocolMagic: 764824073,
addressParameters: {
addressType: 0,
path: "m/1852'/1815'/0'/0/0",
stakingPath: "m/1852'/1815'/0'/2/0",
},
});Result
{
success: true,
payload: {
payload: string, // your payload
signature: string, // raw signature
pubKey: string, // raw public key
coseSignature: string, // COSE cbor encoded signature
coseKey: string, // COSE cbor encoded public key
headers: { // COSE headers
protected: {
1: -8, // EdDSA algorithm
address: string,
},
unprotected: {
hashed: boolean,
version: number,
}
}
}
}Error
{
success: false,
payload: {
error: string // error message
}
}