Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added libtommath-0.38

  • Loading branch information...
commit 21adca01da35edfa8f1daa77142c4d26700907cc 1 parent fde740e
Tom St Denis authored sjaeckel committed
BIN  bn.pdf
Binary file not shown
2  bn.tex
@@ -49,7 +49,7 @@
49 49 \begin{document}
50 50 \frontmatter
51 51 \pagestyle{empty}
52   -\title{LibTomMath User Manual \\ v0.37}
  52 +\title{LibTomMath User Manual \\ v0.38}
53 53 \author{Tom St Denis \\ tomstdenis@iahu.ca}
54 54 \maketitle
55 55 This text, the library and the accompanying textbook are all hereby placed in the public domain. This book has been
5 bn_fast_s_mp_mul_digs.c
@@ -78,10 +78,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
78 78
79 79 /* make next carry */
80 80 _W = _W >> ((mp_word)DIGIT_BIT);
81   - }
82   -
83   - /* store final carry */
84   - W[ix] = (mp_digit)(_W & MP_MASK);
  81 + }
85 82
86 83 /* setup dest */
87 84 olduse = c->used;
3  bn_fast_s_mp_mul_high_digs.c
@@ -70,9 +70,6 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
70 70 _W = _W >> ((mp_word)DIGIT_BIT);
71 71 }
72 72
73   - /* store final carry */
74   - W[ix] = (mp_digit)(_W & MP_MASK);
75   -
76 73 /* setup dest */
77 74 olduse = c->used;
78 75 c->used = pa;
4 changes.txt
... ... @@ -1,3 +1,7 @@
  1 +Jan 26th, 2006
  2 +v0.38 -- broken makefile.shared fixed
  3 + -- removed some carry stores that were not required [updated text]
  4 +
1 5 November 18th, 2005
2 6 v0.37 -- [Don Porter] reported on a TCL list [HEY SEND ME BUGREPORTS ALREADY!!!] that mp_add_d() would compute -0 with some inputs. Fixed.
3 7 -- [rinick@gmail.com] reported the makefile.bcc was messed up. Fixed.
2  makefile
@@ -3,7 +3,7 @@
3 3 #Tom St Denis
4 4
5 5 #version of library
6   -VERSION=0.37
  6 +VERSION=0.38
7 7
8 8 CFLAGS += -I./ -Wall -W -Wshadow -Wsign-compare
9 9
2  makefile.shared
... ... @@ -1,7 +1,7 @@
1 1 #Makefile for GCC
2 2 #
3 3 #Tom St Denis
4   -VERSION=0:37
  4 +VERSION=0:38
5 5
6 6 CC = libtool --mode=compile gcc
7 7
BIN  poster.pdf
Binary file not shown
8 pre_gen/mpi.c
@@ -458,10 +458,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
458 458
459 459 /* make next carry */
460 460 _W = _W >> ((mp_word)DIGIT_BIT);
461   - }
462   -
463   - /* store final carry */
464   - W[ix] = (mp_digit)(_W & MP_MASK);
  461 + }
465 462
466 463 /* setup dest */
467 464 olduse = c->used;
@@ -564,9 +561,6 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
564 561 _W = _W >> ((mp_word)DIGIT_BIT);
565 562 }
566 563
567   - /* store final carry */
568   - W[ix] = (mp_digit)(_W & MP_MASK);
569   -
570 564 /* setup dest */
571 565 olduse = c->used;
572 566 c->used = pa;
BIN  tommath.pdf
Binary file not shown
23 tommath.src
@@ -66,7 +66,7 @@ QUALCOMM Australia \\
66 66 }
67 67 }
68 68 \maketitle
69   -This text has been placed in the public domain. This text corresponds to the v0.37 release of the
  69 +This text has been placed in the public domain. This text corresponds to the v0.38 release of the
70 70 LibTomMath project.
71 71
72 72 \begin{alltt}
@@ -77,7 +77,7 @@ K2L 1C3
77 77 Canada
78 78
79 79 Phone: 1-613-836-3160
80   -Email: tomstdenis@iahu.ca
  80 +Email: tomstdenis@gmail.com
81 81 \end{alltt}
82 82
83 83 This text is formatted to the international B5 paper size of 176mm wide by 250mm tall using the \LaTeX{}
@@ -2190,7 +2190,7 @@ left.
2190 2190
2191 2191 After the digits have been shifted appropriately at most $lg(\beta) - 1$ shifts are left to perform. Step 5 calculates the number of remaining shifts
2192 2192 required. If it is non-zero a modified shift loop is used to calculate the remaining product.
2193   -Essentially the loop is a generic version of algorith mp\_mul2 designed to handle any shift count in the range $1 \le x < lg(\beta)$. The $mask$
  2193 +Essentially the loop is a generic version of algorithm mp\_mul\_2 designed to handle any shift count in the range $1 \le x < lg(\beta)$. The $mask$
