diff --git a/library/std/src/sys/zkvm/abi.rs b/library/std/src/sys/zkvm/abi.rs index 0e5338ae35a..bc365fce194 100644 --- a/library/std/src/sys/zkvm/abi.rs +++ b/library/std/src/sys/zkvm/abi.rs @@ -34,7 +34,7 @@ extern "C" { buf: *const u8, count: u32, ); - pub fn sys_rand(recv_buf: *mut u32, words: usize); + pub fn sys_rand(recv_buf: *mut u8, words: usize); pub fn sys_panic(msg_ptr: *const u8, len: usize) -> !; pub fn sys_log(msg_ptr: *const u8, len: usize); pub fn sys_cycle_count() -> usize; diff --git a/library/std/src/sys/zkvm/mod.rs b/library/std/src/sys/zkvm/mod.rs index eb23608fd2f..0f422e333a4 100644 --- a/library/std/src/sys/zkvm/mod.rs +++ b/library/std/src/sys/zkvm/mod.rs @@ -85,5 +85,12 @@ pub fn abort_internal() -> ! { } pub fn hashmap_random_keys() -> (u64, u64) { - (1, 2) + let mut buf = [0u8; 16]; + unsafe { + abi::sys_rand(buf.as_mut_ptr(), buf.len()); + }; + + let a = u64::from_le_bytes(buf[0..8].try_into().unwrap()); + let b = u64::from_le_bytes(buf[8..16].try_into().unwrap()); + (a, b) }