Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0e6407e
fix(psbt): sign a taptree input with every key the coordinator lists,…
pythcoiner Nov 17, 2026
592e50c
test(psbt): sign a registry input with each key of ours its script ho…
pythcoiner Nov 17, 2026
e8e6a2a
fix(bip322): detect a BIP322 request by its to_sign transaction, not …
pythcoiner Nov 17, 2026
ae3b1ed
feat(ui): show the address next to its QR in 4-char blocks, a tap cyc…
pythcoiner Nov 17, 2026
7b55d92
feat(simulator): show the next --qr-dir image every 12 frames while s…
pythcoiner Nov 17, 2026
6c8e1b8
fix(qr): skip whitespace around a scanned frame
pythcoiner Nov 17, 2026
57a98ff
feat(bbqr): take binary BBQr frames, lowercase ones included, and sho…
pythcoiner Nov 17, 2026
9bf509d
build(bipqr): add the bipqr codec as a submodule at d7363e0 and build…
pythcoiner Nov 17, 2026
fb41e59
feat(registry): store the alias in the backup and register a descript…
pythcoiner Nov 17, 2026
1df5a2a
feat(bip_flow): answer Get Info, Get Keys and Register Descriptor ove…
pythcoiner Nov 17, 2026
defee70
feat(bip_flow): answer Address Verification with a BIP-321 URI, DERIV…
pythcoiner Nov 17, 2026
b444388
feat(bip_flow): answer Signing with protocol error codes, reviewing a…
pythcoiner Nov 17, 2026
879422f
feat(bip_flow): unregister a descriptor alias, advertising Unregister…
pythcoiner Nov 17, 2026
ab4328d
build(secp): compile the BIP352 silentpayments module of libwally's s…
pythcoiner Nov 17, 2026
b45f0f0
feat(sp): add BIP374 DLEQ proofs
pythcoiner Nov 17, 2026
55312f9
feat(sp): fill BIP375 ECDH shares and sign silent payment sends share…
pythcoiner Nov 17, 2026
ff95d2c
feat(psbt): sign beside silent payment outputs with SIGHASH_ALL only
pythcoiner Nov 17, 2026
54d56e6
feat(bip_flow): export the silent payment scan private key over Get Keys
pythcoiner Nov 17, 2026
7de3b01
feat(bip_flow): register silent payment keys under an alias that late…
pythcoiner Nov 17, 2026
4f97d03
feat(bip_flow): unregister a silent payment alias
pythcoiner Nov 17, 2026
7d56f8e
feat(bip_flow): answer Signing with silent payment shares
pythcoiner Nov 17, 2026
19dfee7
build(wally): enable the secp256k1-zkp musig module
pythcoiner Nov 17, 2026
befc7fd
feat(descriptor): accept musig() keys and claim the scripts they pay
pythcoiner Nov 17, 2026
5fb7716
feat(musig): sign MuSig2 inputs in two rounds
pythcoiner Nov 17, 2026
505ea3c
feat(bip_flow): answer Signing with MuSig2 nonces and partial signatu…
pythcoiner Nov 17, 2026
bb0c4a6
feat(musig): sign MuSig2 inputs from a nonce cache session
pythcoiner Nov 17, 2026
b9074af
feat(bip_flow): answer Nonce Preparation from nonce cache sessions, a…
pythcoiner Nov 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/test-all-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
--profile minimal --default-toolchain stable --target riscv32imafc-unknown-none-elf
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- name: Build (${{ matrix.board }})
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test-each-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ jobs:
- name: Install check dependencies
run: apt-get update && apt-get install -y zlib1g-dev libmbedtls-dev

- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
--profile minimal --default-toolchain stable --target riscv32imafc-unknown-none-elf
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"

# Into the IDF Python env, which export.sh puts on PATH for the checks.
- name: Install clang-format 21
run: . $IDF_PATH/export.sh && pip install 'clang-format==21.1.*'
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ sdkconfig
sdkconfig.old
managed_components/
compile_commands.json
**/target/

