Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

Release signing key in the app (kUpdatePublicKeyHex, Tony 11-05); test: 64 hex, a curve point, signatures only under their key

islandmed90a04bf8462d
diff --git a/changes/feat-one-click-update.md b/changes/feat-one-click-update.md
index 40b62649..6983ab16 100644
--- a/changes/feat-one-click-update.md
+++ b/changes/feat-one-click-update.md
@@ -32,6 +32,6 @@ testers:
shows your login; Check for updates offers the newest member build; Sign out, restart: still signed out.
- Flatpak or .deb install: the banner says to update with the package manager instead of showing Update.
---
-The Update button stays hidden until the release signing key exists (kUpdatePublicKeyHex in
-src/core/SelfUpdate.h and the UPDATE_SIGNING_KEY secret; steps in REPORT.md). Tester checks need a signed release
+The release signing key exists (11-05; kUpdatePublicKeyHex in
+src/core/SelfUpdate.h, secret UPDATE_SIGNING_KEY). Tester checks need a signed release
newer than the build under test.
diff --git a/src/core/Ed25519.cpp b/src/core/Ed25519.cpp
index 778677b1..98192adc 100644
--- a/src/core/Ed25519.cpp
+++ b/src/core/Ed25519.cpp
@@ -289,6 +289,11 @@ void sha512(const void* data, size_t size, uint8_t out[64]) {
for (int k = 0; k < 8; ++k) out[w * 8 + k] = uint8_t(h[w] >> (56 - 8 * k));
}
+bool ed25519PublicKeyValid(const uint8_t publicKey[32]) {
+ gf q[4];
+ return unpackNegated(q, publicKey);
+}
+
bool ed25519Verify(const uint8_t signature[64], const void* message, size_t size, const uint8_t publicKey[32]) {
gf p[4], q[4];
if (!belowOrder(signature + 32) || !unpackNegated(q, publicKey)) return false;
diff --git a/src/core/Ed25519.h b/src/core/Ed25519.h
index 09f0f1d1..4a276a7d 100644
--- a/src/core/Ed25519.h
+++ b/src/core/Ed25519.h
@@ -15,6 +15,9 @@ namespace sf {
void sha512(const void* data, size_t size, uint8_t out[64]);
// True when `signature` (R || S, 64 bytes) signs `message` under `publicKey` (32 bytes).
+// True when `publicKey` encodes a point on the curve (a key a signature could ever check out under).
+bool ed25519PublicKeyValid(const uint8_t publicKey[32]);
+
bool ed25519Verify(const uint8_t signature[64], const void* message, size_t size, const uint8_t publicKey[32]);
} // namespace sf
diff --git a/src/core/SelfUpdate.h b/src/core/SelfUpdate.h
index 61f12851..ed99b02f 100644
--- a/src/core/SelfUpdate.h
+++ b/src/core/SelfUpdate.h
@@ -28,10 +28,10 @@ inline constexpr uint64_t kMaxPackageBytes = uint64_t(1) << 30; // 1 GiB (an App
inline constexpr size_t kMaxSumsBytes = 256 * 1024;
inline constexpr int kMaxUnconfirmedStarts = 3; // a new version that never got going this often is rolled back
-// The public half of the release signing key (Ed25519, 32 bytes as hex). Empty: no key yet, and the Update button
-// stays off (the banner's Download link still works). The private half is the repository secret UPDATE_SIGNING_KEY,
+// The public half of the release signing key (Ed25519, 32 bytes as hex; created 11-05). Empty would mean no key: the
+// Update button off (the banner's Download link still works). The private half is the repository secret UPDATE_SIGNING_KEY,
// used only by .github/workflows/release.yml.
-inline constexpr const char* kUpdatePublicKeyHex = "";
+inline constexpr const char* kUpdatePublicKeyHex = "f6f8f8e9e02123a759a974bffaa07db8ebaa0c70ba746a0a86c644eba6a68642";
// --- Where files may come from ---
diff --git a/tests/release_beta_test.sh b/tests/release_beta_test.sh
index 747c6790..3f0282c5 100755
--- a/tests/release_beta_test.sh
+++ b/tests/release_beta_test.sh
@@ -57,7 +57,7 @@ cat > "$S/bin/gh" <<EOF
#!/usr/bin/env bash
case "\$*" in
"auth status"*) echo "Logged in to github.com account islandmed" ;;
- "release view"*) echo SHA256SUMS.txt ;;
+ "release view"*) printf 'SHA256SUMS.txt\nSHA256SUMS.txt.sig\n' ;; # (signed: the app has an update key)
"release download"*) exit 1 ;;
*homebrew-tap*) printf ' version "0.10.10"\n' | base64 ;;
"pr view 1800"*) echo "OPEN islandmed sculptforge-bump" ;;
diff --git a/tests/test_self_update.cpp b/tests/test_self_update.cpp
index 28e96009..bb6323f8 100644
--- a/tests/test_self_update.cpp
+++ b/tests/test_self_update.cpp
@@ -13,6 +13,7 @@
#include "core/Sha256.h"
#include <algorithm>
+#include <cstring>
#include <filesystem>
#include <fstream>
#include <iterator>
@@ -403,9 +404,24 @@ TEST(self_update_refuses_bad_releases) {
Download d;
download(s, f, d);
CHECK(f.asked.size() == 2);
- // No key compiled in yet: the release key's constant parses (once set) or is empty (Update button off).
- uint8_t k[32];
- CHECK(std::string(kUpdatePublicKeyHex).empty() || parseHexKey(kUpdatePublicKeyHex, k));
+}
+
+// The release key compiled into the app (Tony's, 11-05): 64 hex characters, a point on the curve, and the verifier
+// accepts what is signed under a key and only that key (the sign side with the throwaway test key: the release's
+// private half never leaves the UPDATE_SIGNING_KEY secret).
+TEST(self_update_release_key) {
+ const std::string hex = kUpdatePublicKeyHex;
+ CHECK(hex.size() == 64);
+ CHECK(std::all_of(hex.begin(), hex.end(), [](char c) { return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f'); }));
+ uint8_t release[32], test[32];
+ CHECK(parseHexKey(hex, release) && ed25519PublicKeyValid(release));
+ CHECK(parseHexKey(kTestKey, test) && ed25519PublicKeyValid(test));
+ const std::string sig = unhex(kSumsSig);
+ CHECK(sumsSignatureValid(kSums, sig, test)); // signed with a key: accepted under it
+ CHECK(!sumsSignatureValid(kSums, sig, release)); // and under no other, the release key included
+ // A key that is no curve point is refused: y = 2 has no x on the curve ((y^2 - 1) / (d y^2 + 1) is no square).
+ uint8_t bogus[32] = {2};
+ CHECK(!ed25519PublicKeyValid(bogus) && !sumsSignatureValid(kSums, sig, bogus));
}
TEST(self_update_cancel_and_tamper) {