[Gmp-commit] /var/hg/gmp: mpn_sec_powm: Clarify comment and asserts.

mercurial at gmplib.org mercurial at gmplib.org
Sat Mar 1 10:44:08 UTC 2014


details:   /var/hg/gmp/rev/2ac090cf082a
changeset: 16320:2ac090cf082a
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Sat Mar 01 11:42:08 2014 +0100
description:
mpn_sec_powm: Clarify comment and asserts.

diffstat:

 ChangeLog              |   5 +++++
 mpn/generic/sec_powm.c |  11 ++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diffs (42 lines):

diff -r fd2b176da745 -r 2ac090cf082a ChangeLog
--- a/ChangeLog	Fri Feb 28 11:40:41 2014 +0100
+++ b/ChangeLog	Sat Mar 01 11:42:08 2014 +0100
@@ -1,3 +1,8 @@
+2014-03-01  Niels Möller  <nisse at lysator.liu.se>
+
+	* mpn/generic/sec_powm.c (mpn_sec_powm): Clarify comment and
+	asserts.
+
 2014-02-28  Torbjorn Granlund  <tege at gmplib.org>
 
 	* mpn/x86_64/fat/fat.c (fake_cpuid): Handle id 7, make bold claims.
diff -r fd2b176da745 -r 2ac090cf082a mpn/generic/sec_powm.c
--- a/mpn/generic/sec_powm.c	Fri Feb 28 11:40:41 2014 +0100
+++ b/mpn/generic/sec_powm.c	Sat Mar 01 11:42:08 2014 +0100
@@ -250,9 +250,9 @@
   MPN_COPY (rp, tp, n);
 }
 
-/* rp[n-1..0] = bp[bn-1..0] ^ ep[en-1..0] mod mp[n-1..0]
-   Requires that mp[n-1..0] is odd.
-   Requires that ep[en-1..0] > 1.
+/* {rp, n} <-- {bp, bn} ^ {ep, en} mod {mp, n},
+   where en = ceil (enb / GMP_NUMB_BITS)
+   Requires that {mp, n} is odd (and hence also mp[0] odd).
    Uses scratch space at tp as defined by mpn_sec_powm_itch.  */
 void
 mpn_sec_powm (mp_ptr rp, mp_srcptr bp, mp_size_t bn,
@@ -267,10 +267,11 @@
   int cnd;
 
   ASSERT (enb > 0);
-  ASSERT (n >= 1 && ((mp[0] & 1) != 0));
+  ASSERT (n > 0);
   /* The code works for bn = 0, but the defined scratch space is 2 limbs
      greater than we supply, when converting 1 to redc form .  */
-  ASSERT (bn >= 1);
+  ASSERT (bn > 0);
+  ASSERT ((mp[0] & 1) != 0);
 
   windowsize = win_size (enb);
 


More information about the gmp-commit mailing list