mirror of
https://github.com/OpenCoin/oc-mint-cpp.git
synced 2025-07-06 23:29:41 +02:00
Compare commits
2 Commits
feature/ad
...
dac6a78311
Author | SHA1 | Date | |
---|---|---|---|
dac6a78311 | |||
a257fe227a |
11
.github/dependabot.yml
vendored
11
.github/dependabot.yml
vendored
@ -1,11 +0,0 @@
|
|||||||
# To get started with Dependabot version updates, you'll need to specify which
|
|
||||||
# package ecosystems to update and where the package manifests are located.
|
|
||||||
# Please see the documentation for all configuration options:
|
|
||||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
||||||
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "" # See documentation for possible values
|
|
||||||
directory: "/" # Location of package manifests
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
15
.github/workflows/cmake.yaml
vendored
15
.github/workflows/cmake.yaml
vendored
@ -19,9 +19,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest,
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
macos-latest,
|
|
||||||
windows-latest]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -30,13 +28,14 @@ jobs:
|
|||||||
if [ "$RUNNER_OS" == "Linux" ]; then
|
if [ "$RUNNER_OS" == "Linux" ]; then
|
||||||
sudo apt-get update && \
|
sudo apt-get update && \
|
||||||
sudo apt-get install -yq \
|
sudo apt-get install -yq \
|
||||||
libasio-dev \
|
libboost-system-dev \
|
||||||
libssl-dev zlib1g-dev \
|
libboost-date-time-dev \
|
||||||
cmake graphviz doxygen
|
cmake \
|
||||||
|
graphviz doxygen
|
||||||
elif [ "$RUNNER_OS" == "Windows" ]; then
|
elif [ "$RUNNER_OS" == "Windows" ]; then
|
||||||
VCPKG_DEFAULT_TRIPLET=x64-windows vcpkg install
|
choco install boost-msvc-14.3 graphviz doxygen.install
|
||||||
elif [ "$RUNNER_OS" == "macOS" ]; then
|
elif [ "$RUNNER_OS" == "macOS" ]; then
|
||||||
brew install asio openssl zlib doxygen graphviz
|
brew install boost graphviz doxygen
|
||||||
else
|
else
|
||||||
echo "$RUNNER_OS not supported"
|
echo "$RUNNER_OS not supported"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.1.3)
|
||||||
|
|
||||||
project(oc-issuer VERSION 0.0.2 LANGUAGES CXX)
|
|
||||||
|
|
||||||
enable_language(C)
|
enable_language(C)
|
||||||
enable_language(CXX)
|
enable_language(CXX)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS On)
|
|
||||||
|
|
||||||
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
|
||||||
if(POLICY CMP0077)
|
if(POLICY CMP0077)
|
||||||
cmake_policy(SET CMP0077 NEW)
|
cmake_policy(SET CMP0077 NEW)
|
||||||
endif()
|
endif()
|
||||||
@ -18,6 +14,7 @@ else()
|
|||||||
add_compile_options(-Wall -Wextra -pedantic)
|
add_compile_options(-Wall -Wextra -pedantic)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
project(oc-issuer VERSION 0.0.2 LANGUAGES CXX)
|
||||||
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
@ -30,12 +27,11 @@ set(CROW_BUILD_EXAMPLES Off)
|
|||||||
set(CROW_BUILD_TOOLS Off)
|
set(CROW_BUILD_TOOLS Off)
|
||||||
set(CROW_BUILD_TESTS Off)
|
set(CROW_BUILD_TESTS Off)
|
||||||
set(CROW_BUILD_DOCS Off)
|
set(CROW_BUILD_DOCS Off)
|
||||||
set(CROW_FEATURES "ssl;compression")
|
|
||||||
|
|
||||||
# add crow project to the build
|
# add crow project to the build
|
||||||
FetchContent_Declare(crow
|
FetchContent_Declare(crow
|
||||||
GIT_REPOSITORY https://github.com/CrowCpp/Crow.git
|
GIT_REPOSITORY https://github.com/CrowCpp/Crow.git
|
||||||
GIT_TAG v1.2.0
|
GIT_TAG v1.0+5
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT crow_POPULATED)
|
if(NOT crow_POPULATED)
|
||||||
@ -53,16 +49,16 @@ if(NOT expected_POPULATED)
|
|||||||
endif(NOT expected_POPULATED)
|
endif(NOT expected_POPULATED)
|
||||||
|
|
||||||
# add crypt++ (+cmake) library
|
# add crypt++ (+cmake) library
|
||||||
#set(CRYPTOPP_BUILD_TESTING Off)
|
set(CRYPTOPP_BUILD_TESTING Off)
|
||||||
#set(CRYPTOPP_INSTALL Off)
|
set(CRYPTOPP_INSTALL Off)
|
||||||
|
|
||||||
#if(NOT cryptopp_POPULATED)
|
if(NOT cryptopp_POPULATED)
|
||||||
# FetchContent_Declare(cryptopp
|
FetchContent_Declare(cryptopp
|
||||||
# GIT_REPOSITORY https://github.com/abdes/cryptopp-cmake.git
|
GIT_REPOSITORY https://github.com/abdes/cryptopp-cmake.git
|
||||||
# GIT_TAG CRYPTOPP_8_7_0_1)
|
GIT_TAG CRYPTOPP_8_7_0)
|
||||||
# FetchContent_Populate(cryptopp)
|
FetchContent_Populate(cryptopp)
|
||||||
# add_subdirectory(${cryptopp_SOURCE_DIR} ${cryptopp_BINARY_DIR})
|
add_subdirectory(${cryptopp_SOURCE_DIR} ${cryptopp_BINARY_DIR})
|
||||||
#endif(NOT cryptopp_POPULATED)
|
endif(NOT cryptopp_POPULATED)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
@ -72,7 +68,7 @@ set(CATCH_INSTALL_EXTRAS Off)
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
Catch2
|
Catch2
|
||||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||||
GIT_TAG v3.6.0
|
GIT_TAG v3.3.1
|
||||||
)
|
)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(Catch2)
|
FetchContent_MakeAvailable(Catch2)
|
||||||
@ -95,7 +91,7 @@ set(LIB_SOURCES
|
|||||||
src/big_int.hpp src/big_int.cpp )
|
src/big_int.hpp src/big_int.cpp )
|
||||||
|
|
||||||
add_library(oc-mint-lib ${LIB_SOURCES})
|
add_library(oc-mint-lib ${LIB_SOURCES})
|
||||||
target_link_libraries(oc-mint-lib PUBLIC Crow::Crow) # cryptopp::cryptopp)
|
target_link_libraries(oc-mint-lib PUBLIC Crow::Crow cryptopp::cryptopp)
|
||||||
target_include_directories(oc-mint-lib PUBLIC ${expected_SOURCE_DIR}/include src)
|
target_include_directories(oc-mint-lib PUBLIC ${expected_SOURCE_DIR}/include src)
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} src/main.cpp)
|
add_executable(${PROJECT_NAME} src/main.cpp)
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
//#include "cryptlib.h"
|
#include "cryptlib.h"
|
||||||
//#include "integer.h"
|
#include "integer.h"
|
||||||
//#include "nbtheory.h"
|
#include "nbtheory.h"
|
||||||
//#include "osrng.h"
|
#include "osrng.h"
|
||||||
//#include "rsa.h"
|
#include "rsa.h"
|
||||||
//#include "sha.h"
|
#include "sha.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
/*
|
|
||||||
CryptoPP::Integer blind_signature(const CryptoPP::SecByteBlock &orig,
|
CryptoPP::Integer blind_signature(const CryptoPP::SecByteBlock& orig,
|
||||||
const CryptoPP::Integer &r,
|
CryptoPP::Integer& r,
|
||||||
const CryptoPP::RSA::PublicKey &pub_key,
|
const CryptoPP::RSA::PublicKey& pub_key,
|
||||||
const CryptoPP::RSA::PrivateKey &priv_key) {
|
const CryptoPP::RSA::PrivateKey& priv_key) {
|
||||||
using namespace CryptoPP;
|
using namespace CryptoPP;
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
@ -23,7 +23,7 @@ CryptoPP::Integer blind_signature(const CryptoPP::SecByteBlock &orig,
|
|||||||
// Convenience
|
// Convenience
|
||||||
const Integer &n = pub_key.GetModulus();
|
const Integer &n = pub_key.GetModulus();
|
||||||
const Integer &e = pub_key.GetPublicExponent();
|
const Integer &e = pub_key.GetPublicExponent();
|
||||||
// const Integer &d = priv_key.GetPrivateExponent();
|
const Integer &d = priv_key.GetPrivateExponent();
|
||||||
|
|
||||||
// For sizing the hashed message buffer. This should be SHA256 size.
|
// For sizing the hashed message buffer. This should be SHA256 size.
|
||||||
const size_t sig_size = UnsignedMin(SHA256::BLOCKSIZE, n.ByteCount());
|
const size_t sig_size = UnsignedMin(SHA256::BLOCKSIZE, n.ByteCount());
|
||||||
@ -59,19 +59,23 @@ CryptoPP::Integer blind_signature(const CryptoPP::SecByteBlock &orig,
|
|||||||
return ss;
|
return ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptoPP::Integer unblind_signature(const CryptoPP::Integer &ss,
|
CryptoPP::Integer unblind_signature(CryptoPP::Integer const & ss,
|
||||||
const CryptoPP::Integer &r,
|
CryptoPP::Integer& r,
|
||||||
const CryptoPP::RSA::PublicKey &pub_key) {
|
|
||||||
|
const CryptoPP::RSA::PublicKey& pub_key)
|
||||||
|
{
|
||||||
|
|
||||||
const CryptoPP::Integer &n = pub_key.GetModulus();
|
const CryptoPP::Integer &n = pub_key.GetModulus();
|
||||||
CryptoPP::Integer s = a_times_b_mod_c(ss, r.InverseMod(n), n);
|
CryptoPP::Integer s = a_times_b_mod_c(ss, r.InverseMod(n), n);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptoPP::Integer verify(CryptoPP::Integer const &ss,
|
CryptoPP::Integer verify(CryptoPP::Integer const & ss,
|
||||||
const CryptoPP::Integer &r,
|
CryptoPP::Integer& r,
|
||||||
const CryptoPP::RSA::PublicKey &pub_key) {
|
|
||||||
CryptoPP::Integer s = unblind_signature(ss, r, pub_key);
|
const CryptoPP::RSA::PublicKey& pub_key)
|
||||||
|
{
|
||||||
|
CryptoPP::Integer s = unblind_signature(ss,r,pub_key);
|
||||||
CryptoPP::Integer v = pub_key.ApplyFunction(s);
|
CryptoPP::Integer v = pub_key.ApplyFunction(s);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
@ -99,8 +103,8 @@ TEST_CASE("cryptopp1", "[crypto]") {
|
|||||||
cout << "Pub exp: " << std::hex << e << endl;
|
cout << "Pub exp: " << std::hex << e << endl;
|
||||||
cout << "Priv mod: " << std::hex << priv_key.GetModulus() << endl;
|
cout << "Priv mod: " << std::hex << priv_key.GetModulus() << endl;
|
||||||
cout << "Priv exp: " << std::hex << d << endl;
|
cout << "Priv exp: " << std::hex << d << endl;
|
||||||
const char *MESSAGE = "secret";
|
const char* MESSAGE = "secret";
|
||||||
SecByteBlock orig((const byte *) MESSAGE, 6U);
|
SecByteBlock orig((const byte *)MESSAGE, 6U);
|
||||||
|
|
||||||
// Alice blinding
|
// Alice blinding
|
||||||
Integer r;
|
Integer r;
|
||||||
@ -150,8 +154,7 @@ TEST_CASE("cryptopp1", "[crypto]") {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
/*
|
|
||||||
TEST_CASE("cryptopp", "[crypto]") {
|
TEST_CASE("cryptopp", "[crypto]") {
|
||||||
using namespace CryptoPP;
|
using namespace CryptoPP;
|
||||||
using std::cout;
|
using std::cout;
|
||||||
@ -183,7 +186,7 @@ TEST_CASE("cryptopp", "[crypto]") {
|
|||||||
SecByteBlock buff_1, buff_2, buff_3;
|
SecByteBlock buff_1, buff_2, buff_3;
|
||||||
|
|
||||||
// Alice original message to be signed by Bob
|
// Alice original message to be signed by Bob
|
||||||
SecByteBlock orig((const byte *) "secret", 6U);
|
SecByteBlock orig((const byte *)"secret", 6U);
|
||||||
Integer m(orig.data(), orig.size());
|
Integer m(orig.data(), orig.size());
|
||||||
cout << "Message: " << std::hex << m << endl;
|
cout << "Message: " << std::hex << m << endl;
|
||||||
|
|
||||||
@ -247,4 +250,3 @@ TEST_CASE("cryptopp", "[crypto]") {
|
|||||||
}
|
}
|
||||||
cout << "Verified signature" << endl;
|
cout << "Verified signature" << endl;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "crow",
|
|
||||||
"version-string": "master",
|
|
||||||
"dependencies": [
|
|
||||||
"asio",
|
|
||||||
"openssl",
|
|
||||||
"zlib"
|
|
||||||
]
|
|
||||||
}
|
|
Reference in New Issue
Block a user