Skip to content
Merged
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
63 changes: 63 additions & 0 deletions common/protob/messages-stellar.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ message StellarSignTx {
optional uint64 memo_id = 12; // 8-byte uint64
optional bytes memo_hash = 13; // 32 bytes representing a hash
required uint32 num_operations = 14; // number of operations in this transaction
optional uint32 soroban_data_size = 60[default=0]; // soroban transaction

// https://github.com/stellar/stellar-core/blob/02d26858069de7c0eefe065056fb0a19bf72ea56/src/xdr/Stellar-transaction.x#L506-L513
enum StellarMemoType {
Expand All @@ -85,6 +86,7 @@ message StellarSignTx {
* @next StellarAccountMergeOp
* @next StellarManageDataOp
* @next StellarBumpSequenceOp
* @next StellarInvokeHostFunctionOp
*/
message StellarTxOpRequest {
}
Expand Down Expand Up @@ -268,6 +270,44 @@ message StellarBumpSequenceOp {
required uint64 bump_to = 2; // new sequence number
}

/**
* Request: ask device to confirm this operation type
* @next StellarSorobanDataRequest
* @next StellarSignedTx
*/
message StellarInvokeHostFunctionOp {
optional string source_account = 1; // (optional) source account address
required string contract_address = 2; // contract id string
required string function_name = 3; // invoked contract function name (SCSymbol, max 32 bytes)
required uint32 call_args_xdr_size = 4; // the total size of call args xdr
required bytes call_args_xdr_initial_chunk = 5; // invokecontract call args xdr bytes
required uint32 soroban_auth_xdr_size = 6;
required bytes soroban_auth_xdr_initial_chunk = 7; // soroban authorization entries xdr
}

/**
* Response: device is ready for client to send the soroban data
* @next StellarSorobanDataAck
*/
message StellarSorobanDataRequest {
required StellarRequestType type = 1;
required uint32 data_length = 2; // Number of bytes being requested (<= 1024)

enum StellarRequestType {
CALL = 0;
AUTH = 1;
EXT = 2;
}
}

/**
* Request: ask device to confirm
* @next StellarSignedTx
*/
message StellarSorobanDataAck {
required bytes data_chunk_xdr = 1; // the soroban data in xdr format
}

/**
* Response: signature for transaction
* @end
Expand All @@ -276,3 +316,26 @@ message StellarSignedTx {
required bytes public_key = 1; // public key for the private key used to sign data
required bytes signature = 2; // signature suitable for sending to the Stellar network
}

/**
* Request: ask device to sign Stellar message
* @start
* @next StellarSignedTx
*/
message StellarSignMessage {
repeated uint32 address_n = 1; // BIP-32 path. For compatibility with other wallets, must be m/44'/148'/index'
required bytes message = 2;
}

/**
* Request: ask device to sign Sorban address authorization
* @start
* @next StellarSignedTx
*/
message StellarSignAuthorization {
repeated uint32 address_n = 1; // BIP-32 path. For compatibility with other wallets, must be m/44'/148'/index'
required string network_passphrase = 2; // passphrase for signing messages on the destination network
required uint64 nonce = 3; // used to protect from replay attack
required uint32 expiration = 4; // the ledger sequence number on which the signature expires
required bytes invocation = 5; // invocation tree xdr
}
3 changes: 3 additions & 0 deletions common/protob/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ enum MessageType {
MessageType_StellarManageBuyOfferOp = 222 [(wire_in) = true];
MessageType_StellarPathPaymentStrictSendOp = 223 [(wire_in) = true];
MessageType_StellarSignedTx = 230 [(wire_out) = true];
MessageType_StellarInvokeHostFunctionOp = 260 [(wire_in) = true];
MessageType_StellarSorobanDataRequest = 261 [(wire_out) = true];
MessageType_StellarSorobanDataAck = 262 [(wire_in) = true, (wire_no_fsm) = true];

// Cardano
// dropped Sign/VerifyMessage ids 300-302
Expand Down
4 changes: 0 additions & 4 deletions legacy/firmware/alephium.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ bool alephium_get_address(const AlephiumGetAddress *msg,
}

void alephium_sign_tx(const HDNode *node, const AlephiumSignTx *msg) {
char log_buffer[1024];
memcpy(&global_node, node, sizeof(HDNode));
alephium_data_total_size = msg->data_initial_chunk.size;
memcpy(alephium_data_buffer, msg->data_initial_chunk.bytes,
Expand All @@ -34,9 +33,6 @@ void alephium_sign_tx(const HDNode *node, const AlephiumSignTx *msg) {
alephium_data_total_size = msg->data_length;
alephium_data_left =
alephium_data_total_size - msg->data_initial_chunk.size;
snprintf(log_buffer, sizeof(log_buffer),
"Requesting more data chunks, total size: %zu, data left: %zu",
(size_t)alephium_data_total_size, (size_t)alephium_data_left);
alephium_send_request_chunk();
} else {
if (alephium_data_buffer[2] == 1) {
Expand Down
7 changes: 5 additions & 2 deletions legacy/firmware/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ static const uint8_t TRUE_BYTE = '\x01';
static bool derive_cardano = 0;
static bool session_seed_cached_btc = false;
static bool session_seed_cached_cardano = false;
bool reset_after_usb_lock = false;

static secbool usb_lock = secfalse;

Expand Down Expand Up @@ -270,8 +271,10 @@ void config_init(void) {
se_set_ui_callback(&layoutProgressAdapter);

// Restore safetyCheckLevel from soft reset if preserved
uint16_t preserved_level = soft_reset_get_preserved_data();
if (preserved_level != PRESERVED_RESET_DATA_INVALID) {
uint16_t preserved_data = soft_reset_get_preserved_data();
if (preserved_data != PRESERVED_RESET_DATA_INVALID) {
uint8_t preserved_level = (uint8_t)(preserved_data & 0x03);
reset_after_usb_lock = (bool)(preserved_data & 0x04);
if (preserved_level == SafetyCheckLevel_PromptTemporarily) {
safetyCheckLevel = (SafetyCheckLevel)preserved_level;
}
Expand Down
31 changes: 24 additions & 7 deletions legacy/firmware/ethereum_onekey.c
Original file line number Diff line number Diff line change
Expand Up @@ -2689,16 +2689,34 @@ static void ethereum_gnosis_safe_tx_sign(
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
return;
}
display_info_init(&display_info, 2);
prepare_domain_items(&display_info, ack);
if (!display_info_init(&display_info, 2)) {
fsm_sendFailure(FailureType_Failure_ProcessError,
"Failed to allocate display items");
return;
}
if (!prepare_domain_items(&display_info, ack)) {
display_info_cleanup(&display_info);
fsm_sendFailure(FailureType_Failure_ProcessError,
"Failed to prepare display items");
return;
}
if (!layoutTypedData(&display_info, TYPE_NAME_DOMAIN)) {
display_info_cleanup(&display_info);
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
return;
}
display_info_cleanup(&display_info);
display_info_init(&display_info, 10);
prepare_safe_items(&display_info, ack);
if (!display_info_init(&display_info, 10)) {
fsm_sendFailure(FailureType_Failure_ProcessError,
"Failed to allocate display items");
return;
}
if (!prepare_safe_items(&display_info, ack)) {
display_info_cleanup(&display_info);
fsm_sendFailure(FailureType_Failure_ProcessError,
"Failed to prepare display items");
return;
}
if (!layoutTypedData(&display_info, "SafeTx")) {
display_info_cleanup(&display_info);
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
Expand Down Expand Up @@ -2727,7 +2745,7 @@ static void ethereum_gnosis_safe_tx_sign(
void ethereum_typed_data_sign_onekey(const EthereumSignTypedDataOneKey *msg,
const HDNode *node,
EthereumTypedDataSignatureOneKey *resp) {
if (strncmp(msg->primary_type, "SafeTx", strlen("SafeTx")) == 0) {
if (strcmp(msg->primary_type, "SafeTx") == 0) {
EthereumGnosisSafeTxRequest request = {0};
const EthereumGnosisSafeTxAck *ack =
call(MessageType_MessageType_EthereumGnosisSafeTxRequest, &request,
Expand Down Expand Up @@ -2791,8 +2809,7 @@ void ethereum_typed_data_sign_onekey(const EthereumSignTypedDataOneKey *msg,
}
display_info_cleanup(&display_info);
bool has_message_hash = true;
if (strncmp(envelope.primary_type, TYPE_NAME_DOMAIN,
strlen(TYPE_NAME_DOMAIN)) == 0) {
if (strcmp(envelope.primary_type, TYPE_NAME_DOMAIN) == 0) {
has_message_hash = false;
}
uint8_t message_hash[32] = {0};
Expand Down
Loading
Loading