Hide more things behind --verbose + error correction (#27)

---------

Co-authored-by: WitherOrNot <damemem@gmail.com>
This commit is contained in:
TheTank20 2023-06-18 03:28:20 -05:00 committed by GitHub
parent dc64133adf
commit bc23fc5233
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -222,7 +222,7 @@ void CLI::printKey(char *pk) {
assert(strlen(pk) == 25);
std::string spk = pk;
fmt::print("{}-{}-{}-{}-{}\n",
fmt::print("{}-{}-{}-{}-{}",
spk.substr(0,5),
spk.substr(5,5),
spk.substr(10,5),
@ -304,14 +304,34 @@ int CLI::BINK1998() {
for (int i = 0; i < this->total; i++) {
BINK1998::Generate(this->eCurve, this->genPoint, this->genOrder, this->privateKey, nRaw, bUpgrade, this->pKey);
CLI::printKey(this->pKey);
fmt::print("\n");
// verify the key
this->count += BINK1998::Verify(this->eCurve, this->genPoint, this->pubPoint, this->pKey);
bool isValid = BINK1998::Verify(this->eCurve, this->genPoint, this->pubPoint, this->pKey);
if (isValid) {
CLI::printKey(this->pKey);
if (i < this->total - 1 || this->options.verbose) {
fmt::print("\n");
}
this->count += isValid;
}
else {
if (this->options.verbose) {
CLI::printKey(this->pKey);
fmt::print(" [Invalid]");
if (i < this->total - 1) {
fmt::print("\n");
}
}
this->total++; // queue a redo, basically
}
}
fmt::print("Success count: {}/{}\n", this->count, this->total);
if (this->options.verbose) {
fmt::print("\nSuccess count: {}/{}", this->count, this->total);
}
#ifndef _WIN32
fmt::print("\n");
#endif
return 0;
}
@ -333,14 +353,34 @@ int CLI::BINK2002() {
}
BINK2002::Generate(this->eCurve, this->genPoint, this->genOrder, this->privateKey, pChannelID, pAuthInfo, false, this->pKey);
CLI::printKey(this->pKey);
fmt::print("\n\n");
// verify a key
this->count += BINK2002::Verify(this->eCurve, this->genPoint, this->pubPoint, this->pKey);
bool isValid = BINK2002::Verify(this->eCurve, this->genPoint, this->pubPoint, this->pKey);
if (isValid) {
CLI::printKey(this->pKey);
if (i < this->total - 1 || this->options.verbose) {
fmt::print("\n");
}
this->count += isValid;
}
else {
if (this->options.verbose) {
CLI::printKey(this->pKey);
fmt::print(" [Invalid]");
if (i < this->total - 1) {
fmt::print("\n");
}
}
this->total++; // queue a redo, basically
}
}
fmt::print("Success count: {}/{}\n", this->count, this->total);
if (this->options.verbose) {
fmt::print("\nSuccess count: {}/{}", this->count, this->total);
}
#ifndef _WIN32
fmt::print("\n");
#endif
return 0;
}
@ -374,7 +414,10 @@ int CLI::ConfirmationID() {
return 1;
case SUCCESS:
fmt::print("Confirmation ID: {}\n", confirmation_id);
fmt::print(confirmation_id);
#ifndef _WIN32
fmt::print("\n");
#endif
return 0;
default: