Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
2927d17
feat: Added boilerpate code for constellation app
muzaffarbhat07 Mar 6, 2025
b9e9fe8
fix: Corrected constellation boilerplate code
muzaffarbhat07 Mar 6, 2025
5b0f6a7
fix: Constellation proto options
muzaffarbhat07 Mar 6, 2025
3e36ebc
fix: Code formatting
muzaffarbhat07 Mar 6, 2025
642d273
feat: Constellation generate pubkey and address
muzaffarbhat07 Mar 6, 2025
bb1679e
fix: Return uncompressed pubkey in constellation app
muzaffarbhat07 Mar 6, 2025
1a04b50
fix: Corrected constellatio generate address pseudo code
muzaffarbhat07 Mar 6, 2025
5ecaf1d
Merge pull request #628 from Cypherock/feat/constellation/pubkey-address
TejasvOnly Mar 8, 2025
32d223f
feat: Added sign txn functionality to constellation app
muzaffarbhat07 Mar 8, 2025
140c089
fix: Generalized constellation sign txn
muzaffarbhat07 Mar 17, 2025
2950811
fix: Removed unit from amount and fee
muzaffarbhat07 Mar 18, 2025
c472a6e
fix: Code formatting
muzaffarbhat07 Mar 18, 2025
dcdb3b3
fix: Resolve review comments
muzaffarbhat07 Mar 19, 2025
4cde2ed
feat: Added constellation blind signing
muzaffarbhat07 Mar 12, 2025
7c3074a
feat: Added constellation sign msg and data
muzaffarbhat07 Mar 15, 2025
248874e
fix: Resolved review comments
muzaffarbhat07 Mar 19, 2025
346843c
fix: Ci tests
muzaffarbhat07 Mar 19, 2025
26e3fe6
fix: Code formatting
muzaffarbhat07 Mar 19, 2025
5a29ae9
feat: Added constellation blind signing
muzaffarbhat07 Mar 12, 2025
1fc5b4a
feat: Added constellation sign msg and data
muzaffarbhat07 Mar 15, 2025
26be9b9
feat: Modified ending text of constellation
muzaffarbhat07 Mar 18, 2025
e7681a1
fix: Code formatting
muzaffarbhat07 Mar 18, 2025
8076fb5
fix: Code formatting
muzaffarbhat07 Mar 19, 2025
48e3f69
Merge pull request #631 from Cypherock/feat/constellation/sign-txn
muzaffarbhat07 Mar 20, 2025
49422a3
Merge pull request #632 from Cypherock/feat/constellation/sign-msg
muzaffarbhat07 Mar 22, 2025
bafea33
Merge pull request #633 from Cypherock/feat/constellation/ui-text-ending
muzaffarbhat07 Mar 22, 2025
989ef50
chore: Exchange app boilerplate
TejasvOnly Apr 16, 2025
d328e76
feat: Basic interaction with sdk
TejasvOnly Apr 17, 2025
17ff395
feat: Compsable queue and shared context
TejasvOnly Apr 18, 2025
23bbd8d
feat: Exchange app uses composable queue
TejasvOnly Apr 18, 2025
2cad3cc
feat: Validate composable queue in every coin flow
TejasvOnly Apr 18, 2025
7a51fbc
chore: Dummy commit
TejasvOnly Apr 18, 2025
fe8a8a8
chore: Add error logs
TejasvOnly Apr 19, 2025
db55478
feat: Use signature verification in send flow
TejasvOnly Apr 21, 2025
774eeea
feat: Sign address in receive flow for exchange app
TejasvOnly Apr 21, 2025
db42c79
chore: Add doxygen comments
TejasvOnly Apr 21, 2025
182354a
fix: Correct icp txn verification texts
muzaffarbhat07 Apr 16, 2025
959284d
fix: Lvgl kern value
muzaffarbhat07 Apr 17, 2025
a29879f
fix: Code formatting
muzaffarbhat07 Apr 17, 2025
14c17a8
chore: Version bump
muzaffarbhat07 Apr 19, 2025
d87f20a
chore: Version bump for dev release
muzaffarbhat07 Apr 24, 2025
23ed865
feat: Added close swap flow functionality to exchange app
muzaffarbhat07 Apr 25, 2025
b658412
fix: Null title check in core scroll page
muzaffarbhat07 Apr 28, 2025
48d0765
chore: Version bump for dev release
muzaffarbhat07 Apr 28, 2025
a5de5a4
fix: Corrected send wallet id in exchange app
muzaffarbhat07 Apr 29, 2025
d3c0e83
chore: Version bump for dev release
muzaffarbhat07 Apr 29, 2025
fbc1dee
chore: Version bump for dev release
muzaffarbhat07 Apr 29, 2025
372f5e9
chore: Version bump
muzaffarbhat07 Apr 29, 2025
b2382f2
Merge branch 'develop' into feat/swap
muzaffarbhat07 May 8, 2025
c4dab6f
fix: Code formatting
muzaffarbhat07 May 8, 2025
3590ea6
fix: Length validation in apdu exchange
muzaffarbhat07 May 8, 2025
efd2049
chore: Version bump
muzaffarbhat07 May 8, 2025
3eea41a
fix: Added logs for signature invalidation
muzaffarbhat07 May 9, 2025
29f4700
chore: Version bump
muzaffarbhat07 May 9, 2025
662bdaf
fix: Correct logs for sig verification, made test changes for lvgl issue
muzaffarbhat07 May 12, 2025
bbe73e5
chore: Version bump
muzaffarbhat07 May 12, 2025
d5f36c5
revert: Test changes for lvgl issue
muzaffarbhat07 May 12, 2025
7cf258a
fix: Scroll page bug
muzaffarbhat07 May 13, 2025
0f1b07e
fix: Swap signature verification in solana token txn
muzaffarbhat07 May 14, 2025
93d7fe3
fix: Version bump
muzaffarbhat07 May 14, 2025
47b62cd
fix: Commented swap signature verification logs
muzaffarbhat07 May 17, 2025
cd9f555
chore: Version bump
muzaffarbhat07 May 17, 2025
c3c2cae
fix: Removed commented code
muzaffarbhat07 May 19, 2025
9e41874
chore: Version bump
muzaffarbhat07 May 19, 2025
531ce9e
Merge pull request #646 from Cypherock/feat/swap
muzaffarbhat07 May 20, 2025
d3ad8d7
Merge branch 'release/0.6.2304+' into hotfix/apdu-exchange/stackoverflow
muzaffarbhat07 May 20, 2025
88899be
fix: Code formatting
muzaffarbhat07 May 20, 2025
e725952
Merge pull request #649 from Cypherock/hotfix/apdu-exchange/stackover…
muzaffarbhat07 May 20, 2025
91753e4
chore: Version bump
muzaffarbhat07 May 20, 2025
de02c6d
fix: Unit tests
muzaffarbhat07 May 21, 2025
28e3e33
Merge pull request #650 from Cypherock/fix/unit-tests
muzaffarbhat07 May 21, 2025
99d6ebc
chore: Updated cypherock common submodule
muzaffarbhat07 May 22, 2025
be6784e
Merge branch 'release/0.6.2304+' into feat/constellation/base
muzaffarbhat07 May 22, 2025
9a42b4a
feat: Added swap functionality to constellation app
muzaffarbhat07 May 22, 2025
8f632d4
fix: Updated app versions count to allow more apps
muzaffarbhat07 May 22, 2025
8603b46
fix: Code formatting
muzaffarbhat07 May 22, 2025
5f88308
Merge pull request #629 from Cypherock/feat/constellation/base
muzaffarbhat07 May 22, 2025
5aec696
chore: Version bump
muzaffarbhat07 May 22, 2025
0969bd9
fix: Invalid signature in constellation sign msg
muzaffarbhat07 May 29, 2025
537b1d6
Merge pull request #652 from Cypherock/fix/constellation/msg-signature
muzaffarbhat07 May 29, 2025
6e9c454
chore: Version bump
muzaffarbhat07 May 29, 2025
7177731
fix: Invalid constellation signature
muzaffarbhat07 May 29, 2025
6d56d07
chore: Version bump
muzaffarbhat07 May 29, 2025
a705eed
fix: Invalid constellation signature
muzaffarbhat07 May 29, 2025
f5330d2
chore: Version bump
muzaffarbhat07 May 29, 2025
6f9d94c
fix: Removed unnecessary prints
muzaffarbhat07 May 29, 2025
fe574e3
Merge pull request #653 from Cypherock/fix/constellation/invalid-sign…
muzaffarbhat07 May 30, 2025
08151b4
chore: Version bump
muzaffarbhat07 May 30, 2025
e870afb
Merge pull request #648 from Cypherock/release/0.6.2304+
muzaffarbhat07 Jun 6, 2025
5422597
Merge branch 'main' into develop
muzaffarbhat07 Jun 9, 2025
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
22 changes: 22 additions & 0 deletions apps/btc_family/btc_pub_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,17 @@
* INCLUDES
*****************************************************************************/

