code wiki / (root) / nx_xxhash_vectors.nx

nx_xxhash_vectors.nx source

↩ module page · 35 lines · 1044 B

1// nx_xxhash_vectors.nx -- verify xxh64 against canonical reference values. 2// xxh64("") with seed=0 = 0xEF46DB3751D8E999 3// xxh64("a") with seed=0 = 0xD24EC4F1A98C6E5B 4// xxh64(0..255 byte sequence, 256 bytes) with seed=0 = 0xD22DBFE43DC2D9C7 5 6// nx_safety_envelope: 7// intended_use: AUTO_APPLIED -- primitive-specific tuning queued 8// sil_target: SIL1 9// evidence: [bulk_applied_2026-05-16, see-file-comment-for-detail] 10// verdict: NOT_YET_EVALUATED 11 12import "syscalls.nx" 13import "nx_xxhash.nx" 14 15func main() -> i64 { 16 let buf: *u8 = sys_mmap(256) 17 18 // Test 1: empty string 19 let h_empty: i64 = nx_xxh64(buf, 0, 0) 20 let expect_empty: i64 = 0xEF46DB3751D8E999 as i64 21 if h_empty != expect_empty { 22 // Return the diff in low bits so we can debug. 23 return 10 24 } 25 26 // Test 2: single byte 'a' (0x61) 27 buf[0] = 0x61 28 let h_a: i64 = nx_xxh64(buf, 1, 0) 29 let expect_a: i64 = 0xD24EC4F1A98C6E5B as i64 30 if h_a != expect_a { 31 return 20 32 } 33 34 return 0 35}