feat(security): pin two bootstrap signing keys (automated signer + offline backup) (F5)

The single pinned key CbyBk7... has no secret half on record, so it could never
sign anything. Bootstraps are now built, verified and signed weekly by a
dedicated signer box, and an offline backup key covers loss or revocation of
that key. A signature is accepted if it verifies against either pinned key.

- bootstrap.h: kBootstrapSignaturePublicKeysBase64[] = { hot GHgDNfZV..., cold MZi/rTuQ... }
- bootstrap.cpp: Bootstrap::signatureMatchesPinnedKey() checks every pinned key
  (no network, unit-testable); a present signature matching none stays fatal.
- tests: the known answer is now a real signer-box signature over a real weekly
  checksum (height 3449343); covers tamper, garbage, empty and wrong-key cases,
  the two keys being distinct and valid, and CbyBk7 no longer being pinned.
- sign-bootstrap-release.sh: the key check accepts any pinned key.

kBootstrapRequireSignature stays false until every served bootstrap carries a
signature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 17:26:52 -06:00
co-authored by Claude Opus 5.5
parent 6bb72f9878
commit 79aed5462d
4 changed files with 73 additions and 43 deletions
+33 -20
View File
@@ -14716,30 +14716,43 @@ void testDaemonSignatureInterop()
void testBootstrapSignatureInterop()
{
using namespace dragonx::util;
// F5 — known answer from scripts/sign-bootstrap-release.sh (OpenSSL ed25519) over the published
// "<sha256> DRAGONX.zip\n" checksum file, verified with libsodium against the key pinned in
// bootstrap.h. The wallet signs the small checksum (not the multi-GB archive), so this is the exact
// byte string the signer signs and the verifier checks. Proves the pinned bootstrap key matches the
// signing key and that a tampered checksum / wrong key fails closed.
// F5 — known answer: a REAL weekly bootstrap checksum signed by the automated signer box
// (drgx-sign-checksum, OpenSSL ed25519, 2026-11-20 dry run at height 3449343), verified here with
// libsodium against the pinned keys. This is the exact byte string the signer signs and the wallet
// checks ("<sha256> DRAGONX.zip\n"), so it closes the OpenSSL<->libsodium interop loop and proves
// pinned key [0] matches the signer's secret key.
const std::string content =
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 DRAGONX.zip\n";
"25ad8b708465e3eefe5425e145924a23e9035df7b4493ef8b28533928275ee01 DRAGONX.zip\n";
const std::string sigB64 =
"MXcbt9SBbiScAXknsf3vfBDp7pXXC9Ii0Jx3RT03Tssps/LJmxgNyFu2onK7T2VLq8bhaudoyxt0C2cLxyTUAg==";
const std::string pin = Bootstrap::kBootstrapSignaturePublicKeyBase64;
EXPECT_TRUE(verifyXmrigSignature(content, sigB64, pin));
EXPECT_TRUE(verifyXmrigSignature(content, " " + sigB64 + "\n", pin)); // trailing newline tolerated
// Fails closed on a tampered checksum, a different checksum, or the wrong pinned key.
EXPECT_FALSE(verifyXmrigSignature(content + "x", sigB64, pin));
EXPECT_FALSE(verifyXmrigSignature(
"0000000000000000000000000000000000000000000000000000000000000000 DRAGONX.zip\n", sigB64, pin));
"KWFrVunRSgg5NQXLsobea8LmGHftg3yWr/S2xETpQZs9ir/UOS4D9KSnenphvz8pO9sy9cH1H+CBlKg42N3WDA==";
const std::string hot = Bootstrap::kBootstrapSignaturePublicKeysBase64[0];
const std::string cold = Bootstrap::kBootstrapSignaturePublicKeysBase64[1];
EXPECT_TRUE(verifyXmrigSignature(content, sigB64, hot));
EXPECT_TRUE(Bootstrap::signatureMatchesPinnedKey(content, sigB64));
EXPECT_TRUE(Bootstrap::signatureMatchesPinnedKey(content, sigB64 + "\n")); // as published: trailing newline
// Fails closed on a tampered checksum, a different checksum, a garbage signature, or the wrong key.
EXPECT_FALSE(Bootstrap::signatureMatchesPinnedKey(content + "x", sigB64));
EXPECT_FALSE(Bootstrap::signatureMatchesPinnedKey(
"0000000000000000000000000000000000000000000000000000000000000000 DRAGONX.zip\n", sigB64));
EXPECT_FALSE(Bootstrap::signatureMatchesPinnedKey(content, "not a signature"));
EXPECT_FALSE(Bootstrap::signatureMatchesPinnedKey(content, ""));
EXPECT_FALSE(verifyXmrigSignature(content, sigB64, cold)); // the hot key's signature is not the cold key's
EXPECT_FALSE(verifyXmrigSignature(content, sigB64, std::string(kXmrigSignaturePublicKeyBase64)));
// The pinned key must be valid base64 for a 32-byte ed25519 public key.
// The retired single key (no secret half on record) must no longer be pinned.
for (const char* k : Bootstrap::kBootstrapSignaturePublicKeysBase64)
EXPECT_TRUE(std::string(k) != "CbyBk7GAw9PFU3OEWoXdm6FfxdpIX3LMy4b4EnurJDM=");
// Two distinct pinned keys, each valid base64 for a 32-byte ed25519 public key.
EXPECT_EQ(sizeof(Bootstrap::kBootstrapSignaturePublicKeysBase64) / sizeof(const char*), static_cast<std::size_t>(2));
EXPECT_TRUE(hot != cold);
EXPECT_TRUE(sodium_init() >= 0);
unsigned char pk[crypto_sign_PUBLICKEYBYTES];
std::size_t n = 0; const char* end = nullptr;
EXPECT_EQ(sodium_base642bin(pk, sizeof(pk), pin.data(), pin.size(), " \t\r\n", &n, &end,
sodium_base64_VARIANT_ORIGINAL), 0);
EXPECT_EQ(n, static_cast<std::size_t>(crypto_sign_PUBLICKEYBYTES));
for (const char* k : Bootstrap::kBootstrapSignaturePublicKeysBase64) {
const std::string pin = k;
unsigned char pk[crypto_sign_PUBLICKEYBYTES];
std::size_t n = 0; const char* end = nullptr;
EXPECT_EQ(sodium_base642bin(pk, sizeof(pk), pin.data(), pin.size(), " \t\r\n", &n, &end,
sodium_base64_VARIANT_ORIGINAL), 0);
EXPECT_EQ(n, static_cast<std::size_t>(crypto_sign_PUBLICKEYBYTES));
}
}
// F13 — the migrate-to-seed port picker must hand out an OS-assigned free port via a real bind(), not a