#include <string.h>

#include "bip32.h"
#include "btc_api.h"
#include "btc_app.h"
#include "btc_helpers.h"
#include "btc_priv.h"
#include "coin_utils.h"
#include "composable_app_queue.h"
#include "curves.h"
#include "exchange_main.h"
#include "reconstruct_wallet_flow.h"
#include "status_api.h"
#include "ui_core_confirm.h"
Expand Down Expand Up @@ -152,6 +157,7 @@ static void send_public_key(const uint8_t *public_key);
/*****************************************************************************
* STATIC VARIABLES
*****************************************************************************/
static bool sign_address = false;

static bool check_which_request(const btc_query_t *query,
pb_size_t which_request) {
Expand All @@ -173,6 +179,17 @@ static bool validate_request_data(btc_get_public_key_request_t *request) {
ERROR_DATA_FLOW_INVALID_DATA);
status = false;
}

caq_node_data_t data = {.applet_id = get_btc_app_desc()->id};

memzero(data.params, sizeof(data.params));
memcpy(data.params,
request->initiate.wallet_id,
sizeof(request->initiate.wallet_id));
data.params[32] = EXCHANGE_FLOW_TAG_RECEIVE;

sign_address = exchange_app_validate_caq(data);

return status;
}

Expand Down Expand Up @@ -283,6 +300,11 @@ void btc_get_pub_key(btc_query_t *query) {
delay_scr_init(ui_text_processing, DELAY_SHORT);
size_t length = btc_get_address(seed, path, path_length, public_key, msg);
memzero(seed, sizeof(seed));

if (sign_address) {
exchange_sign_address(msg, sizeof(msg));
}

if (0 < length &&
true == core_scroll_page(ui_text_receive_on, msg, btc_send_error)) {
set_app_flow_status(BTC_GET_PUBLIC_KEY_STATUS_VERIFY);
Expand Down
24 changes: 23 additions & 1 deletion apps/btc_family/btc_txn.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@

#include "bip32.h"
#include "btc_api.h"
#include "btc_app.h"
#include "btc_helpers.h"
#include "btc_inputs_validator.h"
#include "btc_priv.h"
Expand All @@ -74,8 +75,10 @@
#include "byte_stream.h"
#include "coin_utils.h"
#include "common.pb.h"
#include "composable_app_queue.h"
#include "constant_texts.h"
#include "curves.h"
#include "exchange_main.h"
#include "reconstruct_wallet_flow.h"
#include "status_api.h"
#include "ui_core_confirm.h"
Expand Down Expand Up @@ -274,7 +277,7 @@ static bool send_script_sig(btc_query_t *query, const scrip_sig_t *sigs);
/*****************************************************************************
* STATIC VARIABLES
*****************************************************************************/

static bool use_signature_verification = false;
static btc_txn_context_t *btc_txn_context = NULL;

/*****************************************************************************
Expand Down Expand Up @@ -305,6 +308,17 @@ static bool validate_request_data(const btc_sign_txn_request_t *request) {
ERROR_DATA_FLOW_INVALID_DATA);
status = false;
}

caq_node_data_t data = {.applet_id = get_btc_app_desc()->id};

memzero(data.params, sizeof(data.params));
memcpy(data.params,
request->initiate.wallet_id,
sizeof(request->initiate.wallet_id));
data.params[32] = EXCHANGE_FLOW_TAG_SEND;

use_signature_verification = exchange_app_validate_caq(data);

return status;
}

Expand Down Expand Up @@ -572,6 +586,14 @@ static bool get_user_verification() {
btc_send_error(ERROR_COMMON_ERROR_UNKNOWN_ERROR_TAG, status);
return false;
}

if (use_signature_verification) {
if (!exchange_validate_stored_signature(address, sizeof(address))) {
btc_send_error(ERROR_COMMON_ERROR_UNKNOWN_ERROR_TAG, status);
return false;
}
}

if (!core_scroll_page(title, address, btc_send_error) ||
!core_scroll_page(title, value, btc_send_error)) {
return false;
Expand Down
200 changes: 200 additions & 0 deletions apps/constellation_app/constellation_api.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
/**
* @file constellation_api.c
* @author Cypherock X1 Team
* @brief Defines helpers apis for CONSTELLATION app.
* @copyright Copyright (c) 2025 HODL TECH PTE LTD
* <br/> You may obtain a copy of license at <a href="https://mitcc.org/"
*target=_blank>https://mitcc.org/</a>
*
******************************************************************************
* @attention
*
* (c) Copyright 2025 by HODL TECH PTE LTD
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* "Commons Clause" License Condition v1.0
*
* The Software is provided to you by the Licensor under the License,
* as defined below, subject to the following condition.
*
* Without limiting other conditions in the License, the grant of
* rights under the License will not include, and the License does not
* grant to you, the right to Sell the Software.
*
* For purposes of the foregoing, "Sell" means practicing any or all
* of the rights granted to you under the License to provide to third
* parties, for a fee or other consideration (including without
* limitation fees for hosting or consulting/ support services related
* to the Software), a product or service whose value derives, entirely
* or substantially, from the functionality of the Software. Any license
* notice or attribution required by the License must also include
* this Commons Clause License Condition notice.
*
* Software: All X1Wallet associated files.
* License: MIT
* Licensor: HODL TECH PTE LTD
*
******************************************************************************
*/

/*****************************************************************************
* INCLUDES
*****************************************************************************/

#include "constellation_api.h"

#include <pb_decode.h>
#include <pb_encode.h>

#include "common_error.h"
#include "core_api.h"
#include "events.h"

/*****************************************************************************
* EXTERN VARIABLES
*****************************************************************************/

/*****************************************************************************
* PRIVATE MACROS AND DEFINES
*****************************************************************************/

/*****************************************************************************
* PRIVATE TYPEDEFS
*****************************************************************************/

/*****************************************************************************
* STATIC VARIABLES
*****************************************************************************/

/*****************************************************************************
* GLOBAL VARIABLES
*****************************************************************************/

/*****************************************************************************
* STATIC FUNCTION PROTOTYPES
*****************************************************************************/

/*****************************************************************************
* STATIC FUNCTIONS
*****************************************************************************/

/*****************************************************************************
* GLOBAL FUNCTIONS
*****************************************************************************/
bool decode_constellation_query(const uint8_t *data,
uint16_t data_size,
constellation_query_t *query_out) {
if (NULL == data || NULL == query_out || 0 == data_size) {
constellation_send_error(ERROR_COMMON_ERROR_CORRUPT_DATA_TAG,
ERROR_DATA_FLOW_DECODING_FAILED);
return false;
}

// zeroise for safety from garbage in the query reference
memzero(query_out, sizeof(constellation_query_t));

/* Create a stream that reads from the buffer. */
pb_istream_t stream = pb_istream_from_buffer(data, data_size);

/* Now we are ready to decode the message. */
bool status = pb_decode(&stream, CONSTELLATION_QUERY_FIELDS, query_out);

/* Send error to host if status is false*/
if (false == status) {
constellation_send_error(ERROR_COMMON_ERROR_CORRUPT_DATA_TAG,
ERROR_DATA_FLOW_DECODING_FAILED);
}

return status;
}

bool encode_constellation_result(const constellation_result_t *result,
uint8_t *buffer,
uint16_t max_buffer_len,
size_t *bytes_written_out) {
if (NULL == result || NULL == buffer || NULL == bytes_written_out)
return false;

/* Create a stream that will write to our buffer. */
pb_ostream_t stream = pb_ostream_from_buffer(buffer, max_buffer_len);

/* Now we are ready to encode the message! */
bool status = pb_encode(&stream, CONSTELLATION_RESULT_FIELDS, result);

if (true == status) {
*bytes_written_out = stream.bytes_written;
}

return status;
}

bool check_constellation_query(const constellation_query_t *query,
pb_size_t exp_query_tag) {
if ((NULL == query) || (exp_query_tag != query->which_request)) {
constellation_send_error(ERROR_COMMON_ERROR_CORRUPT_DATA_TAG,
ERROR_DATA_FLOW_INVALID_QUERY);
return false;
}
return true;
}

constellation_result_t init_constellation_result(pb_size_t result_tag) {
constellation_result_t result = CONSTELLATION_RESULT_INIT_ZERO;
result.which_response = result_tag;
return result;
}

void constellation_send_error(pb_size_t which_error, uint32_t error_code) {
constellation_result_t result =
init_constellation_result(CONSTELLATION_RESULT_COMMON_ERROR_TAG);
result.common_error = init_common_error(which_error, error_code);
constellation_send_result(&result);
}

void constellation_send_result(const constellation_result_t *result) {
// TODO: Set all option files
uint8_t buffer[1700] = {0};
size_t bytes_encoded = 0;
ASSERT(encode_constellation_result(
result, buffer, sizeof(buffer), &bytes_encoded));
send_response_to_host(&buffer[0], bytes_encoded);
}

bool constellation_get_query(constellation_query_t *query,
pb_size_t exp_query_tag) {
evt_status_t event = get_events(EVENT_CONFIG_USB, MAX_INACTIVITY_TIMEOUT);

if (true == event.p0_event.flag) {
return false;
}

if (!decode_constellation_query(
event.usb_event.p_msg, event.usb_event.msg_size, query)) {
return false;
}

if (!check_constellation_query(query, exp_query_tag)) {
return false;
}

return true;
}
Loading