{"record":{"id":"516a830f3f653616","repo":"Pumpkin-MC/Pumpkin","slug":"invalid-public-key-bytes-0","errorCode":null,"errorMessage":"Invalid public key bytes: {0}","messagePattern":"Invalid public key bytes: (.+?)","errorType":"error_code","errorClass":"TelemetryVerificationError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin/src/telemetry.rs","lineNumber":129,"sourceCode":"    let signed_data = compute_signed_data(timestamp_str, body_bytes);\n    let signature = signing_key.sign(&signed_data);\n    let pubkey_hex = hex::encode(signing_key.verifying_key().to_bytes());\n    let sig_hex = hex::encode(signature.to_bytes());\n    (pubkey_hex, sig_hex)\n}\n\n/// Errors that can occur during telemetry request signature verification.\n#[derive(Debug, thiserror::Error, PartialEq, Eq)]\npub enum TelemetryVerificationError {\n    #[error(\"Invalid timestamp string format\")]\n    InvalidTimestamp,\n    #[error(\n        \"Timestamp drift exceeded: drift was {drift}s (max allowed is {MAX_CLOCK_DRIFT_SECS}s)\"\n    )]\n    ClockDriftExceeded { drift: u64 },\n    #[error(\"Invalid public key hex encoding\")]\n    InvalidPublicKeyHex,\n    #[error(\"Invalid public key bytes: {0}\")]\n    InvalidPublicKey(String),\n    #[error(\"Invalid signature hex encoding\")]\n    InvalidSignatureHex,\n    #[error(\"Invalid signature bytes: {0}\")]\n    InvalidSignature(String),\n    #[error(\"Signature verification failed: {0}\")]\n    VerificationFailed(String),\n}\n\n/// Verifies a signed telemetry request against an Ed25519 public key and timestamp.\n///\n/// Ensures clock drift between `current_time_secs` and `timestamp_str` does not exceed `±300` seconds.\npub fn verify_telemetry_request(\n    pubkey_hex: &str,\n    sig_hex: &str,\n    timestamp_str: &str,\n    body_bytes: &[u8],\n    current_time_secs: u64,","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin/src/telemetry.rs#L111-L147","documentation":"TelemetryVerificationError::InvalidPublicKey(String), produced when the hex-decoded public key bytes cannot be converted into a valid Ed25519 public key (e.g. via VerifyingKey::from_bytes). Hex encoding was fine but the resulting 32 bytes are not a valid key or have the wrong length.","triggerScenarios":"Calling telemetry::verify with a hex string that decodes to something other than 32 bytes, or bytes rejected by the Ed25519 key constructor (wrong-length key material, e.g. 64-byte raw key or a private key blob).","commonSituations":"Passing an Ed25519 private key or a 64-byte sign/verify keypair blob instead of the 32-byte public key; pasting an RSA or X25519 key; truncated hex string.","solutions":["Pass the 32-byte Ed25519 public key (64 hex chars), not the private key or keypair","Check the decoded byte length is exactly 32 before calling verify","Regenerate the key pair with the same Ed25519 library and export the verifying/public key"],"exampleFix":"// before\nlet key = hex::encode(secret_key.to_bytes()); // 64 bytes -> 128 hex chars\n// after\nlet key = hex::encode(secret_key.verifying_key().to_bytes()); // 32 bytes -> 64 hex chars","handlingStrategy":"validation","validationCode":"let bytes = hex::decode(key)?;\nif bytes.len() != 32 { return Err(format!(\"public key must be 32 bytes, got {}\", bytes.len())); }","typeGuard":"fn valid_pubkey_bytes(key_hex: &str) -> bool {\n    hex::decode(key_hex).map(|b| b.len() == 32).unwrap_or(false)\n}","tryCatchPattern":"match telemetry::verify(&key, &sig, &msg, now) {\n    Err(TelemetryVerificationError::InvalidPublicKey(m)) => log::error!(\"bad public key: {m}\"),\n    Ok(()) => { /* proceed */ }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Export keys with the verifying/public half, never the secret key","Assert decoded key length == 32 in tests","Label key material in config so the wrong half isn't pasted in"],"tags":["rust","ed25519","key-length","telemetry"],"backgroundTag":"invalid-argument-value","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}