From 4e4c885a65bf707d1db09c56d354b2aa6a90e839 Mon Sep 17 00:00:00 2001 From: Kamen Mladenov Date: Mon, 3 Feb 2025 17:42:10 +0200 Subject: feat(zkvms/zkwasm): Implement proper handling of public and private inputs --- zkvms/zkwasm/guest/src/lib.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'zkvms/zkwasm/guest/src') diff --git a/zkvms/zkwasm/guest/src/lib.rs b/zkvms/zkwasm/guest/src/lib.rs index 5c00fc0..eba34b0 100644 --- a/zkvms/zkwasm/guest/src/lib.rs +++ b/zkvms/zkwasm/guest/src/lib.rs @@ -7,6 +7,10 @@ fn read_private() -> u64 { unsafe { wasm_input(0) } } +fn read_public() -> u64 { + unsafe { wasm_input(1) } +} + fn assert(cond: bool) { unsafe { require(cond); } } @@ -19,11 +23,11 @@ static VERTICES: u64 = 10; macro_rules! read { // HACK for graph_coloring - (Vec , u32) => { + (Vec , u32 $readfn:tt) => { { let mut ret = Vec::new(); for _ in 0..2 { - ret.push(read!(u32)); + ret.push(read!(u32 $readfn)); } ret } @@ -39,12 +43,12 @@ macro_rules! read { ret } }; - (bool) => { - (read_private() != 0) + (bool $readfn:tt) => { + ($readfn() != 0) }; // Has to be primitive! - ($type:ty) => { - (read_private() as $type) + ($type:tt $readfn:tt) => { + ($readfn() as $type) }; } -- cgit v1.2.3