Oh, that's tricky then. I mean, it's not hard to make this particular function behave how you want, but in general ocaml compiler might optimize some constructs such that time behavior of your code changes slightly (and in some cases a lot). For example allocation can increase or decrease with small changes which will affect your program's running time. Now, I don't know much about crypto so I don't know how much you care about this. On Feb 22, 2016 15:16, "Chan Ngo" wrote: > Hi Milan, > > thanks, I see what you mentioned with the “&&” operator. In fact, one case > the behavior as I wanted is in crypto primitive (we need constant-time > function to avoid time side-channel attack, for example, give any input for > comparing with the secret hash value with fixed size, the time execution of > comparing is constant. > > Best, > Chan > > On Feb 22, 2016, at 3:12 PM, Milan Stanojević wrote: > > Compiler short circuits && operator so your loop runs only til the first > element that differs. If you swap the arguments to && you should get the > behavior of visiting all elements (which is of course undesirable in > practice) > > >