Skip to content

Commit 07b394e

Browse files
authored
Merge pull request #8 from mintlayer/sighash_input_commitments
Input commitments v1 support
2 parents 8214307 + 07229ff commit 07b394e

23 files changed

Lines changed: 1712 additions & 501 deletions

File tree

common/protob/messages-mintlayer.proto

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ message MintlayerSignTx {
8787
required uint32 outputs_count = 1; // number of transaction outputs
8888
required uint32 inputs_count = 2; // number of transaction inputs
8989
required MintlayerChainType chain_type = 3; // Chain type to use
90-
optional uint32 version = 4 [default=1]; // transaction version
91-
optional bool chunkify = 5; // display addresses in chunks of 4 characters
90+
required uint32 input_commitments_version = 4; // input commitments version
91+
optional uint32 version = 5 [default=1]; // transaction version
92+
optional bool chunkify = 6; // display addresses in chunks of 4 characters
9293
}
9394

9495
/**
@@ -113,7 +114,7 @@ message MintlayerTxRequest {
113114
* Request for additional data for a tx output
114115
*/
115116
message MintlayerTxOutputRequest {
116-
required uint32 output_index = 1; // index for the requested output
117+
required uint32 output_index = 1; // index for the requested output
117118
optional bytes tx_hash = 2; // transaction hash for the specified output or none for the current transaction that is being signed
118119
}
119120
/**
@@ -237,8 +238,10 @@ message MintlayerFreezeOrder {
237238
*/
238239
message MintlayerConcludeOrderV1 {
239240
required string order_id = 1; // order id in bech32 encoding
240-
required MintlayerOutputValue filled_ask_amount = 2; // the already filled ask amount
241-
required MintlayerOutputValue give_balance = 3; // the remaining give balance of the order
241+
required MintlayerOutputValue initially_asked = 2; // the initial ask balance of the order
242+
required MintlayerOutputValue initially_given = 3; // the initial give balance of the order
243+
required bytes ask_balance = 4; // the remaining ask balance of the order
244+
required bytes give_balance = 5; // the remaining give balance of the order
242245
}
243246

244247
/** Data type for account command Mint tokens
@@ -291,8 +294,10 @@ message MintlayerChangeTokenAuthority {
291294
*/
292295
message MintlayerConcludeOrder {
293296
required string order_id = 1; // order id in bech32 encoding
294-
required MintlayerOutputValue filled_ask_amount = 2; // the already filled ask amount
295-
required MintlayerOutputValue give_balance = 3; // the remaining give balance of the order
297+
required MintlayerOutputValue initially_asked = 2; // the initial ask balance of the order
298+
required MintlayerOutputValue initially_given = 3; // the initial give balance of the order
299+
required bytes ask_balance = 4; // the remaining ask balance of the order
300+
required bytes give_balance = 5; // the remaining give balance of the order
296301
}
297302

298303
/** Data type for account command Fill order
@@ -302,8 +307,10 @@ message MintlayerFillOrder {
302307
required string order_id = 1; // order id in bech32 encoding
303308
required bytes amount = 2; // amount in atoms corresponds to the order's ask currency
304309
required string destination = 3; // the destination in bech32 encoding
305-
required MintlayerOutputValue ask_balance = 4; // the remaining ask balance of the order
306-
required MintlayerOutputValue give_balance = 5; // the remaining give balance of the order
310+
required MintlayerOutputValue initially_asked = 4; // the initial ask balance of the order
311+
required MintlayerOutputValue initially_given = 5; // the initial give balance of the order
312+
required bytes ask_balance = 6; // the remaining ask balance of the order
313+
required bytes give_balance = 7; // the remaining give balance of the order
307314
}
308315

309316
/** Data type for account command Change token metadata uri
@@ -491,30 +498,29 @@ message MintlayerTxAck {
491498
* @next MintlayerTxRequest
492499
*/
493500
message MintlayerTxInput {
494-
optional MintlayerUtxoTxInput utxo = 1; // UTXO input
495-
optional MintlayerAccountTxInput account = 2; // account spending input
496-
optional MintlayerAccountCommandTxInput account_command = 3; // account command input
497-
optional MintlayerOrderCommandTxInput order_command = 4; // order command input
498-
}
501+
optional MintlayerUtxoTxInput utxo = 1; // UTXO input
502+
optional MintlayerAccountTxInput account = 2; // account spending input
503+
optional MintlayerAccountCommandTxInput account_command = 3; // account command input
504+
optional MintlayerOrderCommandTxInput order_command = 4; // order command input
505+
}
499506

