Skip to content

Commit 89fb372

Browse files
wNaf Edwards twisted torsion 16
1 parent 6e01412 commit 89fb372

File tree

4 files changed

+21
-16
lines changed

4 files changed

+21
-16
lines changed

include/core/Version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <string>
55

66
namespace core {
7-
const std::string PRMERS_VERSION = "4.15.25-alpha";
7+
const std::string PRMERS_VERSION = "4.15.26-alpha";
88
} // namespace core
99

1010
#endif // VERSION_HPP

include/io/CliParser.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ struct CliOptions {
3434
uint64_t gerbicz_error_count = 0;
3535
uint64_t erroriter = 0;
3636
bool proof = true;
37-
bool edwards = true;
37+
bool edwards = false;
3838
bool compute_edwards = false;
39-
bool torsion16 = true;
39+
bool torsion16 = false;
4040
bool notorsion = false;
4141
uint64_t sigma = 0ULL;
4242
uint64_t seed = 0ULL;

src/io/CliParser.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@ void printUsage(const char* progName) {
8282
std::cout << " -checklevel <value> : (Optional) Will force gerbicz check every B*<value> by default check is done every 10 min and at the end." << std::endl;
8383
std::cout << " -wagstaff : (Optional) will check PRP if (2^p + 1)/3 is probably prime" << std::endl;
8484
std::cout << " -ecm -b1 <B1> [-b2 <B2>] -K <curves> : Run ECM factoring with bounds B1 [and optional B2], on given number of curves" << std::endl;
85-
std::cout << " -montgomery : (Optional) use Montgomery instead of twisted Edwards curve (compute done in montgomery)" << std::endl;
86-
std::cout << " -edwards : (Optional) use twisted Edwards curve converted to Montgomery (compute done in Montgomery)" << std::endl;
87-
std::cout << " -ced : (Optional) use twisted Edwards compute (notorsion or torsion 2x8 possible) " << std::endl;
85+
std::cout << " -montgomery : (Optional) compute in Montgomery and use Montgomery (compute done in montgomery)" << std::endl;
86+
std::cout << " -edwards : (Optional) compute in Montgomery and use (twisted) Edwards curve converted to Montgomery (compute done in Montgomery)" << std::endl;
87+
std::cout << " -ced : (Optional) compute in Edwards and use (twisted) Edwards curves (notorsion twisted or torsion 2x8 possible no twist a=1) " << std::endl;
8888
std::cout << " -seed : (Optional) force a curve seed" << std::endl;
89-
std::cout << " -torsion8 : (Optional) use torsion-8 instead of default torsion-16" << std::endl;
89+
std::cout << " -torsion8 : (Optional) use torsion-8" << std::endl;
90+
std::cout << " -torsion16 : (Optional) use torsion-16" << std::endl;
9091
std::cout << " -notorsion : (Optional) use no torsion instead of default torsion-16" << std::endl;
9192

9293
//std::cout << " -brent [<d>] : (Optional) use Brent-Suyama variant with default or specified degree d (e.g., -brent 6)" << std::endl;
@@ -203,10 +204,14 @@ CliOptions CliParser::parse(int argc, char** argv ) {
203204
}
204205
else if (std::strcmp(argv[i], "-ced") == 0) {
205206
opts.compute_edwards = true;
207+
opts.torsion16 = true;
206208
}
207209
else if (std::strcmp(argv[i], "-torsion8") == 0) {
208210
opts.torsion16 = false;
209211
}
212+
else if (std::strcmp(argv[i], "-torsion16") == 0) {
213+
opts.torsion16 = true;
214+
}
210215
else if (std::strcmp(argv[i], "-notorsion") == 0) {
211216
opts.notorsion = true;
212217
}

src/modes/RunEcm.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ int App::runECMMarin()
138138
if (forceSigma || options.notorsion) pm_effective = options.edwards ? 3 : 0;
139139
else if (options.torsion16) pm_effective = options.edwards ? 4 : 1;
140140
else pm_effective = options.edwards ? 5 : 2;
141-
mode_name = ((pm_effective==0||pm_effective==1||pm_effective==2) ? "montgomery" : "edwards");
141+
mode_name = ((pm_effective==0||pm_effective==1||pm_effective==2) ? "montgomery" : "edwards--conv-->montgomery");
142142
if (pm_effective==0 || pm_effective==3) torsion_name = "none";
143143
else if (pm_effective==1 || pm_effective==4) torsion_name = "16";
144144
else torsion_name = "8";
@@ -393,7 +393,7 @@ int App::runECMMarin()
393393
gp<<"A=lift(modN(-((4*v+1)^2+16*v)));\n";
394394
gp<<"A24=lift(modN((A+2)/4));\n";
395395
gp<<"x0=lift(modN(4*v+1));\n";
396-
} else if (mode=="edwards") {
396+
} else if (mode=="edwards--conv-->montgomery") {
397397
gp<<"aE="<<(aE_opt? aE_opt->get_str() : "0")<<"; dE="<<(dE_opt? dE_opt->get_str() : "0")<<";\n";
398398
gp<<"A=lift(modN(2*(aE+dE)/(aE-dE)));\n";
399399
gp<<"A24=lift(modN((A+2)/4));\n";
@@ -430,7 +430,7 @@ int App::runECMMarin()
430430
mpz_class A24, x0;
431431

432432
if (resume_stage2) {
433-
if (pm_effective==0 || pm_effective==1 || pm_effective==2) mode_name="montgomery"; else mode_name="edwards";
433+
if (pm_effective==0 || pm_effective==1 || pm_effective==2) mode_name="montgomery"; else mode_name="edwards--conv-->montgomery";
434434
if (pm_effective==0 || pm_effective==3) torsion_name="none"; else if (pm_effective==1 || pm_effective==4) torsion_name="16"; else torsion_name="8";
435435
}
436436
//test case ./prmers 127913 -ecm -b1 50000 -seed 15236911113677539612
@@ -641,7 +641,7 @@ int App::runECMMarin()
641641
}
642642
else if (picked_mode == 3)
643643
{
644-
mode_name="edwards"; torsion_name="none";
644+
mode_name="edwards--conv-->montgomery"; torsion_name="none";
645645
mpz_class sigma_mpz;
646646
if (forceSigma){
647647
curve_seed = options.curve_seed;
@@ -665,13 +665,13 @@ int App::runECMMarin()
665665
mpz_class aE = addm(A, mpz_class(2));
666666
mpz_class dE = subm(A, mpz_class(2));
667667
std::ostringstream head;
668-
head<<"[ECM] Curve "<<(c+1)<<"/"<<curves<<" | edwards | torsion=none | K_bits="<<mpz_sizeinbase(K.get_mpz_t(),2)<<" | seed="<<base_seed;
668+
head<<"[ECM] Curve "<<(c+1)<<"/"<<curves<<" | edwards --conv-->montgomery | torsion=none | K_bits="<<mpz_sizeinbase(K.get_mpz_t(),2)<<" | seed="<<base_seed;
669669
std::cout<<head.str()<<std::endl; if (guiServer_) guiServer_->appendLog(head.str());
670-
write_gp("edwards","none", N, p, B1, B2, base_seed, curve_seed, nullptr, nullptr, nullptr, &aE, &dE, A24, x0);
670+
write_gp("edwards--conv-->montgomery","none", N, p, B1, B2, base_seed, curve_seed, nullptr, nullptr, nullptr, &aE, &dE, A24, x0);
671671
}
672672
else
673673
{
674-
mode_name="edwards"; torsion_name="8";
674+
mode_name="edwards--conv-->montgomery"; torsion_name="8";
675675
if (forceSigma){
676676
curve_seed = options.curve_seed;
677677
}
@@ -690,9 +690,9 @@ int App::runECMMarin()
690690
mpz_class aE = addm(A, mpz_class(2));
691691
mpz_class dE = subm(A, mpz_class(2));
692692
std::ostringstream head;
693-
head<<"[ECM] Curve "<<(c+1)<<"/"<<curves<<" | edwards | torsion=8 | K_bits="<<mpz_sizeinbase(K.get_mpz_t(),2)<<" | seed="<<base_seed;
693+
head<<"[ECM] Curve "<<(c+1)<<"/"<<curves<<" | edwards --conv-->montgomery | torsion=8 | K_bits="<<mpz_sizeinbase(K.get_mpz_t(),2)<<" | seed="<<base_seed;
694694
std::cout<<head.str()<<std::endl; if (guiServer_) guiServer_->appendLog(head.str());
695-
write_gp("edwards","8", N, p, B1, B2, base_seed, curve_seed, nullptr, nullptr, &v, &aE, &dE, A24, x0);
695+
write_gp("edwards--conv-->montgomery","8", N, p, B1, B2, base_seed, curve_seed, nullptr, nullptr, &v, &aE, &dE, A24, x0);
696696
}
697697

698698
mpz_t zA24; mpz_init(zA24); mpz_set(zA24, A24.get_mpz_t()); eng->set_mpz((engine::Reg)6, zA24); mpz_clear(zA24);

0 commit comments

Comments
 (0)