# Release
release/
Expand Down Expand Up @@ -60,6 +61,9 @@ main/core/test/test_bip138_keys
main/core/test/test_bip138_backup
main/core/test/combined.o
main/core/test/libwally.a
main/pages/bip_flow/test/test_bip_flow_register
main/pages/bip_flow/test/test_bip_flow_header
main/pages/bip_flow/test/test_bip388

# IDE / tools
.vscode/
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
[submodule "components/bip138"]
path = components/bip138
url = https://github.com/odudex/bip138.git
[submodule "components/bipqr/upstream"]
path = components/bipqr/upstream
url = https://github.com/pythcoiner/bipqr.git
[submodule "components/bip_nonces_cache/upstream"]
path = components/bip_nonces_cache/upstream
url = https://github.com/pythcoiner/bip_nonces_cache.git
12 changes: 12 additions & 0 deletions .justfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ scan-prof board="wave_4b": (_check_board board)
command -v idf.py >/dev/null || . $IDF_PATH/export.sh
idf.py -B build_scanprof_{{board}} -D SDKCONFIG=build_scanprof_{{board}}/sdkconfig -D "SDKCONFIG_DEFAULTS=$(just _defaults {{board}});sdkconfig.scanprof" flash monitor

debug-log port="/dev/ttyACM0" board="wave_35": (_check_board board)
#!/usr/bin/env sh
set -e
command -v idf.py >/dev/null || . $IDF_PATH/export.sh
out="build_{{board}}/debug_storage.bin"
python -m esptool --chip esp32p4 -p {{port}} read-flash 0xc20000 0x8000 "$out"
strings "$out" | sed -n '/boot\|bip_flow\|descriptor_loader\|debug log trimmed/p'

format:
./scripts/format.sh

Expand All @@ -81,6 +89,9 @@ fuzz iterations="20000":
make -C main/core/test SANITIZE=1 FUZZ_ITERATIONS={{iterations}} fuzz
make -C main/core/test clean

rust-setup:
rustup target add riscv32imafc-unknown-none-elf

clean:
rm -fRd build build_wave_4b build_wave_35 build_wave_5 build_wave_43 build_crowpanel build_wave_7b build_p4_pico
rm -fRd build_*_v3
Expand All @@ -95,6 +106,7 @@ clean:
make -C components/secure_memory/test clean
make -C components/bip138 clean
make -C main/qr/test clean
make -C main/pages/bip_flow/test clean
rm -rf components/k_quirc/test/build
make -C main/core/test clean

Expand Down
176 changes: 120 additions & 56 deletions components/bbqr/src/bbqr.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

