Skip to content

Commit fa0a77d

Browse files
authored
Merge pull request #38 from kkarabin/master
Add hybrid Torus alg. for compressed dlog tables. Replace memcmp calls. Remove unused functions.
2 parents 566630e + 5852de4 commit fa0a77d

19 files changed

+1086
-1660
lines changed

src/P434/P434_compressed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ const unsigned int strat_Bob[MAX_Bob-1] = {
171171
// Fixed traversal strategies for Pohlig-Hellman discrete logs
172172
const unsigned int ph2_path[PLEN_2] = {
173173
#ifdef COMPRESSED_TABLES
174-
#ifdef ELL2_FULL_SIGNED
174+
#ifdef ELL2_TORUS
175175
#if (W_2 == 4)
176176
0, 0, 1, 2, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 9, 10, 11, 12, 13, 13, 13, 14, 14, 15, 16, 17, 18, 19, 19, 19, 19, 20, 21, 22, 22, 23, 24, 25, 26, 27, 27, 28, 28, 28, 28, 28, 29, 30, 31, 32, 33, 34, 34, 35
177177
#endif

src/P434/P434_compressed_dlog_tables.c

Lines changed: 27 additions & 11 deletions
Large diffs are not rendered by default.

src/P434/P434_internal.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,17 @@
7676
#define DLEN_3 ((OBOB_EXPON+W_3-1)/W_3) // ceil(eB/W_3)
7777
// Use compressed tables: FULL_SIGNED
7878
#define COMPRESSED_TABLES
79-
#define ELL2_FULL_SIGNED // Uses signed digits to reduce table size by half
79+
#define ELL2_TORUS
8080
#define ELL3_FULL_SIGNED // Uses signed digits to reduce table size by half
8181
// Length of the optimal strategy path for Pohlig-Hellman
82-
#ifdef COMPRESSED_TABLES
83-
#ifdef ELL2_FULL_SIGNED
84-
#if W_2 == 4
85-
#define PLEN_2 55
86-
#endif
82+
#ifdef COMPRESSED_TABLES
83+
#if W_2 == 4
84+
#define PLEN_2 55
85+
#endif
86+
#ifdef ELL2_TORUS
87+
#define W_2_1 3
88+
#endif
89+
#ifdef ELL3_FULL_SIGNED
8790
#if W_3 == 3
8891
#define PLEN_3 47
8992
#endif

src/P503/P503_compressed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ const unsigned int strat_Bob[MAX_Bob - 1] = {
174174
// Fixed traversal strategies for Pohlig-Hellman discrete logs
175175
const unsigned int ph2_path[PLEN_2] = {
176176
#ifdef COMPRESSED_TABLES
177-
#ifdef ELL2_FULL_SIGNED
177+
#ifdef ELL2_TORUS
178178
#if W_2 == 5
179179
0, 0, 1, 2, 3, 4, 4, 5, 5, 6, 7, 7, 8, 9, 10, 10, 11, 12, 13, 13, 14, 14, 15, 16, 17, 18, 18, 18, 19, 20, 20, 21, 22, 23, 24, 25, 25, 25, 25, 26, 27, 28, 29, 29, 30, 31, 32, 33, 34, 35, 35
180180
#endif

src/P503/P503_compressed_dlog_tables.c

Lines changed: 28 additions & 9 deletions
Large diffs are not rendered by default.

src/P503/P503_internal.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,16 @@
7676
#define DLEN_3 ((OBOB_EXPON + W_3 - 1) / W_3) // ceil(eB/W_3)
7777
// Use compressed tables: FULL_SIGNED
7878
#define COMPRESSED_TABLES
79-
#define ELL2_FULL_SIGNED // Uses signed digits to reduce table size by half
79+
#define ELL2_TORUS
8080
#define ELL3_FULL_SIGNED // Uses signed digits to reduce table size by half
8181
// Length of the optimal strategy path for Pohlig-Hellman
8282
#ifdef COMPRESSED_TABLES
83-
#ifdef ELL2_FULL_SIGNED
84-
#if W_2 == 5
85-
#define PLEN_2 51
86-
#endif
83+
#if W_2 == 5
84+
#define PLEN_2 51
8785
#endif
86+
#ifdef ELL2_TORUS
87+
#define W_2_1 4
88+
#endif
8889
#ifdef ELL3_FULL_SIGNED
8990
#if W_3 == 3
9091
#define PLEN_3 54

src/P610/P610_compressed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ const unsigned int strat_Bob[MAX_Bob-1] = { 86, 48, 27, 15, 8, 4, 2, 1, 1, 2, 1,
164164
// Fixed traversal strategies for Pohlig-Hellman discrete logs
165165
const unsigned int ph2_path[PLEN_2] = {
166166
#ifdef COMPRESSED_TABLES
167-
#ifdef ELL2_FULL_SIGNED
167+
#ifdef ELL2_TORUS
168168
#if (W_2 == 5)
169169
0, 0, 1, 2, 3, 4, 4, 5, 5, 6, 7, 7, 8, 9, 10, 10, 11, 12, 13, 13, 14, 14, 15, 16, 17, 18, 18, 18, 19, 20, 20, 21, 22, 23, 24, 25, 25, 25, 25, 26, 27, 28, 29, 29, 30, 31, 32, 33, 34, 35, 35, 35, 35, 35, 36, 37, 38, 39, 40, 41, 41, 42
170170
#endif

src/P610/P610_compressed_dlog_tables.c

Lines changed: 30 additions & 11 deletions
Large diffs are not rendered by default.

src/P610/P610_internal.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,17 @@
7676
#define DLEN_3 ((OBOB_EXPON+W_3-1)/W_3) // ceil(eB/W_3)
7777
// Use compressed tables: FULL_SIGNED
7878
#define COMPRESSED_TABLES
79-
#define ELL2_FULL_SIGNED // Uses signed digits to reduce table size by half
79+
#define ELL2_TORUS
8080
#define ELL3_FULL_SIGNED // Uses signed digits to reduce table size by half
8181
// Length of the optimal strategy path for Pohlig-Hellman
8282
#ifdef COMPRESSED_TABLES
83-
#ifdef ELL2_FULL_SIGNED
84-
#if W_2 == 5
85-
#define PLEN_2 62
86-
#endif
83+
#if W_2 == 5
84+
#define PLEN_2 62
85+
#endif
86+
#ifdef ELL2_TORUS
87+
#define W_2_1 4
8788
#endif
89+
8890
#ifdef ELL3_FULL_SIGNED
8991
#if W_3 == 3
9092
#define PLEN_3 65

src/P751/P751_compressed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ const unsigned int strat_Bob[MAX_Bob-1] = {
177177
// Fixed traversal strategies for Pohlig-Hellman discrete logs
178178
const unsigned int ph2_path[PLEN_2] = {
179179
#ifdef COMPRESSED_TABLES
180-
#ifdef ELL2_FULL_SIGNED
180+
#ifdef ELL2_TORUS
181181
#if W_2 == 4
182182
0, 0, 1, 2, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 9, 10, 11, 12, 13, 13, 13, 14, 14, 15, 16, 17, 18, 19, 19, 19, 19, 20, 21, 22, 22, 23, 24, 25, 26, 27, 27, 28, 28, 28, 28, 28, 29, 30, 31, 32, 33, 34, 34, 35, 36, 37, 38, 39, 40, 40, 40, 40, 41, 42, 42, 42, 42, 42, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 52, 53, 54, 55, 56, 57, 58, 59, 59, 59, 59, 59, 59, 59
183183
#endif

0 commit comments

Comments
 (0)