projects
/
u
/
mdw
/
catacomb
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1d7857e
)
Bug fix in prime curve doubling: if 2 P = O then it erroneously returned
author
mdw
<mdw>
Wed, 3 Nov 2004 10:42:15 +0000
(10:42 +0000)
committer
mdw
<mdw>
Wed, 3 Nov 2004 10:42:15 +0000
(10:42 +0000)
P instead of O.
ec-prime.c
patch
|
blob
|
blame
|
history
tests/ec
patch
|
blob
|
blame
|
history
diff --git
a/ec-prime.c
b/ec-prime.c
index
c146931
..
dc299fb
100644
(file)
--- a/
ec-prime.c
+++ b/
ec-prime.c
@@
-68,10
+68,8
@@
static ec *ecfind(ec_curve *c, ec *d, mp *x)
static ec *ecdbl(ec_curve *c, ec *d, const ec *a)
{
static ec *ecdbl(ec_curve *c, ec *d, const ec *a)
{
- if (EC_ATINF(a))
+ if (EC_ATINF(a)
|| F_ZEROP(c->f, a->y)
)
EC_SETINF(d);
EC_SETINF(d);
- else if (F_ZEROP(c->f, a->y))
- EC_COPY(d, a);
else {
field *f = c->f;
mp *lambda;
else {
field *f = c->f;
mp *lambda;
@@
-102,10
+100,8
@@
static ec *ecdbl(ec_curve *c, ec *d, const ec *a)
static ec *ecprojdbl(ec_curve *c, ec *d, const ec *a)
{
static ec *ecprojdbl(ec_curve *c, ec *d, const ec *a)
{
- if (EC_ATINF(a))
+ if (EC_ATINF(a)
|| F_ZEROP(c->f, a->y)
)
EC_SETINF(d);
EC_SETINF(d);
- else if (F_ZEROP(c->f, a->y))
- EC_COPY(d, a);
else {
field *f = c->f;
mp *p, *q, *m, *s, *dx, *dy, *dz;
else {
field *f = c->f;
mp *p, *q, *m, *s, *dx, *dy, *dz;
@@
-146,10
+142,8
@@
static ec *ecprojdbl(ec_curve *c, ec *d, const ec *a)
static ec *ecprojxdbl(ec_curve *c, ec *d, const ec *a)
{
static ec *ecprojxdbl(ec_curve *c, ec *d, const ec *a)
{
- if (EC_ATINF(a))
+ if (EC_ATINF(a)
|| F_ZEROP(c->f, a->y)
)
EC_SETINF(d);
EC_SETINF(d);
- else if (F_ZEROP(c->f, a->y))
- EC_COPY(d, a);
else {
field *f = c->f;
mp *p, *q, *m, *s, *dx, *dy, *dz;
else {
field *f = c->f;
mp *p, *q, *m, *s, *dx, *dy, *dz;
diff --git
a/tests/ec
b/tests/ec
index
aba2b58
..
61f78e0
100644
(file)
--- a/
tests/ec
+++ b/
tests/ec
@@
-1,4
+1,4
@@
-# $Id
: ec,v 1.3 2004/03/27 17:54:12 mdw Exp
$
+# $Id$
#
# Elliptic curve tests
#
# Elliptic curve tests
@@
-198,6
+198,9
@@
neg {
}
dbl {
}
dbl {
+ "prime: 23 prime: 1, 1" "4, 0" inf;
+ "prime: 23 primeproj: 1, 1" "4, 0" inf;
+
"prime: 6277101735386680763835789423207666416083908700390324961279
prime: -3, 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1"
"0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012,
"prime: 6277101735386680763835789423207666416083908700390324961279
prime: -3, 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1"
"0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012,
@@
-351,6
+354,11
@@
sub {
}
mul {
}
mul {
+ "prime: 23 prime: 1, 1" "0, 1" 28 inf;
+ "prime: 23 prime: 1, 1" "0, 1" 29 "0, 1";
+ "prime: 23 primeproj: 1, 1" "0, 1" 28 inf;
+ "prime: 23 primeproj: 1, 1" "0, 1" 29 "0, 1";
+
"prime: 6277101735386680763835789423207666416083908700390324961279
prime: -3, 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1"
"0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012,
"prime: 6277101735386680763835789423207666416083908700390324961279
prime: -3, 0x64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1"
"0x188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012,