Skip to content

Commit

Permalink
Merge pull request #57 from iotaledger/chore/removed-chrysalis
Browse files Browse the repository at this point in the history
Chore/removed chrysalis
  • Loading branch information
shufps authored Feb 8, 2024
2 parents ce3f612 + 364897b commit cb0be00
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 474 deletions.
18 changes: 3 additions & 15 deletions src/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ void api_initialize(APP_MODE_TYPE app_mode, uint32_t account_index)

// app-modes
// IOTA App
// 0x00: (107a) IOTA + Chrysalis (default, backwards compatible)
// 0x80: (1) IOTA + Chrysalis Testnet
// 0x00: unused (formerly IOTA + Chrysalis)
// 0x80: unused (formerly IOTA + Chrysalis Testnet)
// 0x01: (107a) IOTA + Stardust
// 0x81: (1) IOTA + Stardust Testnet

Expand All @@ -52,12 +52,6 @@ void api_initialize(APP_MODE_TYPE app_mode, uint32_t account_index)

switch (app_mode & 0x7f) {
#if defined(APP_IOTA)
case APP_MODE_IOTA_CHRYSALIS:
// iota
api.bip32_path[BIP32_COIN_INDEX] = BIP32_COIN_IOTA;
api.protocol = PROTOCOL_CHRYSALIS;
api.coin = COIN_IOTA;
break;
case APP_MODE_IOTA_STARDUST:
// iota
api.bip32_path[BIP32_COIN_INDEX] = BIP32_COIN_IOTA;
Expand Down Expand Up @@ -422,9 +416,7 @@ uint32_t api_prepare_signing(uint8_t has_remainder, const uint8_t *data,
THROW(SW_COMMAND_INVALID_DATA);
}

if ((api.protocol == PROTOCOL_CHRYSALIS &&
req.remainder_index >= OUTPUTS_MAX_COUNT_CHRYSALIS) ||
(api.protocol == PROTOCOL_STARDUST &&
if ((api.protocol == PROTOCOL_STARDUST &&
req.remainder_index >= OUTPUTS_MAX_COUNT_STARDUST)) {
THROW(SW_COMMAND_INVALID_DATA);
}
Expand Down Expand Up @@ -537,8 +529,6 @@ uint32_t api_user_confirm_essence()
api.essence.length >= API_BUFFER_SIZE_BYTES ||
api.data.length < api.essence.length ||
api.essence.inputs_count < INPUTS_MIN_COUNT ||
(api.protocol == PROTOCOL_CHRYSALIS &&
api.essence.inputs_count > INPUTS_MAX_COUNT_CHRYSALIS) ||
(api.protocol == PROTOCOL_STARDUST &&
api.essence.inputs_count > INPUTS_MAX_COUNT_STARDUST)) {
THROW(SW_UNKNOWN);
Expand Down Expand Up @@ -601,8 +591,6 @@ uint32_t api_sign(uint8_t p1)
api.essence.length >= API_BUFFER_SIZE_BYTES ||
api.data.length < api.essence.length ||
api.essence.inputs_count < INPUTS_MIN_COUNT ||
(api.protocol == PROTOCOL_CHRYSALIS &&
api.essence.inputs_count > INPUTS_MAX_COUNT_CHRYSALIS) ||
(api.protocol == PROTOCOL_STARDUST &&
api.essence.inputs_count > INPUTS_MAX_COUNT_STARDUST)) {
THROW(SW_UNKNOWN);
Expand Down
3 changes: 1 addition & 2 deletions src/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ typedef enum {
} DATA_TYPE;

typedef enum {
APP_MODE_IOTA_CHRYSALIS = 0,
APP_MODE_IOTA_STARDUST = 1,
APP_MODE_SHIMMER_CLAIMING = 2,
APP_MODE_SHIMMER = 3
} APP_MODE_TYPE;

typedef enum { PROTOCOL_CHRYSALIS = 0, PROTOCOL_STARDUST = 1 } PROTOCOL_TYPE;
typedef enum { PROTOCOL_STARDUST = 1 } PROTOCOL_TYPE;

typedef enum { COIN_IOTA = 0, COIN_SHIMMER = 1 } COIN_TYPE;

Expand Down
38 changes: 2 additions & 36 deletions src/iota/abstraction.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "os.h"

#include "essence_chrysalis.h"
#include "essence_stardust.h"
#include "abstraction.h"
#include "ui_common.h"
Expand All @@ -33,13 +32,6 @@ const uint8_t *get_output_address_ptr(const API_CTX *api, uint8_t index)
ret = &tmp[index].address_type;
break;
}
case PROTOCOL_CHRYSALIS: {
SIG_LOCKED_SINGLE_OUTPUT *tmp =
(SIG_LOCKED_SINGLE_OUTPUT *)api->essence.outputs;
// address follows the address_type in a pact struct
ret = &tmp[index].address_type;
break;
}
default:
THROW(SW_UNKNOWN);
break;
Expand All @@ -59,12 +51,6 @@ uint64_t get_output_amount(const API_CTX *api, uint8_t index)
memcpy(&amount, &tmp[index].amount, sizeof(uint64_t));
break;
}
case PROTOCOL_CHRYSALIS: {
SIG_LOCKED_SINGLE_OUTPUT *tmp =
(SIG_LOCKED_SINGLE_OUTPUT *)api->essence.outputs;
memcpy(&amount, &tmp[index].amount, sizeof(uint64_t));
break;
}
default:
THROW(SW_UNKNOWN);
break;
Expand Down Expand Up @@ -108,19 +94,14 @@ uint8_t essence_parse_and_validate(API_CTX *api)
MUST(essence_parse_and_validate_stardust(api));
break;
}
case PROTOCOL_CHRYSALIS: {
MUST(essence_parse_and_validate_chryslis(api));
break;
}
default:
THROW(SW_UNKNOWN);
break;
}
return 1;
}

