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): validate pool registration owner witness path #74

Open
wants to merge 5 commits into
base: cardano-multisig
Choose a base branch
from
Open
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
72 changes: 68 additions & 4 deletions common/protob/messages-cardano.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ enum CardanoAddressType {
REWARD_SCRIPT = 15;
}

enum CardanoNativeScriptType {
PUB_KEY = 0;
ALL = 1;
ANY = 2;
N_OF_K = 3;
INVALID_BEFORE = 4;
INVALID_HEREAFTER = 5;
}

enum CardanoNativeScriptHashDisplayFormat {
HIDE = 0;
BECH32 = 1;
POLICY_ID = 2;
}

enum CardanoCertificateType {
STAKE_REGISTRATION = 0;
STAKE_DEREGISTRATION = 1;
Expand All @@ -46,6 +61,7 @@ enum CardanoTxAuxiliaryDataSupplementType {
enum CardanoTxSigningMode {
ORDINARY_TRANSACTION = 0;
POOL_REGISTRATION_AS_OWNER = 1;
SCRIPT_TRANSACTION = 2;
}

enum CardanoTxWitnessType {
Expand All @@ -64,6 +80,39 @@ message CardanoBlockchainPointerType {
required uint32 certificate_index = 3;
}

/*
* @embed
*/
message CardanoNativeScript {
required CardanoNativeScriptType type = 1;
repeated CardanoNativeScript scripts = 2;

optional bytes key_hash = 3;
repeated uint32 key_path = 4;
optional uint32 required_signatures_count = 5;
optional uint64 invalid_before = 6;
optional uint64 invalid_hereafter = 7;
}

/**
* Request: Ask device for Cardano native script hash
* @start
* @next CardanoNativeScriptHash
* @next Failure
*/
message CardanoGetNativeScriptHash {
required CardanoNativeScript script = 1;
required CardanoNativeScriptHashDisplayFormat display_format = 2; // display hash as bech32 or policy id
}

/**
* Request: Ask device for Cardano native script hash
* @end
*/
message CardanoNativeScriptHash {
required bytes script_hash = 1;
}

/**
* Structure to represent address parameters so they can be
* reused in CardanoGetAddress and CardanoTxOutputType.
Expand All @@ -80,6 +129,8 @@ message CardanoAddressParametersType {
// can be sent directly e.g. if it doesn't belong to
// the same account as address_n
optional CardanoBlockchainPointerType certificate_pointer = 5; // a pointer to the staking key registration certificate
optional bytes script_payment_hash = 6;
optional bytes script_staking_hash = 7;
}

/**
Expand Down Expand Up @@ -143,6 +194,7 @@ message CardanoSignTxInit {
required bool has_auxiliary_data = 10;
optional uint64 validity_interval_start = 11;
required uint32 witness_requests_count = 12;
required uint32 minting_asset_groups_count = 13;
}

/**
Expand Down Expand Up @@ -180,7 +232,8 @@ message CardanoAssetGroup {
*/
message CardanoToken {
required bytes asset_name_bytes = 1; // asset name as bytestring (may be either ascii string or hash)
required uint64 amount = 2; // asset amount
optional uint64 amount = 2; // asset amount
optional sint64 mint_amount = 3; // mint amount (can also be negative in which case the tokens are burnt)
}

/**
Expand Down Expand Up @@ -238,18 +291,20 @@ message CardanoPoolParametersType {
*/
message CardanoTxCertificate {
required CardanoCertificateType type = 1; // certificate type
repeated uint32 path = 2; // BIP-32 path to derive (staking) key
repeated uint32 path = 2; // stake credential key path
optional bytes pool = 3; // pool hash
optional CardanoPoolParametersType pool_parameters = 4; // used for stake pool registration certificate
optional bytes script_hash = 5; // stake credential script hash
}

/**
* Request: Transaction withdrawal data
* @next CardanoTxItemAck
*/
message CardanoTxWithdrawal {
repeated uint32 path = 1;
repeated uint32 path = 1; // stake credential key path
required uint64 amount = 2;
optional bytes script_hash = 3; // stake credential script hash
}

/**
Expand All @@ -272,6 +327,14 @@ message CardanoTxAuxiliaryData {
optional bytes hash = 2;
}

/**
* Request: Transaction mint
* @next CardanoTxItemAck
*/
message CardanoTxMint {
required uint32 asset_groups_count = 1;
}

/**
* Response: Acknowledgement of the last transaction item received
* @next CardanoTxInput
Expand All @@ -284,6 +347,7 @@ message CardanoTxAuxiliaryData {
* @next CardanoTxWithdrawal
* @next CardanoTxAuxiliaryData
* @next CardanoTxWitnessRequest
* @next CardanoTxMint
*/
message CardanoTxItemAck {
}
Expand Down Expand Up @@ -392,7 +456,7 @@ message CardanoSignTx {

message CardanoTokenType {
required bytes asset_name_bytes = 1; // asset name as bytestring (may be either ascii string or hash)
required uint64 amount = 2; // asset amount
required uint64 amount = 2; // asset amount
}

/**
Expand Down
4 changes: 3 additions & 1 deletion common/protob/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ enum MessageType {
MessageType_CardanoTxAuxiliaryData = 327 [(wire_in) = true];
MessageType_CardanoPoolOwner = 328 [(wire_in) = true];
MessageType_CardanoPoolRelayParameters = 329 [(wire_in) = true];

MessageType_CardanoGetNativeScriptHash = 330 [(wire_in) = true];
MessageType_CardanoNativeScriptHash = 331 [(wire_out) = true];
MessageType_CardanoTxMint = 332 [(wire_in) = true];

// Ripple
MessageType_RippleGetAddress = 400 [(wire_in) = true];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"setup": {
"mnemonic": "all all all all all all all all all all all all",
"passphrase": ""
},
"tests": [
{
"parameters": {
"address_type": "base_script_key",
"script_payment_hash": "0d5acbf6a1dfb0c8724e60df314987315ccbf78bb6c0f9b6f3d568fe",
"staking_path": "m/1852'/1815'/0'/2/0",
"network_id": 1,
"protocol_magic": 764824073
},
"result": {
"expected_address": "addr1zyx44jlk580mpjrjfesd7v2fsuc4ejlh3wmvp7dk702k3lsj922xhxkn6twlq2wn4q50q352annk3903tj00h45mgfmsf42dkl"
}
},
{
"parameters": {
"address_type": "base_script_key",
"script_payment_hash": "0d5acbf6a1dfb0c8724e60df314987315ccbf78bb6c0f9b6f3d568fe",
"staking_path": "m/1852'/1815'/0'/2/0",
"network_id": 0,
"protocol_magic": 42
},
"result": {
"expected_address": "addr_test1zqx44jlk580mpjrjfesd7v2fsuc4ejlh3wmvp7dk702k3lsj922xhxkn6twlq2wn4q50q352annk3903tj00h45mgfms2rhd6q"
}
},
{
"parameters": {
"address_type": "base_key_script",
"path": "m/1852'/1815'/0'/0/0",
"script_staking_hash": "8d7bebc7a58f1c7b5fb7c9391071ecd3b51b032695522f8c555343a9",
"network_id": 1,
"protocol_magic": 764824073
},
"result": {
"expected_address": "addr1yxq0nckg3ekgzuqg7w5p9mvgnd9ym28qh5grlph8xd2z925d004u0fv0r3a4ld7f8yg8rmxnk5dsxf542ghcc42ngw5s8vnrtt"
}
},
{
"parameters": {
"address_type": "base_key_script",
"path": "m/1852'/1815'/0'/0/0",
"script_staking_hash": "8d7bebc7a58f1c7b5fb7c9391071ecd3b51b032695522f8c555343a9",
"network_id": 0,
"protocol_magic": 42
},
"result": {
"expected_address": "addr_test1yzq0nckg3ekgzuqg7w5p9mvgnd9ym28qh5grlph8xd2z925d004u0fv0r3a4ld7f8yg8rmxnk5dsxf542ghcc42ngw5sy6wr85"
}
},
{
"parameters": {
"address_type": "base_script_script",
"script_payment_hash": "0d5acbf6a1dfb0c8724e60df314987315ccbf78bb6c0f9b6f3d568fe",
"script_staking_hash": "8d7bebc7a58f1c7b5fb7c9391071ecd3b51b032695522f8c555343a9",
"network_id": 1,
"protocol_magic": 764824073
},
"result": {
"expected_address": "addr1xyx44jlk580mpjrjfesd7v2fsuc4ejlh3wmvp7dk702k3l5d004u0fv0r3a4ld7f8yg8rmxnk5dsxf542ghcc42ngw5s3gftll"
}
},
{
"parameters": {
"address_type": "base_script_script",
"script_payment_hash": "0d5acbf6a1dfb0c8724e60df314987315ccbf78bb6c0f9b6f3d568fe",
"script_staking_hash": "8d7bebc7a58f1c7b5fb7c9391071ecd3b51b032695522f8c555343a9",
"network_id": 0,
"protocol_magic": 42
},
"result": {
"expected_address": "addr_test1xqx44jlk580mpjrjfesd7v2fsuc4ejlh3wmvp7dk702k3l5d004u0fv0r3a4ld7f8yg8rmxnk5dsxf542ghcc42ngw5sj75tnq"
}
}
]
}
22 changes: 22 additions & 0 deletions common/tests/fixtures/cardano/get_enterprise_address.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@
"result": {
"expected_address": "addr_test1vzq0nckg3ekgzuqg7w5p9mvgnd9ym28qh5grlph8xd2z92s8k2y47"
}
},
{
"parameters": {
"address_type": "enterprise_script",
"script_payment_hash": "0d5acbf6a1dfb0c8724e60df314987315ccbf78bb6c0f9b6f3d568fe",
"network_id": 1,
"protocol_magic": 764824073
},
"result": {
"expected_address": "addr1wyx44jlk580mpjrjfesd7v2fsuc4ejlh3wmvp7dk702k3lsqee7sp"
}
},
{
"parameters": {
"address_type": "enterprise_script",
"script_payment_hash": "0d5acbf6a1dfb0c8724e60df314987315ccbf78bb6c0f9b6f3d568fe",
"network_id": 0,
"protocol_magic": 42
},
"result": {
"expected_address": "addr_test1wqx44jlk580mpjrjfesd7v2fsuc4ejlh3wmvp7dk702k3lsm3dzly"
}
}
]
}
Loading