// Base36 alphabet (0-9, A-Z)
static const char BASE36_ALPHABET[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static const char HEX_ALPHABET[] = "0123456789ABCDEF";

// BBQr spec: raw deflate with a 1KB window (wbits = -10)
#define BBQR_COMPRESS_WBITS 10
Expand Down Expand Up @@ -66,7 +67,65 @@ bool bbqr_is_valid_encoding(char c) {

bool bbqr_is_valid_file_type(char c) {
return c == BBQR_TYPE_PSBT || c == BBQR_TYPE_TRANSACTION ||
c == BBQR_TYPE_JSON || c == BBQR_TYPE_UNICODE;
c == BBQR_TYPE_JSON || c == BBQR_TYPE_UNICODE || c == BBQR_TYPE_BINARY;
}

static BBQrParts *allocate_parts(size_t encoded_len, size_t payload_per_part,
int num_parts, char encoding, char file_type) {
BBQrParts *parts = (BBQrParts *)calloc(1, sizeof(BBQrParts));
if (!parts) {
return NULL;
}

parts->parts = (char **)calloc(num_parts, sizeof(char *));
if (!parts->parts) {
free(parts);
return NULL;
}

parts->count = num_parts;
parts->encoding = encoding;
parts->file_type = file_type;

if (encoded_len > SIZE_MAX - (size_t)num_parts * (BBQR_HEADER_LEN + 1)) {
free(parts->parts);
free(parts);
return NULL;
}
size_t storage_len = encoded_len + (size_t)num_parts * (BBQR_HEADER_LEN + 1);
parts->storage = (char *)malloc(storage_len);
if (!parts->storage) {
free(parts->parts);
free(parts);
return NULL;
}

size_t storage_offset = 0;
char total_c1, total_c2;
bbqr_base36_encode(num_parts, &total_c1, &total_c2);
for (int i = 0; i < num_parts; i++) {
size_t this_payload_len =
part_payload_len(encoded_len, payload_per_part, i);

char index_c1, index_c2;
bbqr_base36_encode(i, &index_c1, &index_c2);

char *part = parts->storage + storage_offset;
parts->parts[i] = part;
part[0] = 'B';
part[1] = '$';
part[2] = encoding;
part[3] = file_type;
part[4] = total_c1;
part[5] = total_c2;
part[6] = index_c1;
part[7] = index_c2;
part[BBQR_HEADER_LEN + this_payload_len] = '\0';

storage_offset += BBQR_HEADER_LEN + this_payload_len + 1;
}

return parts;
}

int bbqr_base36_decode(char c1, char c2) {
Expand Down Expand Up @@ -109,8 +168,9 @@ bool bbqr_parse_part(const char *data, size_t data_len, BBQrPart *part) {
return false;
}

// Check magic "B$"
if (data[0] != 'B' || data[1] != '$') {
// Check magic "B$" case-insensitively; other alphanumeric header fields are
// normalized below as well.
if (toupper((unsigned char)data[0]) != 'B' || data[1] != '$') {
return false;
}

Expand Down Expand Up @@ -315,78 +375,82 @@ BBQrParts *bbqr_encode(const uint8_t *data, size_t data_len, char file_type,
payload_per_part =
((payload_per_part + 7) / 8) * 8; // Round up to multiple of 8

// Allocate parts structure
BBQrParts *parts = (BBQrParts *)calloc(1, sizeof(BBQrParts));
BBQrParts *parts = allocate_parts(encoded_len, (size_t)payload_per_part,
num_parts, encoding, file_type);
if (!parts) {
free(compressed);
return NULL;
}

parts->parts = (char **)calloc(num_parts, sizeof(char *));
if (!parts->parts) {
free(parts);
free(compressed);
bbqr_parts_writer_t writer = {
.parts = parts,
.part_index = 0,
.payload_offset = 0,
.payload_per_part = (size_t)payload_per_part,
.encoded_len = encoded_len,
.total_written = 0,
};
bool encoded =
base32_encode_write(to_encode, to_encode_len, write_to_parts, &writer);
free(compressed);
if (!encoded || writer.total_written != encoded_len) {
bbqr_parts_free(parts);
return NULL;
}

parts->count = num_parts;
parts->encoding = encoding;
parts->file_type = file_type;
return parts;
}

if (encoded_len > SIZE_MAX - (size_t)num_parts * (BBQR_HEADER_LEN + 1)) {
free(parts->parts);
free(parts);
free(compressed);
BBQrParts *bbqr_encode_hex(const uint8_t *data, size_t data_len, char file_type,
int max_chars_per_qr) {
if (!data || data_len == 0 || !bbqr_is_valid_file_type(file_type)) {
return NULL;
}
size_t storage_len = encoded_len + (size_t)num_parts * (BBQR_HEADER_LEN + 1);
parts->storage = (char *)malloc(storage_len);
if (!parts->storage) {
free(parts->parts);
free(parts);
free(compressed);

if (max_chars_per_qr < BBQR_HEADER_LEN + 2) {
return NULL;
}

// Generate headers and lay out all part strings in one allocation.
size_t storage_offset = 0;
char total_c1, total_c2;
bbqr_base36_encode(num_parts, &total_c1, &total_c2);
for (int i = 0; i < num_parts; i++) {
size_t this_payload_len =
part_payload_len(encoded_len, (size_t)payload_per_part, i);
if (data_len > SIZE_MAX / 2) {
return NULL;
}
size_t encoded_len = data_len * 2;

// Build header: B$ + encoding + file_type + total(2) + index(2)
char index_c1, index_c2;
bbqr_base36_encode(i, &index_c1, &index_c2);
int max_payload_per_part = max_chars_per_qr - BBQR_HEADER_LEN;
size_t payload_per_part = (size_t)(max_payload_per_part & ~1);
if (payload_per_part == 0) {
return NULL;
}

char *part = parts->storage + storage_offset;
parts->parts[i] = part;
part[0] = 'B';
part[1] = '$';
part[2] = encoding;
part[3] = file_type;
part[4] = total_c1;
part[5] = total_c2;
part[6] = index_c1;
part[7] = index_c2;
part[BBQR_HEADER_LEN + this_payload_len] = '\0';
size_t parts_needed =
encoded_len / payload_per_part + (encoded_len % payload_per_part != 0);
if (parts_needed == 0 || parts_needed > 1295) {
return NULL;
}
int num_parts = (int)parts_needed;

storage_offset += BBQR_HEADER_LEN + this_payload_len + 1;
payload_per_part = (encoded_len + (size_t)num_parts - 1) / (size_t)num_parts;
payload_per_part = (payload_per_part + 1) & ~(size_t)1;

BBQrParts *parts = allocate_parts(encoded_len, payload_per_part, num_parts,
BBQR_ENCODING_HEX, file_type);
if (!parts) {
return NULL;
}

bbqr_parts_writer_t writer = {
.parts = parts,
.part_index = 0,
.payload_offset = 0,
.payload_per_part = (size_t)payload_per_part,
.encoded_len = encoded_len,
.total_written = 0,
};
bool encoded =
base32_encode_write(to_encode, to_encode_len, write_to_parts, &writer);
free(compressed);
if (!encoded || writer.total_written != encoded_len) {
size_t byte_offset = 0;
for (int i = 0; i < parts->count; i++) {
char *payload = parts->parts[i] + BBQR_HEADER_LEN;
size_t payload_len = part_payload_len(encoded_len, payload_per_part, i);
size_t bytes_this_part = payload_len / 2;
for (size_t j = 0; j < bytes_this_part; j++) {
uint8_t byte = data[byte_offset++];
payload[j * 2] = HEX_ALPHABET[byte >> 4];
payload[j * 2 + 1] = HEX_ALPHABET[byte & 0x0f];
}
}

if (byte_offset != data_len) {
bbqr_parts_free(parts);
return NULL;
}
Expand Down
17 changes: 17 additions & 0 deletions components/bbqr/src/bbqr.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define BBQR_TYPE_TRANSACTION 'T' // Raw Bitcoin transaction
#define BBQR_TYPE_JSON 'J' // JSON data
#define BBQR_TYPE_UNICODE 'U' // Unicode text
#define BBQR_TYPE_BINARY 'B' // Generic binary data

/**
* @brief Header length for BBQr format
Expand Down Expand Up @@ -113,6 +114,22 @@ uint8_t *bbqr_decode_payload(char encoding, const char *data, size_t data_len,
BBQrParts *bbqr_encode(const uint8_t *data, size_t data_len, char file_type,
int max_chars_per_qr);

/**
* @brief Encode binary data as hex BBQr parts.
*
* Encodes the input data using BBQr hexadecimal encoding, without compression.
* This is the transport used by bipqr response messages (B$HB).
*
* @param data Binary data to encode
* @param data_len Length of data
* @param file_type File type character ('P', 'T', 'J', 'U', 'B')
* @param max_chars_per_qr Maximum characters per QR code (including header)
* @return Pointer to BBQrParts structure, or NULL on failure.
* Caller must free using bbqr_parts_free().
*/
BBQrParts *bbqr_encode_hex(const uint8_t *data, size_t data_len, char file_type,
int max_chars_per_qr);

/**
* @brief Free BBQrParts structure
*
Expand Down
Loading
Loading