SDKs

Client SDK

valkyr-client, the optional user mode client SDK: signed session heartbeats, build attestation and a few integrity hints, with exactly what it sends.

valkyr-client is optional. It lives inside your game client, runs in user mode, needs no admin rights and installs nothing. It gives the server three things the server cannot measure itself:

  1. A signed session. Fresh Ed25519 keys per session, rotated on a schedule, answering server nonces, so heartbeats cannot be forged or replayed.
  2. Build attestation. The hash of the game build and one root hash over the game's own files, checked against the builds you allow.
  3. Integrity hints. A debugger attached, hardware breakpoints, a preload library, wall clock jumps, the game's code section changing in memory.

The server never trusts it more than its own evidence: client signals enter as client.* flags, and a verdict built only from them is capped at review.

The handshake

The client says hello, the server answers with a challenge, the client sends a signed heartbeat, the server verifies it and reports problems. In a real game the JSON travels over your own network channel to the game server, which relays it to valkyr-server (POST /v1/sessions and POST /v1/sessions/{session_id}/heartbeat).

heartbeat.rsRust
fn main() {    let build_hash = Hex32([0x42; 32]);    let manifest_root = Hex32([0x24; 32]);     // Client side: session key and signal collector.    let mut client = ClientSession::new(ClientConfig {        build_hash,        manifest_root,        rotate_every: 2,    })    .expect("os random generator");    let mut collector = SignalCollector::new(SignalConfig::default());    let mut scheduler = Scheduler::new(Duration::from_secs(10), 25);     // 1. Client -> server: hello.    let hello_json = serde_json::to_string(&client.hello()).unwrap();    println!("hello: {hello_json}");     // Server side: accept the hello.    let hello: Hello = serde_json::from_str(&hello_json).unwrap();    let config = VerifierConfig {        allowed_builds: vec![build_hash],        expected_manifest_root: Some(manifest_root),        rotate_after: 2,        ..VerifierConfig::default()    };    let mut server = SessionVerifier::new(&hello, config, wall_ms()).expect("hello accepted");     for round in 1..=3 {        // 2. Server -> client: challenge.        let challenge_json =            serde_json::to_string(&server.issue_challenge(wall_ms()).unwrap()).unwrap();        println!("challenge {round}: {challenge_json}");         // 3. Client -> server: signed heartbeat.        let challenge: Challenge = serde_json::from_str(&challenge_json).unwrap();        client.handle_challenge(&challenge);        collector            .clock_mut()            .observe_server_time(challenge.server_time_ms);        let signals = collector.collect();        let heartbeat = client.heartbeat(signals, code_hash()).unwrap();        let heartbeat_json = serde_json::to_string(&heartbeat).unwrap();        println!("heartbeat {round}: {heartbeat_json}");         // 4. Server verifies.        let heartbeat: Heartbeat = serde_json::from_str(&heartbeat_json).unwrap();        let report: HeartbeatReport = server.verify(&heartbeat, wall_ms());        println!(            "report {round}: {}",            serde_json::to_string(&report).unwrap()        );        for p in &report.problems {            println!("  problem: {p}");        }        println!(            "  next check in {:?} (a real game would wait)",            scheduler.next_delay()        );    }     // A replayed heartbeat is refused.    let challenge = server.issue_challenge(wall_ms()).unwrap();    client.handle_challenge(&challenge);    let hb = client.heartbeat(collector.collect(), None).unwrap();    assert!(server.verify(&hb, wall_ms()).ok);    let replay = server.verify(&hb, wall_ms());    println!("replay: ok={} problems={:?}", replay.ok, replay.problems);}

Run it with cargo run -p valkyr-client --example heartbeat.

Exactly what is sent

This table is part of the crate documentation and is included here as written:

valkyr-client/src/lib.rsText
game enables them in [`signals::SignalConfig`]. | Field | Default | What is sent ||---|---|---|| `client_key`, `next_key` | always | random ed25519 public keys, fresh per session, not tied to the machine or the user || `build_hash` | always | SHA-256 of the game build, chosen by the game || `manifest_root` | always | one SHA-256 over the game's own listed files (paths, sizes, hashes stay local) || `code_hash` | when the game passes it | SHA-256 of the game's own in memory code section || `client_time_ms`, `monotonic_ms` | always | wall clock and time since session start || `signals.debugger` | on | one state: a debugger is attached to the game process || `signals.hardware_breakpoints` | on | one state: debug registers set on the collecting thread || `signals.timing_anomaly` | on | one state from timing a fixed workload || `signals.hypervisor` | on | one state from CPUID, a hint only, never treated as cheating || `signals.preload_env` | on | one state: `LD_PRELOAD` / `DYLD_INSERT_LIBRARIES` is set for the game; the value is not sent || `signals.unexpected_modules` | **opt in** | a count and the SHA-256 of each unexpected module *file name*; never paths, never the allowed modules || `signals.overlay_windows` | **opt in** | for each window covering the game: SHA-256 of a per session random salt plus the title (the title itself is never sent and cannot be correlated across sessions), and four flags (topmost, layered, click through, same process) || `signals.clock` | on | one state, a count of wall clock jumps, the largest jump, and the client to server speed ratio || `signals.code_drift` | on | one state: the game's code section changed since startup | Nothing else is collected: no hardware identifiers, no user names, noprocess lists, no file lists outside the manifest, no screenshots.

Nothing else is collected: no hardware identifiers, no user names, no process lists, no file lists outside the manifest, no screenshots. See Privacy.

Session settings

OptionTypeDefaultDescription
client.allowed_buildsVec<Hex32>[]Allowed build hashes (hex). Empty accepts any build.
client.expected_manifest_rootOption<Hex32>unsetExpected manifest root (hex).
client.max_gap_msu6430000Maximum time between two heartbeats.
client.rotate_afteru640Required key rotation period in heartbeats (0: none).
client.clock_tolerance_msu642000Allowed wall against monotonic clock drift between heartbeats.
client.speed_window_msu6430000Server time span before the clock speed ratio is judged.
client.speed_tolerance_ppmu64100000Allowed speed ratio deviation, parts per million.
client.max_outstanding_noncesusize4Outstanding nonces per session.
client.nonce_ttl_msu6460000Maximum nonce age.

Generated from crates/valkyr-server/src/config.rs (ClientSection) at build time.

From other languages

The C ABI exposes the same client session (valkyr_client_new, valkyr_client_hello_json, valkyr_client_handle_challenge_json, valkyr_client_heartbeat_json) and the manifest helpers. See the C, C++ and C# pages.

Edit this page on GitHub