From 48b24acc2fdc0d6d0731459c95ecd3c3bdf94f48 Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Mon, 26 Oct 2026 17:29:59 +0800 Subject: [PATCH] fix(release): derive the public key from either key file A raw ed25519 private key is 32 bytes and so is its public half, so 'pubkey KEY_FILE' could not tell them apart and printed the private bytes as a public key. Baking those into a build produces a key no signature can verify against, and build.rs accepts any 64 hex characters, so the mistake is silent at build time and shows up on a user's machine as an update check that cannot verify the manifest. Anything not named *.pub is now read as the private key it came from and expanded, so both documented spellings of the command yield the same key. --- scripts/release-key.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/release-key.py b/scripts/release-key.py index b0e3ebf..d8051cd 100755 --- a/scripts/release-key.py +++ b/scripts/release-key.py @@ -28,7 +28,19 @@ USAGE = __doc__ def public_hex(path): - key = Ed25519PublicKey.from_public_bytes(path.read_bytes()) + """Hex of the public half of a key file, whichever half was handed over. + + A raw ed25519 private key is 32 bytes and so is its public half, so the two + cannot be told apart by content. Baking the private bytes as if they were a + public key produces a key no signature ever verifies against, and the build + accepts it without complaint, so the mistake only surfaces on a user's + machine as "this build cannot verify the manifest". Anything not named + ``*.pub`` is therefore read as the private key it came from and expanded. + """ + if path.suffix == ".pub": + key = Ed25519PublicKey.from_public_bytes(path.read_bytes()) + else: + key = Ed25519PrivateKey.from_private_bytes(path.read_bytes()).public_key() return key.public_bytes( serialization.Encoding.Raw, serialization.PublicFormat.Raw ).hex()