Add os_derive_slip21_key helper for SLIP-21 derivations.#1381
Add os_derive_slip21_key helper for SLIP-21 derivations.#1381
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1381 +/- ##
=======================================
Coverage 79.98% 79.98%
=======================================
Files 43 43
Lines 5067 5067
Branches 745 745
=======================================
Hits 4053 4053
Misses 926 926
Partials 88 88
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6434a62 to
fa484c0
Compare
| // Aligned to 4 bytes as this is later passed as a (const unsigned int *) pointer | ||
| // Make sure that the buffer is large enough (account for 1 extra byte per label for the \x00 | ||
| // prefix, and the 1 byte for the '/' separator after the first label). | ||
| unsigned char path_buffer[256 + 2 * 10 - 1] __attribute__((aligned(4))); |
There was a problem hiding this comment.
Difficult to understand this calculation. Why 256?
IMHO it should be:
- either a big "independent" number, e.g.
unsigned char path_buffer[300]as this is the total buffer/path length we can afford - or we should deduct all from the max label count and a label length, e.g.
unsigned char path_buffer[(LABEL_LEN+1+1)*LABEL_COUNT_MAX - 1]
There was a problem hiding this comment.
256 is an arbitrary limit that I chose, and reported in the documentation as a constraint.
Perhaps I can add a constant
#define LABEL_TOTAL_LENGTH_MAXSo the computation becomes:
unsigned char path_buffer[LABEL_TOTAL_LENGTH_MAX + 2 * LABEL_COUNT_MAX - 1] __attribute__((aligned(4)));What do you think?
There was a problem hiding this comment.
In f1507fe I introduced SLIP21_MAX_TOTAL_LENGTH, and rewrote the calculation for this buffer in terms of SLIP21_MAX_TOTAL_LENGTH and SLIP21_MAX_LABELS.
There was a problem hiding this comment.
My point was even that if "256 is an arbitrary limit that I chose" than we would not need the calculation, just:
unsigned char path_buffer[LABEL_TOTAL_LENGTH_MAX] __attribute__((aligned(4)));
;)
There was a problem hiding this comment.
Then you'd have to do the reverse calculation to document what is the maximum total length of labels before they are assembled (which would be size of the buffer - (2 * LABEL_COUNT_MAX - 1)).
While os_derive_bip32_with_seed_no_throw supports SLIP-21, the way parameters were retrofitted from BIP-32 makes it rather hard to use. This adds a helper with a simple interface that takes care of translating the parameters to the expected format.
3ff20ef to
f1507fe
Compare
Description
While os_derive_bip32_with_seed_no_throw supports SLIP-21, the way parameters were retrofitted from BIP-32 makes it rather hard to use.
This adds a helper with a simple interface that takes care of translating the parameters to the expected format.
See for example here for an analogous (but more limited) helper currently used in the bitcoin app.
Changes include
Auto cherry-pick in API_LEVEL
If requested to port the commits from this PR on a dedicated API_LEVEL branch,
select the targeted one(s), or add new references if not listed:
[x] TARGET_API_LEVEL: API_LEVEL_25
This will only create the PR with cherry-picks, ready to be reviewed and merged.
Remember: