Skip to content

Commit

Permalink
Merge pull request #10 from aido/1.7.4-final
Browse files Browse the repository at this point in the history
1.7.4 final
  • Loading branch information
lpascal-ledger authored Jun 24, 2024
2 parents 6a841cf + 57acc91 commit aa58ae5
Show file tree
Hide file tree
Showing 17 changed files with 1,238 additions and 906 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
create_release:
name: Create Release
if: github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_branch, 'v')
if: github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_branch, 'v') && github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
11 changes: 4 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.7.4-rc.2] - 2024-06-03
## [1.7.4] - 2024-06-20

### Fixed
- Use `cx_bn_gf2_n_mul()` syscall instead of internal `bn_gf2_n_mul()` on LNSP and LNX
- Ensure result does not overlap with operands in calls to `cx_bn_gf2_n_mul()`

## [1.7.4-rc.1] - 2024-05-31

### Fixed
- Use internal `bn_gf2_n_mul()` instead of `cx_bn_gf2_n_mul()` syscall on all devices
- Give a warning if a user chooses 1-of-m shares when m > 1
- Use CBOR tag for version 2 `sskr`
- Update restrictions on when a release workflow is triggered

## [1.7.3] - 2024-05-29

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ APPVERSION_N = 7
APPVERSION_P = 4
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"

APPVERSION_RC = 2
ifdef APPVERSION_RC
APPVERSION_RC = 0
ifneq ($(APPVERSION_RC), 0)
APPVERSION := $(APPVERSION)-rc.$(APPVERSION_RC)
endif

