SDK
クライアント SDK
任意のユーザーモードのクライアント SDK である valkyr-client。署名付きのセッションハートビート、ビルドの証明、いくつかの整合性ヒントと、送信内容のすべて。
valkyr-client は任意です。ゲームクライアントの中に組み込まれ、ユーザーモードで動き、管理者権限を必要とせず、何もインストールしません。サーバーが自分では測定できない 3 つのものをサーバーに提供します。
- 署名付きのセッション。 セッションごとに新しい Ed25519 鍵を使い、スケジュールに従ってローテーションし、サーバーのノンスに応答するので、ハートビートを偽造したり再送したりできません。
- ビルドの証明。 ゲームのビルドのハッシュと、ゲーム自身のファイル全体に対する 1 つのルートハッシュを、許可したビルドと照合します。
- 整合性のヒント。 デバッガーのアタッチ、ハードウェアブレークポイント、プリロードされたライブラリ、実時間の時計の飛び、メモリ上でのゲームのコードセクションの変化。
サーバーがこれをサーバー自身の証拠以上に信頼することはありません。クライアントの信号は client.* フラグとして入り、それだけで組み立てた判定は review 止まりです。
ハンドシェイク
クライアントが hello を送り、サーバーがチャレンジで応え、クライアントが署名付きハートビートを送り、サーバーがそれを検証して問題を報告します。実際のゲームでは、JSON はあなた自身のネットワーク経路でゲームサーバーに届き、ゲームサーバーがそれを valkyr-server に中継します (POST /v1/ と 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);}
cargo run -p valkyr-client --example heartbeat で実行できます。
送信される内容のすべて
この表はクレートのドキュメントの一部で、記述どおりにここへ取り込んでいます。
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.
これ以外は何も収集しません。ハードウェア識別子、ユーザー名、プロセスの一覧、マニフェスト外のファイルの一覧、スクリーンショットは収集しません。プライバシーをご覧ください。
セッションの設定
| オプション | 型 | 既定値 | 説明 |
|---|---|---|---|
client. | Vec<Hex32> | [] | Allowed build hashes (hex). Empty accepts any build. |
client. | Option<Hex32> | 未設定 | 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. |
ビルド時に crates/
他の言語から
C ABI は同じクライアントセッション (valkyr_、valkyr_、valkyr_、valkyr_) とマニフェストのヘルパーを公開しています。C、C++、C# のページをご覧ください。