Skip to content

Commit ce1cc53

Browse files
Merge pull request #712 from Cypherock/feat/canton/sign-txn-external
feat: Adds canton sign txn external support (namespace delegation)
2 parents 53a2d72 + 3e88df8 commit ce1cc53

7 files changed

Lines changed: 589 additions & 1 deletion

File tree

apps/canton_app/canton_context.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <stdint.h>
1919

2020
#include "canton/sign_txn.pb.h"
21+
#include "canton/sign_txn_external.pb.h"
2122
#include "sha2.h"
2223

2324
/*****************************************************************************
@@ -63,6 +64,8 @@
6364
#define PREAPPROVAL_TXN_TYPE_TEXT "Enable Transfer Pre-approval"
6465
#define MERGE_DELEGATION_PROPOSAL_TXN_TYPE_TEXT "Enable UTXO Management"
6566

67+
#define NAMESPACE_DELEGATION_TXN_TYPE_TEXT "Namespace Delegation"
68+
6669
/*****************************************************************************
6770
* TYPEDEFS
6871
*****************************************************************************/
@@ -128,6 +131,19 @@ typedef struct {
128131
uint8_t public_key[CANTON_PUB_KEY_SIZE];
129132
} canton_unsigned_topology_txn;
130133

134+
typedef struct {
135+
uint8_t target_public_key[CANTON_PUB_KEY_SIZE];
136+
char namespace[CANTON_FINGERPRINT_STR_SIZE];
137+
} canton_namespace_delegation_txn_display_info_t;
138+
139+
typedef struct {
140+
canton_sign_txn_external_supported_txn_types_t txn_type;
141+
uint8_t hash[CANTON_HASH_SIZE];
142+
union {
143+
canton_namespace_delegation_txn_display_info_t namespace_delegation;
144+
} display_info;
145+
} canton_unsigned_txn_external_info_t;
146+
131147
/*****************************************************************************
132148
* EXPORTED VARIABLES
133149
*****************************************************************************/

apps/canton_app/canton_main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ void canton_main(usb_event_t usb_event, const void *canton_app_config) {
143143
break;
144144
}
145145

146+
case CANTON_QUERY_SIGN_TXN_EXTERNAL_TAG: {
147+
canton_sign_txn_external(&query);
148+
break;
149+
}
150+
146151
/* Incase we encounter an invalid query */
147152
default: {
148153
canton_send_error(ERROR_COMMON_ERROR_CORRUPT_DATA_TAG,

apps/canton_app/canton_priv.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <stdint.h>
1818

1919
#include "canton/core.pb.h"
20+
#include "canton/sign_txn_external.pb.h"
2021
#include "canton_context.h"
2122
#include "canton_txn_encoding.h"
2223
#include "sha2.h"
@@ -48,6 +49,11 @@ typedef struct {
4849

4950
} canton_topology_txn_context_t;
5051

52+
typedef struct {
53+
canton_sign_txn_external_initiate_request_t init_info;
54+
canton_unsigned_txn_external_info_t unsigned_txn_external_info;
55+
} canton_txn_external_context_t;
56+
5157
/*****************************************************************************
5258
* EXPORTED VARIABLES
5359
*****************************************************************************/
@@ -86,4 +92,13 @@ void canton_sign_transaction(canton_query_t *query);
8692
*/
8793
void canton_sign_topology_transaction(canton_query_t *query);
8894

95+
/**
96+
* @brief Entry point for sign_txn_external type queries
97+
* @details Function handles complete flow required to sign and required
98+
* transaction, this includes: recieving further data, parsing and validating
99+
* data, user confirmation, returning data to the host. And incase of any error,
100+
* returns error to the host.
101+
*/
102+
void canton_sign_txn_external(canton_query_t *query);
103+
89104
#endif

0 commit comments

Comments
 (0)