moved extended_extended_private_key unit test from testbed to unit test
This commit is contained in:
parent
deac6e35d1
commit
133b7d27c8
@ -73,7 +73,7 @@ If using queumessage, the testbed code will complete while the dialog
|
||||
// queue_error_message("hello world");
|
||||
// throw MyException("hello world exception", __LINE__, __func__, SrcFilename);
|
||||
ILogMessage("begin testbed");
|
||||
auto text_secret{ DeriveTextSecret(scalar(7), 1) };
|
||||
/* auto text_secret{DeriveTextSecret(scalar(7), 1)};
|
||||
if (text_secret == decltype(text_secret){"Rmc mLSu mDk DhfV 9gBK kKj"}) {
|
||||
ILogMessage("\t\tObtained expected text secret from scalar(7)");
|
||||
}
|
||||
@ -96,17 +96,8 @@ If using queumessage, the testbed code will complete while the dialog
|
||||
throw MyException("Round trip for extended_private_key to and from base 58 representation failed", __LINE__, __func__, SrcFilename);
|
||||
}
|
||||
|
||||
|
||||
/* if (s1 == scalar({0x59, 0xf6, 0x73, 0xb4, 0xa0, 0xc7, 0x0d, 0x8b, 0x51, 0xe5, 0x87, 0x7c, 0xf5, 0xd7, 0x6f, 0x55, 0x31, 0xa7, 0x0b, 0x14, 0x28, 0x54, 0x97, 0x08, 0x9f, 0x27, 0x83, 0xe1, 0xc7, 0x5f, 0x55, 0x0f})) {
|
||||
wxLogMessage("\t\tObtained expected strong scalar secret from scalar(7)");
|
||||
}
|
||||
else {
|
||||
errorCode = 17;
|
||||
szError = "Fail\tUnexpected strong scalar secret from text secret";
|
||||
ILogError(szError.c_str());
|
||||
}*/
|
||||
auto time_taken{ std::chrono::duration_cast<std::chrono::microseconds> (end_time - start_time) };
|
||||
wxLogMessage("\t\tStrong secret derivation took %lld microseconds", time_taken.count());
|
||||
wxLogMessage("\t\tStrong secret derivation took %lld microseconds", time_taken.count());*/
|
||||
|
||||
ILogMessage("end testbed");
|
||||
}
|
||||
|
@ -608,9 +608,9 @@ namespace ristretto255 {
|
||||
v <<= 1;
|
||||
}
|
||||
}
|
||||
if (!(singletonApp->m_quick_unit_test)){
|
||||
if (!(singletonApp->m_quick_unit_test)) {
|
||||
auto start_time{ std::chrono::high_resolution_clock::now() };
|
||||
auto s1{ scalar( DeriveStrongSecretHash(&text_secret[0])) };
|
||||
auto s1{ scalar(DeriveStrongSecretHash(&text_secret[0])) };
|
||||
auto end_time{ std::chrono::high_resolution_clock::now() };
|
||||
if (s1 == scalar({ 0x59, 0xf6, 0x73, 0xb4, 0xa0, 0xc7, 0x0d, 0x8b, 0x51, 0xe5, 0x87, 0x7c, 0xf5, 0xd7, 0x6f, 0x55, 0x31, 0xa7, 0x0b, 0x14, 0x28, 0x54, 0x97, 0x08, 0x9f, 0x27, 0x83, 0xe1, 0xc7, 0x5f, 0x55, 0x0f })) {
|
||||
wxLogMessage("\t\tObtained expected strong scalar secret from scalar(7)");
|
||||
@ -635,6 +635,25 @@ namespace ristretto255 {
|
||||
szError = "Fail\tUnexpected fast scalar secret from strong scalar secret";
|
||||
ILogError(szError.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
{ auto start_time{ std::chrono::high_resolution_clock::now() };
|
||||
extended_private_key s1(&text_secret[0]);
|
||||
auto end_time{ std::chrono::high_resolution_clock::now() };
|
||||
std::string str_s1{ &(base58(s1))[0] };
|
||||
wxLogMessage("\t\textended private key: %s", str_s1);
|
||||
const char* str_s2 = "jyRioJfob242toZDETkd7nG4YW6oYeGBEVEw4KLGWZaJfCPV2hQbT3AFUcnu6ZXEvDPPpSmM5ivMJ2awJxSBS5DoE";
|
||||
if (str_s2 != str_s1) {
|
||||
throw MyException("unexpected value of private key", __LINE__, __func__, SrcFilename);
|
||||
}
|
||||
auto s2 = base58<extended_private_key>::bin(str_s2);
|
||||
if (s1 != s2) {
|
||||
throw MyException("Round trip for extended_private_key to and from base 58 representation failed", __LINE__, __func__, SrcFilename);
|
||||
}
|
||||
auto time_taken{ std::chrono::duration_cast<std::chrono::microseconds> (end_time - start_time) };
|
||||
wxLogMessage("\t\tStrong secret extended private key derivation took %lld microseconds", time_taken.count());
|
||||
}
|
||||
}
|
||||
else {
|
||||
ILogMessage("\t\tSkipping test of strong secret generation in quick unit test, because strong secret generation is deliberately slow.");
|
||||
|
Loading…
Reference in New Issue
Block a user