forked from cheng/wallet
Found the sanity test bug.
My hashing code incorrectly ignored the trailing null in std::strings. (but not in c strings)
This commit is contained in:
parent
bba593180e
commit
883d8c5b51
@ -27,11 +27,11 @@ display_wallet::display_wallet(wxWindow* parent, wxFileName& walletfile) :
|
|||||||
SetSizer(sizer);
|
SetSizer(sizer);
|
||||||
try {
|
try {
|
||||||
ro::sql read_names_and_keys(m_db,
|
ro::sql read_names_and_keys(m_db,
|
||||||
R"|(SELECT Names.name AS name, Keys.pubkey AS pubkey FROM Names INNER JOIN Keys ON Names.ROWID=Keys.id AND Keys.use=1 ORDER BY LOWER(name), name COLLATE NOCASE;)|");
|
R"|(SELECT Names.name AS name, Keys.pubkey AS pubkey FROM Names INNER JOIN Keys ON Names.ROWID=Keys.id AND Keys.use=1 ORDER BY LOWER(name), name COLLATE BINARY;)|");
|
||||||
while (read_names_and_keys.step() == Icompiled_sql::ROW) {
|
while (read_names_and_keys.step() == Icompiled_sql::ROW) {
|
||||||
std::string name = read_names_and_keys.column<const char*>(0);
|
std::string name = read_names_and_keys.column<const char*>(0);
|
||||||
auto pubkey = *read_names_and_keys.column<ristretto255::point>(1);
|
auto pubkey = *read_names_and_keys.column<ristretto255::point>(1);
|
||||||
// if (m_MasterSecret(name).timesBase() != pubkey)throw MyException(std::string(sz_public_key_of) + name + sz_fails_to_correspond);
|
if (m_MasterSecret(name).timesBase() != pubkey)throw MyException(std::string(sz_public_key_of) + name + sz_fails_to_correspond);
|
||||||
m_lSizer->Add(
|
m_lSizer->Add(
|
||||||
new wxStaticText(
|
new wxStaticText(
|
||||||
this,
|
this,
|
||||||
|
@ -65,7 +65,17 @@
|
|||||||
sizeof(std::declval<T>()[0]) == 1,
|
sizeof(std::declval<T>()[0]) == 1,
|
||||||
std::span<const byte>
|
std::span<const byte>
|
||||||
> serialize(const T& a) {
|
> serialize(const T& a) {
|
||||||
return std::span<const byte>(static_cast<const byte *>(static_cast<std::nullptr_t>(&a[0])), std::size(a));
|
int l;
|
||||||
|
const void* pt;
|
||||||
|
if constexpr (std::is_same_v<std::remove_cvref_t<T>, std::string>) {
|
||||||
|
l = a.length() + 1;
|
||||||
|
pt = a.c_str();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
l = std::size(a);
|
||||||
|
pt = &a[0];
|
||||||
|
}
|
||||||
|
return std::span<const byte>(static_cast<const byte *>(pt), l);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile time test to see if a type has a blob array member
|
// Compile time test to see if a type has a blob array member
|
||||||
|
@ -239,9 +239,12 @@ static bool checkDataConversionsProduceExpected(void){
|
|||||||
std::string str_pt_a = &(base58(pt_a))[0];
|
std::string str_pt_a = &(base58(pt_a))[0];
|
||||||
assert(base58<point>::bin(str_pt_a.c_str()) == pt_a);
|
assert(base58<point>::bin(str_pt_a.c_str()) == pt_a);
|
||||||
hash<256> hash_b{ hash_a,str_hash_a,scl_a,str_sclr_a,pt_a,str_pt_a,33, 66ull };
|
hash<256> hash_b{ hash_a,str_hash_a,scl_a,str_sclr_a,pt_a,str_pt_a,33, 66ull };
|
||||||
if (base58(hash_b).operator std::string() !=
|
auto str_b = base58(hash_b).operator std::string();
|
||||||
"i22EVNPsKRjdxYTZrPPu9mx6vnrBjosFix5F4gn2mb2kF"
|
if (str_b != "7cTScjKyUtmbvc28BV3ok51szgrQmaBa2YE5HPBcukC9e"
|
||||||
){ throw MyException("unexpected hash of transformations", __LINE__, __func__, SrcFilename);
|
) {
|
||||||
|
throw MyException(
|
||||||
|
std::format("unexpected hash of transformations: hash256#{}", str_b),
|
||||||
|
__LINE__, __func__, SrcFilename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const MyException& e) {
|
catch (const MyException& e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user