{"record":{"id":"d72964e7d12e9425","repo":"nautechsystems/nautilus_trader","slug":"binance-spot-sbe-market-data-streams-require-an-ed","errorCode":null,"errorMessage":"Binance Spot SBE market-data streams require an Ed25519 API key (HMAC keys are not supported): {e}","messagePattern":"Binance Spot SBE market-data streams require an Ed25519 API key \\(HMAC keys are not supported\\): (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/websocket/streams/client.rs","lineNumber":143,"sourceCode":"    /// # Errors\n    ///\n    /// Returns an error if credential creation fails.\n    pub fn new(\n        url: Option<String>,\n        api_key: Option<String>,\n        api_secret: Option<String>,\n        heartbeat: Option<u64>,\n        transport_backend: TransportBackend,\n    ) -> anyhow::Result<Self> {\n        let url = url.unwrap_or(BINANCE_SPOT_SBE_WS_URL.to_string());\n\n        let credential = match (\n            api_key.map(SecretString::from),\n            api_secret.map(SecretString::from),\n        ) {\n            (Some(key), Some(secret)) => {\n                let credential = Ed25519Credential::new(key, secret).map_err(|e| {\n                    anyhow::anyhow!(\n                        \"Binance Spot SBE market-data streams require an Ed25519 API key \\\n                         (HMAC keys are not supported): {e}\"\n                    )\n                })?;\n                Some(Arc::new(credential))\n            }\n            _ => None,\n        };\n\n        Ok(Self {\n            url,\n            credential,\n            heartbeat,\n            signal: Arc::new(AtomicBool::new(false)),\n            slots: Arc::new(ConnectionSlots(Mutex::new(Vec::new()))),\n            connect_lock: Arc::new(tokio::sync::Mutex::new(())),\n            out_tx: Arc::new(Mutex::new(None)),\n            out_rx: Arc::new(Mutex::new(None)),","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/websocket/streams/client.rs#L125-L161","documentation":"The Binance Spot SBE market-data WebSocket client was constructed without Ed25519-compatible credentials. SBE streams require an Ed25519 API key; an HMAC (secret-key) credential or otherwise malformed key material caused `Ed25519Credential::new` to fail, and the underlying error is surfaced via `{e}`.","triggerScenarios":"Calling `client.new(...)` on the Spot SBE stream client with an HMAC-style API key/secret pair, an empty key, or invalid key material; `Ed25519Credential::new(key, secret)` returns `Err`.","commonSituations":"Users reusing their classic HMAC Binance API key with the newer SBE endpoint; keys created without Ed25519 signing enabled; a typo'd or truncated key pasted into config.","solutions":["Create an Ed25519-type API key on Binance (in the API management page choose Ed25519, not HMAC) and supply its public key as the api key and its private key as the secret.","Verify the private key is a valid PEM/base64 Ed25519 key with no trailing whitespace or newlines.","Check the underlying `{e}` message; if it says the key format is invalid, re-encode the key (e.g. ensure PEM headers/footers).","If you cannot use Ed25519 keys, use the non-SBE (JSON) market-data streams, which accept HMAC keys."],"exampleFix":"// before: HMAC key\napi_key = \"my_hmac_key\"; api_secret = \"my_hmac_secret\";\n// after: Ed25519 key created on Binance\napi_key = \"<ed25519 public key (base64)>\"; api_secret = \"<ed25519 private key (PEM)>\";","handlingStrategy":"validation","validationCode":"fn require_ed25519_key(api_key: &str, api_secret: &str) -> Result<(), String> {\n    if api_key.is_empty() || api_secret.is_empty() {\n        return Err(\"api key/secret must not be empty\".into());\n    }\n    // Ed25519 private keys are PEM or base64 DER, not HMAC hex secrets\n    if api_secret.chars().all(|c| c.is_ascii_hexdigit()) {\n        return Err(\"secret looks like an HMAC key; SBE streams require an Ed25519 key\".into());\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match Ed25519Credential::new(key, secret) {\n    Ok(c) => Ok(Some(Arc::new(c))),\n    Err(e) => Err(anyhow::anyhow!(\n        \"Binance Spot SBE market-data streams require an Ed25519 API key (HMAC keys are not supported): {e}\"\n    )),\n}","preventionTips":["Create Ed25519-type API keys on Binance for SBE market data; never reuse HMAC keys.","Store keys without trailing whitespace/newlines.","Validate credential type at startup, before opening streams."],"tags":["authentication","ed25519","api-key","binance","websocket"],"backgroundTag":"invalid-api-key","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}