1
0
forked from cheng/wallet

Merge remote-tracking branch 'origin/attempt-to-fix-studio-update' into docs

This commit is contained in:
reaction.la 2023-02-24 13:39:53 +08:00
commit dbadd59e3c
No known key found for this signature in database
GPG Key ID: 99914792148C8388
10 changed files with 142 additions and 95 deletions

17
.gitattributes vendored
View File

@ -1,24 +1,25 @@
###############################################################################
# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto
# Force the following filetypes to have unix eols and encoding, so that Windows does not break them.
# If a file is going to be used on linux and windows, we want it invariant,
# rather than automatically translated, because automatic translation always screw things up.
* text=auto eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
* text=auto eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
.gitignore text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
.gitattributes text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
.gitmodules text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
*.sh text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
*.sh text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4 diff=bash
*.c text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
*.cpp text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
*.cpp text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4 diff=cpp
*.rs text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4 diff=rust
*.py text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4 diff=python
*.h text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
*.txt text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
*.html text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
*.htm text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
*.md text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
*.html text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4 diff=html
*.htm text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4 diff=html
*.md text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4 diff=markdown
*.pandoc text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
*.css text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4
*.css text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4 diff=css
*.manifest text eol=lf encoding=utf-8 whitespace=trailing-space,space-before-tab,tabwidth=4

View File

@ -3,50 +3,50 @@ set -e
set -x
echo intended to be run in the event of moving repositories
git remote -v
git remote set-url --push upstream git@rho.la:~/wallet.git
git remote set-url --push origin git@rho.la:~/wallet.git
git submodule foreach --recursive 'git remote -v'
cd libsodium
git remote set-url --push upstream git@rho.la:~/mpir.git
git remote set-url upstream https://github.com/jedisct1/libsodium.git
git remote set-url --push origin git@rho.la:~/mpir.git
git remote set-url origin https://github.com/jedisct1/libsodium.git
cd ..
cd mpir
git remote set-url --push upstream git@rho.la:~/mpir.git
git remote set-url upstream https://github.com/BrianGladman/mpir.git
git remote set-url --push origin git@rho.la:~/mpir.git
git remote set-url origin https://github.com/BrianGladman/mpir.git
cd ..
cd wxWidgets
git remote set-url --push upstream git@rho.la:~/wxWidgets.git
git remote set-url upstream https://github.com/wxWidgets/wxWidgets.git
git remote set-url --push origin git@rho.la:~/wxWidgets.git
git remote set-url origin https://github.com/wxWidgets/wxWidgets.git
cd ..
cd wxWidgets/3rdparty/catch
git remote set-url --push upstream git@rho.la:~/Catch.git
git remote set-url upstream https://github.com/wxWidgets/Catch.git
git remote set-url --push origin git@rho.la:~/Catch.git
git remote set-url origin https://github.com/wxWidgets/Catch.git
cd ../../..
cd wxWidgets/3rdparty/nanosvg
git remote set-url --push upstream git@rho.la:~/nanosvg
git remote set-url upstream https://github.com/wxWidgets/nanosvg
git remote set-url --push origin git@rho.la:~/nanosvg
git remote set-url origin https://github.com/wxWidgets/nanosvg
cd ../../..
cd wxWidgets/3rdparty/pcre
git remote set-url --push upstream git@rho.la:~/pcre
git remote set-url upstream https://github.com/wxWidgets/pcre
git remote set-url --push origin git@rho.la:~/pcre
git remote set-url origin https://github.com/wxWidgets/pcre
cd ../../..
cd wxWidgets/src/expat
git remote set-url --push upstream git@rho.la:~/libexpat.git
git remote set-url upstream https://github.com/wxWidgets/libexpat.git
git remote set-url --push origin git@rho.la:~/libexpat.git
git remote set-url origin https://github.com/wxWidgets/libexpat.git
cd ../../..
cd wxWidgets/src/jpeg
git remote set-url --push upstream git@rho.la:~/libjpeg-turbo.git
git remote set-url upstream https://github.com/wxWidgets/libjpeg-turbo.git
git remote set-url --push origin git@rho.la:~/libjpeg-turbo.git
git remote set-url origin https://github.com/wxWidgets/libjpeg-turbo.git
cd ../../..
cd wxWidgets/src/png
git remote set-url --push upstream git@rho.la:~/libpng.git
git remote set-url upstream https://github.com/wxWidgets/libpng.git
git remote set-url --push origin git@rho.la:~/libpng.git
git remote set-url origin https://github.com/wxWidgets/libpng.git
cd ../../..
cd wxWidgets/src/tiff
git remote set-url --push upstream git@rho.la:~/libtiff.git
git remote set-url upstream https://github.com/wxWidgets/libtiff.git
git remote set-url --push origin git@rho.la:~/libtiff.git
git remote set-url origin https://github.com/wxWidgets/libtiff.git
cd ../../..
cd wxWidgets/src/zlib
git remote set-url --push upstream git@rho.la:~/zlib.git
git remote set-url upstream https://github.com/wxWidgets/zlib.git
git remote set-url --push origin git@rho.la:~/zlib.git
git remote set-url origin https://github.com/wxWidgets/zlib.git
cd ../../..
winConfigure.sh

