SDKs
SDK de cliente
valkyr-client, o SDK de cliente opcional em modo usuário: heartbeats de sessão assinados, atestado do build e alguns indícios de integridade.
O valkyr-client é opcional. Ele fica dentro do cliente do seu jogo, roda em modo usuário, não precisa de privilégios de administrador e não instala nada. Ele entrega ao servidor três coisas que o servidor não consegue medir sozinho:
- Uma sessão assinada. Chaves Ed25519 novas a cada sessão, trocadas periodicamente, respondendo a nonces do servidor, para que os heartbeats não possam ser forjados nem reenviados.
- Atestado do build. O hash do build do jogo e um hash raiz sobre os arquivos do próprio jogo, conferidos contra os builds que você permite.
- Indícios de integridade. Um debugger conectado, breakpoints de hardware, uma biblioteca pré-carregada, saltos no relógio do sistema, a seção de código do jogo mudando na memória.
O servidor nunca confia nele mais do que nas próprias evidências: sinais do cliente entram como flags client.*, e um veredito construído só com eles fica limitado a review.
O handshake
O cliente diz olá, o servidor responde com um desafio, o cliente envia um heartbeat assinado, o servidor verifica e reporta problemas. Em um jogo real, o JSON viaja pelo seu próprio canal de rede até o servidor de jogo, que repassa para o valkyr-server (POST /v1/ e POST /v1/).
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);}
Rode com cargo run -p valkyr-client --example heartbeat.
Exatamente o que é enviado
Esta tabela faz parte da documentação da crate e aparece aqui como foi escrita:
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.
Nada mais é coletado: nenhum identificador de hardware, nenhum nome de usuário, nenhuma lista de processos, nenhuma lista de arquivos fora do manifesto, nenhuma captura de tela. Veja Privacidade.
Configurações de sessão
| Opção | Tipo | Padrão | Descrição |
|---|---|---|---|
client. | Vec<Hex32> | [] | Allowed build hashes (hex). Empty accepts any build. |
client. | Option<Hex32> | não definido | Expected manifest root (hex). |
client. | u64 | 30000 | Maximum time between two heartbeats. |
client. | u64 | 0 | Required key rotation period in heartbeats (0: none). |
client. | u64 | 2000 | Allowed wall against monotonic clock drift between heartbeats. |
client. | u64 | 30000 | Server time span before the clock speed ratio is judged. |
client. | u64 | 100000 | Allowed speed ratio deviation, parts per million. |
client. | usize | 4 | Outstanding nonces per session. |
client. | u64 | 60000 | Maximum nonce age. |
Gerado a partir de crates/
A partir de outras linguagens
A C ABI expõe a mesma sessão de cliente (valkyr_, valkyr_, valkyr_, valkyr_) e os auxiliares de manifesto. Veja as páginas de C, C++ e C#.