Add sign_verify_test.cpp to tests/

pull/37/head
larteyoh 2 years ago
parent 54a6c44d45
commit ce2bbaacc5

@ -63,7 +63,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message(STATUS "Building with clang")
else()
message(STATUS "Building with gcc/g++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -no-pie")# -fsanitize=address") # -no-pie=detach from terminal
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -no-pie")# -fsanitize=address") # -no-pie=can run outside terminal
endif()
endif()

@ -217,7 +217,7 @@ You may support the neroshop project directly by donating Monero (XMR) to the ad
[//]: # (./clean.sh)
[//]: # (git checkout -b main)
[//]: # (git add .gitignore .gitmodules cmake/ CMakeLists.txt external/ fonts/ images/ main.qml premake5.lua qml/ qml.qrc README.md src/ test/)
[//]: # (git add .gitignore .gitmodules cmake/ CMakeLists.txt external/ fonts/ images/ premake5.lua qml/ qml.qrc README.md shaders/ src/ test/)
[//]: # (git commit -m"...")
[//]: # (git push -u origin main --force)
[//]: # (https://git.slipfox.xyz/larteyoh/testshop/settings => Mirror Settings => Synchronize Now)

@ -1,9 +1,9 @@
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>qml/main.qml</file>
<!-- qml sources: components -->
<file>qml/components/Banner.qml</file>
<file>qml/components/BannerPage.qml</file>
<file>qml/components/BannerItem.qml</file>
<file>qml/components/CatalogGrid.qml</file>
<file>qml/components/CatalogList.qml</file>
<file>qml/components/FilterBox.qml</file>
@ -31,10 +31,6 @@
<file>qml/pages/settings/SettingsOrders.qml</file>
<file>qml/pages/settings/SettingsSellersHub.qml</file>
<file>qml/pages/settings/SettingsWallet.qml</file>
<!-- shaders -->
<file>qml/shaders/opacity_mask_qt5.fsh</file>
<file>qml/shaders/opacity_mask_qt6.frag</file>
<file>qml/shaders/opacity_mask_qt6.frag.qsb</file>
<!-- fonts -->
<file>fonts/FiraCode-Bold.ttf</file>
<file>fonts/FiraCode-Light.ttf</file>
@ -84,5 +80,9 @@
<file>images/wallet.png</file>
<file>images/wownero_logo.png</file>
<!--<file>images/</file> -->
<!-- shaders -->
<file>shaders/opacity_mask_qt5.fsh</file>
<file>shaders/opacity_mask_qt6.frag</file>
<file>shaders/opacity_mask_qt6.frag.qsb</file>
</qresource>
</RCC>

@ -27,8 +27,8 @@ Item {
width: container.width
height: container.height
// For Qt5
fragmentShader: "qrc:/qml/shaders/opacity_mask_qt5.fsh"
fragmentShader: "qrc:/shaders/opacity_mask_qt5.fsh"
// For Qt6
// fragmentShader: "qrc:/qml/shaders/opacity_mask_qt6.frag.qsb"
// fragmentShader: "qrc:/shaders/opacity_mask_qt6.frag.qsb"
}
}

@ -37,8 +37,8 @@ QtObject {
tertiaryColor = "#393947"//"#4f4f63"//<= tint
}
else { //"DefaultDark"
primaryColor = "#202020"//"#121212"
secondaryColor = "#2e2e2e"//"#262626"
primaryColor = "#202020"////"#141414"
secondaryColor = "#2e2e2e"////"#1a1a1a"
tertiaryColor = "#595959"
}
}

@ -0,0 +1,216 @@
// requires Qt version 5.12 (latest is 5.15 as of this writing). See https://doc.qt.io/qt-5/qt5-intro.html
import QtQuick 2.12//2.7 //(QtQuick 2.7 is lowest version for Qt 5.7)
import QtQuick.Controls 2.12//2.0 // (requires at least Qt 5.12 where QtQuick.Controls 1 is deprecated. See https://doc.qt.io/qt-5/qtquickcontrols-index.html#versions) // needed for built-in styles // TextField, TextArea (multi-lined TextField), TextFieldStyle//import QtQuick.Controls.Material 2.12 // Other styles:
import QtQuick.Layouts 1.12//1.15 // The module is new in Qt 5.1 and requires Qt Quick 2.1. // RowLayout, ColumnLayout, GridLayout, StackLayout, Layout
import QtGraphicalEffects 1.12 // LinearGradient
import Qt.labs.platform 1.1 // FileDialog (since Qt 5.8) // change to "import QtQuick.Dialogs" if using Qt 6.2
import FontAwesome 1.0
//import neroshop.Wallet 1.0
import "components"
import "components" as NeroshopComponents
import "pages"
ApplicationWindow {
id: mainWindow
visible: true
title: qsTr("neroshop" + " v" + neroshopVersion)
width: Script.getNumber("neroshop.generalsettings.application.window.width")
height: Script.getNumber("neroshop.generalsettings.application.window.height")
minimumWidth: 850
minimumHeight: 500
color: NeroshopComponents.Style.getColorsFromTheme()[0]
header: Rectangle {
color: NeroshopComponents.Style.getColorsFromTheme()[1]
height: 100 // width should be set automatically to the parent's width
NeroshopComponents.SearchBar {
id: searchBar
visible: (!pageLoader.source.toString().match("qml/pages/MainPage.qml")) ? true : false;
anchors.left: parent.left
anchors.leftMargin: 20
anchors.top: parent.top
anchors.topMargin: 20
}
NeroshopComponents.NavigationalBar {
id: navBar
visible: (!pageLoader.source.toString().match("qml/pages/MainPage.qml")) ? true : false;
anchors.left: parent.right
anchors.leftMargin: (-this.width - 20)
anchors.top: parent.top
anchors.topMargin: 20
}
}
///////////////////////////
//ScrollView {
/*StackView {
anchors.fill: parent
////initialItem: pageLoader
}*/
Loader {
id: pageLoader
//anchors.centerIn: parent // place at center of parent // <= don't use this EVER. Not for loading pages
anchors.fill: parent
source: "qrc:/qml/pages/MainPage.qml"
//source: "qrc:/qml/pages/HomePage.qml"
//source: "qrc:/qml/pages/CatalogPage.qml"
//source: "qrc:/qml/pages/ProductPage.qml"
//source: "qrc:/qml/pages/OrderCheckoutPage.qml"
////source: "qrc:/qml/pages/Page.qml"
onSourceChanged: {
console.log(source);
if (pageLoader.status == Loader.Ready) console.log('Loaded')
else console.log('Not Loaded')
}
}
NeroshopComponents.SettingsDialog {
id: settingsDialog
anchors.centerIn: Overlay.overlay//parent: Overlay.overlay; anchors.centerIn: parent
closePolicy: Popup.CloseOnEscape
dim: true
enter: Transition {
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
}
exit: Transition {
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0 }
}
}
// navigating between different pages: https://stackoverflow.com/a/15655043
// The footer item is positioned to the bottom, and resized to the width of the window
// Custom ToolBar
footer: Rectangle {
height: 40//; width: parent.width// width is automatically set to parent's width by default so no need to manually set the footer width
color: NeroshopComponents.Style.getColorsFromTheme()[1]
Row {
anchors.fill: parent//anchors.horizontalCenter: parent.horizontalCenter
anchors.rightMargin: 20 // use leftMargin only if using layoutDirection is Qt.LeftToRight
spacing: 20 // Spacing between each Row item
layoutDirection: Qt.RightToLeft
Rectangle {
width: themeSwitcher.width + settingsButton.width
height: footer.height//themeSwitcher.height
color: "transparent"
//border.color: "blue"
NeroshopComponents.ThemeSwitch {
id: themeSwitcher
width: 40
anchors.left: settingsButton.right
}
Button {
id: settingsButton
display: AbstractButton.IconOnly
checkable: true
checked: settingsDialog.visible
icon.source: "qrc:/images/cog.png"//"/tools.png"
icon.color: "#001677"////hovered ? "#001677" : "#ffffff"//(!checked && hovered) ? "#001677" : "#ffffff"
//icon.width: parent.width//footer.height
//icon.height: parent.height//32//footer.height
hoverEnabled: true
anchors.verticalCenter: parent.verticalCenter
background: Rectangle {
color: "transparent"//(parent.checked) ? "#001677" : "transparent"
radius: 3
border.color: parent.hovered ? "#001677" : this.color//"#001677"
//border.width: (!parent.checked && parent.hovered) ? 1 : 0
}
onClicked: {
settingsDialog.open()
}
NeroshopComponents.Hint {
visible: parent.hovered
x: parent.x + (parent.width - this.width) / 2 // Popups don't have anchors :(
height: contentHeight + 20; width: contentWidth + 20
bottomMargin : footer.height + 5
text: qsTr("Settings")
pointer.visible: false
}
}
}
Rectangle {
width: daemonSyncBar.width
height: footer.height
color: "transparent"
//border.color: "red"
NeroshopComponents.ProgressBar {
id: daemonSyncBar
radius: 20
foregroundColor: "#564978"
backgroundColor: (NeroshopComponents.Style.darkTheme) ? "#8c8c8c" : "#d9d9d9"//backgroundColor: "#d9d9d9"
//textObject.visible: true
hoverEnabled: true
anchors.verticalCenter: parent.verticalCenter//anchors.top: parent.top; anchors.topMargin: (parent.height - this.height) / 2 // center vertically on footer (height)
value: 0.5 // placeholder value
NeroshopComponents.Hint {
visible: parent.hovered
x: parent.x + (parent.width - this.width) / 2 // Popups don't have anchors :(
height: contentHeight + 20; width: parent.width
bottomMargin : footer.height + 5
text: qsTr("neromon\n%1 (%2)").arg((parent.value < 1.0) ? "Synchronizing" : "Connected").arg((parent.value * 100).toString() + "%")
pointer.visible: false
}
}
}
Rectangle {
width: moneroDaemonSyncBar.width
height: footer.height
color: "transparent"
//border.color: "plum"
NeroshopComponents.ProgressBar {
id: moneroDaemonSyncBar
radius: daemonSyncBar.radius
foregroundColor: NeroshopComponents.Style.moneroOrangeColor
backgroundColor: (NeroshopComponents.Style.darkTheme) ? "#8c8c8c" : "#d9d9d9"//backgroundColor: "#d9d9d9"//(NeroshopComponents.Style.darkTheme) ? "#8c8c8c" : NeroshopComponents.Style.moneroGrayColor
//textObject.visible: true
//textObject.text: "wallet sync: " + (this.value * 100).toString() + "%"
//textObject.color: "#ffffff"
hoverEnabled: true
anchors.verticalCenter: parent.verticalCenter//anchors.top: parent.top; anchors.topMargin: (parent.height - this.height) / 2
////value: Wallet.isGenerated() ? Wallet.getSyncPercentage() : 0.0 // this does not work (fails to update value so we use Timer instead)
Timer {
interval: 1 // trigger every x miliseconds
running: true
repeat: true // If repeat is true the timer is triggered repeatedly at the specified interval
onTriggered: {
moneroDaemonSyncBar.value = Wallet.getSyncPercentage()//Math.floor(Math.random() * (moneroDaemonSyncBar.to - moneroDaemonSyncBar.from + 1) + moneroDaemonSyncBar.from);
}
}
NeroshopComponents.Hint {
visible: parent.hovered
x: parent.x + (parent.width - this.width) / 2
height: contentHeight + 20; width: parent.width
bottomMargin : footer.height + 5
text: qsTr("%1\n%2 (%3)\n Blocks remaining: %4 / %5").arg("monerod").arg(!Wallet.isGenerated() ? "Disconnected" : ((parent.value < 1.0) ? Wallet.getSyncMessage() : "Connected")).arg((parent.value * 100).toFixed(2) + "%").arg(!Wallet.isGenerated() ? 0 : Wallet.getSyncHeight()).arg(!Wallet.isGenerated() ? 0 : Wallet.getSyncEndHeight()) // If connected to a remote node, "monerod" will be replaced by the <ip>:<port> of the remote node
pointer.visible: false
}
}
}
//Rectangle {
//}
}
}
}
// error: module "QtQuick.Layouts" version 1.15 is not installed (fix by changing the version specified in /usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick/Layouts/plugins.qmltypes)
// error: module "Qt.labs.platform" is not installed (fix: sudo apt install qml-module-qt-labs-platform)
// error: gtk errors on "wallet_upload_button" clicked (fix: https://forums.wxwidgets.org/viewtopic.php?t=47187)
// install: qtbase5-dev for "../cmake/Qt5/Qt5Config.cmake"
// error: /usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake will set Qt5_FOUND to FALSE so package "Qt5" is considered to be NOT FOUND due to Qml and Quick configuration files (/usr/lib/x86_64-linux-gnu/cmake/Qt5Qml/Qt5QmlConfig.cmake; /usr/lib/x86_64-linux-gnu/cmake/Qt5Quick/Qt5QuickConfig.cmake) not being found (fix: sudo apt install qtdeclarative5-dev)
// error: module "QtQuick" is not installed (fix: qml-module-qtquick-controls qml-module-qtquick-controls2). This will also install qml-module-qtgraphicaleffects, qml-module-qtquick-layouts, qml-module-qtquick-window2, and qml-module-qtquick2
// error: module "QtQuick.Shapes" is not installed (fix: qml-module-qtquick-shapes)

@ -34,7 +34,7 @@ Page {
Layout.preferredWidth: scrollView.width////parent.width // will not fill page if you use parent.width. Use scrollView.width instead
Layout.row: 0 // sets the row position
NeroshopComponents.BannerPage {
NeroshopComponents.BannerItem {
Rectangle {
id: firstPage
anchors.fill: parent
@ -47,7 +47,7 @@ Page {
}
}
NeroshopComponents.BannerPage {
NeroshopComponents.BannerItem {
Rectangle {
id: secondPage
anchors.fill: parent
@ -55,7 +55,7 @@ Page {
}
}
NeroshopComponents.BannerPage {
NeroshopComponents.BannerItem {
Rectangle {
id: thirdPage
anchors.fill: parent
@ -63,6 +63,36 @@ Page {
}
}
} // Banner
Text {
Layout.row: 2
Layout.topMargin: 10
text: "Recently added"//"Featured items"//"Best sellers"//"On Sale"//"Recommended items"//"Shop by Category"
color: (NeroshopComponents.Style.darkTheme) ? "#ffffff" : "#000000"
font.bold: true
font.pointSize: 16
}
Flow {
Layout.row: 3
Layout.preferredWidth: parent.width////scrollView.width
Layout.maximumWidth: scrollView.width////mainWindow.width
Layout.topMargin: 10
spacing: 5
//Layout.alignment: Qt.AlignHCenter | Qt.AlignTop // does nothing
Repeater {
id: itemsRepeater
model: 16//6
delegate: Rectangle {
implicitWidth: 200
implicitHeight: implicitWidth
color: NeroshopComponents.Style.getColorsFromTheme()[1]
radius: 3
Image {
source: "qrc:/images/image_gallery.png"
anchors.centerIn: parent
}
}
}
}
} // GridLayout
} // ScrollView
}

@ -132,7 +132,7 @@ Page {
// GradientStop { position: 0.0; color: "white" }
// GradientStop { position: 1.0; color: "black" }
//}
//anchors.right: parent.right//implicitWidth: 200
//Layout.alignment: Qt.AlignVCenter
//implicitHeight: 200
// add spacing from parent (padding - located inside the borders of an element)
//anchors.margins: 50//anchors.leftPadding: 20
@ -190,19 +190,15 @@ Page {
button.checked = true
if(button.text == restoreFromFileButton.text) {
walletRestoreStack.currentIndex = 0
console.log(button.width)
}
if(button.text == restoreFromSeedButton.text) {
walletRestoreStack.currentIndex = 1
console.log(button.width)
}
if(button.text == restoreFromKeysButton.text) {
walletRestoreStack.currentIndex = 2
console.log(button.width)
}
if(button.text == restoreFromHWButton.text) {
walletRestoreStack.currentIndex = 3
console.log(button.width)
}
}
}
@ -214,18 +210,20 @@ Page {
Layout.column: 0
Layout.fillWidth: true
Layout.topMargin: 15
property real buttonWidth: (500 / 4)
property real buttonHeight: 40
// to add a button to the button group (within the Button object itself): ButtonGroup.group: walletRestoreMethodButtonGroup // attaches a button to a button group
Button {
id: restoreFromFileButton
ButtonGroup.group: walletRestoreMethodButtonGroup
checked: true
text: qsTr("Restore from file")//.arg("\uf8e9")
Layout.preferredHeight: 40
Layout.preferredWidth: hovered ? 180 : (500 / 4)
Layout.maximumWidth: 180//contentWidth + 20
Layout.preferredHeight: parent.buttonHeight
Layout.preferredWidth: parent.buttonWidth//hovered ? 180 : parent.buttonWidth
//Layout.maximumWidth: 180//contentWidth + 20
icon.source: "qrc:/images/file.png" // keys (key.png), seed (sprout.png), file, hardware
//icon.color: "#ffffff"
display: hovered ? AbstractButton.TextBesideIcon : AbstractButton.IconOnly//AbstractButton.TextUnderIcon
display: AbstractButton.IconOnly//hovered ? AbstractButton.TextBesideIcon : AbstractButton.IconOnly//AbstractButton.TextUnderIcon
hoverEnabled: true
background: Rectangle {
color: (parent.checked) ? "#39304f" : "#6b5b95"
@ -243,10 +241,10 @@ Page {
}*/
NeroshopComponents.Hint {
id: restoreFileHint
visible: parent.hovered
visible: parent.hovered; delay: 0
text: parent.text
pointer.visible: true//false
y: parent.y - (parent.height + pointer.height)//(parent.height - this.height) / 2
pointer.visible: false
//y: parent.y - (parent.height + pointer.height)//(parent.height - this.height) / 2
}
}
@ -254,11 +252,11 @@ Page {
id: restoreFromSeedButton
ButtonGroup.group: walletRestoreMethodButtonGroup
text: qsTr("Restore from seed")//.arg("\uf8e9")
Layout.preferredWidth: hovered ? 180 : (500 / 4)//width: contentWidth + 20;
Layout.preferredHeight: 40
Layout.preferredWidth: parent.buttonWidth//width: contentWidth + 20;
Layout.preferredHeight: parent.buttonHeight
icon.source: "qrc:/images/sprout.png" // keys (key.png), seed (sprout.png), file, hardware
//icon.color: "#ffffff"
display: hovered ? AbstractButton.TextBesideIcon : AbstractButton.IconOnly//AbstractButton.TextUnderIcon
display: AbstractButton.IconOnly
hoverEnabled: true
background: Rectangle {
color: (parent.checked) ? "#39304f" : "#6b5b95"
@ -266,17 +264,23 @@ Page {
//border.width: 1
radius: 3
}
NeroshopComponents.Hint {
visible: parent.hovered; delay: 0
text: parent.text
pointer.visible: false
//y: parent.y - (parent.height + pointer.height)//(parent.height - this.height) / 2
}
}
Button {
id: restoreFromKeysButton
ButtonGroup.group: walletRestoreMethodButtonGroup
text: qsTr("Restore from keys")//.arg("\uf8e9")
Layout.preferredWidth: hovered ? 180 : (500 / 4)//width: contentWidth + 20;
Layout.preferredHeight: 40
Layout.preferredWidth: parent.buttonWidth//width: contentWidth + 20;
Layout.preferredHeight: parent.buttonHeight
icon.source: "qrc:/images/key.png" // keys (key.png), seed (sprout.png), file, hardware
//icon.color: "#ffffff"
display: hovered ? AbstractButton.TextBesideIcon : AbstractButton.IconOnly//AbstractButton.TextUnderIcon
display: AbstractButton.IconOnly
hoverEnabled: true
background: Rectangle {
color: (parent.checked) ? "#39304f" : "#6b5b95"
@ -284,18 +288,24 @@ Page {
//border.width: 1
radius: 3
}
NeroshopComponents.Hint {
visible: parent.hovered; delay: 0
text: parent.text
pointer.visible: false
//y: parent.y - (parent.height + pointer.height)//(parent.height - this.height) / 2
}
}
Button {
id: restoreFromHWButton
ButtonGroup.group: walletRestoreMethodButtonGroup
text: qsTr("Restore from HW")//("Restore from hardware")//.arg("\uf8e9")
Layout.preferredWidth: hovered ? Layout.maximumWidth : (500 / 4)//width: contentWidth + 20;
Layout.preferredHeight: 40
Layout.maximumWidth: 180//280
Layout.preferredWidth: parent.buttonWidth//hovered ? Layout.maximumWidth : parent.buttonWidth//width: contentWidth + 20;
Layout.preferredHeight: parent.buttonHeight
//Layout.maximumWidth: 180//280
icon.source: "qrc:/images/usb.png" // keys (key.png), seed (sprout.png), file, hardware
//icon.color: "#ffffff"
display: hovered ? AbstractButton.TextBesideIcon : AbstractButton.IconOnly//AbstractButton.TextUnderIcon
display: AbstractButton.IconOnly
hoverEnabled: true
background: Rectangle {
color: (parent.checked) ? "#39304f" : "#6b5b95"
@ -303,6 +313,12 @@ Page {
//border.width: 1
radius: 3
}
NeroshopComponents.Hint {
visible: parent.hovered; delay: 0
text: parent.text
pointer.visible: false
//y: parent.y - (parent.height + pointer.height)//(parent.height - this.height) / 2
}
}
} // RowLayout
// walletRestoreStack
@ -315,13 +331,11 @@ Page {
// WalletFileStackContent
ColumnLayout {
id: restoreFromWalletFile
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop | Qt.AlignVCenter
Layout.topMargin: 20
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter// | Qt.AlignTop; Layout.topMargin: 20
//Layout.minimumHeight:
Layout.preferredWidth: 500
Layout.maximumWidth: 600
//Layout.preferredHeight: 380
//GridLayout {}
/*color: "transparent"
border.color: (NeroshopComponents.Style.darkTheme) ? "#a9a9a9" : "#696969"
//radius: 3*/
@ -342,7 +356,7 @@ Page {
id: walletFileField
Layout.row: 1
Layout.column: 0
//Layout.alignment: Qt.AlignHCenter//Layout.fillWidth: true
Layout.fillWidth: true//Layout.alignment: Qt.AlignHCenter
Layout.preferredWidth: 500
Layout.preferredHeight: 50
Layout.topMargin: (walletFileText.visible) ? 5 : 0
@ -360,9 +374,11 @@ Page {
// wallet file upload or browse button
Button {
id: walletFileBrowseButton
Layout.row: 2
Layout.column: 0
Layout.preferredWidth: walletFileBrowseButtonText.contentWidth + 20
Layout.row: 2//1
Layout.column: 0//1
Layout.alignment: Qt.AlignHCenter
////Layout.fillWidth: true
Layout.preferredWidth: 125////walletFileBrowseButtonText.contentWidth + 20
Layout.preferredHeight: walletFileField.height
Layout.topMargin: 20
text: qsTr("Browse")
@ -394,6 +410,7 @@ Page {
TextField {
id: walletPasswordRestoreField
//Layout.alignment: Qt.AlignHCenter//Layout.fillWidth: true
Layout.fillWidth: true
Layout.preferredWidth: 500
Layout.preferredHeight: 50
Layout.row: 3
@ -401,6 +418,8 @@ Page {
Layout.topMargin: 15
placeholderText: qsTr("Wallet Password"); placeholderTextColor: (NeroshopComponents.Style.darkTheme) ? "#a9a9a9" : "#696969"
color: (NeroshopComponents.Style.darkTheme) ? "#ffffff" : "#000000" // textColor
echoMode: TextInput.Password
inputMethodHints: Qt.ImhSensitiveData
selectByMouse: true
background: Rectangle {
@ -412,12 +431,20 @@ Page {
}
Rectangle {
id: restoreFromMnemonicSeed
//ColumnLayout {
// TextArea {
// }
//}
}
Rectangle {
id: restoreFromKeys
//ColumnLayout {
//}
}
Rectangle {
id: restoreFromHardwareWallet
//ColumnLayout {
//}
}
}
// confirm button
@ -428,6 +455,7 @@ Page {
Layout.fillWidth: true
Layout.preferredWidth: 500
Layout.preferredHeight: 50
Layout.topMargin: 15
text: qsTr("Confirm")
hoverEnabled: true
////onClicked: login()
@ -880,6 +908,7 @@ Page {
verticalAlignment: TextEdit.AlignVCenter // align the text within the center of TextArea item's height
wrapMode: TextEdit.Wrap // move text to newline if it reaches the width of the TextArea
text: qsTr("")
//font.bold: true
color: (messageCode == 1) ? "#b22222" : ((NeroshopComponents.Style.darkTheme) ? "#ffffff" : "#404040")// text color
property int messageCode: 0 //0 = info; 1 = warning or error
background: Rectangle {
@ -887,7 +916,7 @@ Page {
border.color: (parent.messageCode == 1) ? "#b22222" : ((NeroshopComponents.Style.darkTheme) ? "#a9a9a9" : parent.color)////parent.color
radius: 3
}
leftPadding: 30 + circleInfo.contentWidth
leftPadding: 25 + circleInfo.contentWidth
Text {
////id: circleInfo
anchors.left: parent.left

@ -350,9 +350,6 @@ std::pair<std::string, std::string> neroshop::Encryptor::get_key_pair(const EVP_
// refer to: https://www.openssl.org/docs/man3.0/man3/EVP_PKEY_sign.html
// https://www.openssl.org/docs/man3.0/man3/EVP_PKEY_verify.html
////////////////////
//Experimental function for signing data using a public key. Couldn't get it
//complete working
// None of the code below work properly and are not functional
std::string neroshop::Encryptor::sign_message(const EVP_PKEY *key, const std::string &message)
{
// NB: assumes signing_key and md are set up before the next

@ -0,0 +1 @@
#include "escrow.hpp"

@ -0,0 +1,15 @@
#pragma once
#ifndef ESCROW_HPP_NEROSHOP
#define ESCROW_HPP_NEROSHOP
#include "wallet.hpp"
namespace neroshop {
class Escrow {
};
}
#endif

@ -52,7 +52,6 @@ int main(int argc, char *argv[]) {
QQmlApplicationEngine engine;
//--------------------------
////////////////////////////////////////////////////////
// Configuration file must be loaded right after Qt Application object has been created so that we can get the correct config location
// open configuration script
neroshop::open_configuration_file();
@ -90,8 +89,8 @@ int main(int argc, char *argv[]) {
// register backend
engine.rootContext()->setContextProperty("Backend", new Backend());
//--------------------------
// When using qrc.qml to store images, use: QUrl(QStringLiteral("qrc:///main.qml"))
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));//("../main.qml");//("main.qml");//(QUrl(QStringLiteral("qrc:/main.qml")));
// Load main.qml from the "qml/" directory
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
if (engine.rootObjects().isEmpty()) {
return -1;
}

@ -386,6 +386,10 @@ target_link_libraries(${test_qr_code} ${monero_cpp_src} ${sqlite_src} ${qr_code_
set(test_crypt "encryption_test")
add_executable(${test_crypt} encryption_test.cpp ${neroshop_srcs})
target_link_libraries(${test_crypt} ${monero_cpp_src} ${sqlite_src} ${qr_code_generator_src} ${raft_src} ${libuv_src} ${curl_src} ${monero_src} ${lua_src} ${png_src})
# sign_verify_test
set(test_sign_verify "sign_verify_test")
add_executable(${test_sign_verify} sign_verify_test.cpp ${neroshop_srcs})
target_link_libraries(${test_sign_verify} ${monero_cpp_src} ${sqlite_src} ${qr_code_generator_src} ${raft_src} ${libuv_src} ${curl_src} ${monero_src} ${lua_src} ${png_src})
# Qt gui_test
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
@ -427,6 +431,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(${test_auth} ${posix_src})
target_link_libraries(${test_qr_code} ${posix_src})
target_link_libraries(${test_crypt} ${posix_src})
target_link_libraries(${test_sign_verify} ${posix_src})
target_link_libraries(${test_gui_qt} ${posix_src})
#target_link_libraries(${test_} ${posix_src})
find_package(X11 REQUIRED)

@ -0,0 +1,89 @@
#include <fstream>
#include <iostream>
#include <vector>
#include "../src/core/encryptor.hpp"
EVP_PKEY *read_key_pub(const std::string &filepath)
{
std::ifstream file(filepath);
std::string str;
std::string key;
while (std::getline(file, str)) {
key += str;
key += "\n";
}
BIO *bio_public = BIO_new(BIO_s_mem());
if (BIO_write(bio_public, key.c_str(), key.length()) <= 0) {
return nullptr;
}
return PEM_read_bio_PUBKEY(bio_public, nullptr, nullptr, nullptr);
}
EVP_PKEY *read_key_priv(const std::string &filepath)
{
std::ifstream file(filepath);
std::string str;
std::string key;
while (std::getline(file, str)) {
key += str;
key += "\n";
}
BIO *bio_public = BIO_new(BIO_s_mem());
if (BIO_write(bio_public, key.c_str(), key.length()) <= 0) {
return nullptr;
}
return PEM_read_bio_PrivateKey(bio_public, nullptr, nullptr, nullptr);
}
void test_encrypt_decrypt()
{
auto pkey = neroshop::Encryptor::generate_key_pair_return();
const std::string msg = "olla!";
auto enc = neroshop::Encryptor::encrypt_message(pkey, msg);
auto dec = neroshop::Encryptor::decrypt_message(pkey, enc);
std::cout << __FUNCTION__ << " result: " << (dec == msg ? "pass" : "fail") << std::endl;
}
void test_encrypt_decrypt_file()
{
neroshop::Encryptor::generate_key_pair();
std::ifstream pub("public.pem");
std::string str;
std::string pub_key;
while (std::getline(pub, str)) {
pub_key += str;
pub_key += "\n";
}
std::ifstream priv("private.pem");
std::string priv_key;
while (std::getline(priv, str)) {
priv_key += str;
priv_key += "\n";
}
const std::string msg = "olla!";
auto enc = neroshop::Encryptor::public_encrypt(pub_key, msg);
auto dec = neroshop::Encryptor::private_decrypt(priv_key, enc);
std::cout << __FUNCTION__ << " result: " << (dec == msg ? "pass" : "fail") << std::endl;
}
void test_sign_verify()
{
const std::string msg = "hello";
auto pkey = neroshop::Encryptor::generate_key_pair_return();
auto signature = neroshop::Encryptor::sign_message(pkey, msg);
auto result = neroshop::Encryptor::verify_signature(pkey, msg, signature);
std::cout << __FUNCTION__ << " result: " << (result == 1 ? "pass" : "fail") << std::endl;
}
int main()
{
test_encrypt_decrypt();
test_encrypt_decrypt_file();
test_sign_verify();
return 0;
}
Loading…
Cancel
Save