crash worked around
But the way I fixed it proves it is a visual studio bug, not my bug
This commit is contained in:
parent
5a9296e529
commit
003d671c25
@ -446,6 +446,38 @@ namespace ristretto255 {
|
||||
};
|
||||
assert(i == 0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ristretto255::hsh<hashsize>& operator << (const T& j) {
|
||||
if constexpr (std::is_same_v<std::remove_cvref_t<T>, std::span<const byte> >) {
|
||||
int i = crypto_generichash_blake2b_update(
|
||||
&(this->st),
|
||||
&j[0],
|
||||
j.size()
|
||||
);
|
||||
if (i) throw HashReuseException();
|
||||
return *this;
|
||||
}
|
||||
else if constexpr (std::is_same_v<std::remove_cvref_t<T>, const char*>) {
|
||||
int i = crypto_generichash_blake2b_update(
|
||||
&(this->st),
|
||||
(const unsigned char*)(j),
|
||||
strlen(j) + 1
|
||||
);
|
||||
if (i) throw HashReuseException();
|
||||
return *this;
|
||||
}
|
||||
else {
|
||||
auto sj = ro::serialize(j);
|
||||
int i = crypto_generichash_blake2b_update(
|
||||
&(this->st),
|
||||
(const unsigned char*)&sj[0],
|
||||
sj.size()
|
||||
);
|
||||
if (i) throw HashReuseException();
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
template<typename T, typename... Args,
|
||||
typename std::enable_if< is_serializable<const T, Args...>::value, int >::type dummy_arg = 0
|
||||
>explicit hsh(const T first, Args... args) {
|
||||
@ -470,9 +502,9 @@ namespace ristretto255 {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
template<unsigned int hashsize, typename T>
|
||||
ristretto255::hsh<hashsize>& operator <<(ristretto255::hsh<hashsize> u, const T& j) {
|
||||
ristretto255::hsh<hashsize>& operator <<(ristretto255::hsh<hashsize> &u, const T& j) {
|
||||
if constexpr (std::is_same_v<std::remove_cvref_t<T>, std::span<const byte> >) {
|
||||
int i = crypto_generichash_blake2b_update(
|
||||
&u.st,
|
||||
@ -502,18 +534,7 @@ namespace ristretto255 {
|
||||
return u;
|
||||
}
|
||||
}
|
||||
|
||||
template<unsigned int hashsize, const char *>
|
||||
ristretto255::hsh<hashsize>& operator <<(ristretto255::hsh<hashsize> u, const char* sz) {
|
||||
int i = crypto_generichash_blake2b_update(
|
||||
&u.st,
|
||||
static_cast<std::nullptr_t>(sz),
|
||||
// (unsigned char*)(sz),
|
||||
strlen(sz) + 1
|
||||
);
|
||||
if (i) throw HashReuseException();
|
||||
return u;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// This constructs a finalized hash.
|
||||
|
@ -885,11 +885,20 @@ static bool TestShareSecretGenerationSpeed(void) {
|
||||
}
|
||||
}
|
||||
ILogMessage("\tTesting hashing speed, hashes of hashes");
|
||||
auto first{ "first" };
|
||||
auto second{ "second" };
|
||||
if ( hash(first, second)
|
||||
!=
|
||||
hash(
|
||||
hsh() << first << second
|
||||
)
|
||||
) throw MyException("inconsistent hashes generated on strings");
|
||||
const char* _ = "hello";
|
||||
hash a(_);
|
||||
hash b(a);
|
||||
hash c(b);
|
||||
if(hash(b, c) != hash(hsh() << b << c)) throw MyException("inconsistent hashes generated");
|
||||
if (hash(b, c) != hash(hsh() << b << c)
|
||||
) throw MyException("inconsistent hashes generated");
|
||||
constexpr int hashes{ 3000 };
|
||||
start_time = std::chrono::high_resolution_clock::now();
|
||||
for (int i{ 0 }; i < hashes; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user