Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-protocols-mv/blob/main/specs/microjob/collective-fixtures/oracle/rust-probe/src/main.rs # aien-protocols-mv Canonical specifications, wire protocols, and schemas for the AIEN sovereign ecosystem Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-protocols-mv / specs / microjob / collective-fixtures / oracle / rust-probe / src / main.rs` 87 lines ยท 3319 bytes Raw Blame History 1 // Test instrument only (not production): drives the existing Rust reference. 2 // stdin lines, hex fields separated by spaces. Output: one line per input. 3 use aien_microjob::aienet0::*; 4 use aien_microjob::{dag_digest, decode}; 5 use p256::ecdsa::SigningKey; 6 use std::io::BufRead; 7 fn hx(s: &str) -> Vec { 8 if s == "-" { 9 return vec![]; 10 } 11 (0..s.len() / 2) 12 .map(|i| u8::from_str_radix(&s[2 * i..2 * i + 2], 16).unwrap()) 13 .collect() 14 } 15 fn to(b: &[u8]) -> String { 16 b.iter().map(|x| format!("{:02x}", x)).collect() 17 } 18 fn main() { 19 for l in std::io::stdin().lock().lines() { 20 let l = l.unwrap(); 21 let f: Vec<&str> = l.split(' ').collect(); 22 match f[0] { 23 "pdec" => { 24 let p = hx(f[1]); 25 match MatmulU32::decode(&p) { 26 Ok(j) => { 27 let d = if j.in_bounds() { 28 to(&matmul_u32_digest(&j)) 29 } else { 30 String::new() 31 }; 32 println!( 33 "OK in_bounds={} work={} memory={} digest={}", 34 j.in_bounds(), 35 j.work(), 36 j.memory(), 37 d 38 ) 39 } 40 Err(e) => println!("{}", e.name()), 41 } 42 } 43 "ddec" => { 44 let d = hx(f[1]); 45 match decode(&d) { 46 Ok(_) => println!("OK dag_digest={}", to(&dag_digest(&d))), 47 Err(e) => println!("{}", e.name()), 48 } 49 } 50 // mkdoc payloadhex op noncehex submitter_keyseed now 51 "mkbundle" => { 52 let p = hx(f[1]); 53 let op: u8 = f[2].parse().unwrap(); 54 let n: [u8; 16] = hx(f[3]).try_into().unwrap(); 55 let k = SigningKey::from_slice(&[f[4].parse::().unwrap(); 32]).unwrap(); 56 let now: u64 = f[5].parse().unwrap(); 57 let doc = build_document(&p, op, n, &public_key(&k), now); 58 println!( 59 "{} {} {}", 60 to(&public_key(&k)), 61 to(&doc), 62 to(&seal_bundle(&doc, &p, &k)) 63 ); 64 } 65 // admit bundlehex pinned_keyseed now 66 "admit" => { 67 let b = hx(f[1]); 68 let k = SigningKey::from_slice(&[f[2].parse::().unwrap(); 32]).unwrap(); 69 let now: u64 = f[3].parse().unwrap(); 70 match admit_bundle(&b, &public_key(&k), now) { 71 Ok(a) => println!("OK dag_digest={}", to(&a.digest)), 72 Err(e) => println!("{}", e.name()), 73 } 74 } 75 "admitkey" => { 76 let b = hx(f[1]); 77 let pin: [u8; 33] = hx(f[2]).try_into().unwrap(); 78 let now: u64 = f[3].parse().unwrap(); 79 match admit_bundle(&b, &pin, now) { 80 Ok(a) => println!("OK dag_digest={}", to(&a.digest)), 81 Err(e) => println!("{}", e.name()), 82 } 83 } 84 _ => println!("BADCMD"), 85 } 86 } 87 }