2194 2194 variable is used to extract the upper $d$ bits to form the carry for the next iteration.
2195 2195
2196 2196 This algorithm is loosely measured as a $O(2n)$ algorithm which means that if the input is $n$-digits that it takes $2n$ ``time'' to
@@ -2611,17 +2611,16 @@ Place an array of \textbf{MP\_WARRAY} single precision digits named $W$ on the s
2611 2611 \hspace{6mm}5.4.1 $\_ \hat W \leftarrow \_ \hat W + a_{tx+iy}b_{ty-iy}$ \\
2612 2612 \hspace{3mm}5.5 $W_{ix} \leftarrow \_ \hat W (\mbox{mod }\beta)$\\
2613 2613 \hspace{3mm}5.6 $\_ \hat W \leftarrow \lfloor \_ \hat W / \beta \rfloor$ \\
2614   -6. $W_{pa} \leftarrow \_ \hat W (\mbox{mod }\beta)$ \\
2615 2614 \\
2616   -7. $oldused \leftarrow c.used$ \\
2617   -8. $c.used \leftarrow digs$ \\
2618   -9. for $ix$ from $0$ to $pa$ do \\
2619   -\hspace{3mm}9.1 $c_{ix} \leftarrow W_{ix}$ \\
2620   -10. for $ix$ from $pa + 1$ to $oldused - 1$ do \\
2621   -\hspace{3mm}10.1 $c_{ix} \leftarrow 0$ \\
  2615 +6. $oldused \leftarrow c.used$ \\
  2616 +7. $c.used \leftarrow digs$ \\
  2617 +8. for $ix$ from $0$ to $pa$ do \\
  2618 +\hspace{3mm}8.1 $c_{ix} \leftarrow W_{ix}$ \\
  2619 +9. for $ix$ from $pa + 1$ to $oldused - 1$ do \\
  2620 +\hspace{3mm}9.1 $c_{ix} \leftarrow 0$ \\
2622 2621 \\
2623   -11. Clamp $c$. \\
2624   -12. Return MP\_OKAY. \\
  2622 +10. Clamp $c$. \\
  2623 +11. Return MP\_OKAY. \\
2625 2624 \hline
2626 2625 \end{tabular}
2627 2626 \end{center}
74 tommath.tex
@@ -66,7 +66,7 @@
66 66 }
67 67 }
68 68 \maketitle
69   -This text has been placed in the public domain. This text corresponds to the v0.37 release of the
  69 +This text has been placed in the public domain. This text corresponds to the v0.38 release of the
70 70 LibTomMath project.
71 71
72 72 \begin{alltt}
@@ -77,7 +77,7 @@
77 77 Canada
78 78
79 79 Phone: 1-613-836-3160
80   -Email: tomstdenis@iahu.ca
  80 +Email: tomstdenis@gmail.com
81 81 \end{alltt}
82 82
83 83 This text is formatted to the international B5 paper size of 176mm wide by 250mm tall using the \LaTeX{}
@@ -3169,7 +3169,7 @@ \subsection{Multiplication by Power of Two}
3169 3169
3170 3170 After the digits have been shifted appropriately at most $lg(\beta) - 1$ shifts are left to perform. Step 5 calculates the number of remaining shifts
3171 3171 required. If it is non-zero a modified shift loop is used to calculate the remaining product.
3172   -Essentially the loop is a generic version of algorith mp\_mul2 designed to handle any shift count in the range $1 \le x < lg(\beta)$. The $mask$
  3172 +Essentially the loop is a generic version of algorithm mp\_mul\_2 designed to handle any shift count in the range $1 \le x < lg(\beta)$. The $mask$
