Last active
April 20, 2020 16:47
-
-
Save kunigami/0e09bab60377dbd401151bf42f082b04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (bigvalue < a.length) { | |
value = a[bigvalue]; | |
if (value & 1 > 0) { | |
x = a[100]; | |
} else { | |
x = a[200]; | |
} | |
} | |
// Timing attack | |
const t1 = performance.now(); | |
const y1 = a[100]; | |
const duration1 = performance.now() - t1; | |
const t2 = performance.now(); | |
const y2 = a[200]; | |
const duration2 = performance.now() - t2; | |
if (duration1 * 10 < duration2) { | |
// a[100] is cached, value & 1 = 1 | |
} else if (duration2 * 10 < duration1) { | |
// a[200] is cached, value & 1 = 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment