<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">On 2/7/25 20:05, NIIBE Yutaka via
      Gcrypt-devel wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:87frkpmbsb.fsf@haruna.fsij.org">
      <pre wrap="" class="moz-quote-pre">NIIBE Yutaka <a class="moz-txt-link-rfc2396E" href="mailto:gniibe@fsij.org"><gniibe@fsij.org></a> wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="" class="moz-quote-pre">I think that this implementation could be improved.
</pre>
      </blockquote>
      <pre wrap="" class="moz-quote-pre">
I should use ct_limb_gen_inv_mask function instead of directly use unary
minus operator.</pre>
    </blockquote>
    <p>Could it make more sense to write:</p>
    <pre>result &= ct_limb_gen_inv_mask (gt) & ct_limb_gen_inv_mask (lt);
result |= gt | -lt;
</pre>
    <p>Assuming that ct_limb_gen_inv_mask returns all-bits-set if its
      argument is zero and all-bits-clear otherwise, the first line
      clears result if a previous value is to be overwritten and the
      second sets the new value.</p>
    <p>I also still suggest considering an alternate encoding for the
      comparison result.  The Hamming distance between 0 and 1 is 1, but
      the Hamming distance between 0 and -1 is the maximum on a 2's
      complement machine, which means that any information leakage on
      the power rail will be at its strongest when the comparison result
      is "less than".</p>
    <p>A one-hot encoding would have a constant Hamming distance (of 2)
      between any pair of valid values.<br>
    </p>
    <p>I remember reading a paper some years ago by an academic research
      group that was able to recover private keys by observing noise on
      a laptop's ground (a USB port shield connection, if I recall
      correctly).</p>
    <p><br>
    </p>
    <p>-- Jacob<br>
    </p>
    <p><br>
    </p>
  </body>
</html>