uint8_t get_amount(const API_CTX *api, int index, char *dst, size_t dst_len,
uint8_t full)
uint8_t get_amount(const API_CTX *api, int index, char *dst, size_t dst_len)
{
uint64_t amount;

Expand All @@ -129,22 +110,7 @@ uint8_t get_amount(const API_CTX *api, int index, char *dst, size_t dst_len,

switch (api->coin) {
case COIN_IOTA: {
// IOTA + Chrysalis uses metric units
if (api->protocol == PROTOCOL_CHRYSALIS) {
// show IOTA in full or short mode
if (full) { // full
// max supply is 2779530283277761 - this fits nicely in one line
// on the Ledger nano s always cut after the 16th char to not
// make a page with a single 'i'.
format_value_full(dst, dst_len, amount);
}
else { // short
format_value_short(dst, dst_len, amount);
}
}
else {
format_value_full_decimals(dst, dst_len, amount);
}
format_value_full_decimals(dst, dst_len, amount);
break;
}
case COIN_SHIMMER: {
Expand Down
3 changes: 1 addition & 2 deletions src/iota/abstraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ uint8_t address_encode_bech32(const API_CTX *api, const uint8_t *addr_with_type,

uint8_t essence_parse_and_validate(API_CTX *api);

uint8_t get_amount(const API_CTX *api, int index, char *dst, size_t dst_len,
uint8_t full);
uint8_t get_amount(const API_CTX *api, int index, char *dst, size_t dst_len);
6 changes: 1 addition & 5 deletions src/iota/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

#define TOTAL_AMOUNT_MAX 2779530283277761ull

#define INPUTS_MAX_COUNT_CHRYSALIS 127
#define INPUTS_MAX_COUNT_STARDUST 128
#define INPUTS_MIN_COUNT 1

#define OUTPUTS_MAX_COUNT_CHRYSALIS 127
#define OUTPUTS_MAX_COUNT_STARDUST 128
#define OUTPUTS_MIN_COUNT 1

Expand All @@ -46,7 +44,7 @@
#define BIP32_COIN_TESTNET 0x80000001

#if defined(APP_IOTA)
#define APP_MODE_INIT APP_MODE_IOTA_CHRYSALIS
#define APP_MODE_INIT APP_MODE_IOTA_STARDUST
#elif defined(APP_SHIMMER)
#define APP_MODE_INIT APP_MODE_SHIMMER
#else
Expand Down Expand Up @@ -93,8 +91,6 @@


#define TRANSACTION_ESSENCE_TYPE_STARDUST 1
#define TRANSACTION_ESSENCE_TYPE_CHRYSALIS 0


// following constants are valid with bech32 encoding (address_type included)
#define ADDRESS_SIZE_BASE32 ((ADDRESS_WITH_TYPE_SIZE_BYTES * 8 + 4) / 5)
Expand Down
Loading

0 comments on commit cb0be00

Please sign in to comment.