Expand Down
41 changes: 33 additions & 8 deletions src/nano/ux_nano_sskr.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ void generate_sskr(void) {
io_seproxyhal_general_status();
#endif

PRINTF("generate_sskr threshold: %d\n", G_bolos_ux_context.sskr_group_descriptor[0][0]);
PRINTF("generate_sskr sskr number: %d\n", G_bolos_ux_context.sskr_group_descriptor[0][1]);
PRINTF("SSKR threshold selected: %d\n", G_bolos_ux_context.sskr_group_descriptor[0][0]);
PRINTF("SSKR share count selected: %d\n", G_bolos_ux_context.sskr_group_descriptor[0][1]);

G_bolos_ux_context.sskr_share_count = 0;
G_bolos_ux_context.sskr_words_buffer_length = 0;
Expand All @@ -133,8 +133,7 @@ void generate_sskr(void) {
&G_bolos_ux_context.sskr_words_buffer_length);

if (G_bolos_ux_context.sskr_share_count > 0) {
PRINTF("SSKR share_count from generate_sskr(): \n%d\n",
G_bolos_ux_context.sskr_share_count);
PRINTF("SSKR share_count from generate_sskr(): %d\n", G_bolos_ux_context.sskr_share_count);
for (uint8_t share = 0; share < G_bolos_ux_context.sskr_share_count; share++) {
PRINTF("SSKR share %d:\n", share + 1);
PRINTF(
Expand All @@ -149,6 +148,27 @@ void generate_sskr(void) {
ux_flow_init(0, dynamic_flow, NULL);
}

UX_STEP_NOCB(ux_threshold_warn_step_1,
pnn,
{
&C_icon_warning,
"1-of-m shares",
"where m > 1",
});

UX_STEP_NOCB(ux_threshold_warn_step_2,
pbb,
{
&C_icon_warning,
"Not",
"Supported",
});

UX_FLOW(ux_threshold_warn_flow,
&ux_threshold_warn_step_1,
&ux_threshold_warn_step_2,
&step_sskr_clean_exit);

const char* const sskr_descriptor_values[] = {"1",
"2",
"3",
Expand Down Expand Up @@ -179,13 +199,18 @@ const char* sskr_threshold_getter(unsigned int idx) {
void sskr_threshold_selector(unsigned int idx) {
G_bolos_ux_context.sskr_group_descriptor[0][0] = idx + 1;

if (G_bolos_ux_context.sskr_group_descriptor[0][0] == 1 &&
G_bolos_ux_context.sskr_group_descriptor[0][1] > 1) {
ux_flow_init(0, ux_threshold_warn_flow, NULL);
} else {
#if defined(TARGET_NANOS)
// Display processing warning to user
screen_processing_init();
G_bolos_ux_context.processing = PROCESSING_GENERATE_SSKR;
// Display processing warning to user
screen_processing_init();
G_bolos_ux_context.processing = PROCESSING_GENERATE_SSKR;
#else
generate_sskr();
generate_sskr();
#endif
}
}

UX_STEP_NOCB(ux_threshold_instruction_step, nn, {"Select", "threshold"});
Expand Down
52 changes: 28 additions & 24 deletions src/ux_common/onboarding_seed_sskr.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
#error "What kind of system is this?"
#endif

unsigned int bolos_ux_sskr_size_get(uint8_t bip39_onboarding_kind,
uint8_t groups_threshold,
unsigned int *group_descriptor,
uint8_t groups_len,
uint8_t *share_len) {
int16_t bolos_ux_sskr_size_get(uint8_t bip39_onboarding_kind,
uint8_t groups_threshold,
unsigned int *group_descriptor,
uint8_t groups_len,
uint8_t *share_len) {
sskr_group_descriptor_t groups[SSKR_MAX_GROUP_COUNT];
for (uint8_t i = 0; i < groups_len; i++) {
groups[i].threshold = *(group_descriptor + i * sizeof(*(group_descriptor)) / groups_len);
groups[i].count = *(group_descriptor + 1 + i * sizeof(*(group_descriptor)) / groups_len);
}

unsigned int share_count_expected = sskr_count_shards(groups_threshold, groups, groups_len);
int16_t share_count_expected = sskr_count_shards(groups_threshold, groups, groups_len);
*share_len = bip39_onboarding_kind * 4 / 3 + SSKR_METADATA_LENGTH_BYTES;

return share_count_expected;
Expand Down Expand Up @@ -93,7 +93,7 @@ unsigned int bolos_ux_sskr_generate(uint8_t groups_threshold,
unsigned char *share_buffer,
unsigned int share_buffer_len,
uint8_t share_len_expected,
uint8_t share_count_expected) {
int16_t share_count_expected) {
sskr_group_descriptor_t groups[SSKR_MAX_GROUP_COUNT];

for (uint8_t i = 0; i < (uint8_t) groups_len; i++) {
Expand All @@ -108,24 +108,28 @@ unsigned int bolos_ux_sskr_generate(uint8_t groups_threshold,

PRINTF("SSKR generate input:\n %.*H\n", seed_len, seed);
// convert seed to SSKR shares
int share_count = sskr_generate_shards(groups_threshold,
groups,
groups_len,
seed,
seed_len,
share_len,
share_buffer,
share_buffer_len,
cx_rng);

if ((share_count < 0) || ((unsigned int) share_count != share_count_expected) ||
int16_t share_count = sskr_generate_shards(groups_threshold,
groups,
groups_len,
seed,
seed_len,
share_len,
share_buffer,
share_buffer_len,
cx_rng);

PRINTF("SSKR share count expected: %d\n", share_count_expected);
PRINTF("SSKR share count returned: %d\n", share_count);
PRINTF("SSKR share length expected: %d\n", share_len_expected);
PRINTF("SSKR share length returned: %d\n", *share_len);

if ((share_count < 0) || (share_count != share_count_expected) ||
(*share_len != share_len_expected)) {
memzero(&share_buffer, sizeof(share_buffer));
return 0;
}

PRINTF("SSKR generate output:\n %.*H\n", share_buffer_len, share_buffer);
PRINTF("SSKR share count:\n %d\n", share_count);
PRINTF("SSKR share length :\n %d\n", *share_len);

return share_count;
}
Expand Down Expand Up @@ -173,7 +177,7 @@ unsigned int bolos_ux_bip39_to_sskr_convert(unsigned char *bip39_words_buffer,
uint8_t groups_len = 1;
uint8_t groups_threshold = 1;
uint8_t share_len_expected = 0;
uint8_t share_count_expected = bolos_ux_sskr_size_get(bip39_onboarding_kind,
int16_t share_count_expected = bolos_ux_sskr_size_get(bip39_onboarding_kind,
groups_threshold,
group_descriptor,
groups_len,
Expand All @@ -195,10 +199,10 @@ unsigned int bolos_ux_bip39_to_sskr_convert(unsigned char *bip39_words_buffer,
share_count_expected);
memzero(seed_buffer, sizeof(seed_buffer));
if (*share_count > 0) {
// CBOR Tag #309 is D9 0135
// CBOR Tag #6.40309 is D9 9D75
// CBOR Major type 2 is 0x40
// (see https://www.rfc-editor.org/rfc/rfc8949#name-major-types)
uint8_t cbor[] = {0xD9, 0x01, 0x35, 0x40, 0x00};
uint8_t cbor[] = {0xD9, 0x9D, 0x75, 0x40, 0x00};
size_t cbor_len = sizeof(cbor);
if (share_len < 24) {
cbor[3] |= (share_len & 0x1F);
Expand Down Expand Up @@ -254,7 +258,7 @@ unsigned int bolos_ux_bip39_to_sskr_convert(unsigned char *bip39_words_buffer,
unsigned int bolos_ux_sskr_hex_check(unsigned char *mnemonic_hex,
unsigned int mnemonic_length,
unsigned int sskr_shares_count) {
uint8_t cbor[] = {0xD9, 0x01, 0x35}; // CBOR tag
uint8_t cbor[] = {0xD9, 0x9D, 0x75}; // CBOR Tag #6.40309 is D9 9D75
uint32_t checksum = 0;
uint8_t checksum_len = sizeof(checksum);

Expand Down
Loading

0 comments on commit aa58ae5

Please sign in to comment.