500507
/**
501508
* Request: Data about output to be signed.
502509
*
503510
* @next MintlayerTxRequest
504511
*/
505512
message MintlayerTxOutput {
506-
optional MintlayerTransferTxOutput transfer = 1; // transfer output
507-
optional MintlayerLockThenTransferTxOutput lock_then_transfer = 2; // lock then transfer output
508-
optional MintlayerBurnTxOutput burn = 3; // burn output
509-
optional MintlayerCreateStakePoolTxOutput create_stake_pool = 4; // create stake pool output
510-
optional MintlayerProduceBlockFromStakeTxOutput produce_block_from_stake = 5; // create block from stake output
511-
optional MintlayerCreateDelegationIdTxOutput create_delegation_id = 6; // create delegation Id output
512-
optional MintlayerDelegateStakingTxOutput delegate_staking = 7; // delegate staking output
513-
optional MintlayerIssueFungibleTokenTxOutput issue_fungible_token = 8; // issue fungible token output
514-
optional MintlayerIssueNftTxOutput issue_nft = 9; // issue NFT output
515-
optional MintlayerDataDepositTxOutput data_deposit = 10; // data deposit output
516-
optional MintlayerHtlcTxOutput htlc = 11; // HTLC output
517-
optional MintlayerCreateOrderTxOutput create_order = 12; // Create order output
518-
}
513+
optional MintlayerTransferTxOutput transfer = 1; // transfer output
514+
optional MintlayerLockThenTransferTxOutput lock_then_transfer = 2; // lock then transfer output
515+
optional MintlayerBurnTxOutput burn = 3; // burn output
516+
optional MintlayerCreateStakePoolTxOutput create_stake_pool = 4; // create stake pool output
517+
optional MintlayerProduceBlockFromStakeTxOutput produce_block_from_stake = 5; // create block from stake output
518+
optional MintlayerCreateDelegationIdTxOutput create_delegation_id = 6; // create delegation Id output
519+
optional MintlayerDelegateStakingTxOutput delegate_staking = 7; // delegate staking output
520+
optional MintlayerIssueFungibleTokenTxOutput issue_fungible_token = 8; // issue fungible token output
521+
optional MintlayerIssueNftTxOutput issue_nft = 9; // issue NFT output
522+
optional MintlayerDataDepositTxOutput data_deposit = 10; // data deposit output
523+
optional MintlayerHtlcTxOutput htlc = 11; // HTLC output
524+
optional MintlayerCreateOrderTxOutput create_order = 12; // Create order output
525+
}
519526
}
520-

core/SConscript.firmware

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ SOURCE_MOD += [
8989
'embed/upymod/modtrezorcrypto/modtrezorcrypto.c',
9090
'embed/upymod/modtrezorcrypto/rand.c',
9191
'embed/upymod/modtrezormintlayer/modtrezormintlayer.c',
92+
'embed/upymod/modtrezormintlayer/utils.c',
9293
]
9394
SOURCE_MOD_CRYPTO += [
9495
'vendor/trezor-crypto/address.c',

core/SConscript.unix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ SOURCE_MOD += [
8686
'embed/upymod/modtrezorcrypto/crc.c',
8787
'embed/upymod/modtrezorcrypto/modtrezorcrypto.c',
8888
'embed/upymod/modtrezormintlayer/modtrezormintlayer.c',
89+
'embed/upymod/modtrezormintlayer/utils.c',
8990
]
9091
SOURCE_MOD_CRYPTO += [
9192
'vendor/trezor-crypto/address.c',

core/embed/rust/Cargo.lock

Lines changed: 53 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/embed/rust/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ parity-scale-codec = { version = "3.1", default-features = false, features = [
100100
"derive",
101101
"chain-error",
102102
], optional = true }
103-
ml_common = { git = "https://github.com/mintlayer/mintlayer-core", package = "trezor-common", branch = "master", optional = true }
103+
[dependencies.ml_common]
104+
git = "https://github.com/mintlayer/mintlayer-core"
105+
rev = "563511e331fd2d619f2699612863df9ecee58ff8" # Commit "Sighash input commitments v1"
106+
package = "trezor-common"
107+
optional = true
104108

105109
# Runtime dependencies
106110

core/embed/rust/mintlayer.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#ifndef MINTLAYER_H
2+
#define MINTLAYER_H
3+
14
#include "common.h"
25

36
uint32_t mintlayer_screen_fatal_error_rust(const char* title, const char* msg,
@@ -142,3 +145,36 @@ ByteArray mintlayer_encode_create_order_output(
142145
uint32_t give_token_id_data_len);
143146

144147
ByteArray mintlayer_encode_compact_length(uint32_t length);
148+
149+
ByteArray mintlayer_encode_empty_input_commitment();
150+
151+
ByteArray mintlayer_encode_input_commitment_for_utxo(
152+
const unsigned char* encoded_utxo_data, uint32_t encoded_utxo_data_len);
153+
154+
ByteArray
155+
mintlayer_encode_input_commitment_v1_for_produce_block_from_stake_utxo(
156+
const unsigned char* encoded_utxo_data, uint32_t encoded_utxo_data_len,
157+
const unsigned char* staker_balance_amount_data,
158+
uint32_t staker_balance_amount_data_len);
159+
160+
ByteArray mintlayer_encode_input_commitment_v1_for_fill_order(
161+
const unsigned char* asked_token_data, uint32_t asked_token_data_len,
162+
const unsigned char* initially_asked_amount_data,
163+
uint32_t initially_asked_amount_data_len,
164+
const unsigned char* given_token_data, uint32_t given_token_data_len,
165+
const unsigned char* initially_given_amount_data,
166+
uint32_t initially_given_amount_data_len);
167+
168+
ByteArray mintlayer_encode_input_commitment_v1_for_conclude_order(
169+
const unsigned char* asked_token_data, uint32_t asked_token_data_len,
170+
const unsigned char* initially_asked_amount_data,
171+
uint32_t initially_asked_amount_data_len,
172+
const unsigned char* ask_balance_amount_data,
173+
uint32_t ask_balance_amount_data_len, const unsigned char* given_token_data,
174+
uint32_t given_token_data_len,
175+
const unsigned char* initially_given_amount_data,
176+
uint32_t initially_given_amount_data_len,
177+
const unsigned char* give_balance_amount_data,
178+
uint32_t give_balance_amount_data_len);
179+
180+
#endif // MINTLAYER_H

0 commit comments

Comments
 (0)