1
0
forked from cheng/wallet

minimally broken branch to isolate what is broken

This commit is contained in:
Cheng 2023-09-22 19:49:30 +10:00
parent 3dabb9992c
commit 9a12dbbd7e
No known key found for this signature in database
GPG Key ID: 571C3A9C3B9E6FCA

View File

@ -449,35 +449,36 @@ namespace ristretto255 {
template<typename T>
ristretto255::hsh<hashsize>& operator << (const T& j) {
int i{ 1 };
if constexpr (std::is_same_v<std::remove_cvref_t<T>, std::span<const byte> >) {
int i = crypto_generichash_blake2b_update(
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(
i = crypto_generichash_blake2b_update(
&(this->st),
(const unsigned char*)(j),
strlen(j) + 1
);
if (i) throw HashReuseException();
return *this;
}
else {
else if constexpr (is_serializable<const T>::value) {
auto sj = ro::serialize(j);
int i = crypto_generichash_blake2b_update(
i = crypto_generichash_blake2b_update(
&(this->st),
(const unsigned char*)&sj[0],
sj.size()
);
if (i) throw HashReuseException();
return *this;
}
else {
static_assert(false, "don't know a machine and compiler independent representation of this type");
}
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) {
@ -502,40 +503,6 @@ namespace ristretto255 {
}
}
};
/*
template<unsigned int hashsize, typename T>
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,
&j[0],
j.size()
);
if (i) throw HashReuseException();
return u;
}
else if constexpr (std::is_same_v<std::remove_cvref_t<T>, const char*>) {
int i = crypto_generichash_blake2b_update(
&u.st,
(const unsigned char *)(j),
strlen(j) + 1
);
if (i) throw HashReuseException();
return u;
}
else {
auto sj = ro::serialize(j);
int i = crypto_generichash_blake2b_update(
&u.st,
(const unsigned char*)&sj[0],
sj.size()
);
if (i) throw HashReuseException();
return u;
}
}
*/
// This constructs a finalized hash.
// If it has one argument, and that argument is hsh (unfinalized hash) object,