From b153f9a00bbec4c2bd2348496729dde0836eff32 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 30 Nov 2026 11:16:31 -0300 Subject: [PATCH 01/63] third_party: Bitcoin Core's key_io vectors, test data of hash's Base58Check --- third_party/Jamfile | 10 ++++++---- tools/test/hash_jamfiles_test.py | 2 +- tools/test/third_party_test.py | 8 +++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/third_party/Jamfile b/third_party/Jamfile index 1d52dbf..85675f4 100644 --- a/third_party/Jamfile +++ b/third_party/Jamfile @@ -361,15 +361,17 @@ lib ctaes : libs/bitcoin/src/crypto/ctaes/ctaes.c $(CRYPTO)/src/canary_ctaes.c explicit ctaes ; # Bitcoin Core's base58 vectors (MIT), src/test/data/base58_encode_decode.json -# of the same submodule at the tag, read at run time by codecs' tests from the -# directory WEBCPP_TEST_BITCOIN_BASE58_VECTORS gives, on every target, as test -# data that nothing compiles. Quoted as blake3_vectors' define is, with +# and key_io_valid.json of the same submodule at the tag, read at run time by +# codecs' tests (the first) and by hash's Base58Check test (the second) from +# the directory WEBCPP_TEST_BITCOIN_BASE58_VECTORS gives, on every target, as +# test data that nothing compiles. Quoted as blake3_vectors' define is, with # forward slashes, so that a path with a space or a backslash survives. .bitcoin-base58-vectors = [ regex.replace $(BITCOIN)/src/test/data "\\\\" "/" ] ; alias bitcoin_base58_vectors : : @bitcoin-checked-out : : "\"WEBCPP_TEST_BITCOIN_BASE58_VECTORS=\\\"$(.bitcoin-base58-vectors)\\\"\"" [ webcpp.data $(BITCOIN)/src/test/data ] - libs/bitcoin/src/test/data/base58_encode_decode.json ; + libs/bitcoin/src/test/data/base58_encode_decode.json + libs/bitcoin/src/test/data/key_io_valid.json ; explicit bitcoin_base58_vectors ; # The precomputed tables of libsecp256k1 (spec section 3.5): auto (the diff --git a/tools/test/hash_jamfiles_test.py b/tools/test/hash_jamfiles_test.py index 067fe98..f9f499c 100644 --- a/tools/test/hash_jamfiles_test.py +++ b/tools/test/hash_jamfiles_test.py @@ -99,7 +99,7 @@ def message_faults(cases: list[Path]) -> list[str]: def main(argv: list[str]) -> int: return user_jamfiles.main('hash_jamfiles', CASES, - ('config', 'secure', 'hash', 'crypto', 'asio'), NOT_YET, + ('config', 'secure', 'codecs', 'hash', 'crypto', 'asio'), NOT_YET, argv, message_faults) diff --git a/tools/test/third_party_test.py b/tools/test/third_party_test.py index 094327b..50e8bef 100755 --- a/tools/test/third_party_test.py +++ b/tools/test/third_party_test.py @@ -519,8 +519,8 @@ def test_ctaes_not_checked_out_is_refused(root: Path) -> None: def test_bitcoin_base58_vectors_reach_a_test(root: Path) -> None: # /third_party//bitcoin_base58_vectors gives a program Bitcoin Core's src/test/data at the pin, - # by its define, and the file webcpp::codecs reads is there, natively and on wasip2, where - # wasmtime is given the directory. + # by its define, and the files webcpp::codecs and webcpp::hash read are there, natively and on + # wasip2, where wasmtime is given the directory. harness.add_library(root, 'base58_data', ( 'import webcpp ;\n\n' 'webcpp.targets native wasip2 ;\n\n' @@ -528,7 +528,9 @@ def test_bitcoin_base58_vectors_reach_a_test(root: Path) -> None: {'reads.cpp': '#include \n\nint main() {\n' ' std::ifstream in(WEBCPP_TEST_BITCOIN_BASE58_VECTORS\n' ' "/base58_encode_decode.json");\n' - ' return in ? 0 : 1;\n}\n'}) + ' std::ifstream keys(WEBCPP_TEST_BITCOIN_BASE58_VECTORS\n' + ' "/key_io_valid.json");\n' + ' return in && keys ? 0 : 1;\n}\n'}) result = harness.run_b2(root, '-a', 'libs/base58_data/test') harness.expect(result, True) assert '**passed**' in result.stdout, result.stdout[-4000:] From b31936b8280f2bd6ee184ce945bbb37c19b9c814 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 30 Nov 2026 15:30:16 -0300 Subject: [PATCH 02/63] guidelines: hash reads Bitcoin Core's key_io vectors --- CODING-GUIDELINES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 842fbc4..7ccb0ea 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -986,7 +986,7 @@ update --init third_party/libs/`; a build that needs none never looks. | --- | --- | --- | | `bearssl` | BearSSL from webcpp's mirror `webcpporg/bearssl` at `32381d6`, its branch `webcpp`: upstream's `7bea48e` and one fix, ECDSA's nonce decoded at its full length (chapter 5 rule 1); a static library built file by file by `third_party/Jamfile` with webcpp::crypto's and webcpp::hash's canaries (hash's when `libs/hash` is checked out), on every target; `WEBCPP_CRYPTO_HAS_BEARSSL=1`, and `WEBCPP_HASH_HAS_BEARSSL=1` with hash's canary | MIT | | `bips` | `bitcoin/bips` at `927b6de9`, shallow, test data: crypto's tests read BIP340's `bip-0340/test-vectors.csv` and BIP341's `bip-0341/wallet-test-vectors.json` at run time under the directory its define `WEBCPP_TEST_BIPS` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when it changes | BSD-2-Clause, as BIP340's header states | -| `bitcoin_base58_vectors` | Bitcoin Core's base58 vectors, `src/test/data/base58_encode_decode.json` of the submodule `third_party/libs/bitcoin` (Bitcoin Core v31.1 at `9be056a`, shallow), test data that nothing compiles: codecs' tests read it at run time under the directory its define `WEBCPP_TEST_BITCOIN_BASE58_VECTORS` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when it changes | MIT | +| `bitcoin_base58_vectors` | Bitcoin Core's base58 vectors, `src/test/data/base58_encode_decode.json` and `src/test/data/key_io_valid.json` of the submodule `third_party/libs/bitcoin` (Bitcoin Core v31.1 at `9be056a`, shallow), test data that nothing compiles: codecs' tests (the first file) and hash's Base58Check test (the second) read them at run time under the directory its define `WEBCPP_TEST_BITCOIN_BASE58_VECTORS` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when either changes | MIT | | `blake2_vectors` | BLAKE2's reference code package `BLAKE2/BLAKE2` at `ed1974e` (2023-02-12), the submodule `third_party/libs/blake2`, shallow, test data that nothing compiles: hash's tests read `testvectors/blake2b-kat.txt` and `testvectors/blake2-kat.json` at run time under the directory its define `WEBCPP_TEST_BLAKE2_VECTORS` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when one of them changes | CC0-1.0 | | `blake3` | BLAKE3 1.8.7 at `f3149ec`; `third_party/Jamfile` compiles `c/blake3.c`, `blake3_dispatch.c` and `blake3_portable.c` on every target, the intrinsics files on their instruction sets alone (an exception to chapter 5 rule 2), with webcpp::hash's canary; `WEBCPP_HASH_HAS_BLAKE3=1` | CC0-1.0, Apache-2.0, or Apache-2.0 with LLVM exception | | `blake3_vectors` | BLAKE3's official vectors, `test_vectors/test_vectors.json` of the submodule `third_party/libs/blake3` at `f3149ec`, test data: hash's tests read it at run time under the directory its define `WEBCPP_TEST_BLAKE3_VECTORS` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when it changes | CC0-1.0, Apache-2.0, or Apache-2.0 with LLVM exception | From 18a9ef7c1ad07453225f5aa557d0bbaed942c9d5 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 30 Nov 2026 17:02:05 -0300 Subject: [PATCH 03/63] tools: the crypto fixtures name the schemes in crypto::signing_schemes --- .../crypto_jamfiles/canary_secp256k1_missing/app.cpp | 2 +- .../fixtures/crypto_jamfiles/canary_secp256k1_small/app.cpp | 2 +- tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp | 4 ++-- .../ed25519_unknown_policy_on_emscripten/app.cpp | 2 +- .../test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp | 6 +++--- .../test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp | 4 ++-- .../crypto_jamfiles/secp256k1_musig_default/app.cpp | 2 +- tools/test/fixtures/crypto_jamfiles/sign/sign.cpp | 6 +++--- tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp | 6 +++--- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_missing/app.cpp b/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_missing/app.cpp index 9c74a12..c936e3b 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_missing/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_missing/app.cpp @@ -18,5 +18,5 @@ int main() { std::array const message{}; std::array const aux{}; auto key = webcpp::crypto::curves::secp256k1::keypair::from_secret(secret); - return key && key->sign(webcpp::crypto::schnorr, message, aux) ? 0 : 1; + return key && key->sign(webcpp::crypto::signing_schemes::schnorr, message, aux) ? 0 : 1; } diff --git a/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_small/app.cpp b/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_small/app.cpp index 9c74a12..c936e3b 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_small/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/canary_secp256k1_small/app.cpp @@ -18,5 +18,5 @@ int main() { std::array const message{}; std::array const aux{}; auto key = webcpp::crypto::curves::secp256k1::keypair::from_secret(secret); - return key && key->sign(webcpp::crypto::schnorr, message, aux) ? 0 : 1; + return key && key->sign(webcpp::crypto::signing_schemes::schnorr, message, aux) ? 0 : 1; } diff --git a/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp index 951f29c..256a231 100644 --- a/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp @@ -36,10 +36,10 @@ int main() { auto const key = ed25519::keypair::from_secret(seed); bool ok = false; if (key) { - auto const signature = key->sign(crypto::eddsa, message); + auto const signature = key->sign(crypto::signing_schemes::eddsa, message); auto const public_key = key->public_key(); ok = signature && public_key && secure::constant_time_equal(signature->bytes(), expected) && - crypto::verify(crypto::eddsa, *signature, message, *public_key).has_value(); + crypto::verify(crypto::signing_schemes::eddsa, *signature, message, *public_key).has_value(); } auto const name = ed25519::keypair::backend_type::name; std::printf("ed25519 %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()), diff --git a/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/app.cpp index b4e74cd..6b1986b 100644 --- a/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/app.cpp @@ -25,7 +25,7 @@ int main() { webcpp::crypto::curves::ed25519::public_key::from_bytes(std::array{}); webcpp::crypto::curves::ed25519::signature const signature{}; return public_key && - webcpp::crypto::verify(webcpp::crypto::eddsa, signature, + webcpp::crypto::verify(webcpp::crypto::signing_schemes::eddsa, signature, std::span{}, *public_key, lenient{}) ? 0 : 1; diff --git a/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp b/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp index 41f84cf..7a2df7d 100644 --- a/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp @@ -50,13 +50,13 @@ int main() { auto pair = secp256k1::keypair::from_secret(secret); bool signed_ok = false; if (pair) { - auto const signature = pair->sign(webcpp::crypto::schnorr, message, aux); + auto const signature = pair->sign(webcpp::crypto::signing_schemes::schnorr, message, aux); auto const public_key = pair->public_key(); signed_ok = signature && public_key && - webcpp::crypto::verify(webcpp::crypto::schnorr, *signature, message, *public_key); + webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, *public_key); message[0] ^= 1U; - signed_ok = signed_ok && !webcpp::crypto::verify(webcpp::crypto::schnorr, *signature, + signed_ok = signed_ok && !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, *public_key); } std::printf("schnorr %s\n", signed_ok ? "ok" : "FAILED"); diff --git a/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp index 477963b..3f378e2 100644 --- a/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp @@ -31,11 +31,11 @@ int main() { auto const key = secp256k1::keypair::from_secret(secret); bool ok = false; if (key) { - auto const signature = key->sign(webcpp::crypto::schnorr, message, aux); + auto const signature = key->sign(webcpp::crypto::signing_schemes::schnorr, message, aux); auto const public_key = key->public_key(); ok = signature && public_key && webcpp::secure::constant_time_equal(signature->bytes(), expected) && - webcpp::crypto::verify(webcpp::crypto::schnorr, *signature, message, *public_key); + webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, *public_key); } auto const name = secp256k1::keypair::backend_type::name; std::printf("schnorr %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()), diff --git a/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp index 21a3bd9..efe9add 100644 --- a/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp @@ -68,7 +68,7 @@ bool sign_and_verify(secp256k1::keypair const& first, secp256k1::keypair const& } std::array const parts{*first_part, *second_part}; auto const signature = musig::partial_signature_aggregate(*session, parts, space); - return signature && webcpp::crypto::verify(webcpp::crypto::schnorr, *signature, message, + return signature && webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, aggregate->xonly_public_key()); } diff --git a/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp b/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp index 335fcf0..d44b0a2 100644 --- a/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp +++ b/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp @@ -22,13 +22,13 @@ int main() { auto key = secp256k1::keypair::from_secret(secret); bool ok = false; if (key) { - auto const signature = key->sign(webcpp::crypto::schnorr, message, aux); + auto const signature = key->sign(webcpp::crypto::signing_schemes::schnorr, message, aux); auto const public_key = key->public_key(); ok = signature && public_key && - webcpp::crypto::verify(webcpp::crypto::schnorr, *signature, message, *public_key); + webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, *public_key); message[0] ^= 1U; ok = ok && - !webcpp::crypto::verify(webcpp::crypto::schnorr, *signature, message, *public_key); + !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, *public_key); } std::printf("schnorr %s\n", ok ? "ok" : "FAILED"); return ok ? 0 : 1; diff --git a/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp b/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp index 335fcf0..d44b0a2 100644 --- a/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp +++ b/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp @@ -22,13 +22,13 @@ int main() { auto key = secp256k1::keypair::from_secret(secret); bool ok = false; if (key) { - auto const signature = key->sign(webcpp::crypto::schnorr, message, aux); + auto const signature = key->sign(webcpp::crypto::signing_schemes::schnorr, message, aux); auto const public_key = key->public_key(); ok = signature && public_key && - webcpp::crypto::verify(webcpp::crypto::schnorr, *signature, message, *public_key); + webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, *public_key); message[0] ^= 1U; ok = ok && - !webcpp::crypto::verify(webcpp::crypto::schnorr, *signature, message, *public_key); + !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, *public_key); } std::printf("schnorr %s\n", ok ? "ok" : "FAILED"); return ok ? 0 : 1; From b9c8fa0295cebc0df9899424f7c316b662e4907d Mon Sep 17 00:00:00 2001 From: R Date: Mon, 30 Nov 2026 17:22:51 -0300 Subject: [PATCH 04/63] tools: the crypto fixtures name the schemes in crypto::signing_schemes, formatted --- .../fixtures/crypto_jamfiles/ed25519_default/app.cpp | 3 ++- .../fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp | 10 +++++----- .../fixtures/crypto_jamfiles/secp256k1_default/app.cpp | 3 ++- .../crypto_jamfiles/secp256k1_musig_default/app.cpp | 4 ++-- tools/test/fixtures/crypto_jamfiles/sign/sign.cpp | 7 ++++--- .../test/fixtures/crypto_jamfiles/sign_small/sign.cpp | 7 ++++--- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp index 256a231..670713d 100644 --- a/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp @@ -39,7 +39,8 @@ int main() { auto const signature = key->sign(crypto::signing_schemes::eddsa, message); auto const public_key = key->public_key(); ok = signature && public_key && secure::constant_time_equal(signature->bytes(), expected) && - crypto::verify(crypto::signing_schemes::eddsa, *signature, message, *public_key).has_value(); + crypto::verify(crypto::signing_schemes::eddsa, *signature, message, *public_key) + .has_value(); } auto const name = ed25519::keypair::backend_type::name; std::printf("ed25519 %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()), diff --git a/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp b/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp index 7a2df7d..1c61fe1 100644 --- a/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp @@ -52,12 +52,12 @@ int main() { if (pair) { auto const signature = pair->sign(webcpp::crypto::signing_schemes::schnorr, message, aux); auto const public_key = pair->public_key(); - signed_ok = - signature && public_key && - webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, *public_key); + signed_ok = signature && public_key && + webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, + message, *public_key); message[0] ^= 1U; - signed_ok = signed_ok && !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, - message, *public_key); + signed_ok = signed_ok && !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, + *signature, message, *public_key); } std::printf("schnorr %s\n", signed_ok ? "ok" : "FAILED"); return sealed && opened && signed_ok ? 0 : 1; diff --git a/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp index 3f378e2..eba2bc0 100644 --- a/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp @@ -35,7 +35,8 @@ int main() { auto const public_key = key->public_key(); ok = signature && public_key && webcpp::secure::constant_time_equal(signature->bytes(), expected) && - webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, *public_key); + webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, + *public_key); } auto const name = secp256k1::keypair::backend_type::name; std::printf("schnorr %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()), diff --git a/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp index efe9add..1e8b507 100644 --- a/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp @@ -68,8 +68,8 @@ bool sign_and_verify(secp256k1::keypair const& first, secp256k1::keypair const& } std::array const parts{*first_part, *second_part}; auto const signature = musig::partial_signature_aggregate(*session, parts, space); - return signature && webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, - aggregate->xonly_public_key()); + return signature && webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, + message, aggregate->xonly_public_key()); } } // namespace diff --git a/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp b/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp index d44b0a2..0d4b584 100644 --- a/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp +++ b/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp @@ -25,10 +25,11 @@ int main() { auto const signature = key->sign(webcpp::crypto::signing_schemes::schnorr, message, aux); auto const public_key = key->public_key(); ok = signature && public_key && - webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, *public_key); + webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, + *public_key); message[0] ^= 1U; - ok = ok && - !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, *public_key); + ok = ok && !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, + message, *public_key); } std::printf("schnorr %s\n", ok ? "ok" : "FAILED"); return ok ? 0 : 1; diff --git a/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp b/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp index d44b0a2..0d4b584 100644 --- a/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp +++ b/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp @@ -25,10 +25,11 @@ int main() { auto const signature = key->sign(webcpp::crypto::signing_schemes::schnorr, message, aux); auto const public_key = key->public_key(); ok = signature && public_key && - webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, *public_key); + webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, + *public_key); message[0] ^= 1U; - ok = ok && - !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, *public_key); + ok = ok && !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, + message, *public_key); } std::printf("schnorr %s\n", ok ? "ok" : "FAILED"); return ok ? 0 : 1; From b4d063c2abbdb73b4b0e9f5b665f62b5c64dcf69 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 30 Nov 2026 18:58:47 -0300 Subject: [PATCH 05/63] guidelines: crypto's current rules name the schemes in crypto::signing_schemes --- CODING-GUIDELINES.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 7ccb0ea..0b476c7 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7222,7 +7222,8 @@ since that change); what is decided and not built is in chapter 17. creates libsecp256k1's context in it with `secp256k1_context_preallocated_create`, aligned to `alignof(std::max_align_t)`, and randomizes it from `random_device`; - `crypto::verify` with `crypto::schnorr` and `crypto::ecdsa_sha256` uses + `crypto::verify` with `crypto::signing_schemes::schnorr` and + `crypto::signing_schemes::ecdsa_sha256` uses `secp256k1_context_static` after `secp256k1_selftest()` on every call and allocates nothing.** The resource serves the context alone, so that the counting test sees every allocation; @@ -7286,7 +7287,8 @@ since that change); what is decided and not built is in chapter 17. - **One name per signing operation, the scheme always named: `key.sign(scheme, input)` and `crypto::verify(scheme, signature, input, public_key)`, and their `async_` forms, on Ed25519, P-256 and secp256k1; a digest only as - `crypto::prehashed{digest}`; every key pair a `crypto::keypair`, with a + `crypto::signing_schemes::prehashed{digest}`; every key pair a + `crypto::keypair`, with a typed public key and `secret()`.** A span is a message whatever its size, so a 32-byte message is never read as a digest; a pair of scheme and input that is not valid stops the build with its reason. `Backend` is the first From bec59b429e7a90a49a80140fe19fc0515b4db874 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 30 Nov 2026 20:00:54 -0300 Subject: [PATCH 06/63] tools: the crypto fixtures verify with a policy --- .../fixtures/crypto_jamfiles/ed25519_default/app.cpp | 8 +++++--- .../ed25519_unknown_policy_on_emscripten/app.cpp | 9 +++++---- .../ed25519_unknown_policy_on_emscripten.outcome | 2 +- .../fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp | 11 +++++++---- .../crypto_jamfiles/secp256k1_default/app.cpp | 5 +++-- .../crypto_jamfiles/secp256k1_musig_default/app.cpp | 5 +++-- tools/test/fixtures/crypto_jamfiles/sign/sign.cpp | 10 ++++++---- .../test/fixtures/crypto_jamfiles/sign_small/sign.cpp | 10 ++++++---- 8 files changed, 36 insertions(+), 24 deletions(-) diff --git a/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp index 670713d..0c98eb1 100644 --- a/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/ed25519_default/app.cpp @@ -38,9 +38,11 @@ int main() { if (key) { auto const signature = key->sign(crypto::signing_schemes::eddsa, message); auto const public_key = key->public_key(); - ok = signature && public_key && secure::constant_time_equal(signature->bytes(), expected) && - crypto::verify(crypto::signing_schemes::eddsa, *signature, message, *public_key) - .has_value(); + ok = + signature && public_key && secure::constant_time_equal(signature->bytes(), expected) && + crypto::verify(crypto::signing_schemes::eddsa, crypto::verification_policies::canonical, + *signature, message, *public_key) + .has_value(); } auto const name = ed25519::keypair::backend_type::name; std::printf("ed25519 %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()), diff --git a/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/app.cpp index 6b1986b..201dfa3 100644 --- a/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/app.cpp @@ -4,8 +4,9 @@ // accompanying file LICENSE_1_0.txt or copy at // https://www.boost.org/LICENSE_1_0.txt) -// A program that names a policy of its own in Ed25519's crypto::verify, on its default backend -// linked, stops where it calls it, with the one policy there is. +// A program that names a policy of its own in Ed25519's crypto::verify, in the policy's place after +// the scheme, on its default backend linked, stops where it calls it, with the one policy Ed25519 +// takes. #include #include @@ -25,8 +26,8 @@ int main() { webcpp::crypto::curves::ed25519::public_key::from_bytes(std::array{}); webcpp::crypto::curves::ed25519::signature const signature{}; return public_key && - webcpp::crypto::verify(webcpp::crypto::signing_schemes::eddsa, signature, - std::span{}, *public_key, lenient{}) + webcpp::crypto::verify(webcpp::crypto::signing_schemes::eddsa, lenient{}, + signature, std::span{}, *public_key) ? 0 : 1; } diff --git a/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/ed25519_unknown_policy_on_emscripten.outcome b/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/ed25519_unknown_policy_on_emscripten.outcome index 929fb29..97fdf99 100644 --- a/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/ed25519_unknown_policy_on_emscripten.outcome +++ b/tools/test/fixtures/crypto_jamfiles/ed25519_unknown_policy_on_emscripten/ed25519_unknown_policy_on_emscripten.outcome @@ -12,5 +12,5 @@ targets: emscripten build: fails # tag::messages[] -contains: webcpp::crypto: Ed25519's only verification policy is curves::ed25519::strict. +contains: webcpp::crypto: verify: crypto::signing_schemes::eddsa and eddsa_prehashed take crypto::verification_policies::canonical. # end::messages[] diff --git a/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp b/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp index 1c61fe1..987146f 100644 --- a/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/encrypt_and_sign/app.cpp @@ -53,11 +53,14 @@ int main() { auto const signature = pair->sign(webcpp::crypto::signing_schemes::schnorr, message, aux); auto const public_key = pair->public_key(); signed_ok = signature && public_key && - webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, - message, *public_key); + webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, + webcpp::crypto::verification_policies::canonical, + *signature, message, *public_key); message[0] ^= 1U; - signed_ok = signed_ok && !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, - *signature, message, *public_key); + signed_ok = + signed_ok && !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, + webcpp::crypto::verification_policies::canonical, + *signature, message, *public_key); } std::printf("schnorr %s\n", signed_ok ? "ok" : "FAILED"); return sealed && opened && signed_ok ? 0 : 1; diff --git a/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp index eba2bc0..013eadf 100644 --- a/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_default/app.cpp @@ -35,8 +35,9 @@ int main() { auto const public_key = key->public_key(); ok = signature && public_key && webcpp::secure::constant_time_equal(signature->bytes(), expected) && - webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, - *public_key); + webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, + webcpp::crypto::verification_policies::canonical, *signature, + message, *public_key); } auto const name = secp256k1::keypair::backend_type::name; std::printf("schnorr %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()), diff --git a/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp index 1e8b507..175c5ba 100644 --- a/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp +++ b/tools/test/fixtures/crypto_jamfiles/secp256k1_musig_default/app.cpp @@ -68,8 +68,9 @@ bool sign_and_verify(secp256k1::keypair const& first, secp256k1::keypair const& } std::array const parts{*first_part, *second_part}; auto const signature = musig::partial_signature_aggregate(*session, parts, space); - return signature && webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, - message, aggregate->xonly_public_key()); + return signature && webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, + webcpp::crypto::verification_policies::canonical, + *signature, message, aggregate->xonly_public_key()); } } // namespace diff --git a/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp b/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp index 0d4b584..30de116 100644 --- a/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp +++ b/tools/test/fixtures/crypto_jamfiles/sign/sign.cpp @@ -25,11 +25,13 @@ int main() { auto const signature = key->sign(webcpp::crypto::signing_schemes::schnorr, message, aux); auto const public_key = key->public_key(); ok = signature && public_key && - webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, - *public_key); + webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, + webcpp::crypto::verification_policies::canonical, *signature, + message, *public_key); message[0] ^= 1U; - ok = ok && !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, - message, *public_key); + ok = ok && !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, + webcpp::crypto::verification_policies::canonical, + *signature, message, *public_key); } std::printf("schnorr %s\n", ok ? "ok" : "FAILED"); return ok ? 0 : 1; diff --git a/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp b/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp index 0d4b584..30de116 100644 --- a/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp +++ b/tools/test/fixtures/crypto_jamfiles/sign_small/sign.cpp @@ -25,11 +25,13 @@ int main() { auto const signature = key->sign(webcpp::crypto::signing_schemes::schnorr, message, aux); auto const public_key = key->public_key(); ok = signature && public_key && - webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, message, - *public_key); + webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, + webcpp::crypto::verification_policies::canonical, *signature, + message, *public_key); message[0] ^= 1U; - ok = ok && !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, *signature, - message, *public_key); + ok = ok && !webcpp::crypto::verify(webcpp::crypto::signing_schemes::schnorr, + webcpp::crypto::verification_policies::canonical, + *signature, message, *public_key); } std::printf("schnorr %s\n", ok ? "ok" : "FAILED"); return ok ? 0 : 1; From 8fd5db699679a958664880e25cadef8ce1af023c Mon Sep 17 00:00:00 2001 From: R Date: Mon, 30 Nov 2026 20:00:54 -0300 Subject: [PATCH 07/63] guidelines: crypto's verification takes a policy after the scheme --- CODING-GUIDELINES.md | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 0b476c7..17d53fe 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7271,22 +7271,28 @@ since that change); what is decided and not built is in chapter 17. WebCrypto write, checked by the oracles; anything else is `invalid_encoding`. Source: `include/webcpp/crypto/curves/p256/formats.hpp` (libs/crypto). -- **ECDSA signs low S on both curves; P-256's verification accepts both - forms, as FIPS 186-5 and WebCrypto do, and secp256k1's refuses a high S.** - P-256's `sign` normalizes RFC 6979's S after signing, selecting n - s by a - mask without a branch; `normalize_low_s` gives the low form of a signature - made elsewhere and `is_low_s` answers whether one is low, neither calling a - backend. A protocol that requires low S of its peers (Trystero's - handshakes) checks `is_low_s` before `crypto::verify`; the protocol itself - is webcpp::trystero's (D24), which the guide's section on signed handshakes - shows with an example. Their verdict is marked public for the constant-time - checkers, a signature being public once made. +- **ECDSA signs low S on both curves; every verification takes a mandatory + policy after the scheme, which each scheme declares: P-256's ECDSA + `crypto::verification_policies::low_s_only` or `any_s` (both forms, as FIPS + 186-5 and WebCrypto accept), secp256k1's ECDSA and `recover` `low_s_only`, + Ed25519 and BIP340 `canonical`; another policy, or none, stops the build + with the accepted ones.** P-256's `sign` normalizes RFC 6979's S after + signing, selecting n - s by a mask without a branch, and `low_s_only` + refuses a high S before BearSSL; `normalize_low_s` gives the low form of a + signature made elsewhere and `is_low_s` answers whether one is low, neither + calling a backend. A protocol that requires low S of its peers (Trystero's + handshakes) verifies under `low_s_only`, a browser's or a passkey's + signature under `any_s`; the protocol itself is webcpp::trystero's (D24), + which the guide's section on signed handshakes shows with an example. + Their verdict is marked public for the constant-time checkers, a signature + being public once made. Source: `include/webcpp/crypto/curves/p256.hpp`, `doc/p2p.adoc` (libs/crypto); `libraries/crypto/openspec/changes/unified-sign/design.md` - D3 and D4b (proposals). + D3 and D4b, `libraries/crypto/openspec/changes/formats/design.md` D9 + (proposals). - **One name per signing operation, the scheme always named: `key.sign(scheme, - input)` and `crypto::verify(scheme, signature, input, public_key)`, and - their `async_` forms, on Ed25519, P-256 and secp256k1; a digest only as + input)` and `crypto::verify(scheme, policy, signature, input, public_key)`, + and their `async_` forms, on Ed25519, P-256 and secp256k1; a digest only as `crypto::signing_schemes::prehashed{digest}`; every key pair a `crypto::keypair`, with a typed public key and `secret()`.** A span is a message whatever its size, From 22bb880e1235b32c8cfdf2fc6ff5101ab5634efb Mon Sep 17 00:00:00 2001 From: R Date: Mon, 30 Nov 2026 23:00:32 -0300 Subject: [PATCH 08/63] guidelines: low S is the ECDSA signatures' members is_low_s() and low_s() --- CODING-GUIDELINES.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 17d53fe..05bcf0d 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7236,7 +7236,7 @@ since that change); what is decided and not built is in chapter 17. Source: `libraries/crypto/openspec/changes/genesis/reference/spec.md` section 2.8 (proposals). - **ECDSA's DER is strict (`to_der`, `from_der`, at most 72 bytes) and - `normalize_low_s` gives the low-S form; the x-only tweak takes any 32-byte + an ECDSA signature's `low_s()` gives the low-S form; the x-only tweak takes any 32-byte tweak, as a free `tweak_xonly` on an x-only key, giving the key and its parity, and as `keypair::tweak_xonly` in place, and a tweak not below the group order is `invalid_secret_key` and wipes the key pair.** A wallet's @@ -7278,9 +7278,9 @@ since that change); what is decided and not built is in chapter 17. Ed25519 and BIP340 `canonical`; another policy, or none, stops the build with the accepted ones.** P-256's `sign` normalizes RFC 6979's S after signing, selecting n - s by a mask without a branch, and `low_s_only` - refuses a high S before BearSSL; `normalize_low_s` gives the low form of a - signature made elsewhere and `is_low_s` answers whether one is low, neither - calling a backend. A protocol that requires low S of its peers (Trystero's + refuses a high S before BearSSL; an ECDSA signature's `low_s()` gives the low form of a + signature made elsewhere and `is_low_s()` answers whether one is low, those of + P-256 calling no backend. A protocol that requires low S of its peers (Trystero's handshakes) verifies under `low_s_only`, a browser's or a passkey's signature under `any_s`; the protocol itself is webcpp::trystero's (D24), which the guide's section on signed handshakes shows with an example. From 95f244930cc182d1a158b12f9481cf19d1c5ceb1 Mon Sep 17 00:00:00 2001 From: R Date: Mon, 30 Nov 2026 23:52:59 -0300 Subject: [PATCH 09/63] guidelines: the low S paragraphs wrapped to the file's width --- CODING-GUIDELINES.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 05bcf0d..2571547 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7236,10 +7236,10 @@ since that change); what is decided and not built is in chapter 17. Source: `libraries/crypto/openspec/changes/genesis/reference/spec.md` section 2.8 (proposals). - **ECDSA's DER is strict (`to_der`, `from_der`, at most 72 bytes) and - an ECDSA signature's `low_s()` gives the low-S form; the x-only tweak takes any 32-byte - tweak, as a free `tweak_xonly` on an x-only key, giving the key and its - parity, and as `keypair::tweak_xonly` in place, and a tweak not below the - group order is `invalid_secret_key` and wipes the key pair.** A wallet's + an ECDSA signature's `low_s()` gives the low-S form; the x-only tweak takes + any 32-byte tweak, as a free `tweak_xonly` on an x-only key, giving the key + and its parity, and as `keypair::tweak_xonly` in place, and a tweak not below + the group order is `invalid_secret_key` and wipes the key pair.** A wallet's needs without a protocol's rules: the caller computes BIP341's TapTweak, and BIP341's vectors test the tweak that way. Source: `libraries/crypto/openspec/changes/genesis/design.md` (proposals); @@ -7278,12 +7278,13 @@ since that change); what is decided and not built is in chapter 17. Ed25519 and BIP340 `canonical`; another policy, or none, stops the build with the accepted ones.** P-256's `sign` normalizes RFC 6979's S after signing, selecting n - s by a mask without a branch, and `low_s_only` - refuses a high S before BearSSL; an ECDSA signature's `low_s()` gives the low form of a - signature made elsewhere and `is_low_s()` answers whether one is low, those of - P-256 calling no backend. A protocol that requires low S of its peers (Trystero's - handshakes) verifies under `low_s_only`, a browser's or a passkey's - signature under `any_s`; the protocol itself is webcpp::trystero's (D24), - which the guide's section on signed handshakes shows with an example. + refuses a high S before BearSSL; an ECDSA signature's `low_s()` gives the + low form of a signature made elsewhere and `is_low_s()` answers whether one + is low, those of P-256 calling no backend. A protocol that requires low S of + its peers (Trystero's handshakes) verifies under `low_s_only`, a browser's + or a passkey's signature under `any_s`; the protocol itself is + webcpp::trystero's (D24), which the guide's section on signed handshakes + shows with an example. Their verdict is marked public for the constant-time checkers, a signature being public once made. Source: `include/webcpp/crypto/curves/p256.hpp`, `doc/p2p.adoc` From a043ff851b3a8937d0b14bb707513a3c5eb62e75 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 00:26:30 -0300 Subject: [PATCH 10/63] tools: crypto's Jamfile fixtures copy codecs into their scratch superproject, which crypto's target now names --- tools/test/crypto_jamfiles_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/test/crypto_jamfiles_test.py b/tools/test/crypto_jamfiles_test.py index 6a23350..d36b791 100644 --- a/tools/test/crypto_jamfiles_test.py +++ b/tools/test/crypto_jamfiles_test.py @@ -30,8 +30,8 @@ def main(argv: list[str]) -> int: - return user_jamfiles.main('crypto_jamfiles', CASES, ('config', 'secure', 'crypto', 'hash'), - NOT_YET, argv) + return user_jamfiles.main('crypto_jamfiles', CASES, + ('config', 'secure', 'codecs', 'crypto', 'hash'), NOT_YET, argv) if __name__ == '__main__': From 99f1d8f8e228ff379e153fdde449c1395656dbee Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 02:58:58 -0300 Subject: [PATCH 11/63] tools: crypto's fuzz own lane installs libFuzzer's and the sanitizers' runtimes, as codecs' does --- tools/ci/matrix.py | 11 ++++++----- tools/ci/matrix_test.py | 21 +++++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/tools/ci/matrix.py b/tools/ci/matrix.py index 0970187..0b7e22c 100755 --- a/tools/ci/matrix.py +++ b/tools/ci/matrix.py @@ -198,16 +198,17 @@ # native programs under Valgrind's memcheck (valgrind, with valgrind/memcheck.h) and under # MemorySanitizer, whose runtime and sanitizer/ headers are libclang-rt-18-dev's, and their # drivers read MemorySanitizer's frames with llvm-symbolizer-18, which llvm-18 installs; on -# wasip2 crypto's runs dudect alone, which needs none. codecs' fuzz lane links libFuzzer, -# AddressSanitizer and UndefinedBehaviorSanitizer, whose runtimes and sanitizer/ headers (the -# malloc hooks its targets count the heap with) are libclang-rt-18-dev's, and its sanitizers -# symbolise their reports with llvm-symbolizer-18. The lint, which analyses those programs +# wasip2 crypto's runs dudect alone, which needs none. codecs' and crypto's fuzz lanes link +# libFuzzer, AddressSanitizer and UndefinedBehaviorSanitizer, whose runtimes and sanitizer/ headers +# (the malloc hooks their targets count the heap with) are libclang-rt-18-dev's, and their +# sanitizers symbolise their reports with llvm-symbolizer-18. The lint, which analyses those programs # natively, installs every package of the table (lint-packages). OWN_LANE_PACKAGES: dict[tuple[str, str, str], tuple[str, ...]] = { ('crypto', 'constant-time', 'native'): ('valgrind', 'llvm-18', 'libclang-rt-18-dev'), ('secure', 'constant-time', 'native'): ('valgrind', 'llvm-18', 'libclang-rt-18-dev'), ('codecs', 'constant-time', 'native'): ('valgrind', 'llvm-18', 'libclang-rt-18-dev'), - ('codecs', 'fuzz', 'native'): ('llvm-18', 'libclang-rt-18-dev')} + ('codecs', 'fuzz', 'native'): ('llvm-18', 'libclang-rt-18-dev'), + ('crypto', 'fuzz', 'native'): ('llvm-18', 'libclang-rt-18-dev')} # MSVC's lanes build 64-bit programs, embed their manifest with the linker and abbreviate b2's # paths against Windows's MAX_PATH, as xstate-cpp's green Windows jobs did. b2 abbreviates each diff --git a/tools/ci/matrix_test.py b/tools/ci/matrix_test.py index bad0ab6..e3ae796 100755 --- a/tools/ci/matrix_test.py +++ b/tools/ci/matrix_test.py @@ -1338,24 +1338,27 @@ def test_an_own_lane_installs_its_packages(root): # its entry, by library, lane and target: crypto's, secure's and codecs' constant-time lanes # natively have Valgrind, llvm-18 (llvm-symbolizer-18, which reads MemorySanitizer's frames) and # libclang-rt-18-dev (clang-18's MemorySanitizer runtime and its sanitizer/ headers); - # crypto's on wasip2, where it runs dudect alone, none; codecs' fuzz lane natively llvm-18 and - # libclang-rt-18-dev (libFuzzer's and the sanitizers' runtimes, and the sanitizer/ header of - # the malloc hooks), and no Valgrind; every other own lane none. The own-lanes job installs + # crypto's on wasip2, where it runs dudect alone, none; codecs' and crypto's fuzz lanes + # natively llvm-18 and libclang-rt-18-dev (libFuzzer's and the sanitizers' runtimes, and the + # sanitizer/ header of the malloc hooks), and no Valgrind; every other own lane none. The own-lanes job installs # them with apt on Linux, only where the list is not empty, before the lane runs. packages = ('valgrind', 'llvm-18', 'libclang-rt-18-dev') fuzz_packages = ('llvm-18', 'libclang-rt-18-dev') assert matrix.OWN_LANE_PACKAGES == {('crypto', 'constant-time', 'native'): packages, ('secure', 'constant-time', 'native'): packages, ('codecs', 'constant-time', 'native'): packages, - ('codecs', 'fuzz', 'native'): fuzz_packages} + ('codecs', 'fuzz', 'native'): fuzz_packages, + ('crypto', 'fuzz', 'native'): fuzz_packages} boost_only(root) oracle_library(root, 'beta') harness.add_library(root, 'crypto', 'import webcpp ;\n' 'webcpp.targets native wasip2 ;\n' 'webcpp.run plain : plain.cpp ;\n' - 'webcpp.lane constant-time : plain : native wasip2 ;\n', - {'plain.cpp': 'int main() {}\n'}) + 'webcpp.run fuzzed : fuzzed.cpp ;\n' + 'webcpp.lane constant-time : plain : native wasip2 ;\n' + 'webcpp.lane fuzz : fuzzed : native ;\n', + {'plain.cpp': 'int main() {}\n', 'fuzzed.cpp': 'int main() {}\n'}) harness.add_library(root, 'secure', 'import webcpp ;\n' 'webcpp.targets native ;\n' @@ -1372,7 +1375,8 @@ def test_an_own_lane_installs_its_packages(root): {'plain.cpp': 'int main() {}\n', 'fuzzed.cpp': 'int main() {}\n'}) assert {entry.get('id', entry['lane']): entry['apt'] for entry in own_lanes(root)} == { 'oracle': [], 'native.crypto.constant-time': list(packages), - 'wasip2.crypto.constant-time': [], 'native.secure.constant-time': list(packages), + 'wasip2.crypto.constant-time': [], 'native.crypto.fuzz': list(fuzz_packages), + 'native.secure.constant-time': list(packages), 'native.codecs.constant-time': list(packages), 'native.codecs.fuzz': list(fuzz_packages)}, own_lanes(root) steps = job_steps(workflow_jobs()['own-lanes']) @@ -1389,7 +1393,8 @@ def test_the_lint_installs_the_own_lanes_packages(root): # The lint analyses every own lane's programs, natively with clang-18 on Linux, so it needs # their headers: lint-packages prints every package of OWN_LANE_PACKAGES once, sorted, the # one source (crypto's, secure's and codecs' constant-time lanes list the same three, and - # codecs' fuzz lane two of them), and the lint job installs them before the lint runs. + # codecs' and crypto's fuzz lanes two of them), and the lint job installs them before the lint + # runs. result = run(root, 'lint-packages') assert result.returncode == 0, (result.returncode, result.stderr) assert result.stdout == 'libclang-rt-18-dev llvm-18 valgrind\n', result.stdout From 0037294fa696e2ffc353a7da94f83c5a7506cdaa Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 03:11:03 -0300 Subject: [PATCH 12/63] tools: crypto's fuzz own lane lint fix --- tools/ci/matrix.py | 4 ++-- tools/ci/matrix_test.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/ci/matrix.py b/tools/ci/matrix.py index 0b7e22c..467c2a1 100755 --- a/tools/ci/matrix.py +++ b/tools/ci/matrix.py @@ -201,8 +201,8 @@ # wasip2 crypto's runs dudect alone, which needs none. codecs' and crypto's fuzz lanes link # libFuzzer, AddressSanitizer and UndefinedBehaviorSanitizer, whose runtimes and sanitizer/ headers # (the malloc hooks their targets count the heap with) are libclang-rt-18-dev's, and their -# sanitizers symbolise their reports with llvm-symbolizer-18. The lint, which analyses those programs -# natively, installs every package of the table (lint-packages). +# sanitizers symbolise their reports with llvm-symbolizer-18. The lint, which analyses those +# programs natively, installs every package of the table (lint-packages). OWN_LANE_PACKAGES: dict[tuple[str, str, str], tuple[str, ...]] = { ('crypto', 'constant-time', 'native'): ('valgrind', 'llvm-18', 'libclang-rt-18-dev'), ('secure', 'constant-time', 'native'): ('valgrind', 'llvm-18', 'libclang-rt-18-dev'), diff --git a/tools/ci/matrix_test.py b/tools/ci/matrix_test.py index e3ae796..062329f 100755 --- a/tools/ci/matrix_test.py +++ b/tools/ci/matrix_test.py @@ -1340,8 +1340,9 @@ def test_an_own_lane_installs_its_packages(root): # libclang-rt-18-dev (clang-18's MemorySanitizer runtime and its sanitizer/ headers); # crypto's on wasip2, where it runs dudect alone, none; codecs' and crypto's fuzz lanes # natively llvm-18 and libclang-rt-18-dev (libFuzzer's and the sanitizers' runtimes, and the - # sanitizer/ header of the malloc hooks), and no Valgrind; every other own lane none. The own-lanes job installs - # them with apt on Linux, only where the list is not empty, before the lane runs. + # sanitizer/ header of the malloc hooks), and no Valgrind; every other own lane none. The + # own-lanes job installs them with apt on Linux, only where the list is not empty, before the + # lane runs. packages = ('valgrind', 'llvm-18', 'libclang-rt-18-dev') fuzz_packages = ('llvm-18', 'libclang-rt-18-dev') assert matrix.OWN_LANE_PACKAGES == {('crypto', 'constant-time', 'native'): packages, From f650d72653e5fdf588dfa1c39fadf19b8ed2e410 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 07:29:20 -0300 Subject: [PATCH 13/63] libs/crypto: the gitlink at Ed25519's formats as codecs value codecs (4d8fd11) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 7b2c776..4d8fd11 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 7b2c7769c9d45804e0e365bdce8e465df021c7cc +Subproject commit 4d8fd11aa89fb8ceb2e75fdd3b5494cf1afe0313 From 8f998625131c44eff649189be95e0c042e3e3e37 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 08:31:37 -0300 Subject: [PATCH 14/63] libs/crypto: the gitlink at Ed25519's formats fix round 1 (48a1146) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 4d8fd11..48a1146 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 4d8fd11aa89fb8ceb2e75fdd3b5494cf1afe0313 +Subproject commit 48a114670a90d0dea02f7cbc16d6bf35bdb48a2b From ca0fa4dcd11ca821a5693387d71b4ee2ba867664 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 09:27:59 -0300 Subject: [PATCH 15/63] libs/crypto: the gitlink at X25519's formats (fa45a2f) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 48a1146..fa45a2f 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 48a114670a90d0dea02f7cbc16d6bf35bdb48a2b +Subproject commit fa45a2f7c22578808537380bd3d21def2dc8b552 From 5bc7be63294ecdd1d61636eab5d0512f9b1bb182 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 09:56:19 -0300 Subject: [PATCH 16/63] libs/crypto: the gitlink at X25519's formats lint fix (9f7551d) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index fa45a2f..9f7551d 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit fa45a2f7c22578808537380bd3d21def2dc8b552 +Subproject commit 9f7551dfe9212bb5efae195443f061e38da613f8 From 8d954ed779c8ac2ea1664bbf89afff710a27a6f9 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 12:57:48 -0300 Subject: [PATCH 17/63] libs/crypto: the gitlink at X25519's formats fix round 1 (d6943a6) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 9f7551d..d6943a6 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 9f7551dfe9212bb5efae195443f061e38da613f8 +Subproject commit d6943a6d811b2b70570f88c62d9e9f7405180533 From c2bd048b13793dd5456a9d605e52213d7a5f035f Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 14:03:40 -0300 Subject: [PATCH 18/63] guidelines: P-256's key formats take the compressed point, decompressed by crypto --- CODING-GUIDELINES.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 2571547..ef190c9 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7264,11 +7264,13 @@ since that change); what is decided and not built is in chapter 17. (proposals); `include/webcpp/crypto/curves/p256.hpp` and `backends/bearssl.hpp` (libs/crypto). - **The key formats are fixed layouts: SPKI of 91 bytes (RFC 5480, the - uncompressed point) and PKCS#8 of 138 bytes (version 0, RFC 5915's - ECPrivateKey version 1 without parameters and with the public key); a - decoder accepts exactly what the encoder writes, the point checked against - the scalar.** The bytes OpenSSL's and BearSSL's encoders and node's - WebCrypto write, checked by the oracles; anything else is + uncompressed point), or 59 around the compressed point, and PKCS#8 of 138 + bytes (version 0, RFC 5915's ECPrivateKey version 1 without parameters and + with the public key); a decoder accepts exactly what the encoder writes, the + point checked against the scalar; a compressed point is decompressed by + crypto, a square root modulo p on public data, since BearSSL decodes + uncompressed points alone.** The bytes OpenSSL's and BearSSL's encoders and + node's WebCrypto write, checked by the oracles; anything else is `invalid_encoding`. Source: `include/webcpp/crypto/curves/p256/formats.hpp` (libs/crypto). - **ECDSA signs low S on both curves; every verification takes a mandatory From f9d5558bcbd492e717b56ef1ec4de89c62703cb1 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 14:03:40 -0300 Subject: [PATCH 19/63] libs/crypto: the gitlink at P-256's formats (9558ee9) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index d6943a6..9558ee9 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit d6943a6d811b2b70570f88c62d9e9f7405180533 +Subproject commit 9558ee9faf96347a3b7c0b0bd1860e3bea34a981 From b85c0ee60bb73681ea4a1a5b326d51c4cb7ff59b Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 14:35:13 -0300 Subject: [PATCH 20/63] libs/crypto: the gitlink at P-256's formats lint fix (8cc2ba7) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 9558ee9..8cc2ba7 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 9558ee9faf96347a3b7c0b0bd1860e3bea34a981 +Subproject commit 8cc2ba7eae3c3536ae1a2bbe1200fbc9db3134ee From fb150bca201326e3bd07cd0181f81161ab1ee9b6 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 15:05:05 -0300 Subject: [PATCH 21/63] libs/crypto: the gitlink at P-256's formats page fix (7f7be0e) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 8cc2ba7..7f7be0e 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 8cc2ba7eae3c3536ae1a2bbe1200fbc9db3134ee +Subproject commit 7f7be0e439a02616348c3a6858ebe5832c389066 From 5c90c63066d5d569b3c45d01cd01ec23048cc525 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 15:08:06 -0300 Subject: [PATCH 22/63] libs/crypto: the gitlink at P-256's constant-time check fix (794637e) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 7f7be0e..794637e 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 7f7be0e439a02616348c3a6858ebe5832c389066 +Subproject commit 794637e132592ea9de208f620d75f4a27ee17712 From ff9ac453687909a689dead7d2424ec20f0718962 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 15:24:07 -0300 Subject: [PATCH 23/63] libs/crypto: the gitlink at P-256's formats MSVC fix (eedc974) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 794637e..eedc974 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 794637e132592ea9de208f620d75f4a27ee17712 +Subproject commit eedc974d73fdd4f8fe079135a0ba5254117791c4 From 5b6c4f2ca5ae05de0b0e46e42a05a5ba878e3d07 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 15:35:44 -0300 Subject: [PATCH 24/63] third_party: BearSSL's library compiles crypto's P-256 decompression on its internal integers --- CODING-GUIDELINES.md | 4 ++-- third_party/Jamfile | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index ef190c9..1c5d81b 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7268,8 +7268,8 @@ since that change); what is decided and not built is in chapter 17. bytes (version 0, RFC 5915's ECPrivateKey version 1 without parameters and with the public key); a decoder accepts exactly what the encoder writes, the point checked against the scalar; a compressed point is decompressed by - crypto, a square root modulo p on public data, since BearSSL decodes - uncompressed points alone.** The bytes OpenSSL's and BearSSL's encoders and + BearSSL's internal i31 integers, a square root modulo p on public data, + since BearSSL decodes uncompressed points alone.** The bytes OpenSSL's and BearSSL's encoders and node's WebCrypto write, checked by the oracles; anything else is `invalid_encoding`. Source: `include/webcpp/crypto/curves/p256/formats.hpp` (libs/crypto). diff --git a/third_party/Jamfile b/third_party/Jamfile index 85675f4..eddfc30 100644 --- a/third_party/Jamfile +++ b/third_party/Jamfile @@ -327,9 +327,12 @@ alias bearssl-test-config : : : : $(.bearssl-config) libs/bearssl/src ; explicit bearssl-test-config ; # webcpp::hash's canary joins crypto's when libs/hash is checked out -# (bearssl-hash-canary, after the C libraries of webcpp::hash below). +# (bearssl-hash-canary, after the C libraries of webcpp::hash below). P-256's +# compressed point is decompressed by libs/crypto/src/p256_decompress_bearssl.c, +# on BearSSL's internal i31 integers (src/inner.h), compiled in with them. lib bearssl : [ glob libs/bearssl/src/*.c libs/bearssl/src/*/*.c ] $(CRYPTO)/src/canary_bearssl.c + $(CRYPTO)/src/p256_decompress_bearssl.c : $(.c-library) @bearssl-checked-out libs/bearssl/inc libs/bearssl/src $(.bearssl-config) @bearssl-hash-canary From 2eb7a618a2317b14250f08d75cac49729f10b03d Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 15:35:44 -0300 Subject: [PATCH 25/63] libs/crypto: the gitlink at P-256's decompression on BearSSL (1d59350) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index eedc974..1d59350 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit eedc974d73fdd4f8fe079135a0ba5254117791c4 +Subproject commit 1d593506f48d5c5ffbfe04e8d1d213ff38c08bf6 From 7bf5537dfb27d3299e824149d0e410c05f3845fe Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 16:40:31 -0300 Subject: [PATCH 26/63] libs/crypto: the gitlink at P-256's decompression MSVC fix (8edf524) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 1d59350..8edf524 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 1d593506f48d5c5ffbfe04e8d1d213ff38c08bf6 +Subproject commit 8edf52410e3ba58e90febf51d223396fb28092fe From b7678724c6e8f5a85bab880f83dda774236dece5 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 17:24:29 -0300 Subject: [PATCH 27/63] tools: the crypto fixtures' BearSSL text names src/p256_decompress_bearssl.c --- .../no_backend_on_emscripten/no_backend_on_emscripten.outcome | 2 +- .../p256_default_not_linked_on_emscripten.outcome | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/test/fixtures/crypto_jamfiles/no_backend_on_emscripten/no_backend_on_emscripten.outcome b/tools/test/fixtures/crypto_jamfiles/no_backend_on_emscripten/no_backend_on_emscripten.outcome index b0197f5..2ef1899 100644 --- a/tools/test/fixtures/crypto_jamfiles/no_backend_on_emscripten/no_backend_on_emscripten.outcome +++ b/tools/test/fixtures/crypto_jamfiles/no_backend_on_emscripten/no_backend_on_emscripten.outcome @@ -12,5 +12,5 @@ targets: emscripten build: fails # tag::messages[] -contains: webcpp::crypto: AES-GCM's default backend on this target is BearSSL, which is not linked, and the one backend that has it there. Add /webcpp/crypto//gcm-default, the default's library on every target, to the program's Jamfile, as in: exe app : app.cpp /webcpp/crypto//crypto /webcpp/crypto//gcm-default ; (without b2: define WEBCPP_CRYPTO_HAS_BEARSSL=1 and link BearSSL built with webcpp's src/canary_bearssl.c) +contains: webcpp::crypto: AES-GCM's default backend on this target is BearSSL, which is not linked, and the one backend that has it there. Add /webcpp/crypto//gcm-default, the default's library on every target, to the program's Jamfile, as in: exe app : app.cpp /webcpp/crypto//crypto /webcpp/crypto//gcm-default ; (without b2: define WEBCPP_CRYPTO_HAS_BEARSSL=1 and link BearSSL built with webcpp's src/canary_bearssl.c and src/p256_decompress_bearssl.c) # end::messages[] diff --git a/tools/test/fixtures/crypto_jamfiles/p256_default_not_linked_on_emscripten/p256_default_not_linked_on_emscripten.outcome b/tools/test/fixtures/crypto_jamfiles/p256_default_not_linked_on_emscripten/p256_default_not_linked_on_emscripten.outcome index c8a6066..4eced18 100644 --- a/tools/test/fixtures/crypto_jamfiles/p256_default_not_linked_on_emscripten/p256_default_not_linked_on_emscripten.outcome +++ b/tools/test/fixtures/crypto_jamfiles/p256_default_not_linked_on_emscripten/p256_default_not_linked_on_emscripten.outcome @@ -12,5 +12,5 @@ targets: emscripten build: fails # tag::messages[] -contains: webcpp::crypto: P-256's default backend on this target is BearSSL, which is not linked, and the one backend that has it there. Add /webcpp/crypto//p256-default, the default's library on every target, to the program's Jamfile, as in: exe app : app.cpp /webcpp/crypto//crypto /webcpp/crypto//p256-default ; (without b2: define WEBCPP_CRYPTO_HAS_BEARSSL=1 and link BearSSL built with webcpp's src/canary_bearssl.c) +contains: webcpp::crypto: P-256's default backend on this target is BearSSL, which is not linked, and the one backend that has it there. Add /webcpp/crypto//p256-default, the default's library on every target, to the program's Jamfile, as in: exe app : app.cpp /webcpp/crypto//crypto /webcpp/crypto//p256-default ; (without b2: define WEBCPP_CRYPTO_HAS_BEARSSL=1 and link BearSSL built with webcpp's src/canary_bearssl.c and src/p256_decompress_bearssl.c) # end::messages[] From fa62b325c523d740e8a5570f3d8deccf093936e6 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 17:24:29 -0300 Subject: [PATCH 28/63] guidelines: the P-256 key formats line rewrapped to its paragraph's width --- CODING-GUIDELINES.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 1c5d81b..581364b 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7269,9 +7269,9 @@ since that change); what is decided and not built is in chapter 17. with the public key); a decoder accepts exactly what the encoder writes, the point checked against the scalar; a compressed point is decompressed by BearSSL's internal i31 integers, a square root modulo p on public data, - since BearSSL decodes uncompressed points alone.** The bytes OpenSSL's and BearSSL's encoders and - node's WebCrypto write, checked by the oracles; anything else is - `invalid_encoding`. + since BearSSL decodes uncompressed points alone.** The bytes OpenSSL's and + BearSSL's encoders and node's WebCrypto write, checked by the oracles; + anything else is `invalid_encoding`. Source: `include/webcpp/crypto/curves/p256/formats.hpp` (libs/crypto). - **ECDSA signs low S on both curves; every verification takes a mandatory policy after the scheme, which each scheme declares: P-256's ECDSA From 65129e077437a9c0b2638e6b93bb52c1fa39b8e1 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 17:24:29 -0300 Subject: [PATCH 29/63] libs/crypto: the gitlink at Task 8 fix round 1 (6a9bba8) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 8edf524..6a9bba8 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 8edf52410e3ba58e90febf51d223396fb28092fe +Subproject commit 6a9bba860e7aa467c4e29a0f071e12455fec2bf2 From fc54a0e08ac12f7cf67b00847bf676d5a20e8fbd Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 17:33:55 -0300 Subject: [PATCH 30/63] third_party: BearSSL's library compiles src/canary_bearssl.c alone again; the crypto fixtures' BearSSL text as before --- third_party/Jamfile | 5 +---- .../no_backend_on_emscripten.outcome | 2 +- .../p256_default_not_linked_on_emscripten.outcome | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/third_party/Jamfile b/third_party/Jamfile index eddfc30..85675f4 100644 --- a/third_party/Jamfile +++ b/third_party/Jamfile @@ -327,12 +327,9 @@ alias bearssl-test-config : : : : $(.bearssl-config) libs/bearssl/src ; explicit bearssl-test-config ; # webcpp::hash's canary joins crypto's when libs/hash is checked out -# (bearssl-hash-canary, after the C libraries of webcpp::hash below). P-256's -# compressed point is decompressed by libs/crypto/src/p256_decompress_bearssl.c, -# on BearSSL's internal i31 integers (src/inner.h), compiled in with them. +# (bearssl-hash-canary, after the C libraries of webcpp::hash below). lib bearssl : [ glob libs/bearssl/src/*.c libs/bearssl/src/*/*.c ] $(CRYPTO)/src/canary_bearssl.c - $(CRYPTO)/src/p256_decompress_bearssl.c : $(.c-library) @bearssl-checked-out libs/bearssl/inc libs/bearssl/src $(.bearssl-config) @bearssl-hash-canary diff --git a/tools/test/fixtures/crypto_jamfiles/no_backend_on_emscripten/no_backend_on_emscripten.outcome b/tools/test/fixtures/crypto_jamfiles/no_backend_on_emscripten/no_backend_on_emscripten.outcome index 2ef1899..b0197f5 100644 --- a/tools/test/fixtures/crypto_jamfiles/no_backend_on_emscripten/no_backend_on_emscripten.outcome +++ b/tools/test/fixtures/crypto_jamfiles/no_backend_on_emscripten/no_backend_on_emscripten.outcome @@ -12,5 +12,5 @@ targets: emscripten build: fails # tag::messages[] -contains: webcpp::crypto: AES-GCM's default backend on this target is BearSSL, which is not linked, and the one backend that has it there. Add /webcpp/crypto//gcm-default, the default's library on every target, to the program's Jamfile, as in: exe app : app.cpp /webcpp/crypto//crypto /webcpp/crypto//gcm-default ; (without b2: define WEBCPP_CRYPTO_HAS_BEARSSL=1 and link BearSSL built with webcpp's src/canary_bearssl.c and src/p256_decompress_bearssl.c) +contains: webcpp::crypto: AES-GCM's default backend on this target is BearSSL, which is not linked, and the one backend that has it there. Add /webcpp/crypto//gcm-default, the default's library on every target, to the program's Jamfile, as in: exe app : app.cpp /webcpp/crypto//crypto /webcpp/crypto//gcm-default ; (without b2: define WEBCPP_CRYPTO_HAS_BEARSSL=1 and link BearSSL built with webcpp's src/canary_bearssl.c) # end::messages[] diff --git a/tools/test/fixtures/crypto_jamfiles/p256_default_not_linked_on_emscripten/p256_default_not_linked_on_emscripten.outcome b/tools/test/fixtures/crypto_jamfiles/p256_default_not_linked_on_emscripten/p256_default_not_linked_on_emscripten.outcome index 4eced18..c8a6066 100644 --- a/tools/test/fixtures/crypto_jamfiles/p256_default_not_linked_on_emscripten/p256_default_not_linked_on_emscripten.outcome +++ b/tools/test/fixtures/crypto_jamfiles/p256_default_not_linked_on_emscripten/p256_default_not_linked_on_emscripten.outcome @@ -12,5 +12,5 @@ targets: emscripten build: fails # tag::messages[] -contains: webcpp::crypto: P-256's default backend on this target is BearSSL, which is not linked, and the one backend that has it there. Add /webcpp/crypto//p256-default, the default's library on every target, to the program's Jamfile, as in: exe app : app.cpp /webcpp/crypto//crypto /webcpp/crypto//p256-default ; (without b2: define WEBCPP_CRYPTO_HAS_BEARSSL=1 and link BearSSL built with webcpp's src/canary_bearssl.c and src/p256_decompress_bearssl.c) +contains: webcpp::crypto: P-256's default backend on this target is BearSSL, which is not linked, and the one backend that has it there. Add /webcpp/crypto//p256-default, the default's library on every target, to the program's Jamfile, as in: exe app : app.cpp /webcpp/crypto//crypto /webcpp/crypto//p256-default ; (without b2: define WEBCPP_CRYPTO_HAS_BEARSSL=1 and link BearSSL built with webcpp's src/canary_bearssl.c) # end::messages[] From 9183d066564bd4a455b9abde9d5d874c5e143056 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 17:33:55 -0300 Subject: [PATCH 31/63] libs/crypto: the gitlink at P-256's decompression in the BearSSL header (d571045) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 6a9bba8..d571045 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 6a9bba860e7aa467c4e29a0f071e12455fec2bf2 +Subproject commit d571045839993e4224ebcfa704fc87a7dc937939 From 6d7f716af1e63f0e54491b5365e6c11708c9bcfb Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 17:41:17 -0300 Subject: [PATCH 32/63] libs/crypto: the gitlink at the i31 prototypes compiling alone (93e98e0) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index d571045..93e98e0 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit d571045839993e4224ebcfa704fc87a7dc937939 +Subproject commit 93e98e080498fcd8b9ce06f399c0c5641f7bf059 From e09bd8f6be0b135e83b2e8db4bd0e8963cad1ca9 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 18:07:50 -0300 Subject: [PATCH 33/63] libs/crypto: the gitlink at the i31 prototypes' MSVC fix (e31a70c) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 93e98e0..e31a70c 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 93e98e080498fcd8b9ce06f399c0c5641f7bf059 +Subproject commit e31a70c2b80375b2cbfbb203523fc55afd49c335 From 563794f75aef0e8446e0e27a9044691d683c5cba Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 18:51:28 -0300 Subject: [PATCH 34/63] guidelines: secp256k1's x-only key is a type; its tweak is xonly_public_key::tweak_add, checked by verify_tweak --- CODING-GUIDELINES.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 581364b..c0fdfe0 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7237,13 +7237,22 @@ since that change); what is decided and not built is in chapter 17. section 2.8 (proposals). - **ECDSA's DER is strict (`to_der`, `from_der`, at most 72 bytes) and an ECDSA signature's `low_s()` gives the low-S form; the x-only tweak takes - any 32-byte tweak, as a free `tweak_xonly` on an x-only key, giving the key - and its parity, and as `keypair::tweak_xonly` in place, and a tweak not below - the group order is `invalid_secret_key` and wipes the key pair.** A wallet's - needs without a protocol's rules: the caller computes BIP341's TapTweak, - and BIP341's vectors test the tweak that way. - Source: `libraries/crypto/openspec/changes/genesis/design.md` (proposals); - `test/secp256k1_xonly_tweak_test.cpp` (libs/crypto). + any 32-byte tweak, as `xonly_public_key::tweak_add` on the typed x-only key, + giving the key and its parity, which `verify_tweak` checks, and as + `keypair::tweak_xonly` in place, and a tweak not below the group order is + `invalid_secret_key` and wipes the key pair.** A wallet's needs without a + protocol's rules: the caller computes BIP341's TapTweak, and BIP341's vectors + test the tweak that way. + Source: `libraries/crypto/openspec/changes/genesis/design.md`, + `libraries/crypto/openspec/changes/formats/design.md` D12 (proposals); + `test/secp256k1_xonly_tweak_test.cpp`, `test/secp256k1_xonly_key_test.cpp` + (libs/crypto). +- **secp256k1's x-only public key is a type, `xonly_public_key`, never unset + (no default constructor: libsecp256k1 aborts on an unset key); `crypto::verify` + of `schnorr` takes it or a `public_key`, and no 32-byte span.** Verification + is typed; x-only bytes that are protocol data stay bytes. + Source: `libraries/crypto/openspec/changes/formats/design.md` D12, R30 + (proposals); `test/secp256k1_xonly_key_test.cpp` (libs/crypto). **P-256 (the foundation's increment 3, its first part; built on the branch `crypto/p256`, merged 2026-11-22).** From dc3dcc1b5faa27c90b637d82841ca5c443d25bd7 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 18:51:28 -0300 Subject: [PATCH 35/63] libs/crypto: the gitlink at secp256k1's typed x-only key (19a1fb6) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index e31a70c..19a1fb6 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit e31a70c2b80375b2cbfbb203523fc55afd49c335 +Subproject commit 19a1fb6fef78edc01d168220f10e1ff2be82cf3a From 86eba3f07c7009253b13ea37e6b3f284c6624142 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 19:18:46 -0300 Subject: [PATCH 36/63] libs/crypto: the gitlink at secp256k1's x-only key lint fix (402996c) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 19a1fb6..402996c 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 19a1fb6fef78edc01d168220f10e1ff2be82cf3a +Subproject commit 402996c2f23610a5f3d44e878c5280157ce2f17c From c79c052ea872e0cf8813ec143b6ee1830f972792 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 20:04:51 -0300 Subject: [PATCH 37/63] libs/crypto: the gitlink at Task 9's fix round 1 (f1cc3b0) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 402996c..f1cc3b0 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 402996c2f23610a5f3d44e878c5280157ce2f17c +Subproject commit f1cc3b05c7fbf2d922807457dd616c5ca12df961 From a65fee2bd3962962ddd51a6f70637532b5b5109e Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 21:12:41 -0300 Subject: [PATCH 38/63] guidelines: secp256k1's DER is formats::der; its PKCS#8 decode named as the format's --- CODING-GUIDELINES.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index c0fdfe0..b43fc7d 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7235,7 +7235,7 @@ since that change); what is decided and not built is in chapter 17. point. Source: `libraries/crypto/openspec/changes/genesis/reference/spec.md` section 2.8 (proposals). -- **ECDSA's DER is strict (`to_der`, `from_der`, at most 72 bytes) and +- **ECDSA's DER is strict (`formats::der`, BIP66, at most 72 bytes) and an ECDSA signature's `low_s()` gives the low-S form; the x-only tweak takes any 32-byte tweak, as `xonly_public_key::tweak_add` on the typed x-only key, giving the key and its parity, which `verify_tweak` checks, and as @@ -7343,7 +7343,7 @@ since that change); what is decided and not built is in chapter 17. 1 to 14, D1 to D12 (proposals). - **Constant time, sizes and throughput cover the family.** memcheck and MemorySanitizer run the key pair's making, signing with its low-S - normalization and check, `agree` and `decode_pkcs8` (`paths.hpp`), each + normalization and check, `agree` and the PKCS#8 decode (`paths.hpp`), each checker failing on a planted early exit in a copy of the scalar check; BearSSL's own branches on its signing's verdicts are listed for memcheck in `bearssl_verdicts.supp`. dudect times `sign` and `agree` against the @@ -7675,7 +7675,7 @@ since that change); what is decided and not built is in chapter 17. - **The vectors run on every backend that has the algorithm: the GCM specification's cases and Wycheproof's AES-GCM files, sealed whole and in pieces; FIPS 197 for the block cipher; BIP340's vectors, Wycheproof's - Bitcoin ECDSA file and DER through `from_der`, and BIP341's wallet + Bitcoin ECDSA file and DER through `formats::der`, and BIP341's wallet vectors through the tweak.** Every case runs because keys of 24 bytes and nonces of any size up to 128 are accepted. Source: `test/Jamfile` (libs/crypto); `third_party/libs/wycheproof`, From 1732c2031e24cb3cadc758e1f0d845ae3c578ec2 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 21:12:41 -0300 Subject: [PATCH 39/63] libs/crypto: the gitlink at secp256k1's formats (3b3fd30) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index f1cc3b0..3b3fd30 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit f1cc3b05c7fbf2d922807457dd616c5ca12df961 +Subproject commit 3b3fd30fa3569284313a04e29c72a992220ffdf2 From c0d19949f5ee27e977458a39a80772dc716caebd Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 21:51:23 -0300 Subject: [PATCH 40/63] libs/crypto: the gitlink at secp256k1's formats lint fix (3675f3a) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 3b3fd30..3675f3a 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 3b3fd30fa3569284313a04e29c72a992220ffdf2 +Subproject commit 3675f3aa6887c5634d7d5279a3915b620be12fc5 From f2cb1512523150ff71a2aa41355e8fec24d18201 Mon Sep 17 00:00:00 2001 From: R Date: Tue, 1 Dec 2026 23:06:38 -0300 Subject: [PATCH 41/63] libs/crypto: the gitlink at secp256k1's formats fix round 1 (c7eb353) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 3675f3a..c7eb353 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 3675f3aa6887c5634d7d5279a3915b620be12fc5 +Subproject commit c7eb353006e1567223cb823bf2c3fe0fd81b9abb From 9de20517ca2922e27e0634c422f188ce54cd356e Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 00:02:24 -0300 Subject: [PATCH 42/63] tools: the crypto fixtures of the pem family go --- .../crypto_jamfiles/pem_default/Jamfile | 9 ------ .../crypto_jamfiles/pem_default/app.cpp | 32 ------------------- .../pem_default/pem_default.outcome | 20 ------------ .../Jamfile | 9 ------ .../app.cpp | 19 ----------- ...m_default_not_linked_on_emscripten.outcome | 16 ---------- 6 files changed, 105 deletions(-) delete mode 100644 tools/test/fixtures/crypto_jamfiles/pem_default/Jamfile delete mode 100644 tools/test/fixtures/crypto_jamfiles/pem_default/app.cpp delete mode 100644 tools/test/fixtures/crypto_jamfiles/pem_default/pem_default.outcome delete mode 100644 tools/test/fixtures/crypto_jamfiles/pem_default_not_linked_on_emscripten/Jamfile delete mode 100644 tools/test/fixtures/crypto_jamfiles/pem_default_not_linked_on_emscripten/app.cpp delete mode 100644 tools/test/fixtures/crypto_jamfiles/pem_default_not_linked_on_emscripten/pem_default_not_linked_on_emscripten.outcome diff --git a/tools/test/fixtures/crypto_jamfiles/pem_default/Jamfile b/tools/test/fixtures/crypto_jamfiles/pem_default/Jamfile deleted file mode 100644 index dfe9afd..0000000 --- a/tools/test/fixtures/crypto_jamfiles/pem_default/Jamfile +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2026 WebCpp.org -# -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# https://www.boost.org/LICENSE_1_0.txt) - -# tag::jamfile[] -exe app : app.cpp /webcpp/crypto//crypto /webcpp/crypto//pem-default ; -# end::jamfile[] diff --git a/tools/test/fixtures/crypto_jamfiles/pem_default/app.cpp b/tools/test/fixtures/crypto_jamfiles/pem_default/app.cpp deleted file mode 100644 index 3d28b7c..0000000 --- a/tools/test/fixtures/crypto_jamfiles/pem_default/app.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2026 WebCpp.org -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// Reads RFC 8410's Ed25519 public key in PEM (section 10.1) on PEM's default backend, armours its -// DER again, checks that the text is the same, and prints the backend that ran. -#include - -#include -#include -#include -#include - -int main() { - namespace pem = webcpp::crypto::pem; - constexpr std::string_view text = - "-----BEGIN PUBLIC KEY-----\n" - "MCowBQYDK2VwAyEAGb9ECWmEzf6FQbrBZ9w7lshQhqowtrbLDFw4rXAxZuE=\n" - "-----END PUBLIC KEY-----\n"; - std::array der{}; - auto const read = pem::unarmour(pem::public_key_label, text, der); - std::array again{}; - auto const written = pem::armour(pem::public_key_label, der, again); - bool const ok = - read && *read == der.size() && written && std::string_view(again.data(), *written) == text; - auto const name = pem::algorithm<>::backend_type::name; - std::printf("pem %s backend=%.*s\n", ok ? "ok" : "FAILED", static_cast(name.size()), - name.data()); - return ok ? 0 : 1; -} diff --git a/tools/test/fixtures/crypto_jamfiles/pem_default/pem_default.outcome b/tools/test/fixtures/crypto_jamfiles/pem_default/pem_default.outcome deleted file mode 100644 index 8684e53..0000000 --- a/tools/test/fixtures/crypto_jamfiles/pem_default/pem_default.outcome +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (c) 2026 WebCpp.org -# -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# https://www.boost.org/LICENSE_1_0.txt) - -[all] -targets: native wasip2 wasip3 emscripten -build: succeeds -run: app -# tag::output[] -[native] -pem ok backend=sodium -[wasip2] -pem ok backend=sodium -[wasip3] -pem ok backend=sodium -[emscripten] -pem ok backend=sodium -# end::output[] diff --git a/tools/test/fixtures/crypto_jamfiles/pem_default_not_linked_on_emscripten/Jamfile b/tools/test/fixtures/crypto_jamfiles/pem_default_not_linked_on_emscripten/Jamfile deleted file mode 100644 index 4b12ef4..0000000 --- a/tools/test/fixtures/crypto_jamfiles/pem_default_not_linked_on_emscripten/Jamfile +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2026 WebCpp.org -# -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# https://www.boost.org/LICENSE_1_0.txt) - -# tag::jamfile[] -exe app : app.cpp /webcpp/crypto//crypto ; -# end::jamfile[] diff --git a/tools/test/fixtures/crypto_jamfiles/pem_default_not_linked_on_emscripten/app.cpp b/tools/test/fixtures/crypto_jamfiles/pem_default_not_linked_on_emscripten/app.cpp deleted file mode 100644 index f19bc16..0000000 --- a/tools/test/fixtures/crypto_jamfiles/pem_default_not_linked_on_emscripten/app.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2026 WebCpp.org -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// A program that armours DER as PEM on its default backend, libsodium on every target, without -// linking it, stops where it calls it, with the line that links libsodium, the one backend that has -// it (design D32). -#include - -#include -#include - -int main() { - std::array const der{}; - std::array out{}; - return webcpp::crypto::pem::armour("A", der, out) ? 0 : 1; -} diff --git a/tools/test/fixtures/crypto_jamfiles/pem_default_not_linked_on_emscripten/pem_default_not_linked_on_emscripten.outcome b/tools/test/fixtures/crypto_jamfiles/pem_default_not_linked_on_emscripten/pem_default_not_linked_on_emscripten.outcome deleted file mode 100644 index 75a70e2..0000000 --- a/tools/test/fixtures/crypto_jamfiles/pem_default_not_linked_on_emscripten/pem_default_not_linked_on_emscripten.outcome +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2026 WebCpp.org -# -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# https://www.boost.org/LICENSE_1_0.txt) - -# The compiler's line of the refusal starts with the header's path on the machine, so the message is -# a contains: line. wasip2 and wasip3 have the same message in a compile-diagnostic -# (test/messages/pem_default_not_linked); compile-diagnostic is clang's and skips Emscripten, so -# this fixture is the Emscripten one. -[all] -targets: emscripten -build: fails -# tag::messages[] -contains: webcpp::crypto: PEM's default backend on this target is libsodium, which is not linked, and the one backend that has it there. Add /webcpp/crypto//pem-default, the default's library on every target, to the program's Jamfile, as in: exe app : app.cpp /webcpp/crypto//crypto /webcpp/crypto//pem-default ; (without b2: define WEBCPP_CRYPTO_HAS_SODIUM=1 and link libsodium built with webcpp's src/canary_sodium.c) -# end::messages[] From ef42fdbe7c57f952d6d7f23a787d3b6624c80e78 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 00:46:49 -0300 Subject: [PATCH 43/63] libs/crypto: the gitlink at PEM's old home removed and the asynchronous formats checks (308a650) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index c7eb353..308a650 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit c7eb353006e1567223cb823bf2c3fe0fd81b9abb +Subproject commit 308a650fa8831250dfd7926c3eb1cfe1464767d8 From 902edf9073a6b4b4565b08e54b49461be5f53e0f Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 00:52:34 -0300 Subject: [PATCH 44/63] libs/crypto: the gitlink at PEM's old home removed, fix round 1 (78cb548) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 308a650..78cb548 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 308a650fa8831250dfd7926c3eb1cfe1464767d8 +Subproject commit 78cb548b3c1f6e81c14371b218004eca7dc852e2 From e96b2f0afdaecdaed4152cb70d484c6d12d2b595 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 02:10:33 -0300 Subject: [PATCH 45/63] libs/crypto: the gitlink at the guide on the new names and the formats table (8e011df) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 78cb548..8e011df 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 78cb548b3c1f6e81c14371b218004eca7dc852e2 +Subproject commit 8e011dfd286ed0ccfb9c156e1d03708758fa59ee From da5010bef4bd0fdaf64dd263a6a9ff55be2c435d Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 02:54:09 -0300 Subject: [PATCH 46/63] libs/crypto: the gitlink at the guide's fix round 1 (892211e) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 8e011df..892211e 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 8e011dfd286ed0ccfb9c156e1d03708758fa59ee +Subproject commit 892211e954e6afa028d76e4a594bc0fc9b11ffcc From 6dbee4f1d90360e8ded2d1e72a56c7d292bf13a8 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 02:57:30 -0300 Subject: [PATCH 47/63] guidelines: crypto's formats on codecs, its policies and its x-only key --- CODING-GUIDELINES.md | 47 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index b43fc7d..f41e127 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -8802,7 +8802,7 @@ What webcpp does not have yet, and the chapters that mention it: randomness are webcpp::crypto's, and the relays' WebSockets Beast's. Trystero can then retain its protocol over those shared facilities. - **crypto after 0.1** (chapter 17): the browser lane, the CI's nightly - level, NIST CAVP's vectors and Botan. Its constant-time lane, its sizes and + level, NIST CAVP's vectors and Botan; its key formats on codecs are built. Its constant-time lane, its sizes and throughput, and ChaCha20-Poly1305 merged with the foundation's increment 1. - **The libraries web developers use most,** brought to C++: a JavaScript interpreter (QuickJS), libp2p, HTTP fetch. @@ -8867,7 +8867,7 @@ specification hold it in full and rule over this summary; the change that builds it moves its decisions into chapter 14 or 15. Their conflicts with chapters 1 to 13 are in chapter 19. -### crypto, after 0.1 (genesis accepted 2026-10-11, foundation accepted 2026-11-14; the foundation's increments 1 and 2, increment 3's P-256 and increment 4's asynchronous family merged) +### crypto, after 0.1 (genesis accepted 2026-10-11, foundation accepted 2026-11-14; the foundation's increments 1 and 2, increment 3's P-256 and increment 4's asynchronous family merged; the formats change built on codecs, not merged) The genesis's plan (`reference/plan.md`, revised on 2026-11-14) built version 0.1 from its increments 1 and 2, and OpenSSL's memory option after it. The @@ -8991,6 +8991,44 @@ Tasks 3.1 to 3.6, merged 2026-11-22).** Source: `libraries/crypto/openspec/changes/foundation/reference/plan.md` Tasks 3.7 to 3.11 (proposals). +**The formats change (branch `crypto/formats` of the library and of the +superproject; built on codecs, not merged).** + +- **crypto's key formats are codecs formats: `crypto::formats::raw`, `spki`, + `pkcs8`, `der` and `pem(spki)` or `pem(pkcs8)` (RFC 7468's armor over the + DER), each with `codecs::value_codec` specializations in the curve's + `formats.hpp`, and the verbs `crypto::encode` and `crypto::decode` (and + the members `encode` and `T::decode`) that check the pair, then call codecs'.** + A pair a type does not have stops the build with the type's list of formats; + one list, `detail::all_formats`, feeds the checks, the tests and the page's + table. The old names (`encode_spki`, `to_der`, `crypto::pem`, the pem + defaults, the `max_*_size` constants) are removed, each with its replacement in + the changelog; no name stays as an alias. A program that uses one curve's + formats includes that curve's formats header and pulls no other curve. + Source: `libraries/crypto/openspec/changes/formats/design.md` D1 to D8 + (proposals); `doc/formats.adoc`, `doc/changelog.adoc` (libs/crypto). +- **Every verification takes a policy, `crypto::verification_policies::low_s_only`, + `any_s` or `canonical`, after the scheme, which `crypto::signing_schemes` + declares; P-256's decompression of a compressed point is crypto's, on + BearSSL's own i31 integers (owner decision of 2026-12-01).** BearSSL decodes + uncompressed points alone; the square root runs on public data in + `backends/bearssl.hpp`, through prototypes copied from BearSSL's `inner.h` + and pinned by a test that compiles both, with no C file of crypto's. A + secp256k1 key pair's raw, PKCS#8 and PEM decodes may throw where exceptions + exist, since its signing context allocates; `keypair::decode(format, input, + resource)` keeps the arena form of the removed `decode_pkcs8`. + Source: `libraries/crypto/openspec/changes/formats/design.md` D5, D9 and + D12 (proposals, to be amended at delivery); `include/webcpp/crypto/backends/bearssl.hpp` + (libs/crypto). +- **hash's `hash::formats::base58_with_checksum` is Base58Check, the codecs + format `basic_base58<100, bitcoin_alphabet, hash::checksums::double_sha256>` + (branch `hash/base58-with-checksum`, not merged).** Bitcoin Core's vectors + test it (chapter 10's `bitcoin_base58_vectors`); a secret decode wipes its + scratch, and the library's wallet guide decodes a WIF key with it. hash + depends on codecs, never the reverse. + Source: `libraries/hash/openspec/changes/base58-with-checksum/design.md` + D1 to D4 (proposals); `doc/use-cases/cryptocurrencies.adoc` (libs/hash). + **Constant time (increment 1, Task 14; merged).** - **Constant time is checked deterministically on Linux x86-64 and arm64 @@ -10072,8 +10110,9 @@ The owner's decisions: `basic_base58<100, bitcoin_alphabet, hash::checksums::double_sha256>` (decision 26 renames decision 7's `base58check`); crypto registers its key formats through `value_codec` in a change of its own, and `crypto::encode` and `crypto::decode` - no longer exist. Both are follow-ups, and hash will depend on codecs, never the - reverse. + are that change's verbs over codecs'. Both follow-ups are built (crypto's + `formats` change and hash's `base58-with-checksum`, chapter 17's crypto + entry), and hash depends on codecs, never the reverse. Source: design.md owner decisions 7 and 26 (proposals); `test/messages/base58_with_checksum_unseen` (libs/codecs). - **Owner decision 8: the tests.** RFC 4648 section 10, BIP-173's and BIP-350's From 7f329c1e0e2469069073258acdfe8a80160e5c92 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 02:57:30 -0300 Subject: [PATCH 48/63] libs/hash: the gitlink at base58_with_checksum (cf30e13) --- libs/hash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hash b/libs/hash index d4d0119..cf30e13 160000 --- a/libs/hash +++ b/libs/hash @@ -1 +1 @@ -Subproject commit d4d0119ca17ebde9faa00bb61352471d06a7eaa3 +Subproject commit cf30e134dd3cb845ea264772256a3b772dddeefe From 2d762940bceb0d3f84b6a394b28cd436fe4b1ec2 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 03:00:12 -0300 Subject: [PATCH 49/63] guidelines: the formats block names the typed x-only key; the intro, roadmap line and heading current and wrapped --- CODING-GUIDELINES.md | 77 ++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index f41e127..d3804b7 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -8802,8 +8802,9 @@ What webcpp does not have yet, and the chapters that mention it: randomness are webcpp::crypto's, and the relays' WebSockets Beast's. Trystero can then retain its protocol over those shared facilities. - **crypto after 0.1** (chapter 17): the browser lane, the CI's nightly - level, NIST CAVP's vectors and Botan; its key formats on codecs are built. Its constant-time lane, its sizes and - throughput, and ChaCha20-Poly1305 merged with the foundation's increment 1. + level, NIST CAVP's vectors and Botan; its key formats on codecs are built, + not merged. Its constant-time lane, its sizes and throughput, and + ChaCha20-Poly1305 merged with the foundation's increment 1. - **The libraries web developers use most,** brought to C++: a JavaScript interpreter (QuickJS), libp2p, HTTP fetch. - **The site, increments 2 to 8.** Increment 1 is done: the site's @@ -8859,15 +8860,16 @@ What webcpp does not have yet, and the chapters that mention it: ## 17. Decided, not yet in chapters 14 and 15 The proposals the owner accepted whose decisions are not yet in chapter 14 or -15, each with its decisions as decided and its heading saying how much of it -the superproject's `main` holds: wasi's redesign and the site's increments 4 -and 5 are not built, codecs is built and not merged, crypto's foundation is -merged in part, and hash and secure are merged whole. While a proposal is open, its own `design.md` and -specification hold it in full and rule over this summary; the change that -builds it moves its decisions into chapter 14 or 15. Their conflicts with -chapters 1 to 13 are in chapter 19. +15, each with its decisions as decided and its heading saying how much of it the +superproject's `main` holds: wasi's redesign and the site's increments 4 and 5 +are not built, codecs and secure are merged, crypto's foundation is merged in +part and its formats change, with hash's Base58Check, is built and not merged, +and hash is merged whole. While a proposal is open, its own `design.md` and +specification hold it in full and rule over this summary; the change that builds +it moves its decisions into chapter 14 or 15. Their conflicts with chapters 1 to +13 are in chapter 19. -### crypto, after 0.1 (genesis accepted 2026-10-11, foundation accepted 2026-11-14; the foundation's increments 1 and 2, increment 3's P-256 and increment 4's asynchronous family merged; the formats change built on codecs, not merged) +### crypto, after 0.1 (genesis accepted 2026-10-11, foundation accepted 2026-11-14; the foundation's increments 1 and 2, increment 3's P-256 and increment 4's asynchronous family merged; the formats change built, not merged) The genesis's plan (`reference/plan.md`, revised on 2026-11-14) built version 0.1 from its increments 1 and 2, and OpenSSL's memory option after it. The @@ -8994,32 +8996,45 @@ Tasks 3.1 to 3.6, merged 2026-11-22).** **The formats change (branch `crypto/formats` of the library and of the superproject; built on codecs, not merged).** -- **crypto's key formats are codecs formats: `crypto::formats::raw`, `spki`, +- - **crypto's key formats are codecs formats: `crypto::formats::raw`, `spki`, `pkcs8`, `der` and `pem(spki)` or `pem(pkcs8)` (RFC 7468's armor over the DER), each with `codecs::value_codec` specializations in the curve's - `formats.hpp`, and the verbs `crypto::encode` and `crypto::decode` (and - the members `encode` and `T::decode`) that check the pair, then call codecs'.** - A pair a type does not have stops the build with the type's list of formats; - one list, `detail::all_formats`, feeds the checks, the tests and the page's - table. The old names (`encode_spki`, `to_der`, `crypto::pem`, the pem - defaults, the `max_*_size` constants) are removed, each with its replacement in - the changelog; no name stays as an alias. A program that uses one curve's - formats includes that curve's formats header and pulls no other curve. + `formats.hpp`, and the verbs `crypto::encode` and `crypto::decode` (and the + members `encode` and `T::decode`) that check the pair, then call codecs'.** A + pair a type does not have stops the build with the type's list of formats; one + list, `detail::all_formats`, feeds the checks, the tests and the page's table. + The old names (`encode_spki`, `to_der`, `crypto::pem`, the pem defaults, the + `max_*_size` constants) are removed, each with its replacement in the + changelog; no name stays as an alias. A program that uses one curve's formats + includes that curve's formats header and pulls no other curve. Source: `libraries/crypto/openspec/changes/formats/design.md` D1 to D8 (proposals); `doc/formats.adoc`, `doc/changelog.adoc` (libs/crypto). -- **Every verification takes a policy, `crypto::verification_policies::low_s_only`, - `any_s` or `canonical`, after the scheme, which `crypto::signing_schemes` - declares; P-256's decompression of a compressed point is crypto's, on - BearSSL's own i31 integers (owner decision of 2026-12-01).** BearSSL decodes - uncompressed points alone; the square root runs on public data in - `backends/bearssl.hpp`, through prototypes copied from BearSSL's `inner.h` - and pinned by a test that compiles both, with no C file of crypto's. A - secp256k1 key pair's raw, PKCS#8 and PEM decodes may throw where exceptions - exist, since its signing context allocates; `keypair::decode(format, input, - resource)` keeps the arena form of the removed `decode_pkcs8`. - Source: `libraries/crypto/openspec/changes/formats/design.md` D5, D9 and - D12 (proposals, to be amended at delivery); `include/webcpp/crypto/backends/bearssl.hpp` +- **secp256k1's x-only key is a type, `curves::secp256k1::xonly_public_key`, + with the formats of its own.** BIP340's key, made by `from_bytes` (32 bytes) + or taken from a `public_key::xonly()`, a key pair's `xonly_public_key()` + (with `xonly_parity()`) or MuSig2's `aggregate_key::xonly_public_key()`; it + has `bytes()` and an ordering, is checked by `verify` under `canonical`, and + is tweaked by `tweak_add` and checked by `verify_tweak`. Its `formats::raw` + is its 32 bytes; `raw(formats::xonly)` of a `public_key` writes the same 32 + bytes and encodes only, because 32 bytes are not that key: they decode into + the x-only key, and a `public_key` decode of them stops the build. + Source: `libraries/crypto/openspec/changes/formats/design.md` D12 + (proposals); `include/webcpp/crypto/curves/secp256k1/formats.hpp` (libs/crypto). +- - **Every verification takes a policy, `low_s_only`, `any_s` or `canonical` + (`crypto::verification_policies`), after the scheme, which + `crypto::signing_schemes` declares; P-256's decompression of a compressed + point is crypto's, on BearSSL's own i31 integers (owner decision of + 2026-12-01).** BearSSL decodes uncompressed points alone; the square root runs + on public data in `backends/bearssl.hpp`, through prototypes copied from + BearSSL's `inner.h` and pinned by a test that compiles both, with no C file of + crypto's. A secp256k1 key pair's raw, PKCS#8 and PEM decodes may throw where + exceptions exist, since its signing context allocates; + `keypair::decode(format, input, resource)` keeps the arena form of the removed + `decode_pkcs8`. + Source: `libraries/crypto/openspec/changes/formats/design.md` D5, D9 and + D12 (proposals, to be amended at delivery); + `include/webcpp/crypto/backends/bearssl.hpp` (libs/crypto). - **hash's `hash::formats::base58_with_checksum` is Base58Check, the codecs format `basic_base58<100, bitcoin_alphabet, hash::checksums::double_sha256>` (branch `hash/base58-with-checksum`, not merged).** Bitcoin Core's vectors From 64b31581414f3250bbbc672204bdc58379b24470 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 03:37:01 -0300 Subject: [PATCH 50/63] guidelines: codecs merged, hash merged but for its Base58Check; chapter 17's bullets single, a line rewrapped, the migration table named --- CODING-GUIDELINES.md | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index d3804b7..dc81817 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7248,8 +7248,9 @@ since that change); what is decided and not built is in chapter 17. `test/secp256k1_xonly_tweak_test.cpp`, `test/secp256k1_xonly_key_test.cpp` (libs/crypto). - **secp256k1's x-only public key is a type, `xonly_public_key`, never unset - (no default constructor: libsecp256k1 aborts on an unset key); `crypto::verify` - of `schnorr` takes it or a `public_key`, and no 32-byte span.** Verification + (no default constructor: libsecp256k1 aborts on an unset key); + `crypto::verify` of `schnorr` takes it or a `public_key`, and no 32-byte + span.** Verification is typed; x-only bytes that are protocol data stay bytes. Source: `libraries/crypto/openspec/changes/formats/design.md` D12, R30 (proposals); `test/secp256k1_xonly_key_test.cpp` (libs/crypto). @@ -8864,7 +8865,8 @@ The proposals the owner accepted whose decisions are not yet in chapter 14 or superproject's `main` holds: wasi's redesign and the site's increments 4 and 5 are not built, codecs and secure are merged, crypto's foundation is merged in part and its formats change, with hash's Base58Check, is built and not merged, -and hash is merged whole. While a proposal is open, its own `design.md` and +and hash is merged but for its Base58Check. While a proposal is open, its own +`design.md` and specification hold it in full and rule over this summary; the change that builds it moves its decisions into chapter 14 or 15. Their conflicts with chapters 1 to 13 are in chapter 19. @@ -8996,7 +8998,7 @@ Tasks 3.1 to 3.6, merged 2026-11-22).** **The formats change (branch `crypto/formats` of the library and of the superproject; built on codecs, not merged).** -- - **crypto's key formats are codecs formats: `crypto::formats::raw`, `spki`, +- **crypto's key formats are codecs formats: `crypto::formats::raw`, `spki`, `pkcs8`, `der` and `pem(spki)` or `pem(pkcs8)` (RFC 7468's armor over the DER), each with `codecs::value_codec` specializations in the curve's `formats.hpp`, and the verbs `crypto::encode` and `crypto::decode` (and the @@ -9004,9 +9006,10 @@ superproject; built on codecs, not merged).** pair a type does not have stops the build with the type's list of formats; one list, `detail::all_formats`, feeds the checks, the tests and the page's table. The old names (`encode_spki`, `to_der`, `crypto::pem`, the pem defaults, the - `max_*_size` constants) are removed, each with its replacement in the - changelog; no name stays as an alias. A program that uses one curve's formats - includes that curve's formats header and pulls no other curve. + `max_*_size` constants) are removed, each with its replacement in the guide's + migration table (`doc/formats.adoc`); no name stays as an alias. A program + that uses one curve's formats includes that curve's formats header and pulls + no other curve. Source: `libraries/crypto/openspec/changes/formats/design.md` D1 to D8 (proposals); `doc/formats.adoc`, `doc/changelog.adoc` (libs/crypto). - **secp256k1's x-only key is a type, `curves::secp256k1::xonly_public_key`, @@ -9021,7 +9024,7 @@ superproject; built on codecs, not merged).** Source: `libraries/crypto/openspec/changes/formats/design.md` D12 (proposals); `include/webcpp/crypto/curves/secp256k1/formats.hpp` (libs/crypto). -- - **Every verification takes a policy, `low_s_only`, `any_s` or `canonical` +- **Every verification takes a policy, `low_s_only`, `any_s` or `canonical` (`crypto::verification_policies`), after the scheme, which `crypto::signing_schemes` declares; P-256's decompression of a compressed point is crypto's, on BearSSL's own i31 integers (owner decision of @@ -10046,15 +10049,15 @@ delivery. `tools/test/crypto_jamfiles_test.py`, `tools/test/hash_jamfiles_test.py` (webcpp). -### codecs (bytes and values to text and back, and the conversion contract; own; accepted 2026-11-26, built, not merged) +### codecs (bytes and values to text and back, and the conversion contract; own; accepted 2026-11-26, merged) webcpp::codecs is webcpp's one contract for converting bytes and typed values to text and back, and any data through one-shot and stream transformers, with seven formats over it, webcpp's own (`"port-of": null`, categories String and Cryptography). It is implemented in `webcpporg/codecs`, the submodule `libs/codecs`, built on the branch `codecs/genesis` of its repository and of the -superproject and not merged: the owner's CI runs once, at the end, and the -merge follows it. Its headers are ``, the core, which +superproject and merged on 2026-11-30, after the owner's CI ran once, at the +end. Its headers are ``, the core, which registers no format and includes none, and ``, each format reachable only through its own header, with `detail/core/` and From ca8492568dfc849dd3883b23f23aadec36414217 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 04:39:27 -0300 Subject: [PATCH 51/63] libs/crypto: the gitlink at the final review's fix wave (f5a27df) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 892211e..f5a27df 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 892211e954e6afa028d76e4a594bc0fc9b11ffcc +Subproject commit f5a27df4286c4de4de025d8822ea2a0ef0f48c30 From fbc89401ed35774e88bf54ef94629b947f4161fb Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 04:39:27 -0300 Subject: [PATCH 52/63] libs/hash: the gitlink at the final review's fix wave (f9188f2) --- libs/hash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hash b/libs/hash index cf30e13..f9188f2 160000 --- a/libs/hash +++ b/libs/hash @@ -1 +1 @@ -Subproject commit cf30e134dd3cb845ea264772256a3b772dddeefe +Subproject commit f9188f2c51eaa350592402daa46f1741beec6746 From 0b8d803d92178d92fdc0c7f48736048561f83c4f Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 04:48:38 -0300 Subject: [PATCH 53/63] guidelines: two paragraphs of chapter 17 reflowed --- CODING-GUIDELINES.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index dc81817..598c006 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -7250,8 +7250,8 @@ since that change); what is decided and not built is in chapter 17. - **secp256k1's x-only public key is a type, `xonly_public_key`, never unset (no default constructor: libsecp256k1 aborts on an unset key); `crypto::verify` of `schnorr` takes it or a `public_key`, and no 32-byte - span.** Verification - is typed; x-only bytes that are protocol data stay bytes. + span.** Verification is typed; x-only bytes that are protocol data stay + bytes. Source: `libraries/crypto/openspec/changes/formats/design.md` D12, R30 (proposals); `test/secp256k1_xonly_key_test.cpp` (libs/crypto). @@ -8866,10 +8866,9 @@ superproject's `main` holds: wasi's redesign and the site's increments 4 and 5 are not built, codecs and secure are merged, crypto's foundation is merged in part and its formats change, with hash's Base58Check, is built and not merged, and hash is merged but for its Base58Check. While a proposal is open, its own -`design.md` and -specification hold it in full and rule over this summary; the change that builds -it moves its decisions into chapter 14 or 15. Their conflicts with chapters 1 to -13 are in chapter 19. +`design.md` and specification hold it in full and rule over this summary; the +change that builds it moves its decisions into chapter 14 or 15. Their conflicts +with chapters 1 to 13 are in chapter 19. ### crypto, after 0.1 (genesis accepted 2026-10-11, foundation accepted 2026-11-14; the foundation's increments 1 and 2, increment 3's P-256 and increment 4's asynchronous family merged; the formats change built, not merged) From 6e38dc4dd5f46276713d24b6801f77dd2cbc92e2 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 05:05:46 -0300 Subject: [PATCH 54/63] libs/crypto: the gitlink at the final review's residual fix (25bd6e3) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index f5a27df..25bd6e3 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit f5a27df4286c4de4de025d8822ea2a0ef0f48c30 +Subproject commit 25bd6e3a46a936ee56e25c5d49613c9a9721c8c2 From 5b5315d5f1167cf0a4ec1661644da25aa71a2b0f Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 07:18:49 -0300 Subject: [PATCH 55/63] third_party: BearSSL at 27611cc, webcpp's ECDSA nonce fix corrected for P-521 (nonce bias at 32381d6; P-256 and P-384 unaffected) --- CODING-GUIDELINES.md | 7 ++++-- libs/crypto | 2 +- libs/hash | 2 +- third_party/libs/bearssl | 2 +- .../canary_missing/canary_missing.outcome | 12 +++++----- .../canary_other_configuration.outcome | 12 +++++----- .../canary_without/canary_without.outcome | 22 +++++++++---------- .../canary_bearssl_missing.outcome | 12 +++++----- tools/test/third_party_test.py | 5 +++-- 9 files changed, 40 insertions(+), 36 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 598c006..cc2e20f 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -984,7 +984,7 @@ update --init third_party/libs/`; a build that needs none never looks. | Target | What it is | Licence | | --- | --- | --- | -| `bearssl` | BearSSL from webcpp's mirror `webcpporg/bearssl` at `32381d6`, its branch `webcpp`: upstream's `7bea48e` and one fix, ECDSA's nonce decoded at its full length (chapter 5 rule 1); a static library built file by file by `third_party/Jamfile` with webcpp::crypto's and webcpp::hash's canaries (hash's when `libs/hash` is checked out), on every target; `WEBCPP_CRYPTO_HAS_BEARSSL=1`, and `WEBCPP_HASH_HAS_BEARSSL=1` with hash's canary | MIT | +| `bearssl` | BearSSL from webcpp's mirror `webcpporg/bearssl` at `27611cc`, its branch `webcpp`: upstream's `7bea48e` and one fix, ECDSA's nonce decoded at its full length (`32381d6`, chapter 5 rule 1), with its P-521 correction (`205c5ff`, merged at `27611cc`: the fix alone biased every P-521 nonce; P-256 and P-384 unaffected); a static library built file by file by `third_party/Jamfile` with webcpp::crypto's and webcpp::hash's canaries (hash's when `libs/hash` is checked out), on every target; `WEBCPP_CRYPTO_HAS_BEARSSL=1`, and `WEBCPP_HASH_HAS_BEARSSL=1` with hash's canary | MIT | | `bips` | `bitcoin/bips` at `927b6de9`, shallow, test data: crypto's tests read BIP340's `bip-0340/test-vectors.csv` and BIP341's `bip-0341/wallet-test-vectors.json` at run time under the directory its define `WEBCPP_TEST_BIPS` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when it changes | BSD-2-Clause, as BIP340's header states | | `bitcoin_base58_vectors` | Bitcoin Core's base58 vectors, `src/test/data/base58_encode_decode.json` and `src/test/data/key_io_valid.json` of the submodule `third_party/libs/bitcoin` (Bitcoin Core v31.1 at `9be056a`, shallow), test data that nothing compiles: codecs' tests (the first file) and hash's Base58Check test (the second) read them at run time under the directory its define `WEBCPP_TEST_BITCOIN_BASE58_VECTORS` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when either changes | MIT | | `blake2_vectors` | BLAKE2's reference code package `BLAKE2/BLAKE2` at `ed1974e` (2023-02-12), the submodule `third_party/libs/blake2`, shallow, test data that nothing compiles: hash's tests read `testvectors/blake2b-kat.txt` and `testvectors/blake2-kat.json` at run time under the directory its define `WEBCPP_TEST_BLAKE2_VECTORS` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when one of them changes | CC0-1.0 | @@ -7364,7 +7364,10 @@ since that change); what is decided and not built is in chapter 17. Source: `libs/crypto/test/constant_time/Jamfile`, `test/sizes/Jamfile`, `bench/throughput.cpp`, `doc/backends.adoc` (libs/crypto); https://github.com/webcpporg/bearssl/commit/32381d6e787a32cbb7a687246349200d78b8ff7c - (the fix) and BearSSL's `src/ec/ecdsa_i31_bits.c` at `7bea48e` (upstream). + (the fix), + https://github.com/webcpporg/bearssl/commit/205c5ffdc95dc03c8c28ffbc1bc5d4ffb5c887a4 + (its P-521 correction, merged at `27611cc`, which leaves P-256 unchanged) and + BearSSL's `src/ec/ecdsa_i31_bits.c` at `7bea48e` (upstream). **Errors and exceptions.** diff --git a/libs/crypto b/libs/crypto index 25bd6e3..332a0a8 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 25bd6e3a46a936ee56e25c5d49613c9a9721c8c2 +Subproject commit 332a0a823252ba8bfccd570eff8d027e1912d609 diff --git a/libs/hash b/libs/hash index f9188f2..a3cd1e8 160000 --- a/libs/hash +++ b/libs/hash @@ -1 +1 @@ -Subproject commit f9188f2c51eaa350592402daa46f1741beec6746 +Subproject commit a3cd1e86cd502d1223d133ffabf858da276e2eb5 diff --git a/third_party/libs/bearssl b/third_party/libs/bearssl index 32381d6..27611cc 160000 --- a/third_party/libs/bearssl +++ b/third_party/libs/bearssl @@ -1 +1 @@ -Subproject commit 32381d6e787a32cbb7a687246349200d78b8ff7c +Subproject commit 27611ccd8bd8f0fc8478db1a2c0e14167eac4ad1 diff --git a/tools/test/fixtures/crypto_jamfiles/canary_missing/canary_missing.outcome b/tools/test/fixtures/crypto_jamfiles/canary_missing/canary_missing.outcome index 6d58dbb..e7d0e07 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_missing/canary_missing.outcome +++ b/tools/test/fixtures/crypto_jamfiles/canary_missing/canary_missing.outcome @@ -10,18 +10,18 @@ build: fails # tag::messages[] [native-darwin] contains: Undefined symbols for architecture -contains: _webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +contains: _webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link [native-linux] -contains: webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link -contains: undefined reference to `webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link' +contains: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: undefined reference to `webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link' [wasip2] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link [wasip3] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link [emscripten] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link contains: em++: error: # end::messages[] diff --git a/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/canary_other_configuration.outcome b/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/canary_other_configuration.outcome index de1d559..21e2834 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/canary_other_configuration.outcome +++ b/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/canary_other_configuration.outcome @@ -10,18 +10,18 @@ build: fails # tag::messages[] [native-darwin] contains: Undefined symbols for architecture -contains: _webcpp_crypto_bearssl_32381d6_sysrng__add_third_party_bearssl_to_your_link +contains: _webcpp_crypto_bearssl_27611cc_sysrng__add_third_party_bearssl_to_your_link [native-linux] -contains: webcpp_crypto_bearssl_32381d6_sysrng__add_third_party_bearssl_to_your_link -contains: undefined reference to `webcpp_crypto_bearssl_32381d6_sysrng__add_third_party_bearssl_to_your_link' +contains: webcpp_crypto_bearssl_27611cc_sysrng__add_third_party_bearssl_to_your_link +contains: undefined reference to `webcpp_crypto_bearssl_27611cc_sysrng__add_third_party_bearssl_to_your_link' [wasip2] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_32381d6_sysrng__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_27611cc_sysrng__add_third_party_bearssl_to_your_link [wasip3] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_32381d6_sysrng__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_27611cc_sysrng__add_third_party_bearssl_to_your_link [emscripten] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_32381d6_sysrng__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_27611cc_sysrng__add_third_party_bearssl_to_your_link contains: em++: error: # end::messages[] diff --git a/tools/test/fixtures/crypto_jamfiles/canary_without/canary_without.outcome b/tools/test/fixtures/crypto_jamfiles/canary_without/canary_without.outcome index d693f32..d4c7a69 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_without/canary_without.outcome +++ b/tools/test/fixtures/crypto_jamfiles/canary_without/canary_without.outcome @@ -10,31 +10,31 @@ build: fails # tag::messages[] [native-darwin] contains: Undefined symbols for architecture -contains: _webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +contains: _webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link [native-linux] -contains: webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link -contains: undefined reference to `webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link' +contains: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: undefined reference to `webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link' [wasip2] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link [wasip3] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link [emscripten] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link contains: em++: error: # end::messages[] # The canary is the only link error (spec section 4.3): no line names an undefined symbol or # reference that is not it. Each linker's own words for one. [native-darwin] -not-contains: ", referenced from: unless webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +not-contains: ", referenced from: unless webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link [native-linux] -not-contains: undefined reference unless webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +not-contains: undefined reference unless webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link [wasip2] -not-contains: undefined symbol unless webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +not-contains: undefined symbol unless webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link [wasip3] -not-contains: undefined symbol unless webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +not-contains: undefined symbol unless webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link [emscripten] -not-contains: undefined symbol unless webcpp_crypto_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +not-contains: undefined symbol unless webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link diff --git a/tools/test/fixtures/hash_jamfiles/canary_bearssl_missing/canary_bearssl_missing.outcome b/tools/test/fixtures/hash_jamfiles/canary_bearssl_missing/canary_bearssl_missing.outcome index 20202ed..27eb0d7 100644 --- a/tools/test/fixtures/hash_jamfiles/canary_bearssl_missing/canary_bearssl_missing.outcome +++ b/tools/test/fixtures/hash_jamfiles/canary_bearssl_missing/canary_bearssl_missing.outcome @@ -9,17 +9,17 @@ targets: native wasip2 wasip3 emscripten build: fails [native-darwin] contains: Undefined symbols for architecture -contains: _webcpp_hash_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +contains: _webcpp_hash_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link [native-linux] -contains: webcpp_hash_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link -contains: undefined reference to `webcpp_hash_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link' +contains: webcpp_hash_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: undefined reference to `webcpp_hash_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link' [wasip2] contains: wasm-ld: error: -contains: undefined symbol: webcpp_hash_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_hash_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link [wasip3] contains: wasm-ld: error: -contains: undefined symbol: webcpp_hash_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_hash_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link [emscripten] contains: wasm-ld: error: -contains: undefined symbol: webcpp_hash_bearssl_32381d6_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_hash_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link contains: em++: error: diff --git a/tools/test/third_party_test.py b/tools/test/third_party_test.py index 50e8bef..a78d040 100755 --- a/tools/test/third_party_test.py +++ b/tools/test/third_party_test.py @@ -53,8 +53,9 @@ BEARSSL = 'third_party/libs/bearssl' # The commit BearSSL is pinned at: webcpporg/bearssl's webcpp branch, upstream 7bea48e with one -# fix (ECDSA decodes the RFC 6979 nonce at its full length). -BEARSSL_COMMIT = '32381d6e787a32cbb7a687246349200d78b8ff7c' +# fix (ECDSA decodes the RFC 6979 nonce at its full length, 32381d6) and its P-521 correction +# (205c5ff), merged at 27611cc. +BEARSSL_COMMIT = '27611ccd8bd8f0fc8478db1a2c0e14167eac4ad1' BITCOIN = 'third_party/libs/bitcoin' From b616e4ce69bcb4bfdd8e8f517665c5aa7b190ee0 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 09:18:13 -0300 Subject: [PATCH 56/63] third_party: BearSSL at upstream 7bea48e (owner decision of 2026-12-02: never patch third-party code) --- third_party/Jamfile | 19 ++++++++-------- third_party/libs/bearssl | 2 +- .../canary_missing/canary_missing.outcome | 12 +++++----- .../canary_other_configuration.outcome | 12 +++++----- .../canary_without/canary_without.outcome | 22 +++++++++---------- .../canary_bearssl_missing.outcome | 12 +++++----- tools/test/third_party_test.py | 7 +++--- 7 files changed, 42 insertions(+), 44 deletions(-) diff --git a/third_party/Jamfile b/third_party/Jamfile index 85675f4..63e8500 100644 --- a/third_party/Jamfile +++ b/third_party/Jamfile @@ -278,16 +278,15 @@ rule crypto-checked-out ( properties * ) .c-library = $(.c-sections) @crypto-checked-out $(CRYPTO)/include ; -# BearSSL (MIT), from webcpp's fork webcpporg/bearssl, branch webcpp: upstream -# 7bea48e with one commit, ECDSA's nonce decoded at its full length so that -# signing does not branch on its bit length (CODING-GUIDELINES chapter 5, -# rule 1). Every .c of src/, the POWER8 ones too, which off POWER compile to -# the stubs other files call. One source of entropy, getentropy, with RDRAND -# and /dev/urandom off (libs/crypto's random_device reads the same source): -# wasi-libc and Emscripten declare getentropy only under _DEFAULT_SOURCE, and -# macOS only in , which src/rand/sysrng.c does not include. On -# Windows BearSSL's only seeder is CryptGenRandom, not the system's -# BCryptGenRandom, so every seeder is off there and BearSSL has none. +# BearSSL (MIT), upstream's 7bea48e, unmodified, from webcpp's mirror +# webcpporg/bearssl (CODING-GUIDELINES chapter 5, rule 1: never patch +# third-party code). Every .c of src/, the POWER8 ones too, which off POWER +# compile to the stubs other files call. One source of entropy, getentropy, with +# RDRAND and /dev/urandom off (libs/crypto's random_device reads the same +# source): wasi-libc and Emscripten declare getentropy only under +# _DEFAULT_SOURCE, and macOS only in , which src/rand/sysrng.c +# does not include. On Windows BearSSL's only seeder is CryptGenRandom, not the +# system's BCryptGenRandom, so every seeder is off there and BearSSL has none. path-constant BEARSSL : libs/bearssl ; rule bearssl-checked-out ( properties * ) diff --git a/third_party/libs/bearssl b/third_party/libs/bearssl index 27611cc..7bea48e 160000 --- a/third_party/libs/bearssl +++ b/third_party/libs/bearssl @@ -1 +1 @@ -Subproject commit 27611ccd8bd8f0fc8478db1a2c0e14167eac4ad1 +Subproject commit 7bea48e5e850ab4cafbe68d3765cdaba13a86d6f diff --git a/tools/test/fixtures/crypto_jamfiles/canary_missing/canary_missing.outcome b/tools/test/fixtures/crypto_jamfiles/canary_missing/canary_missing.outcome index e7d0e07..8848ddb 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_missing/canary_missing.outcome +++ b/tools/test/fixtures/crypto_jamfiles/canary_missing/canary_missing.outcome @@ -10,18 +10,18 @@ build: fails # tag::messages[] [native-darwin] contains: Undefined symbols for architecture -contains: _webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: _webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link [native-linux] -contains: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link -contains: undefined reference to `webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link' +contains: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: undefined reference to `webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link' [wasip2] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link [wasip3] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link [emscripten] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link contains: em++: error: # end::messages[] diff --git a/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/canary_other_configuration.outcome b/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/canary_other_configuration.outcome index 21e2834..e6f40bf 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/canary_other_configuration.outcome +++ b/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/canary_other_configuration.outcome @@ -10,18 +10,18 @@ build: fails # tag::messages[] [native-darwin] contains: Undefined symbols for architecture -contains: _webcpp_crypto_bearssl_27611cc_sysrng__add_third_party_bearssl_to_your_link +contains: _webcpp_crypto_bearssl_7bea48e_sysrng__add_third_party_bearssl_to_your_link [native-linux] -contains: webcpp_crypto_bearssl_27611cc_sysrng__add_third_party_bearssl_to_your_link -contains: undefined reference to `webcpp_crypto_bearssl_27611cc_sysrng__add_third_party_bearssl_to_your_link' +contains: webcpp_crypto_bearssl_7bea48e_sysrng__add_third_party_bearssl_to_your_link +contains: undefined reference to `webcpp_crypto_bearssl_7bea48e_sysrng__add_third_party_bearssl_to_your_link' [wasip2] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_27611cc_sysrng__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_sysrng__add_third_party_bearssl_to_your_link [wasip3] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_27611cc_sysrng__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_sysrng__add_third_party_bearssl_to_your_link [emscripten] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_27611cc_sysrng__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_sysrng__add_third_party_bearssl_to_your_link contains: em++: error: # end::messages[] diff --git a/tools/test/fixtures/crypto_jamfiles/canary_without/canary_without.outcome b/tools/test/fixtures/crypto_jamfiles/canary_without/canary_without.outcome index d4c7a69..dccf794 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_without/canary_without.outcome +++ b/tools/test/fixtures/crypto_jamfiles/canary_without/canary_without.outcome @@ -10,31 +10,31 @@ build: fails # tag::messages[] [native-darwin] contains: Undefined symbols for architecture -contains: _webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: _webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link [native-linux] -contains: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link -contains: undefined reference to `webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link' +contains: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: undefined reference to `webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link' [wasip2] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link [wasip3] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link [emscripten] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link contains: em++: error: # end::messages[] # The canary is the only link error (spec section 4.3): no line names an undefined symbol or # reference that is not it. Each linker's own words for one. [native-darwin] -not-contains: ", referenced from: unless webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +not-contains: ", referenced from: unless webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link [native-linux] -not-contains: undefined reference unless webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +not-contains: undefined reference unless webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link [wasip2] -not-contains: undefined symbol unless webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +not-contains: undefined symbol unless webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link [wasip3] -not-contains: undefined symbol unless webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +not-contains: undefined symbol unless webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link [emscripten] -not-contains: undefined symbol unless webcpp_crypto_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +not-contains: undefined symbol unless webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link diff --git a/tools/test/fixtures/hash_jamfiles/canary_bearssl_missing/canary_bearssl_missing.outcome b/tools/test/fixtures/hash_jamfiles/canary_bearssl_missing/canary_bearssl_missing.outcome index 27eb0d7..108021f 100644 --- a/tools/test/fixtures/hash_jamfiles/canary_bearssl_missing/canary_bearssl_missing.outcome +++ b/tools/test/fixtures/hash_jamfiles/canary_bearssl_missing/canary_bearssl_missing.outcome @@ -9,17 +9,17 @@ targets: native wasip2 wasip3 emscripten build: fails [native-darwin] contains: Undefined symbols for architecture -contains: _webcpp_hash_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: _webcpp_hash_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link [native-linux] -contains: webcpp_hash_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link -contains: undefined reference to `webcpp_hash_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link' +contains: webcpp_hash_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: undefined reference to `webcpp_hash_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link' [wasip2] contains: wasm-ld: error: -contains: undefined symbol: webcpp_hash_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_hash_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link [wasip3] contains: wasm-ld: error: -contains: undefined symbol: webcpp_hash_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_hash_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link [emscripten] contains: wasm-ld: error: -contains: undefined symbol: webcpp_hash_bearssl_27611cc_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_hash_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link contains: em++: error: diff --git a/tools/test/third_party_test.py b/tools/test/third_party_test.py index a78d040..ac8a9f2 100755 --- a/tools/test/third_party_test.py +++ b/tools/test/third_party_test.py @@ -52,10 +52,9 @@ BEARSSL = 'third_party/libs/bearssl' -# The commit BearSSL is pinned at: webcpporg/bearssl's webcpp branch, upstream 7bea48e with one -# fix (ECDSA decodes the RFC 6979 nonce at its full length, 32381d6) and its P-521 correction -# (205c5ff), merged at 27611cc. -BEARSSL_COMMIT = '27611ccd8bd8f0fc8478db1a2c0e14167eac4ad1' +# The commit BearSSL is pinned at: upstream's 7bea48e, unmodified, the master branch of the mirror +# webcpporg/bearssl. +BEARSSL_COMMIT = '7bea48e5e850ab4cafbe68d3765cdaba13a86d6f' BITCOIN = 'third_party/libs/bitcoin' From 822ebc2d7384842cb9a185938da7b9c9f4891b29 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 09:18:13 -0300 Subject: [PATCH 57/63] guidelines: chapter 5 rule 1, never patch third-party code; a dependency's defect is reported to the owner for upstream --- CODING-GUIDELINES.md | 65 ++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index cc2e20f..ba9e9a2 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -340,19 +340,17 @@ A webcpp library that builds on a C library (webcpp::crypto on BearSSL and libsecp256k1, for example) brings it in this way, so that the C code stays exactly its authors' and the program carries only what it calls. -1. The C library is a submodule under `third_party/libs/`, pinned at a - commit and never edited. When upstream is not on GitHub, an unmodified - `webcpporg/` mirror stands in (BearSSL's is `webcpporg/bearssl`), - refreshed only when the pin moves. One exception, a security fix upstream - does not have yet: a branch `webcpp` of the mirror carries upstream's - commit and the fix, one commit each, pinned there and carried to each new - pin until upstream has it. The fix is minimal, preserves every value the - library computes, and is reported upstream (an owner item). A library - whose upstream is not mirrored under webcpporg takes such a fix the same - way, in a `webcpporg/` fork created for it, with the same `webcpp` - branch rule. BearSSL's has one, of 2026-11-21: ECDSA decodes RFC 6979's - nonce at its full length, so that signing does not branch on the nonce's - bit length (chapter 15, webcpp::crypto's P-256). +1. The C library is a submodule under `third_party/libs/`, pinned at an + upstream commit and never edited. When upstream is not on GitHub, an + unmodified `webcpporg/` mirror stands in (BearSSL's is + `webcpporg/bearssl`), refreshed only when the pin moves. webcpp never + patches third-party code, in the submodule or on a branch of a mirror or + fork: a defect found in a dependency is reported to the owner, who reports + it upstream, and the pin moves only to an upstream commit. Until upstream + fixes it, the defect stays what it is, stated where webcpp's pages describe + the library, and a lane that finds it stays red rather than silenced (owner + decision of 2026-12-02, which superseded the exception of 2026-11-21 that + let a mirror's `webcpp` branch carry a security fix). 2. `third_party/Jamfile` builds it from its own sources, file by file, as a static library, in the library's own C dialect, on every target and with every file: a file that does not apply to a target still compiles, to the @@ -984,7 +982,7 @@ update --init third_party/libs/`; a build that needs none never looks. | Target | What it is | Licence | | --- | --- | --- | -| `bearssl` | BearSSL from webcpp's mirror `webcpporg/bearssl` at `27611cc`, its branch `webcpp`: upstream's `7bea48e` and one fix, ECDSA's nonce decoded at its full length (`32381d6`, chapter 5 rule 1), with its P-521 correction (`205c5ff`, merged at `27611cc`: the fix alone biased every P-521 nonce; P-256 and P-384 unaffected); a static library built file by file by `third_party/Jamfile` with webcpp::crypto's and webcpp::hash's canaries (hash's when `libs/hash` is checked out), on every target; `WEBCPP_CRYPTO_HAS_BEARSSL=1`, and `WEBCPP_HASH_HAS_BEARSSL=1` with hash's canary | MIT | +| `bearssl` | BearSSL at upstream's `7bea48e`, unmodified (chapter 5 rule 1), from webcpp's mirror `webcpporg/bearssl`; a static library built file by file by `third_party/Jamfile` with webcpp::crypto's and webcpp::hash's canaries (hash's when `libs/hash` is checked out), on every target; `WEBCPP_CRYPTO_HAS_BEARSSL=1`, and `WEBCPP_HASH_HAS_BEARSSL=1` with hash's canary | MIT | | `bips` | `bitcoin/bips` at `927b6de9`, shallow, test data: crypto's tests read BIP340's `bip-0340/test-vectors.csv` and BIP341's `bip-0341/wallet-test-vectors.json` at run time under the directory its define `WEBCPP_TEST_BIPS` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when it changes | BSD-2-Clause, as BIP340's header states | | `bitcoin_base58_vectors` | Bitcoin Core's base58 vectors, `src/test/data/base58_encode_decode.json` and `src/test/data/key_io_valid.json` of the submodule `third_party/libs/bitcoin` (Bitcoin Core v31.1 at `9be056a`, shallow), test data that nothing compiles: codecs' tests (the first file) and hash's Base58Check test (the second) read them at run time under the directory its define `WEBCPP_TEST_BITCOIN_BASE58_VECTORS` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when either changes | MIT | | `blake2_vectors` | BLAKE2's reference code package `BLAKE2/BLAKE2` at `ed1974e` (2023-02-12), the submodule `third_party/libs/blake2`, shallow, test data that nothing compiles: hash's tests read `testvectors/blake2b-kat.txt` and `testvectors/blake2-kat.json` at run time under the directory its define `WEBCPP_TEST_BLAKE2_VECTORS` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when one of them changes | CC0-1.0 | @@ -7355,19 +7353,20 @@ since that change); what is decided and not built is in chapter 17. Linux container (`linux-lint:arm64`, clang 18, Valgrind 3.22), the lane's CI command: both found upstream BearSSL's signing branching on the RFC 6979 nonce's bit length, `br_ecdsa_i31_bits2int` decoding it with its actual - length and `br_i31_rshift` looping by it (a Minerva-class leak), and nothing - once webcpp's BearSSL carried the fix, one commit setting the order's length - before the shift (chapter 5 rule 1); the planted programs failed and dudect - passed there too: dudect judged P-256's signing with its low-S step (|t| - 1.70 on Linux, 1.63 natively on an Apple M5 Max, release, one run each; - provisional, measured again in the final quiet pass). + length and `br_i31_rshift` looping by it (a Minerva-class leak). From + 2026-11-21 to 2026-12-02 webcpp's BearSSL carried a fix of its own on the + mirror's `webcpp` branch and the checkers found nothing; the owner decision + of 2026-12-02 (chapter 5 rule 1) superseded it: BearSSL is upstream's + `7bea48e` again, the leak is upstream's, reported to the owner for upstream, + and the constant-time lane shows it until upstream fixes it. The planted + programs failed and dudect passed there too: dudect judged P-256's signing + with its low-S step (|t| 1.70 on Linux, 1.63 natively on an Apple M5 Max, + release, one run each; provisional, measured again in the final quiet + pass). Source: `libs/crypto/test/constant_time/Jamfile`, `test/sizes/Jamfile`, `bench/throughput.cpp`, `doc/backends.adoc` (libs/crypto); - https://github.com/webcpporg/bearssl/commit/32381d6e787a32cbb7a687246349200d78b8ff7c - (the fix), - https://github.com/webcpporg/bearssl/commit/205c5ffdc95dc03c8c28ffbc1bc5d4ffb5c887a4 - (its P-521 correction, merged at `27611cc`, which leaves P-256 unchanged) and - BearSSL's `src/ec/ecdsa_i31_bits.c` at `7bea48e` (upstream). + BearSSL's `src/ec/ecdsa_i31_bits.c` at `7bea48e` (upstream); the superseded + fix's commits, `32381d6` and `205c5ff` of `webcpporg/bearssl`, are history. **Errors and exceptions.** @@ -7394,14 +7393,14 @@ since that change); what is decided and not built is in chapter 17. Source: `libraries/crypto/openspec/changes/genesis/design.md` D1 (proposals). - **BearSSL comes from webcpp's mirror `webcpporg/bearssl`, upstream's code - with one security fix on its branch `webcpp` (chapter 5 rule 1); its - notice ships as `LICENSE-BEARSSL.txt`, and webcpp's canary lives in the - library's `src/`. The backend names its code itself: the CTR class of - AES-NI, then POWER8, then `aes_ct64`, and GHASH by PCLMUL, then POWER8, - then `ghash_ctmul64`; the test seam `WEBCPP_CRYPTO_DETAIL_BEARSSL_PORTABLE` - keeps it on the portable pair.** On wasm32 BearSSL's own default would be - its 32-bit code; the seam lets the agreement test compare both of BearSSL's - code paths with OpenSSL's on x86-64. + unmodified (chapter 5 rule 1); its notice ships as `LICENSE-BEARSSL.txt`, + and webcpp's canary lives in the library's `src/`. The backend names its + code itself: the CTR class of AES-NI, then POWER8, then `aes_ct64`, and + GHASH by PCLMUL, then POWER8, then `ghash_ctmul64`; the test seam + `WEBCPP_CRYPTO_DETAIL_BEARSSL_PORTABLE` keeps it on the portable pair.** On + wasm32 BearSSL's own default would be its 32-bit code; the seam lets the + agreement test compare both of BearSSL's code paths with OpenSSL's on + x86-64. Source: `include/webcpp/crypto/backends/bearssl.hpp`, `test/agreement_gcm_portable_test.cpp` (libs/crypto). - **OpenSSL is the superproject's source-built OpenSSL 3.5.9, static, From 32eab228153c4a8d2d9e5903a94c05e8497e5353 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 09:18:13 -0300 Subject: [PATCH 58/63] libs: the crypto and hash gitlinks at BearSSL upstream 7bea48e --- libs/crypto | 2 +- libs/hash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/crypto b/libs/crypto index 332a0a8..5d2be9e 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 332a0a823252ba8bfccd570eff8d027e1912d609 +Subproject commit 5d2be9ee77b6c1905a38a8c7aca5d6c96241aff5 diff --git a/libs/hash b/libs/hash index a3cd1e8..d033ddb 160000 --- a/libs/hash +++ b/libs/hash @@ -1 +1 @@ -Subproject commit a3cd1e86cd502d1223d133ffabf858da276e2eb5 +Subproject commit d033ddb162c2169629b2dd3f2bc6bc2bb8c548a7 From 09e4ea24f30bcbd20a8247a906d61679a275d2c5 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 09:41:49 -0300 Subject: [PATCH 59/63] third_party: BearSSL at our fork's upstream-submission commit ae63032 (upstream 7bea48e and the bits2int fix submitted upstream) --- third_party/Jamfile | 20 +++++++++-------- third_party/libs/bearssl | 2 +- .../canary_missing/canary_missing.outcome | 12 +++++----- .../canary_other_configuration.outcome | 12 +++++----- .../canary_without/canary_without.outcome | 22 +++++++++---------- .../canary_bearssl_missing.outcome | 12 +++++----- tools/test/third_party_test.py | 7 +++--- 7 files changed, 45 insertions(+), 42 deletions(-) diff --git a/third_party/Jamfile b/third_party/Jamfile index 63e8500..887f329 100644 --- a/third_party/Jamfile +++ b/third_party/Jamfile @@ -278,15 +278,17 @@ rule crypto-checked-out ( properties * ) .c-library = $(.c-sections) @crypto-checked-out $(CRYPTO)/include ; -# BearSSL (MIT), upstream's 7bea48e, unmodified, from webcpp's mirror -# webcpporg/bearssl (CODING-GUIDELINES chapter 5, rule 1: never patch -# third-party code). Every .c of src/, the POWER8 ones too, which off POWER -# compile to the stubs other files call. One source of entropy, getentropy, with -# RDRAND and /dev/urandom off (libs/crypto's random_device reads the same -# source): wasi-libc and Emscripten declare getentropy only under -# _DEFAULT_SOURCE, and macOS only in , which src/rand/sysrng.c -# does not include. On Windows BearSSL's only seeder is CryptGenRandom, not the -# system's BCryptGenRandom, so every seeder is off there and BearSSL has none. +# BearSSL (MIT) at ae63032 of webcpp's fork webcpporg/bearssl, branch +# upstream/ecdsa-bits2int-constant-time: upstream's 7bea48e and exactly the +# ECDSA nonce fix submitted upstream, until upstream applies it +# (CODING-GUIDELINES chapter 5, rule 1). Every .c of src/, the POWER8 ones too, +# which off POWER compile to the stubs other files call. One source of entropy, +# getentropy, with RDRAND and /dev/urandom off (libs/crypto's random_device +# reads the same source): wasi-libc and Emscripten declare getentropy only +# under _DEFAULT_SOURCE, and macOS only in , which +# src/rand/sysrng.c does not include. On Windows BearSSL's only seeder is +# CryptGenRandom, not the system's BCryptGenRandom, so every seeder is off +# there and BearSSL has none. path-constant BEARSSL : libs/bearssl ; rule bearssl-checked-out ( properties * ) diff --git a/third_party/libs/bearssl b/third_party/libs/bearssl index 7bea48e..ae63032 160000 --- a/third_party/libs/bearssl +++ b/third_party/libs/bearssl @@ -1 +1 @@ -Subproject commit 7bea48e5e850ab4cafbe68d3765cdaba13a86d6f +Subproject commit ae63032d9f30bf53674db5445875adf71b8626b7 diff --git a/tools/test/fixtures/crypto_jamfiles/canary_missing/canary_missing.outcome b/tools/test/fixtures/crypto_jamfiles/canary_missing/canary_missing.outcome index 8848ddb..80b6e69 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_missing/canary_missing.outcome +++ b/tools/test/fixtures/crypto_jamfiles/canary_missing/canary_missing.outcome @@ -10,18 +10,18 @@ build: fails # tag::messages[] [native-darwin] contains: Undefined symbols for architecture -contains: _webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: _webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link [native-linux] -contains: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link -contains: undefined reference to `webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link' +contains: webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link +contains: undefined reference to `webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link' [wasip2] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link [wasip3] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link [emscripten] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link contains: em++: error: # end::messages[] diff --git a/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/canary_other_configuration.outcome b/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/canary_other_configuration.outcome index e6f40bf..6cac727 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/canary_other_configuration.outcome +++ b/tools/test/fixtures/crypto_jamfiles/canary_other_configuration/canary_other_configuration.outcome @@ -10,18 +10,18 @@ build: fails # tag::messages[] [native-darwin] contains: Undefined symbols for architecture -contains: _webcpp_crypto_bearssl_7bea48e_sysrng__add_third_party_bearssl_to_your_link +contains: _webcpp_crypto_bearssl_ae63032_sysrng__add_third_party_bearssl_to_your_link [native-linux] -contains: webcpp_crypto_bearssl_7bea48e_sysrng__add_third_party_bearssl_to_your_link -contains: undefined reference to `webcpp_crypto_bearssl_7bea48e_sysrng__add_third_party_bearssl_to_your_link' +contains: webcpp_crypto_bearssl_ae63032_sysrng__add_third_party_bearssl_to_your_link +contains: undefined reference to `webcpp_crypto_bearssl_ae63032_sysrng__add_third_party_bearssl_to_your_link' [wasip2] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_sysrng__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_ae63032_sysrng__add_third_party_bearssl_to_your_link [wasip3] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_sysrng__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_ae63032_sysrng__add_third_party_bearssl_to_your_link [emscripten] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_sysrng__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_ae63032_sysrng__add_third_party_bearssl_to_your_link contains: em++: error: # end::messages[] diff --git a/tools/test/fixtures/crypto_jamfiles/canary_without/canary_without.outcome b/tools/test/fixtures/crypto_jamfiles/canary_without/canary_without.outcome index dccf794..d33df05 100644 --- a/tools/test/fixtures/crypto_jamfiles/canary_without/canary_without.outcome +++ b/tools/test/fixtures/crypto_jamfiles/canary_without/canary_without.outcome @@ -10,31 +10,31 @@ build: fails # tag::messages[] [native-darwin] contains: Undefined symbols for architecture -contains: _webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: _webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link [native-linux] -contains: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link -contains: undefined reference to `webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link' +contains: webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link +contains: undefined reference to `webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link' [wasip2] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link [wasip3] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link [emscripten] contains: wasm-ld: error: -contains: undefined symbol: webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link contains: em++: error: # end::messages[] # The canary is the only link error (spec section 4.3): no line names an undefined symbol or # reference that is not it. Each linker's own words for one. [native-darwin] -not-contains: ", referenced from: unless webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +not-contains: ", referenced from: unless webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link [native-linux] -not-contains: undefined reference unless webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +not-contains: undefined reference unless webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link [wasip2] -not-contains: undefined symbol unless webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +not-contains: undefined symbol unless webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link [wasip3] -not-contains: undefined symbol unless webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +not-contains: undefined symbol unless webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link [emscripten] -not-contains: undefined symbol unless webcpp_crypto_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +not-contains: undefined symbol unless webcpp_crypto_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link diff --git a/tools/test/fixtures/hash_jamfiles/canary_bearssl_missing/canary_bearssl_missing.outcome b/tools/test/fixtures/hash_jamfiles/canary_bearssl_missing/canary_bearssl_missing.outcome index 108021f..591a0f4 100644 --- a/tools/test/fixtures/hash_jamfiles/canary_bearssl_missing/canary_bearssl_missing.outcome +++ b/tools/test/fixtures/hash_jamfiles/canary_bearssl_missing/canary_bearssl_missing.outcome @@ -9,17 +9,17 @@ targets: native wasip2 wasip3 emscripten build: fails [native-darwin] contains: Undefined symbols for architecture -contains: _webcpp_hash_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: _webcpp_hash_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link [native-linux] -contains: webcpp_hash_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link -contains: undefined reference to `webcpp_hash_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link' +contains: webcpp_hash_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link +contains: undefined reference to `webcpp_hash_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link' [wasip2] contains: wasm-ld: error: -contains: undefined symbol: webcpp_hash_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_hash_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link [wasip3] contains: wasm-ld: error: -contains: undefined symbol: webcpp_hash_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_hash_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link [emscripten] contains: wasm-ld: error: -contains: undefined symbol: webcpp_hash_bearssl_7bea48e_getentropy__add_third_party_bearssl_to_your_link +contains: undefined symbol: webcpp_hash_bearssl_ae63032_getentropy__add_third_party_bearssl_to_your_link contains: em++: error: diff --git a/tools/test/third_party_test.py b/tools/test/third_party_test.py index ac8a9f2..5d189ee 100755 --- a/tools/test/third_party_test.py +++ b/tools/test/third_party_test.py @@ -52,9 +52,10 @@ BEARSSL = 'third_party/libs/bearssl' -# The commit BearSSL is pinned at: upstream's 7bea48e, unmodified, the master branch of the mirror -# webcpporg/bearssl. -BEARSSL_COMMIT = '7bea48e5e850ab4cafbe68d3765cdaba13a86d6f' +# The commit BearSSL is pinned at: ae63032 of the fork webcpporg/bearssl, branch +# upstream/ecdsa-bits2int-constant-time, upstream's 7bea48e and exactly the ECDSA nonce fix +# submitted upstream (CODING-GUIDELINES chapter 5 rule 1); back to upstream once it is applied. +BEARSSL_COMMIT = 'ae63032d9f30bf53674db5445875adf71b8626b7' BITCOIN = 'third_party/libs/bitcoin' From c83e9567770b5b14adc7a83eb71e3426f5ec9a9a Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 09:42:10 -0300 Subject: [PATCH 60/63] guidelines: chapter 5 rule 1, a dependency's fix is submitted upstream and pinned until applied --- CODING-GUIDELINES.md | 43 +++++++++++++++++++++++++------------------ CONTRIBUTING.md | 5 +++-- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index ba9e9a2..16d6fa6 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -341,16 +341,18 @@ libsecp256k1, for example) brings it in this way, so that the C code stays exactly its authors' and the program carries only what it calls. 1. The C library is a submodule under `third_party/libs/`, pinned at an - upstream commit and never edited. When upstream is not on GitHub, an - unmodified `webcpporg/` mirror stands in (BearSSL's is - `webcpporg/bearssl`), refreshed only when the pin moves. webcpp never - patches third-party code, in the submodule or on a branch of a mirror or - fork: a defect found in a dependency is reported to the owner, who reports - it upstream, and the pin moves only to an upstream commit. Until upstream - fixes it, the defect stays what it is, stated where webcpp's pages describe - the library, and a lane that finds it stays red rather than silenced (owner - decision of 2026-12-02, which superseded the exception of 2026-11-21 that - let a mirror's `webcpp` branch carry a security fix). + upstream commit and never edited. When upstream is not on GitHub, a + `webcpporg/` mirror stands in (BearSSL's is `webcpporg/bearssl`), + refreshed only when the pin moves. webcpp never modifies third-party code: + a defect found in a dependency is reported to the owner, who submits the + fix upstream. Until upstream applies it, the pin may point at our fork's + branch carrying exactly that submitted patch and nothing else, and it + returns to upstream once the patch is applied. BearSSL is pinned so: + `ae63032` of `webcpporg/bearssl`'s branch + `upstream/ecdsa-bits2int-constant-time`, upstream's `7bea48e` and the ECDSA + nonce fix submitted upstream (owner decision of 2026-12-02, which + superseded the exception of 2026-11-21 that let a mirror's `webcpp` branch + carry a fix of webcpp's own). 2. `third_party/Jamfile` builds it from its own sources, file by file, as a static library, in the library's own C dialect, on every target and with every file: a file that does not apply to a target still compiles, to the @@ -982,7 +984,7 @@ update --init third_party/libs/`; a build that needs none never looks. | Target | What it is | Licence | | --- | --- | --- | -| `bearssl` | BearSSL at upstream's `7bea48e`, unmodified (chapter 5 rule 1), from webcpp's mirror `webcpporg/bearssl`; a static library built file by file by `third_party/Jamfile` with webcpp::crypto's and webcpp::hash's canaries (hash's when `libs/hash` is checked out), on every target; `WEBCPP_CRYPTO_HAS_BEARSSL=1`, and `WEBCPP_HASH_HAS_BEARSSL=1` with hash's canary | MIT | +| `bearssl` | BearSSL at `ae63032` of webcpp's fork `webcpporg/bearssl`, branch `upstream/ecdsa-bits2int-constant-time`: upstream's `7bea48e` and exactly the ECDSA nonce fix submitted upstream, until upstream applies it (chapter 5 rule 1); a static library built file by file by `third_party/Jamfile` with webcpp::crypto's and webcpp::hash's canaries (hash's when `libs/hash` is checked out), on every target; `WEBCPP_CRYPTO_HAS_BEARSSL=1`, and `WEBCPP_HASH_HAS_BEARSSL=1` with hash's canary | MIT | | `bips` | `bitcoin/bips` at `927b6de9`, shallow, test data: crypto's tests read BIP340's `bip-0340/test-vectors.csv` and BIP341's `bip-0341/wallet-test-vectors.json` at run time under the directory its define `WEBCPP_TEST_BIPS` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when it changes | BSD-2-Clause, as BIP340's header states | | `bitcoin_base58_vectors` | Bitcoin Core's base58 vectors, `src/test/data/base58_encode_decode.json` and `src/test/data/key_io_valid.json` of the submodule `third_party/libs/bitcoin` (Bitcoin Core v31.1 at `9be056a`, shallow), test data that nothing compiles: codecs' tests (the first file) and hash's Base58Check test (the second) read them at run time under the directory its define `WEBCPP_TEST_BITCOIN_BASE58_VECTORS` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when either changes | MIT | | `blake2_vectors` | BLAKE2's reference code package `BLAKE2/BLAKE2` at `ed1974e` (2023-02-12), the submodule `third_party/libs/blake2`, shallow, test data that nothing compiles: hash's tests read `testvectors/blake2b-kat.txt` and `testvectors/blake2-kat.json` at run time under the directory its define `WEBCPP_TEST_BLAKE2_VECTORS` gives, on every target (wasmtime is given it, `webcpp.data`), and run again when one of them changes | CC0-1.0 | @@ -7356,17 +7358,21 @@ since that change); what is decided and not built is in chapter 17. length and `br_i31_rshift` looping by it (a Minerva-class leak). From 2026-11-21 to 2026-12-02 webcpp's BearSSL carried a fix of its own on the mirror's `webcpp` branch and the checkers found nothing; the owner decision - of 2026-12-02 (chapter 5 rule 1) superseded it: BearSSL is upstream's - `7bea48e` again, the leak is upstream's, reported to the owner for upstream, - and the constant-time lane shows it until upstream fixes it. The planted + of 2026-12-02 (chapter 5 rule 1) replaced it with the same fix submitted + upstream: BearSSL is pinned at `ae63032` of `webcpporg/bearssl`'s branch + `upstream/ecdsa-bits2int-constant-time`, upstream's `7bea48e` and that one + patch, until upstream applies it, and the checkers find nothing under it + (2026-12-02). The planted programs failed and dudect passed there too: dudect judged P-256's signing with its low-S step (|t| 1.70 on Linux, 1.63 natively on an Apple M5 Max, release, one run each; provisional, measured again in the final quiet pass). Source: `libs/crypto/test/constant_time/Jamfile`, `test/sizes/Jamfile`, `bench/throughput.cpp`, `doc/backends.adoc` (libs/crypto); - BearSSL's `src/ec/ecdsa_i31_bits.c` at `7bea48e` (upstream); the superseded - fix's commits, `32381d6` and `205c5ff` of `webcpporg/bearssl`, are history. + BearSSL's `src/ec/ecdsa_i31_bits.c` at `7bea48e` (upstream) and at + `ae63032` (`webcpporg/bearssl`, the patch submitted upstream); the + superseded fix's commits, `32381d6` and `205c5ff` of the mirror's `webcpp` + branch, are history. **Errors and exceptions.** @@ -7392,8 +7398,9 @@ since that change); what is decided and not built is in chapter 17. measured, a port is a new thing to review. Source: `libraries/crypto/openspec/changes/genesis/design.md` D1 (proposals). -- **BearSSL comes from webcpp's mirror `webcpporg/bearssl`, upstream's code - unmodified (chapter 5 rule 1); its notice ships as `LICENSE-BEARSSL.txt`, +- **BearSSL comes from webcpp's fork `webcpporg/bearssl`, upstream's code + and exactly the ECDSA nonce fix submitted upstream, until upstream applies + it (chapter 5 rule 1); its notice ships as `LICENSE-BEARSSL.txt`, and webcpp's canary lives in the library's `src/`. The backend names its code itself: the CTR class of AES-NI, then POWER8, then `aes_ct64`, and GHASH by PCLMUL, then POWER8, then `ghash_ctmul64`; the test seam diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 373c1bf..4b46b8a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,8 +58,9 @@ Each line is a rule of CODING-GUIDELINES.md, named by its chapter. customize, and on emscripten a library uses what the browser offers (chapter 4). - **A C library is brought in as its authors wrote it:** a pinned submodule, - never edited (an unmodified `webcpporg` mirror when upstream is not on - GitHub), built file by file by webcpp's Jamfile with function sections, named + never edited (a `webcpporg` mirror when upstream is not on GitHub; our + fork's branch carrying exactly a fix submitted upstream, until upstream + applies it), built file by file by webcpp's Jamfile with function sections, named by the program in its own Jamfile (`/third_party//`), and guarded by a compile-time check, a link-time canary and, on MSVC, `detect_mismatch`, each saying what to add (chapter 5, "Bringing a C library into webcpp"). From 07e970ba738be8b403e5d012b34d527ec3ddadd2 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 09:43:32 -0300 Subject: [PATCH 61/63] libs: the crypto and hash gitlinks at BearSSL ae63032, the bits2int fix submitted upstream --- libs/crypto | 2 +- libs/hash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/crypto b/libs/crypto index 5d2be9e..0915042 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 5d2be9ee77b6c1905a38a8c7aca5d6c96241aff5 +Subproject commit 09150425fe4ed0f88d167b57bb26aebb5655f690 diff --git a/libs/hash b/libs/hash index d033ddb..56e7e65 160000 --- a/libs/hash +++ b/libs/hash @@ -1 +1 @@ -Subproject commit d033ddb162c2169629b2dd3f2bc6bc2bb8c548a7 +Subproject commit 56e7e658bdb4ea20c05f942eb0850d300dc32050 From c1e319d1522a3392d87d8e712f67181ff16a6433 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 12:36:45 -0300 Subject: [PATCH 62/63] libs/crypto: the gitlink at the merge of crypto's formats change (6052c7c) --- libs/crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/crypto b/libs/crypto index 0915042..6052c7c 160000 --- a/libs/crypto +++ b/libs/crypto @@ -1 +1 @@ -Subproject commit 09150425fe4ed0f88d167b57bb26aebb5655f690 +Subproject commit 6052c7c8df4e14cfa4b53441dc5cf7d7b48ca6e2 From 09f59d1a0a524067ccb6764898f058eeaabd0804 Mon Sep 17 00:00:00 2001 From: R Date: Wed, 2 Dec 2026 12:36:46 -0300 Subject: [PATCH 63/63] libs/hash: the gitlink at the merge of hash's base58_with_checksum (33b8f9e) --- libs/hash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hash b/libs/hash index 56e7e65..33b8f9e 160000 --- a/libs/hash +++ b/libs/hash @@ -1 +1 @@ -Subproject commit 56e7e658bdb4ea20c05f942eb0850d300dc32050 +Subproject commit 33b8f9e045399f29930c6db634fd221c36534e9b