Skip to content

Commit 5da5f63

Browse files
committed
Partition sign_psbt.c into smaller submodules
Also, updated the copyright notices, or added where missing.
1 parent b541de2 commit 5da5f63

28 files changed

Lines changed: 2920 additions & 2151 deletions

src/handler/sign_psbt.c

Lines changed: 10 additions & 2082 deletions
Large diffs are not rendered by default.

src/handler/sign_psbt.h

Lines changed: 17 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*****************************************************************************
2+
* Ledger App Bitcoin.
3+
* (c) 2025, 2026 Ledger SAS.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*****************************************************************************/
17+
118
#pragma once
219

320
/* Local headers */
@@ -160,63 +177,3 @@ typedef struct {
160177
tx_ux_warning_t warnings;
161178

162179
} sign_psbt_state_t;
163-
164-
/**
165-
* Signs a legacy or SegwitV0 sighash using the ECDSA algorithm, and yields the necessary
166-
* info for the partial signature.
167-
*
168-
* @param[in] dc The dispatcher context
169-
* @param[in] st The signing state
170-
* @param[in] input_index The index of the input whose sighash is being signed
171-
* @param[in] sign_path The BIP32 path of the key being used to sign
172-
* @param[in] sign_path_len The number of derivation steps of the BIP32 path
173-
* @param[in] sighash_byte The sighash type byte
174-
* @param[out] sighash Pointer to a 32-byte array that will receive the computed sighash
175-
* @return true if the computation is successful, false otherwise. On failure, an error status word
176-
* is already sent.
177-
*/
178-
bool __attribute__((noinline)) sign_sighash_ecdsa_and_yield(dispatcher_context_t *dc,
179-
sign_psbt_state_t *st,
180-
unsigned int input_index,
181-
const uint32_t sign_path[],
182-
size_t sign_path_len,
183-
uint8_t sighash_byte,
184-
uint8_t sighash[static 32]);
185-
186-
/**
187-
* Signs a legacy or SegwitV0 sighash using the ECDSA algorithm, and yields the necessary
188-
* info for the partial signature.
189-
*
190-
* This function allows to select the tweak_data to be used after the BIP-32 derivation. This should
191-
* be:
192-
* - a zero-length array for key conforming to BIP-86 and BIP-386.abort
193-
* - a 32-byte array containing the taproot Merkle tree root for taproot Script path spends.
194-
* Passing NULL allows to sign with an untweaked key, for example in case this is used for a
195-
* protocol using the `rawtr()` expression.
196-
*
197-
* @param[in] dc The dispatcher context
198-
* @param[in] st The signing state
199-
* @param[in] input_index The index of the input whose sighash is being signed
200-
* @param[in] sign_path The BIP32 path of the key being used to sign
201-
* @param[in] sign_path_len The number of derivation steps of the BIP32 path
202-
* @param[in] tweak_data If the key used to sign has to be tweaked, a pointer to an array containing
203-
* the tweak data. NULL otherwise.
204-
* @param[in] tweak_data_len The length of the `tweak_data` array. If `tweak_data` is NULL, this
205-
* should be 0.
206-
* @param[in] tapleaf_hash NULL if the sighash was signed using the keypath spend, or the tapleaf
207-
* hash if the sighash was signed using a script path spend.
208-
* @param[in] sighash_byte The sighash type byte
209-
* @param[in] sighash Pointer to a 32-byte array containing the sighash to sign
210-
* @return true if the computation is successful, false otherwise. On failure, an error status word
211-
* is already sent.
212-
*/
213-
bool __attribute__((noinline)) sign_sighash_schnorr_and_yield(dispatcher_context_t *dc,
214-
sign_psbt_state_t *st,
215-
unsigned int input_index,
216-
const uint32_t sign_path[],
217-
size_t sign_path_len,
218-
const uint8_t *tweak_data,
219-
size_t tweak_data_len,
220-
const uint8_t *tapleaf_hash,
221-
uint8_t sighash_byte,
222-
const uint8_t sighash[static 32]);

src/handler/sign_psbt/amount_from_psbt.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*****************************************************************************
2+
* Ledger App Bitcoin.
3+
* (c) 2025, 2026 Ledger SAS.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*****************************************************************************/
17+
118
#include "amount_from_psbt.h"
219

320
/* Local headers */

src/handler/sign_psbt/amount_from_psbt.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*****************************************************************************
2+
* Ledger App Bitcoin.
3+
* (c) 2025, 2026 Ledger SAS.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*****************************************************************************/
17+
118
#pragma once
219

320
/* Local headers */

src/handler/sign_psbt/compare_wallet_script_at_path.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*****************************************************************************
2+
* Ledger App Bitcoin.
3+
* (c) 2025, 2026 Ledger SAS.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*****************************************************************************/
17+
118
#include <stdint.h>
219
#include <string.h>
320

src/handler/sign_psbt/compare_wallet_script_at_path.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*****************************************************************************
2+
* Ledger App Bitcoin.
3+
* (c) 2025, 2026 Ledger SAS.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*****************************************************************************/
17+
118
#pragma once
219

320
/* Local headers */

src/handler/sign_psbt/extract_bip32_derivation.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*****************************************************************************
2+
* Ledger App Bitcoin.
3+
* (c) 2025, 2026 Ledger SAS.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*****************************************************************************/
17+
118
#include <stdint.h>
219
#include <string.h>
320
#include <limits.h>

src/handler/sign_psbt/extract_bip32_derivation.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*****************************************************************************
2+
* Ledger App Bitcoin.
3+
* (c) 2025, 2026 Ledger SAS.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*****************************************************************************/
17+
118
#pragma once
219

320
/* SDK headers */

0 commit comments

Comments
 (0)