fn compare_hashes(a: &[u8], b: &[u8]) -> bool {
let size = a.len();
fact!{
for (uint64 i from 0 to size) {
if (x[i] != y[i]) { return -1; }
}
return 0;
}
}
It would get compiled into asm and inlined.I'm also wondering how this interacts with bounds checking, which would introduce branches. I tried searching the paper (sorry, no time to read the whole thing today) for 'bounds' but did not get a result.
Semi-related. One (insufficient) option for dealing with timing leaks is to add a random delay. ie: `sleep_ms(rand(1,1000))`. The problem is that given N leaks an attacker can remove that noise. I have two questions here:
1. What is "N"?
2. Does that sleeping introduce any additional vulnerabilities? Basically, is this a "if you can afford that latency it won't hurt".