View File

@ -1,4 +1,4 @@
echo off
echo on
call C:\"Program Files (x86)"\"Microsoft Visual Studio"\2022\BuildTools\VC\Auxiliary\Build\vcvarsamd64_x86.bat
call C:\"Program Files"\"Microsoft Visual Studio"\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
echo on

View File

@ -19,12 +19,10 @@ App::~App()
bool App::OnInit()
{ if (wxApp::OnInit()) {
SetVendorName(wxT("rho")); /* This causes the non volatile config data to be stored under the rho on
windows.*/
SetAppName(wxT("wallet")); /* This causes the non volatile config data to be stored under rho\wallet
pConfig = std::unique_ptr<wxConfig>(new wxConfig("wallet", "rho"));
/* This causes the non volatile config data to be stored under rho\wallet
We will generally place data in the database, and if additional executables need their own data
in the config, they will create their own subkey under Computer\HKEY_CURRENT_USER\Software\rho */
pConfig = std::unique_ptr<wxConfigBase>(wxConfigBase::Get());
pConfig->SetRecordDefaults(false);
/* pConfig corresponds to the Windows Registry entry
Computer\HKEY_CURRENT_USER\Software\rho\wallet

View File

@ -3,7 +3,7 @@
class App : public wxApp
{
public:
std::unique_ptr<wxConfigBase>pConfig;
std::unique_ptr<wxConfig>pConfig;
// pConfig corresponds to the Windows Registry entry Computer\HKEY_CURRENT_USER\Software\ro\wallet
// Don't use the registry for stuff better served by wxStandardPaths and sqlit3 files located
// in locations specified by wxStandardPaths

View File

@ -70,7 +70,7 @@ try {
singletonFrame = this;
SetIcon(wxICON(AAArho));
sqlite3_init();
if (sodium_init() == -1) {
if (sodium_init() < 0) {
szError = "Fatal Error: Encryption library did not init.";
errorCode = 6;
// Cannot log the error, because logging not set up yet, so logging itself causes an exception

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,
@ -146,10 +144,11 @@ namespace ro {
// template class that generates a std::span of bytes over the blob
// field of any object containing a blob record, which is normally sufficient
// for a machine independent representation of that object
template <
typename T,
decltype(std::size(std::declval<T>().blob)) dummy_arg = 0
> auto serialize(const T& pt) {
template <typename T>
std::enable_if_t<
is_blob_field_type<T>::value,
std::span<const byte>
> serialize(const T& pt) {
return serialize(pt.blob);
}
@ -182,17 +181,17 @@ namespace ro {
template<class T, std::enable_if_t<is_standard_unsigned_integer<T>, int> = 0>
class userial : public std::span<byte> {
public:
std::array<byte, (std::numeric_limits<T>::digits + 6) / 7> blob;
std::array<byte, (std::numeric_limits<T>::digits + 6) / 7> bblob;
userial(T i) {
byte* p = &blob[0] + sizeof(blob);
byte* p = &bblob[0] + sizeof(bblob);
*(--p) = i & 0x7f;
i >>= 7;
while (i != 0) {
*(--p) = (i & 0x7f) | 0x80;
i >>= 7;
}
assert(p >= &blob[0]);
*static_cast<std::span<byte>*>(this) = std::span<byte>(p, &blob[0] + sizeof(blob));;
assert(p >= &bblob[0]);
*static_cast<std::span<byte>*>(this) = std::span<byte>(p, &bblob[0] + sizeof(bblob));;
}
};
@ -200,10 +199,10 @@ namespace ro {
template<class T, std::enable_if_t<is_standard_signed_integer<T>, int> = 0>
class iserial : public std::span<byte> {
public:
std::array<byte, (std::numeric_limits<T>::digits + 7) / 7> blob;
std::array<byte, (std::numeric_limits<T>::digits + 7) / 7> bblob;
iserial(T i) {
// Throw away the repeated leading bits, and g
byte* p = &blob[0] + sizeof(blob);
byte* p = &bblob[0] + sizeof(bblob);
unsigned count;
if (i < 0) {
size_t ui = i;
@ -218,8 +217,8 @@ namespace ro {
i >>= 7;
*(--p) = (i & 0x7f) | 0x80;
}
assert(p >= &blob[0]);
*static_cast<std::span<byte>*>(this) = std::span<byte>(p, &blob[0] + sizeof(blob));;
assert(p >= &bblob[0]);
*static_cast<std::span<byte>*>(this) = std::span<byte>(p, &bblob[0] + sizeof(bblob));;
}
};
@ -447,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) {
@ -462,13 +493,6 @@ namespace ristretto255 {
}
}
template < typename T>
decltype(ro::serialize(std::declval<std::remove_cvref<T>::type >()), hsh<hashsize>())&
operator <<(const T & j) {
return *this << ro::serialize(j);
}
template<typename T, typename... Args,
typename std::enable_if< ro::is_serializable<const T>::value, int >::type dummy_arg = 0
> void hashinto(const T first, Args... args) {
@ -477,27 +501,41 @@ namespace ristretto255 {
(*this).hashinto(args...);
}
}
hsh<hashsize>& operator <<(const std::span<const byte> j) {
};
/*
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(
&st,
&u.st,
&j[0],
j.size()
);
if (i) throw HashReuseException();
return *this;
return u;
}
hsh<hashsize>& operator <<(char* sz) {
else if constexpr (std::is_same_v<std::remove_cvref_t<T>, const char*>) {
int i = crypto_generichash_blake2b_update(
&st,
static_cast<std::nullptr_t>(sz),
strlen(sz) + 1
&u.st,
(const unsigned char *)(j),
strlen(j) + 1
);
if (i) throw HashReuseException();
return *this;
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,

View File

@ -62,7 +62,7 @@ constexpr bool b_WINDOWS = false;
static_assert(wxUSE_UNSAFE_WXSTRING_CONV == 1,
R"(In fully utf environment, (wallet.manifest plus
/utf-8 compile option) all string conversions are safe.)");
static_assert(wxMAJOR_VERSION == 3 && wxMINOR_VERSION == 1 && wxRELEASE_NUMBER == 7 && wxSUBRELEASE_NUMBER == 0, "expecting wxWidgets 3.1.7");
static_assert(wxMAJOR_VERSION == 3 && wxMINOR_VERSION == 2 && wxRELEASE_NUMBER == 0 && wxSUBRELEASE_NUMBER == 1, "expecting wxWidgets 3.1.7");
static_assert(wxUSE_IPV6 == 1, "IP6 unavailable in wxWidgets");
static_assert(WXWIN_COMPATIBILITY_3_0 == 0, "wxWidgets api out of date");
static_assert(wxUSE_COMPILER_TLS == (b_WINDOWS ? 2 : 1), "out of date workarounds in wxWidgets for windows bugs");
@ -79,7 +79,7 @@ std::span<uint8_t>& operator^=(std::span<byte>&, byte *);
#ifdef __WXMSW__
#include <wx/msw/msvcrt.h> // redefines the new() operator
#endif
#define SODIUM_STATIC
#define SODIUM_STATIC 1
#include <sodium.h>
#include <mpir.h>
#pragma comment(lib, "libsodium.lib")
@ -98,6 +98,7 @@ enum MyIDs {
myID_MAINFRAME_PANEL, myID_TESTWINDOW, myID_WELCOME_TO_ROCOIN, myID_WALLET_UI,
mID_CLOSE_WALLET, myID_MYEXIT
};
#include "localization.h"
#include "db_accessors.h"
#include "app.h"

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.");
@ -863,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++) {