Skip to content

Commit 7cf2c4d

Browse files
Merge pull request #423 from LedgerHQ/codespell
Codespell workflow and corresponding fixes
2 parents d384a37 + 9204806 commit 7cf2c4d

File tree

15 files changed

+54
-36
lines changed

15 files changed

+54
-36
lines changed

.github/workflows/codespell.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Misspellings CI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
- main
9+
- develop
10+
pull_request:
11+
12+
jobs:
13+
misspell:
14+
name: Check misspellings
15+
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_spell_check.yml@v1
16+
with:
17+
src_path: src, bitcoin_client, bitcoin_client_js, bitcoin_client_rs, doc
18+
ignore_words_list: usig,Bu,fpr

doc/bitcoin.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Once the user approves, the `REGISTER_WALLET` returns to the client a 32-byte HM
6565
| 0xE000 | `SW_INTERRUPTED_EXECUTION` | The command is interrupted, and requires the client's response |
6666
| 0x9000 | `SW_OK` | Success |
6767

68-
<!-- TODO: add an introduction section explaining the comand reference notations (e.g. the Bitcoin style varint) -->
68+
<!-- TODO: add an introduction section explaining the command reference notations (e.g. the Bitcoin style varint) -->
6969

7070
## Commands
7171

@@ -106,7 +106,7 @@ The paths defined in [BIP-44](https://github.com/bitcoin/bips/blob/master/bip-00
106106

107107
If the `display` parameter is `0` and the path is not standard, an error is returned.
108108

109-
If the `display` parameter is `1`, the result is also shown on the secure screen for verification. The UX flow shows on the device screen the exact path and the complete serialized extended pubkey as defined in [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) for that path. If the path is not standard, an additional warning is shown to the user.
109+
If the `display` parameter is `1`, the result is also shown on the secure screen for verification. The UX flow shows on the device screen the exact path and the complete serialized extended pubkey as defined in [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) for that path. If the path is not standard, an additional warning is shown to the user.
110110

111111
### REGISTER_WALLET
112112

@@ -214,9 +214,9 @@ Given a PSBTv2 and a registered wallet (or a standard one), sign all the inputs
214214
| `<var>` | `global_map_size` | The number of key/value pairs of the global map of the psbt |
215215
| `32` | `global_map_keys_root` | The Merkle root of the keys of the global map |
216216
| `32` | `global_map_vals_root` | The Merkle root of the values of the global map |
217-
| `<var>` | `n_inputs` | The number of inputs of the psbt |
217+
| `<var>` | `n_inputs` | The number of inputs of the psbt |
218218
| `32` | `inputs_maps_root` | The Merkle root of the vector of Merkleized map commitments for the input maps |
219-
| `<var>` | `n_outputs` | The number of outputs of the psbt |
219+
| `<var>` | `n_outputs` | The number of outputs of the psbt |
220220
| `32` | `outputs_maps_root` | The Merkle root of the vector of Merkleized map commitments for the output maps |
221221
| `32` | `wallet_id` | The id of the wallet |
222222
| `32` | `wallet_hmac` | The hmac of a registered wallet, or exactly 32 0 bytes |
@@ -382,7 +382,7 @@ The response must contain:
382382
- `1` byte: a 1-byte unsigned integer `b`, the length of the prefix of the pre-image that is part of the response;
383383
- `b` bytes: corresponding to the first `b` bytes of the preimage.
384384

385-
If the pre-image is too long to be contained in a single response, the client should choose `b` to be as large as possible; subsequent bytes are enqueued as single-byte elements that the Hardware Wallet will request with one ore more `GET_MORE_ELEMENTS` requests.
385+
If the pre-image is too long to be contained in a single response, the client should choose `b` to be as large as possible; subsequent bytes are enqueued as single-byte elements that the Hardware Wallet will request with one or more `GET_MORE_ELEMENTS` requests.
386386

387387
### GET_MERKLE_LEAF_PROOF
388388

doc/merkle.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ Operations on Merkle trees are composed to create commitments to more complex da
99
## Merkle trees
1010
### Definition
1111

12-
A Merkle tree allows to create a commitment to an arbitrarily large list of values; short membership proofs can be provided that can be verified solely withthe knowledge of a single hash (the Merkle tree root)
12+
A Merkle tree allows to create a commitment to an arbitrarily large list of values; short membership proofs can be provided that can be verified solely with the knowledge of a single hash (the Merkle tree root)
1313

1414
Our implementation of Merkle trees loosely follow the structure defined in [RFC 6962](https://www.rfc-editor.org/rfc/pdfrfc/rfc6962.txt.pdf), using SHA-256 as the hash function. We refer to the linked document for a more detailed description. Only one difference (the hash of the empty list) is defined below.
1515

1616
We call a *byte string* an arbitrary array of bytes, where each byte is a value between `0` and `255`. A *hash function* takes as input an arbitrary length byte string, and produces a fixed-length output. Outputs of SHA-256 are 32 bytes long.
1717

1818
Following the notation of RFC 6962, we are given an ordered list of inputs `D[n] = {d(0), d(1), ..., d(n-1)}`, where each element `d(i)` is a byte string. We denote with `||` the concatenation operator, and with `D[a:b]` the list `{d(a), d(a+1), ..., d(b - 1)}`.
1919

20-
We define the Merkle Tree Hash (MTH) (also called the *Merkle root*) as follows.
20+
We define the Merkle Tree Hash (MTH) (also called the *Merkle root*) as follows.
2121

2222
The hash of the empty list is `MTH({}) = 0`, a string of 32 bytes identically equal to `0`. *This definition differs from RFC 6962*.
2323

doc/v0/bitcoin.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Once the user approves, the `REGISTER_WALLET` returns to the client a 32-byte HM
6262
| 0xE000 | `SW_INTERRUPTED_EXECUTION` | The command is interrupted, and requires the client's response |
6363
| 0x9000 | `SW_OK` | Success |
6464

65-
<!-- TODO: add an introduction section explaining the comand reference notations (e.g. the Bitcoin style varint) -->
65+
<!-- TODO: add an introduction section explaining the command reference notations (e.g. the Bitcoin style varint) -->
6666

6767
## Commands
6868

@@ -103,7 +103,7 @@ The paths defined in [BIP-44](https://github.com/bitcoin/bips/blob/master/bip-00
103103

104104
If the `display` parameter is `0` and the path is not standard, an error is returned.
105105

106-
If the `display` parameter is `1`, the result is also shown on the secure screen for verification. The UX flow shows on the device screen the exact path and the complete serialized extended pubkey as defined in [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) for that path. If the path is not standard, an additional warning is shown to the user.
106+
If the `display` parameter is `1`, the result is also shown on the secure screen for verification. The UX flow shows on the device screen the exact path and the complete serialized extended pubkey as defined in [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) for that path. If the path is not standard, an additional warning is shown to the user.
107107

108108
### REGISTER_WALLET
109109

@@ -209,9 +209,9 @@ Given a PSBTv2 and a registered wallet (or a standard one), sign all the inputs
209209
| `<var>` | `global_map_size` | The number of key/value pairs of the global map of the psbt |
210210
| `32` | `global_map_keys_root` | The Merkle root of the keys of the global map |
211211
| `32` | `global_map_vals_root` | The Merkle root of the values of the global map |
212-
| `<var>` | `n_inputs` | The number of inputs of the psbt |
212+
| `<var>` | `n_inputs` | The number of inputs of the psbt |
213213
| `32` | `inputs_maps_root` | The Merkle root of the vector of Merkleized map commitments for the input maps |
214-
| `<var>` | `n_outputs` | The number of outputs of the psbt |
214+
| `<var>` | `n_outputs` | The number of outputs of the psbt |
215215
| `32` | `outputs_maps_root` | The Merkle root of the vector of Merkleized map commitments for the output maps |
216216
| `32` | `wallet_id` | The id of the wallet |
217217
| `32` | `wallet_hmac` | The hmac of a registered wallet, or exactly 32 0 bytes |
@@ -352,7 +352,7 @@ The response must contain:
352352
- `1` byte: a 1-byte unsigned integer `b`, the length of the prefix of the pre-image that is part of the response;
353353
- `b` bytes: corresponding to the first `b` bytes of the preimage.
354354

355-
If the pre-image is too long to be contained in a single response, the client should choose `b` to be as large as possible; subsequent bytes are enqueued as single-byte elements that the Hardware Wallet will request with one ore more `GET_MORE_ELEMENTS` requests.
355+
If the pre-image is too long to be contained in a single response, the client should choose `b` to be as large as possible; subsequent bytes are enqueued as single-byte elements that the Hardware Wallet will request with one or more `GET_MORE_ELEMENTS` requests.
356356

357357
### GET_MERKLE_LEAF_PROOF
358358

@@ -414,4 +414,4 @@ All the current commands use a commit-and-reveal approach: the APDU that starts
414414
- If a Merkle proof is asked via `GET_MERKLE_LEAF_PROOF`, the proof is verified.
415415
- If the index of a leaf is asked `GET_MERKLE_LEAF_INDEX`, the proof for that element is requested via `GET_MERKLE_LEAF_PROOF` and the proof verified, *even if the leaf value is known*.
416416

417-
Care needs to be taken in designing protocols, as the client might lie by omission (for example, fail to reveal that a leaf of a Merkle tree is present during a call to `GET_MERKLE_LEAF_INDEX`).
417+
Care needs to be taken in designing protocols, as the client might lie by omission (for example, fail to reveal that a leaf of a Merkle tree is present during a call to `GET_MERKLE_LEAF_INDEX`).

doc/v0/wallet.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ Key placeholder `KP` expressions consist of
2727
- a single character `@`
2828
- followed by a non-negative decimal number, with no leading zeros (except for `@0`).
2929

30-
The placeholder `@i` for some number *i* represents the *i*-th key in the vector of key orgin informations (which must be of size at least *i* + 1, or the wallet is invalid.
30+
The placeholder `@i` for some number *i* represents the *i*-th key in the vector of key origin information (which must be of size at least *i* + 1, or the wallet is invalid.
3131

32-
Each element of the *key origin informations* list is a `KEY` expression.
32+
Each element of the *key origin information* list is a `KEY` expression.
3333
`KEY` expressions:
3434

3535
- Key origin information, consisting of:
@@ -61,7 +61,7 @@ The app supports a number of features related to wallet policies. In order to se
6161

6262
- register a wallet, validating all the information (policy and keys involved) with the user on the trusted screen;
6363
- show the addresses for a registered wallet on the trusted screen;
64-
- sign spends from the wallet.
64+
- sign spends from the wallet.
6565

6666
Since the application is stateless, wallet registration is not persisted on device. In order to make it possible to use a registered wallet in future requests, the device returns a hmac-sha256 (32 bytes long) for the wallet upon a successful registration. The client side is responsible for persisting the wallet policy *and* the returned hmac-sha256, and to provide this information in future requests.
6767

@@ -122,4 +122,4 @@ A few policies that correspond to standardized single-key wallets can be used wi
122122
- ``sh(wpkh(@0))`` - nested segwit addresses as per [BIP-49](https://github.com/bitcoin/bips/blob/master/bip-0049.mediawiki)
123123
- ``tr(@0)`` - single Key P2TR as per [BIP-86](https://github.com/bitcoin/bips/blob/master/bip-0086.mediawiki)
124124

125-
Note that the wallet policy is considered standard (and therefore usable for signing without prior registration) only if the signing paths (defined in the key origin information) adheres to the corresponding BIP.
125+
Note that the wallet policy is considered standard (and therefore usable for signing without prior registration) only if the signing paths (defined in the key origin information) adheres to the corresponding BIP.

doc/wallet.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ a wallet descriptor template and the vector of key placeholder expressions.
55

66
A _wallet descriptor template_ follows language very similar to output descriptor, with a few differences; the biggest one is that each `KEY` expression with a key placeholder `KP` expression, that refers to one of the keys in the _keys information vector_, plus the additional derivation steps to use for that key. Contextually, the keys information vector contains all the relevant _xpubs_, and possibly their key origin information.
77

8-
Each entry in the key information vector contains an _xpub_ (other types of keys supported in output script descriptors are not allowed), possible preceeded by the key origin information. The key origin information is compulsory for internal keys.
8+
Each entry in the key information vector contains an _xpub_ (other types of keys supported in output script descriptors are not allowed), possible preceded by the key origin information. The key origin information is compulsory for internal keys.
99

1010
This section formally defines wallet policies, and how they relate to
1111
output script descriptors.
@@ -127,7 +127,7 @@ The app supports a number of features related to wallet policies. In order to se
127127

128128
- register a wallet, validating all the information (policy and keys involved) with the user on the trusted screen;
129129
- show the addresses for a registered wallet on the trusted screen;
130-
- sign spends from the wallet.
130+
- sign spends from the wallet.
131131

132132
Since the application is stateless, wallet registration is not persisted on device. In order to make it possible to use a registered wallet in future requests, the device returns a hmac-sha256 (32 bytes long) for the wallet upon a successful registration. The client side is responsible for persisting the wallet policy *and* the returned hmac-sha256, and to provide this information in future requests.
133133

src/common/merkle.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ int merkle_get_ith_direction(size_t size, size_t index, size_t i);
7575
/**
7676
* Represents the Merkleized version of a key-value map, holding the number of elements, the root of
7777
* the Merkle tree of the sorted list of keys, and the root of the Merkle tree of the values (sorted
78-
* by their correpsonding key).
78+
* by their corresponding key).
7979
*/
8080
typedef struct {
8181
uint64_t size;
8282
uint8_t keys_root[32];
8383
uint8_t values_root[32];
84-
} merkleized_map_commitment_t;
84+
} merkleized_map_commitment_t;

src/common/wallet.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ typedef enum {
308308
// The compiler doesn't like /** inside a block comment, so we disable this warning temporarily.
309309

310310
/** Structure representing a key expression.
311-
* In V1, it's the index of a key in the key informations array, which includes the final /** step.
312-
* In V2, it's the index of a key in the key informations array, plus the two numbers a, b in the
313-
* /<NUM_a;NUM_b>/* derivation steps; here, the xpubs in the key informations array don't have extra
311+
* In V1, it's the index of a key in the key information array, which includes the final /** step.
312+
* In V2, it's the index of a key in the key information array, plus the two numbers a, b in the
313+
* /<NUM_a;NUM_b>/* derivation steps; here, the xpubs in the key information array don't have extra
314314
* derivation steps.
315315
*/
316316
#pragma GCC diagnostic pop

src/crypto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ bool crypto_derive_symmetric_key(const char *label, size_t label_len, uint8_t ke
329329
int base58_encode_address(const uint8_t in[20], uint32_t version, char *out, size_t out_len);
330330

331331
/**
332-
* Signs a SHA-256 hash using the ECDSA with deterministic nonce accordin to RFC6979; the signing
332+
* Signs a SHA-256 hash using the ECDSA with deterministic nonce according to RFC6979; the signing
333333
* private key is the one derived at the given BIP-32 path. The signature is returned in the
334334
* conventional DER encoding.
335335
*

src/handler/lib/policy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ execute_processor(policy_parser_state_t *state, policy_parser_processor_t proc,
417417

418418
// p2pkh ==> legacy address (start with 1 on mainnet, m or n on testnet)
419419
// p2sh (also nested segwit) ==> legacy script (start with 3 on mainnet, 2 on testnet)
420-
// p2wpkh or p2wsh ==> bech32 (sart with bc1 on mainnet, tb1 on testnet)
420+
// p2wpkh or p2wsh ==> bech32 (start with bc1 on mainnet, tb1 on testnet)
421421

422422
// convenience function, split from get_derived_pubkey only to improve stack usage
423423
// returns -1 on error, 0 if the returned key info has no wildcard (**), 1 if it has the wildcard
@@ -1163,7 +1163,7 @@ int get_wallet_script(dispatcher_context_t *dispatcher_context,
11631163
out[1] = 32; // PUSH 32 bytes
11641164

11651165
// uint8_t h[32];
1166-
uint8_t *h = out + 2; // hack: re-use the output array to save memory
1166+
uint8_t *h = out + 2; // hack: reuse the output array to save memory
11671167

11681168
int h_length = 0;
11691169
if (!isnull_policy_node_tree(&tr_policy->tree)) {

0 commit comments

Comments
 (0)