Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cardano): add support for CIP36 governance registration format #82

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions common/protob/messages-cardano.proto
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ enum CardanoPoolRelayType {

enum CardanoTxAuxiliaryDataSupplementType {
NONE = 0;
CATALYST_REGISTRATION_SIGNATURE = 1;
GOVERNANCE_REGISTRATION_SIGNATURE = 1;
}

enum CardanoGovernanceRegistrationFormat {
CIP15 = 0;
CIP36 = 1;
}

enum CardanoTxSigningMode {
Expand Down Expand Up @@ -332,7 +337,7 @@ message CardanoPoolParametersType {
* Request: Transaction certificate data
* @next CardanoTxItemAck
*/
message CardanoTxCertificate {
message CardanoTxCertificate {
required CardanoCertificateType type = 1; // certificate type
repeated uint32 path = 2; // stake credential key path
optional bytes pool = 3; // pool hash
Expand All @@ -355,11 +360,22 @@ message CardanoTxWithdrawal {
/**
* @embed
*/
message CardanoCatalystRegistrationParametersType {
message CardanoGovernanceRegistrationDelegation {
required bytes voting_public_key = 1;
required uint32 weight = 2;
}

/**
* @embed
*/
message CardanoGovernanceRegistrationParametersType {
optional bytes voting_public_key = 1;
repeated uint32 staking_path = 2;
required CardanoAddressParametersType reward_address_parameters = 3;
required uint64 nonce = 4;
optional CardanoGovernanceRegistrationFormat format = 5 [default=CIP15];
repeated CardanoGovernanceRegistrationDelegation delegations = 6; // mutually exclusive with voting_public_key; max 32 delegations
optional uint64 voting_purpose = 7;
}

/**
Expand All @@ -368,7 +384,7 @@ message CardanoCatalystRegistrationParametersType {
* @next CardanoTxAuxiliaryDataSupplement
*/
message CardanoTxAuxiliaryData {
optional CardanoCatalystRegistrationParametersType catalyst_registration_parameters = 1;
optional CardanoGovernanceRegistrationParametersType governance_registration_parameters = 1;
optional bytes hash = 2;
}

Expand Down Expand Up @@ -436,7 +452,7 @@ message CardanoTxItemAck {
message CardanoTxAuxiliaryDataSupplement {
required CardanoTxAuxiliaryDataSupplementType type = 1;
optional bytes auxiliary_data_hash = 2;
optional bytes catalyst_signature = 3;
optional bytes governance_signature = 3;
}

/**
Expand Down
65 changes: 61 additions & 4 deletions common/tests/fixtures/cardano/sign_tx.failed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@
}
},
{
"description": "transaction with catalyst registration containing byron reward address",
"description": "transaction with governance registration containing byron reward address",
"parameters": {
"protocol_magic": 764824073,
"network_id": 1,
Expand All @@ -1309,7 +1309,7 @@
"certificates": [],
"withdrawals": [],
"auxiliary_data": {
"catalyst_registration_parameters": {
"governance_registration_parameters": {
"voting_public_key": "3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7",
"staking_path": "m/1852'/1815'/0'/2/0",
"nonce": 22634813,
Expand Down Expand Up @@ -1348,7 +1348,7 @@
}
},
{
"description": "transaction with both auxiliary data blob and catalyst registration",
"description": "transaction with both auxiliary data blob and governance registration",
"parameters": {
"protocol_magic": 764824073,
"network_id": 1,
Expand All @@ -1359,7 +1359,7 @@
"withdrawals": [],
"auxiliary_data": {
"hash": "ea4c91860dd5ec5449f8f985d227946ff39086b17f10b5afb93d12ee87050b6a",
"catalyst_registration_parameters": {
"governance_registration_parameters": {
"voting_public_key": "38DA0B509D45BF6C87BD55594B92F97081D3923B8C1334B9B8D0BF13FC1C12D0",
"staking_path": "m/1852'/1815'/0'/2/0",
"reward_address_parameters": {
Expand Down Expand Up @@ -1398,6 +1398,63 @@
"error_message": "Invalid auxiliary data"
}
},
{
"description": "transaction with both voting public key and delegations in governance registration",
"parameters": {
"protocol_magic": 764824073,
"network_id": 1,
"fee": 42,
"ttl": 10,
"validity_interval_start": null,
"certificates": [],
"withdrawals": [],
"auxiliary_data": {
"governance_registration_parameters": {
"voting_public_key": "38DA0B509D45BF6C87BD55594B92F97081D3923B8C1334B9B8D0BF13FC1C12D0",
"staking_path": "m/1852'/1815'/0'/2/0",
"reward_address_parameters": {
"addressType": 0,
"path": "m/1852'/1815'/0'/0/0",
"stakingPath": "m/1852'/1815'/0'/2/0"
},
"nonce": 140,
"format": 1,
"delegations": [
{
"voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc",
"weight": 1
}
]
}
},
"inputs": [
{
"path": "m/1852'/1815'/0'/0/0",
"prev_hash": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc",
"prev_index": 0
}
],
"outputs": [
{
"address": "addr1q84sh2j72ux0l03fxndjnhctdg7hcppsaejafsa84vh7lwgmcs5wgus8qt4atk45lvt4xfxpjtwfhdmvchdf2m3u3hlsd5tq5r",
"amount": "1"
}
],
"mint": [],
"script_data_hash": null,
"collateral_inputs": [],
"required_signers": [],
"collateral_return": null,
"total_collateral": null,
"reference_inputs": [],
"signing_mode": "ORDINARY_TRANSACTION",
"additional_witness_requests": [],
"include_network_id": false
},
"result": {
"error_message": "Invalid auxiliary data"
}
},
{
"description": "Output datum hash has incorrect length",
"parameters": {
Expand Down
Loading