mirror of
https://github.com/OpenCoin/oc-mint-cpp.git
synced 2024-12-22 07:39:40 +01:00
removed cryptopp, openssl shall be used instead for blinding (but not implemented yet)
This commit is contained in:
parent
96d25a0a9a
commit
2a33e41376
@ -7,6 +7,7 @@ enable_language(CXX)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS On)
|
||||
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
||||
if(POLICY CMP0077)
|
||||
cmake_policy(SET CMP0077 NEW)
|
||||
endif()
|
||||
@ -52,16 +53,16 @@ if(NOT expected_POPULATED)
|
||||
endif(NOT expected_POPULATED)
|
||||
|
||||
# add crypt++ (+cmake) library
|
||||
set(CRYPTOPP_BUILD_TESTING Off)
|
||||
set(CRYPTOPP_INSTALL Off)
|
||||
#set(CRYPTOPP_BUILD_TESTING Off)
|
||||
#set(CRYPTOPP_INSTALL Off)
|
||||
|
||||
if(NOT cryptopp_POPULATED)
|
||||
FetchContent_Declare(cryptopp
|
||||
GIT_REPOSITORY https://github.com/abdes/cryptopp-cmake.git
|
||||
GIT_TAG CRYPTOPP_8_7_0)
|
||||
FetchContent_Populate(cryptopp)
|
||||
add_subdirectory(${cryptopp_SOURCE_DIR} ${cryptopp_BINARY_DIR})
|
||||
endif(NOT cryptopp_POPULATED)
|
||||
#if(NOT cryptopp_POPULATED)
|
||||
# FetchContent_Declare(cryptopp
|
||||
# GIT_REPOSITORY https://github.com/abdes/cryptopp-cmake.git
|
||||
# GIT_TAG CRYPTOPP_8_7_0_1)
|
||||
# FetchContent_Populate(cryptopp)
|
||||
# add_subdirectory(${cryptopp_SOURCE_DIR} ${cryptopp_BINARY_DIR})
|
||||
#endif(NOT cryptopp_POPULATED)
|
||||
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
@ -94,7 +95,7 @@ set(LIB_SOURCES
|
||||
src/big_int.hpp src/big_int.cpp )
|
||||
|
||||
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)
|
||||
|
||||
add_executable(${PROJECT_NAME} src/main.cpp)
|
||||
|
@ -1,21 +1,21 @@
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "cryptlib.h"
|
||||
#include "integer.h"
|
||||
#include "nbtheory.h"
|
||||
#include "osrng.h"
|
||||
#include "rsa.h"
|
||||
#include "sha.h"
|
||||
//#include "cryptlib.h"
|
||||
//#include "integer.h"
|
||||
//#include "nbtheory.h"
|
||||
//#include "osrng.h"
|
||||
//#include "rsa.h"
|
||||
//#include "sha.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
CryptoPP::Integer blind_signature(const CryptoPP::SecByteBlock& orig,
|
||||
CryptoPP::Integer& r,
|
||||
const CryptoPP::RSA::PublicKey& pub_key,
|
||||
const CryptoPP::RSA::PrivateKey& priv_key) {
|
||||
/*
|
||||
CryptoPP::Integer blind_signature(const CryptoPP::SecByteBlock &orig,
|
||||
const CryptoPP::Integer &r,
|
||||
const CryptoPP::RSA::PublicKey &pub_key,
|
||||
const CryptoPP::RSA::PrivateKey &priv_key) {
|
||||
using namespace CryptoPP;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
@ -23,7 +23,7 @@ CryptoPP::Integer blind_signature(const CryptoPP::SecByteBlock& orig,
|
||||
// Convenience
|
||||
const Integer &n = pub_key.GetModulus();
|
||||
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.
|
||||
const size_t sig_size = UnsignedMin(SHA256::BLOCKSIZE, n.ByteCount());
|
||||
@ -59,23 +59,19 @@ CryptoPP::Integer blind_signature(const CryptoPP::SecByteBlock& orig,
|
||||
return ss;
|
||||
}
|
||||
|
||||
CryptoPP::Integer unblind_signature(CryptoPP::Integer const & ss,
|
||||
CryptoPP::Integer& r,
|
||||
|
||||
const CryptoPP::RSA::PublicKey& pub_key)
|
||||
{
|
||||
CryptoPP::Integer unblind_signature(const CryptoPP::Integer &ss,
|
||||
const CryptoPP::Integer &r,
|
||||
const CryptoPP::RSA::PublicKey &pub_key) {
|
||||
|
||||
const CryptoPP::Integer &n = pub_key.GetModulus();
|
||||
CryptoPP::Integer s = a_times_b_mod_c(ss, r.InverseMod(n), n);
|
||||
return s;
|
||||
}
|
||||
|
||||
CryptoPP::Integer verify(CryptoPP::Integer const & ss,
|
||||
CryptoPP::Integer& r,
|
||||
|
||||
const CryptoPP::RSA::PublicKey& pub_key)
|
||||
{
|
||||
CryptoPP::Integer s = unblind_signature(ss,r,pub_key);
|
||||
CryptoPP::Integer verify(CryptoPP::Integer const &ss,
|
||||
const CryptoPP::Integer &r,
|
||||
const CryptoPP::RSA::PublicKey &pub_key) {
|
||||
CryptoPP::Integer s = unblind_signature(ss, r, pub_key);
|
||||
CryptoPP::Integer v = pub_key.ApplyFunction(s);
|
||||
return v;
|
||||
}
|
||||
@ -103,8 +99,8 @@ TEST_CASE("cryptopp1", "[crypto]") {
|
||||
cout << "Pub exp: " << std::hex << e << endl;
|
||||
cout << "Priv mod: " << std::hex << priv_key.GetModulus() << endl;
|
||||
cout << "Priv exp: " << std::hex << d << endl;
|
||||
const char* MESSAGE = "secret";
|
||||
SecByteBlock orig((const byte *)MESSAGE, 6U);
|
||||
const char *MESSAGE = "secret";
|
||||
SecByteBlock orig((const byte *) MESSAGE, 6U);
|
||||
|
||||
// Alice blinding
|
||||
Integer r;
|
||||
@ -154,7 +150,8 @@ TEST_CASE("cryptopp1", "[crypto]") {
|
||||
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
/*
|
||||
TEST_CASE("cryptopp", "[crypto]") {
|
||||
using namespace CryptoPP;
|
||||
using std::cout;
|
||||
@ -186,7 +183,7 @@ TEST_CASE("cryptopp", "[crypto]") {
|
||||
SecByteBlock buff_1, buff_2, buff_3;
|
||||
|
||||
// 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());
|
||||
cout << "Message: " << std::hex << m << endl;
|
||||
|
||||
@ -250,3 +247,4 @@ TEST_CASE("cryptopp", "[crypto]") {
|
||||
}
|
||||
cout << "Verified signature" << endl;
|
||||
}
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user