{"record":{"id":"a9e64c603dd2ef05","repo":"nikivdev/code","slug":"invalid-base58-sealer-secret-e","errorCode":null,"errorMessage":"invalid base58 sealer secret: {e}","messagePattern":"invalid base58 sealer secret: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sealer_crypto.rs","lineNumber":27,"sourceCode":"\nconst SECRET_PREFIX: &str = \"sealerSecret_z\";\nconst ID_PREFIX: &str = \"sealer_z\";\n\npub fn new_x25519_private_key() -> Vec<u8> {\n    let mut bytes = [0u8; 32];\n    SysRng\n        .try_fill_bytes(&mut bytes)\n        .expect(\"system RNG should provide x25519 key material\");\n    bytes.to_vec()\n}\n\npub fn get_sealer_id(secret: &str) -> Result<String> {\n    let secret_raw = secret\n        .strip_prefix(SECRET_PREFIX)\n        .ok_or_else(|| anyhow::anyhow!(\"invalid sealer secret prefix\"))?;\n    let private_bytes = bs58::decode(secret_raw)\n        .into_vec()\n        .map_err(|e| anyhow::anyhow!(\"invalid base58 sealer secret: {e}\"))?;\n    let bytes: [u8; 32] = private_bytes\n        .as_slice()\n        .try_into()\n        .map_err(|_| anyhow::anyhow!(\"invalid sealer secret length\"))?;\n\n    let public = PublicKey::from(&StaticSecret::from(bytes)).to_bytes();\n    Ok(format!(\n        \"{}{}\",\n        ID_PREFIX,\n        bs58::encode(public).into_string()\n    ))\n}\n\npub fn seal(\n    message: &[u8],\n    sender_secret: &str,\n    recipient_id: &str,\n    nonce_material: &[u8],","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/sealer_crypto.rs#L9-L45","documentation":"After stripping the \"sealerSecret_z\" prefix, get_sealer_id base58-decodes the remainder. If bs58::decode fails (characters outside the base58 alphabet, whitespace, or mixed-alphabet input) this error wraps the decoder's message. The prefix was right but the encoded key material is corrupt.","triggerScenarios":"Calling get_sealer_id with a secret whose base58 body contains invalid characters (0, O, I, l, spaces, newlines, quotes) or was truncated/modified after the prefix.","commonSituations":"Copy-paste mangling (line breaks inserted, lookalike characters typed), storing the secret through a system that uppercased it, or manual transcription of the key.","solutions":["Re-copy the secret carefully ensuring only base58 characters (no 0/O/I/l) follow the prefix.","Trim whitespace/newlines from the value before passing it in.","Regenerate the sealer identity if the original secret cannot be recovered.","Validate the secret format with a pre-check: starts with \"sealerSecret_z\" and the rest is valid base58."],"exampleFix":"// before\nlet s = \"sealerSecret_z5Kd3NB0Ad2...\"; // contains '0' (invalid in base58)\n// after\nlet s = \"sealerSecret_z5Kd3NBOAd2...\"; // corrected character, or re-copy from source","handlingStrategy":"validation","validationCode":"fn secret_body_is_base58(s: &str) -> bool {\n    match s.strip_prefix(\"sealerSecret_z\") {\n        Some(body) => !body.is_empty()\n            && body.bytes().all(|b| bs58_alphabet_contains(b)),\n        None => false,\n    }\n}\n// simpler pre-check: no 0, O, I, l, whitespace, or punctuation in the body","typeGuard":null,"tryCatchPattern":"match get_sealer_id(secret) {\n    Err(e) if e.to_string().starts_with(\"invalid base58 sealer secret\") => {\n        eprintln!(\"secret body is not valid base58; re-copy the value without modifications\");\n        // surface e for the exact decode failure\n    }\n    other => other?,\n}","preventionTips":["Copy secrets through tools that preserve exact bytes (pbcopy from a file, not retyping).","Never uppercase/lowercase or trim-inside secret strings.","Avoid pasting secrets through editors or terminals that insert line wraps.","Round-trip validate: decode then re-encode and compare strings."],"tags":["crypto","base58","encoding","parsing"],"backgroundTag":"invalid-base58-encoding","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}