Now it compiles, but still fails unit test

So, though it compiles, the hashing code is compiling
to the wrong thing.

I conclude that my investment in template coding has been
excessive.  It is time to switch to rust.  Template
coding contains too much logically incoherent and
internally inconsistent backward compatibility
making it fragile to subtle changes in the compiler.
This commit is contained in:
Cheng 2023-02-16 15:24:43 +08:00
parent 0967d18cc4
commit 5a9296e529
No known key found for this signature in database
GPG Key ID: 571C3A9C3B9E6FCA
3 changed files with 23 additions and 25 deletions

View File

@ -1,28 +1,6 @@
#include "stdafx.h"
void randombytes_buf(std::span<byte> in) { randombytes_buf(&in[0], in.size_bytes()); }
void randombytes_buf(std::span< char> in) { randombytes_buf(&in[0], in.size_bytes()); }
bool operator ==(const std::span<byte>& p, const std::span<byte>& q) {
bool breturn{ true };
for (auto xq = q.begin(); auto xp:p) {
if (xp != *xq++) {
breturn = false;
break;
}
}
return breturn;
}
bool operator !=(const std::span<byte>& p, const std::span<byte>& q) {
bool breturn{ false };
for (auto xq = q.begin(); auto xp:p) {
if (xp != *xq++) {
breturn = true;
break;
}
}
return breturn;
}
namespace ristretto255 {
bool scalar::constant_time_required{ true };
bool point::constant_time_required{ true };

View File

@ -54,8 +54,6 @@
void randombytes_buf(std::span<byte> in);
void randombytes_buf(std::span<char > in);
bool operator !=(const std::span<byte>&, const std::span<byte>&);
bool operator ==(const std::span<byte>&, const std::span<byte>&);
namespace ro {
// Decay to pointer is dangerously convenient,
@ -497,7 +495,7 @@ namespace ristretto255 {
auto sj = ro::serialize(j);
int i = crypto_generichash_blake2b_update(
&u.st,
&sj[0],
(const unsigned char*)&sj[0],
sj.size()
);
if (i) throw HashReuseException();

View File

@ -612,6 +612,28 @@ static bool TestShareSecretGenerationSpeed(void) {
return true;
}
bool operator ==(const std::span<byte>& p, const std::span<byte>& q) {
bool breturn{ true };
for (auto xq = q.begin(); auto xp:p) {
if (xp != *xq++) {
breturn = false;
break;
}
}
return breturn;
}
bool operator !=(const std::span<byte>& p, const std::span<byte>& q) {
bool breturn{ false };
for (auto xq = q.begin(); auto xp:p) {
if (xp != *xq++) {
breturn = true;
break;
}
}
return breturn;
}
static bool TestSignatures(void) {
try {
ILogMessage("\tTest Schnorr signatures.");