Skip to content

Commit 21adca0

Browse files
Tom St Denissjaeckel
Tom St Denis
authored andcommitted
added libtommath-0.38
1 parent fde740e commit 21adca0

12 files changed

+55
-68
lines changed

bn.pdf

-136 Bytes
Binary file not shown.

bn.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
\begin{document}
5050
\frontmatter
5151
\pagestyle{empty}
52-
\title{LibTomMath User Manual \\ v0.37}
52+
\title{LibTomMath User Manual \\ v0.38}
5353
\author{Tom St Denis \\ tomstdenis@iahu.ca}
5454
\maketitle
5555
This text, the library and the accompanying textbook are all hereby placed in the public domain. This book has been

bn_fast_s_mp_mul_digs.c

+1-4
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
7878

7979
/* make next carry */
8080
_W = _W >> ((mp_word)DIGIT_BIT);
81-
}
82-
83-
/* store final carry */
84-
W[ix] = (mp_digit)(_W & MP_MASK);
81+
}
8582

8683
/* setup dest */
8784
olduse = c->used;

bn_fast_s_mp_mul_high_digs.c

-3
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
7070
_W = _W >> ((mp_word)DIGIT_BIT);
7171
}
7272

73-
/* store final carry */
74-
W[ix] = (mp_digit)(_W & MP_MASK);
75-
7673
/* setup dest */
7774
olduse = c->used;
7875
c->used = pa;

changes.txt

+4
Original file line numberDiff line numberDiff line change
@@ -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+
15
November 18th, 2005
26
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.
37
-- [rinick@gmail.com] reported the makefile.bcc was messed up. Fixed.

makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#Tom St Denis
44

55
#version of library
6-
VERSION=0.37
6+
VERSION=0.38
77

88
CFLAGS += -I./ -Wall -W -Wshadow -Wsign-compare
99

makefile.shared

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#Makefile for GCC
22
#
33
#Tom St Denis
4-
VERSION=0:37
4+
VERSION=0:38
55

66
CC = libtool --mode=compile gcc
77

poster.pdf

22 Bytes
Binary file not shown.

pre_gen/mpi.c

+1-7
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,7 @@ int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
458458

459459
/* make next carry */
460460
_W = _W >> ((mp_word)DIGIT_BIT);
461-
}
462-
463-
/* store final carry */
464-
W[ix] = (mp_digit)(_W & MP_MASK);
461+
}
465462

466463
/* setup dest */
467464
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)
564561
_W = _W >> ((mp_word)DIGIT_BIT);
565562
}
566563

567-
/* store final carry */
568-
W[ix] = (mp_digit)(_W & MP_MASK);
569-
570564
/* setup dest */
571565
olduse = c->used;
572566
c->used = pa;

tommath.pdf

-292 Bytes
Binary file not shown.

tommath.src

+11-12
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ QUALCOMM Australia \\
6666
}
6767
}
6868
\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
7070
LibTomMath project.
7171

7272
\begin{alltt}
@@ -77,7 +77,7 @@ K2L 1C3
7777
Canada
7878

7979
Phone: 1-613-836-3160
80-
Email: tomstdenis@iahu.ca
80+
Email: tomstdenis@gmail.com
8181
\end{alltt}
8282

8383
This text is formatted to the international B5 paper size of 176mm wide by 250mm tall using the \LaTeX{}
@@ -2190,7 +2190,7 @@ left.
21902190

21912191
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
21922192
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$
21942194
variable is used to extract the upper $d$ bits to form the carry for the next iteration.
21952195

21962196
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
26112611
\hspace{6mm}5.4.1 $\_ \hat W \leftarrow \_ \hat W + a_{tx+iy}b_{ty-iy}$ \\
26122612
\hspace{3mm}5.5 $W_{ix} \leftarrow \_ \hat W (\mbox{mod }\beta)$\\
26132613
\hspace{3mm}5.6 $\_ \hat W \leftarrow \lfloor \_ \hat W / \beta \rfloor$ \\
2614-
6. $W_{pa} \leftarrow \_ \hat W (\mbox{mod }\beta)$ \\
26152614
\\
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$ \\
26222621
\\
2623-
11. Clamp $c$. \\
2624-
12. Return MP\_OKAY. \\
2622+
10. Clamp $c$. \\
2623+
11. Return MP\_OKAY. \\
26252624
\hline
26262625
\end{tabular}
26272626
\end{center}

tommath.tex

+35-39
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
}
6767
}
6868
\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
7070
LibTomMath project.
7171

7272
\begin{alltt}
@@ -77,7 +77,7 @@
7777
Canada
7878
7979
Phone: 1-613-836-3160
80-
Email: tomstdenis@iahu.ca
80+
Email: tomstdenis@gmail.com
8181
\end{alltt}
8282

8383
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}
31693169
31703170
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
31713171
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$
31733173
variable is used to extract the upper $d$ bits to form the carry for the next iteration.
31743174
31753175
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.}
38643864
\hspace{6mm}5.4.1 $\_ \hat W \leftarrow \_ \hat W + a_{tx+iy}b_{ty-iy}$ \\
38653865
\hspace{3mm}5.5 $W_{ix} \leftarrow \_ \hat W (\mbox{mod }\beta)$\\
38663866
\hspace{3mm}5.6 $\_ \hat W \leftarrow \lfloor \_ \hat W / \beta \rfloor$ \\
3867-
6. $W_{pa} \leftarrow \_ \hat W (\mbox{mod }\beta)$ \\
38683867
\\
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$ \\
38753874
\\
3876-
11. Clamp $c$. \\
3877-
12. Return MP\_OKAY. \\
3875+
10. Clamp $c$. \\
3876+
11. Return MP\_OKAY. \\
38783877
\hline
38793878
\end{tabular}
38803879
\end{center}
@@ -3977,33 +3976,30 @@ \subsubsection{Column Weight.}
39773976
077
39783977
078 /* make next carry */
39793978
079 _W = _W >> ((mp_word)DIGIT_BIT);
3980-
080 \}
3979+
080 \}
39813980
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
40074003
\end{alltt}
40084004
\end{small}
40094005
@@ -4020,7 +4016,7 @@ \subsubsection{Column Weight.}
40204016
compiler has aliased $\_ \hat W$ to a CPU register.
40214017
40224018
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.
40244020
40254021
\subsection{Polynomial Basis Multiplication}
40264022
To break the $O(n^2)$ barrier in multiplication requires a completely different look at integer multiplication. In the following algorithms

0 commit comments

Comments
 (0)