chore(workspace): Rust workspace R0 — builder image, core crate (JS-compatible JSON, report contracts, facade), wasm facade, core-wasm package with proofs
This commit is contained in:
1 parent
5fec0654d3
commit
2a38fa37b5
39 files changed
+1913
-1
No files matched your search
@@ -0,0 +1,43 @@
|
||||
//! wasm-bindgen facade over `faunosteo-core` (review III.3): JSON strings in and out, closed
|
||||
//! outcome kinds. Built by `docker/wasm-build.sh` into `packages/core-wasm/pkg`; loaded
|
||||
//! lazily by the application from R2 on (never at R0).
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
/// Version of the core compiled into this module.
|
||||
#[wasm_bindgen]
|
||||
pub fn core_version() -> String {
|
||||
faunosteo_core::CORE_VERSION.to_owned()
|
||||
}
|
||||
|
||||
/// Runs one core operation: `op` names it, `input` is its JSON text, the result is the
|
||||
/// JSON text of the outcome envelope (`{"ok":true,"value":…}` or `{"ok":false,"kind":…}`).
|
||||
#[wasm_bindgen]
|
||||
pub fn call(op: &str, input: &str) -> String {
|
||||
faunosteo_core::facade::call(op, input)
|
||||
}
|
||||
|
||||
/// R0 proof: on wasm32 a panic is a trap (panic = abort), reaching JavaScript as a
|
||||
/// `WebAssembly.RuntimeError`; the caller re-instantiates the module.
|
||||
#[wasm_bindgen]
|
||||
pub fn panic_for_test() {
|
||||
panic!("deliberate panic for the R0 proof");
|
||||
}
|
||||
|
||||
/// R0 proof: exhausting the shadow stack traps instead of corrupting memory.
|
||||
#[wasm_bindgen]
|
||||
pub fn recurse_for_test(depth: u32) -> u32 {
|
||||
recurse(depth)
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn recurse(depth: u32) -> u32 {
|
||||
let mut frame = [depth; 32];
|
||||
if depth == 0 {
|
||||
return std::hint::black_box(&frame)[0];
|
||||
}
|
||||
let below = recurse(depth - 1);
|
||||
frame[(below as usize) % 32] ^= below;
|
||||
std::hint::black_box(&frame);
|
||||
below.wrapping_add(1)
|
||||
}
|
||||
Reference in new issue
Block a user