3173 3173 variable is used to extract the upper $d$ bits to form the carry for the next iteration.
3174 3174
3175 3175 This algorithm is loosely measured as a $O(2n)$ algorithm which means that if the input is $n$-digits that it takes $2n$ ``time'' to
@@ -3864,17 +3864,16 @@ \subsubsection{Column Weight.}
3864 3864 \hspace{6mm}5.4.1 $\_ \hat W \leftarrow \_ \hat W + a_{tx+iy}b_{ty-iy}$ \\
3865 3865 \hspace{3mm}5.5 $W_{ix} \leftarrow \_ \hat W (\mbox{mod }\beta)$\\
3866 3866 \hspace{3mm}5.6 $\_ \hat W \leftarrow \lfloor \_ \hat W / \beta \rfloor$ \\
3867   -6. $W_{pa} \leftarrow \_ \hat W (\mbox{mod }\beta)$ \\
3868 3867 \\
3869   -7. $oldused \leftarrow c.used$ \\
3870   -8. $c.used \leftarrow digs$ \\
3871   -9. for $ix$ from $0$ to $pa$ do \\
3872   -\hspace{3mm}9.1 $c_{ix} \leftarrow W_{ix}$ \\
3873   -10. for $ix$ from $pa + 1$ to $oldused - 1$ do \\
3874   -\hspace{3mm}10.1 $c_{ix} \leftarrow 0$ \\
  3868 +6. $oldused \leftarrow c.used$ \\
  3869 +7. $c.used \leftarrow digs$ \\
  3870 +8. for $ix$ from $0$ to $pa$ do \\
  3871 +\hspace{3mm}8.1 $c_{ix} \leftarrow W_{ix}$ \\
  3872 +9. for $ix$ from $pa + 1$ to $oldused - 1$ do \\
  3873 +\hspace{3mm}9.1 $c_{ix} \leftarrow 0$ \\
3875 3874 \\
3876   -11. Clamp $c$. \\
3877   -12. Return MP\_OKAY. \\
  3875 +10. Clamp $c$. \\
  3876 +11. Return MP\_OKAY. \\
3878 3877 \hline
3879 3878 \end{tabular}
3880 3879 \end{center}
@@ -3977,33 +3976,30 @@ \subsubsection{Column Weight.}
3977 3976 077
3978 3977 078 /* make next carry */
3979 3978 079 _W = _W >> ((mp_word)DIGIT_BIT);
3980   -080 \}
  3979 +080 \}
3981 3980 081
3982   -082 /* store final carry */
3983   -083 W[ix] = (mp_digit)(_W & MP_MASK);
3984   -084
3985   -085 /* setup dest */
3986   -086 olduse = c->used;
3987   -087 c->used = pa;
3988   -088
3989   -089 \{
3990   -090 register mp_digit *tmpc;
3991   -091 tmpc = c->dp;
3992   -092 for (ix = 0; ix < pa+1; ix++) \{
3993   -093 /* now extract the previous digit [below the carry] */
3994   -094 *tmpc++ = W[ix];
3995   -095 \}
3996   -096
3997   -097 /* clear unused digits [that existed in the old copy of c] */
3998   -098 for (; ix < olduse; ix++) \{
3999   -099 *tmpc++ = 0;
4000   -100 \}
4001   -101 \}
4002   -102 mp_clamp (c);
4003   -103 return MP_OKAY;
4004   -104 \}
4005   -105 #endif
4006   -106
  3981 +082 /* setup dest */
  3982 +083 olduse = c->used;
  3983 +084 c->used = pa;
  3984 +085
  3985 +086 \{
  3986 +087 register mp_digit *tmpc;
  3987 +088 tmpc = c->dp;
  3988 +089 for (ix = 0; ix < pa+1; ix++) \{
  3989 +090 /* now extract the previous digit [below the carry] */
  3990 +091 *tmpc++ = W[ix];
  3991 +092 \}
  3992 +093
  3993 +094 /* clear unused digits [that existed in the old copy of c] */
  3994 +095 for (; ix < olduse; ix++) \{
  3995 +096 *tmpc++ = 0;
  3996 +097 \}
  3997 +098 \}
  3998 +099 mp_clamp (c);
  3999 +100 return MP_OKAY;
  4000 +101 \}
  4001 +102 #endif
  4002 +103
4007 4003 \end{alltt}
4008 4004 \end{small}
4009 4005
@@ -4020,7 +4016,7 @@ \subsubsection{Column Weight.}
4020 4016 compiler has aliased $\_ \hat W$ to a CPU register.
4021 4017
4022 4018 After the inner loop we store the current accumulator in $W$ and shift $\_ \hat W$ (lines 76, 79) to forward it as
4023   -a carry for the next pass. After the outer loop we use the final carry (line 83) as the last digit of the product.
  4019 +a carry for the next pass. After the outer loop we use the final carry (line 76) as the last digit of the product.
4024 4020
4025 4021 \subsection{Polynomial Basis Multiplication}
4026 4022 To break the $O(n^2)$ barrier in multiplication requires a completely different look at integer multiplication. In the following algorithms

0 comments on commit 21adca0

Please sign in to comment.
Something went wrong with that request. Please try again.