@@ -5,8 +5,9 @@ use std::time::Duration; |
5 | 5 |
|
6 | 6 | use keystore::{default_wallets_dir, load_hotkey, mini_secret_from_key_file, BittensorWallet}; |
7 | 7 | use proof_submit::{ |
8 | | - fresh_submit_nonce_hex, hotkey_hex, manifest_lists, parse_hotkey_hex, parse_signature_hex, |
9 | | - parse_submit_nonce_hex, sign_submit, verify_submit, SubmitFields, PROOF_SUBMIT_DOMAIN_LABEL, |
| 8 | + canonical_hex, fresh_submit_nonce_hex, hotkey_hex, is_lowercase_hex, manifest_lists, |
| 9 | + parse_hotkey_hex, parse_signature_hex, parse_submit_nonce_hex, sign_submit, verify_submit, |
| 10 | + SubmitFields, PROOF_SUBMIT_DOMAIN_LABEL, |
10 | 11 | }; |
11 | 12 | use serde_json::{json, Value}; |
12 | 13 |
|
@@ -185,7 +186,7 @@ fn resolve_signed( |
185 | 186 | .map_err(|_| "manifest lists must be arrays of strings".to_owned())?; |
186 | 187 | let nonce = match &input.key.submit_nonce { |
187 | 188 | Some(raw) => { |
188 | | - let n = raw.trim().to_ascii_lowercase(); |
| 189 | + let n = canonical_hex(raw); |
189 | 190 | parse_submit_nonce_hex(&n).map_err(|_| "submit-nonce must be 64 hex characters")?; |
190 | 191 | n |
191 | 192 | } |
@@ -243,7 +244,7 @@ fn resolve_hotkey_and_sig( |
243 | 244 | "hotkey", |
244 | 245 | )?; |
245 | 246 | let pk = parse_hotkey_hex(&hotkey).map_err(|e| e.to_string())?; |
246 | | - let sig_hex = hex_sig.trim().trim_start_matches("0x").to_ascii_lowercase(); |
| 247 | + let sig_hex = canonical_hex(hex_sig); |
247 | 248 | let sig = |
248 | 249 | parse_signature_hex(&sig_hex).map_err(|_| "hotkey_signature invalid".to_owned())?; |
249 | 250 | let fields = SubmitFields { |
@@ -436,12 +437,14 @@ fn ensure_declared(manifest: &Value) -> Result<(), String> { |
436 | 437 | Ok(()) |
437 | 438 | } |
438 | 439 |
|
| 440 | +/// The one wire form of a 64-hex field, produced by the same `proof-submit` |
| 441 | +/// canonicaliser the host's parser accepts — `ctx` never spells hex itself. |
439 | 442 | fn normalize_hex64(s: &str, field: &str) -> Result<String, String> { |
440 | | - let t = s.trim().trim_start_matches("0x"); |
441 | | - if t.len() != 64 || !t.chars().all(|c| c.is_ascii_hexdigit()) { |
| 443 | + let canonical = canonical_hex(s); |
| 444 | + if !is_lowercase_hex(&canonical, 64) { |
442 | 445 | return Err(format!("{field} must be 64 hex characters")); |
443 | 446 | } |
444 | | - Ok(t.to_ascii_lowercase()) |
| 447 | + Ok(canonical) |
445 | 448 | } |
446 | 449 |
|
447 | 450 | fn print_fields(body: &Value) { |
|