From c6c8ddb7e4117628549afdb382b0d46f830f242d Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 8 Nov 2026 03:36:26 +0100 Subject: crash: show and verify the revealed seed in the TUI and GUI The crash board gained a fairness line: the short commit while the round runs, then the short seed marked verified when sha256(seed) and the recomputed crash point both match. The terminal board grew from six to seven lines and the GUI sidebar shows the same values. --- gui/src/crash.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'gui/src/crash.rs') diff --git a/gui/src/crash.rs b/gui/src/crash.rs index 08113a8..a73c3bd 100644 --- a/gui/src/crash.rs +++ b/gui/src/crash.rs @@ -2,9 +2,18 @@ use eframe::egui::{Align2, Color32, Pos2, Rect, Sense, Shape, Stroke, StrokeKind, Ui, pos2, vec2}; use zagan_bet::client::view::{Command, CrashView}; +use zagan_bet::crash::{crash_point_from_seed, seed_from_hex, verify_seed}; use crate::{theme, widgets}; +fn short_hash(hash: &str) -> String { + hash.char_indices() + .nth(12) + .map(|(index, _)| &hash[..index]) + .unwrap_or(hash) + .to_string() +} + /// One sample of the running curve. struct Sample { seconds: f32, @@ -136,6 +145,31 @@ fn sidebar(ui: &mut Ui, view: &CrashView, fx: &mut Fx) -> Option { theme::GOLD, ); + if let Some(commit) = &view.commit { + widgets::row(ui, "Commit", &short_hash(commit), theme::TEXT_FAINT); + } + if let Some(seed) = &view.seed { + let commit_ok = view + .commit + .as_deref() + .map(|commit| verify_seed(seed, commit)) + .unwrap_or(false); + let point_ok = seed_from_hex(seed) + .map(|bytes| { + view.crash_point + .map(|point| { + (crash_point_from_seed(&bytes) - point).abs() < 1e-9 + }) + .unwrap_or(false) + }) + .unwrap_or(false); + if commit_ok && point_ok { + widgets::row(ui, "Seed ✓", &short_hash(seed), theme::WIN); + } else { + widgets::row(ui, "Seed ✗", &short_hash(seed), theme::LOSS); + } + } + ui.add_space(theme::SPACE_3); status(ui, view); -- cgit v1.2.3