-
Notifications
You must be signed in to change notification settings - Fork 33
Closed
Description
I'm trying to implement a proof of work and its verification. The proving should use the fast mode, while verification - light. However, I'm failing to make it work, the light VM returns different hashes for the same input. I expect both to return the same hash. I'm unsure if I'm using RandomX properly - could you help?
Here's a minimal test that fails:
#[test]
fn randomx_hash_fast_vs_light() {
let input = b"input";
let key = b"key";
let cache = RandomXCache::new(RandomXFlag::FLAG_DEFAULT, key).unwrap();
let dataset = RandomXDataset::new(RandomXFlag::FLAG_DEFAULT, cache.clone(), 0).unwrap();
let fast_vm = RandomXVM::new(
RandomXFlag::FLAG_HARD_AES | RandomXFlag::FLAG_FULL_MEM,
Some(cache),
Some(dataset),
)
.unwrap();
let cache = RandomXCache::new(RandomXFlag::FLAG_DEFAULT, key).unwrap();
let dataset = RandomXDataset::new(RandomXFlag::FLAG_DEFAULT, cache.clone(), 0).unwrap();
let light_vm = RandomXVM::new(RandomXFlag::FLAG_HARD_AES, Some(cache), Some(dataset)).unwrap();
let fast = fast_vm.calculate_hash(input).unwrap();
let light = light_vm.calculate_hash(input).unwrap();
assert_eq!(fast, light);
}---- tests::randomx_hash_fast_vs_light stdout ----
thread 'tests::randomx_hash_fast_vs_light' panicked at 'assertion failed: `(left == right)`
left: `[167, 233, 27, 2, 242, 232, 157, 112, 180, 51, 158, 61, 223, 56, 79, 10, 59, 180, 15, 197, 102, 64, 227, 3, 92, 119, 17, 45, 168, 85, 221, 180]`,
right: `[46, 44, 66, 118, 196, 74, 91, 214, 215, 78, 199, 115, 206, 141, 89, 33, 28, 12, 213, 87, 88, 170, 103, 218, 161, 162, 49, 100, 85, 218, 102, 211]`', src/lib.rs:684:9I pushed the test to https://github.com/poszu/randomx-rs/blob/7bd6939ef204ea56bc2764f0a5314aaa896676c6/src/lib.rs#L664-L685
Metadata
Metadata
Assignees
Labels
No labels