You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scauligi edited this page Mar 17, 2018
·
1 revision
All of the following snippets are valid FaCT code, and thus will compile to constant time instructions.
// Assignment based on a secret conditionvoidselecting_things(secretboolcond) {
// mut because we reassign latersecretmutint32x=0;
if (cond) {
x=42;
} else {
x=137;
}
// or even more succinctly (and without mut)secretint32y=cond ? 42 : 137;
}
// Accessing a secret index in a buffervoiduse_secret_index(secretuint8[] buf, secretuint32index) {
for (uint32i=0; i<lenbuf; i+=1) {
if (i==index) {
// ... do something with buf[i] ...
}
}
}