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
16 changes: 16 additions & 0 deletions apps/canton_app/canton_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <stdint.h>

#include "canton/sign_txn.pb.h"
#include "canton/sign_txn_external.pb.h"
#include "sha2.h"

/*****************************************************************************
Expand Down Expand Up @@ -63,6 +64,8 @@
#define PREAPPROVAL_TXN_TYPE_TEXT "Enable Transfer Pre-approval"
#define MERGE_DELEGATION_PROPOSAL_TXN_TYPE_TEXT "Enable UTXO Management"

#define NAMESPACE_DELEGATION_TXN_TYPE_TEXT "Namespace Delegation"

/*****************************************************************************
* TYPEDEFS
*****************************************************************************/
Expand Down Expand Up @@ -128,6 +131,19 @@ typedef struct {
uint8_t public_key[CANTON_PUB_KEY_SIZE];
} canton_unsigned_topology_txn;

typedef struct {
uint8_t target_public_key[CANTON_PUB_KEY_SIZE];
char namespace[CANTON_FINGERPRINT_STR_SIZE];
} canton_namespace_delegation_txn_display_info_t;

typedef struct {
canton_sign_txn_external_supported_txn_types_t txn_type;
uint8_t hash[CANTON_HASH_SIZE];
union {
canton_namespace_delegation_txn_display_info_t namespace_delegation;
} display_info;
} canton_unsigned_txn_external_info_t;

/*****************************************************************************
* EXPORTED VARIABLES
*****************************************************************************/
Expand Down
5 changes: 5 additions & 0 deletions apps/canton_app/canton_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ void canton_main(usb_event_t usb_event, const void *canton_app_config) {
break;
}

case CANTON_QUERY_SIGN_TXN_EXTERNAL_TAG: {
canton_sign_txn_external(&query);
break;
}

/* Incase we encounter an invalid query */
default: {
canton_send_error(ERROR_COMMON_ERROR_CORRUPT_DATA_TAG,
Expand Down
15 changes: 15 additions & 0 deletions apps/canton_app/canton_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <stdint.h>

#include "canton/core.pb.h"
#include "canton/sign_txn_external.pb.h"
#include "canton_context.h"
#include "canton_txn_encoding.h"
#include "sha2.h"
Expand Down Expand Up @@ -48,6 +49,11 @@ typedef struct {

} canton_topology_txn_context_t;

typedef struct {
canton_sign_txn_external_initiate_request_t init_info;
canton_unsigned_txn_external_info_t unsigned_txn_external_info;
} canton_txn_external_context_t;

/*****************************************************************************
* EXPORTED VARIABLES
*****************************************************************************/
Expand Down Expand Up @@ -86,4 +92,13 @@ void canton_sign_transaction(canton_query_t *query);
*/
void canton_sign_topology_transaction(canton_query_t *query);

/**
* @brief Entry point for sign_txn_external type queries
* @details Function handles complete flow required to sign and required
* transaction, this includes: recieving further data, parsing and validating
* data, user confirmation, returning data to the host. And incase of any error,
* returns error to the host.
*/
void canton_sign_txn_external(canton_query_t *query);

#endif
Loading