Electroneum
delegated_pow.cpp File Reference
#include "gtest/gtest.h"
#include "crypto/crypto.h"
Include dependency graph for delegated_pow.cpp:

Go to the source code of this file.

Functions

std::string message ("Message requiring signing")
 
std::string unusedMessage ("Unused message")
 
 TEST (ed25519_signature, CreateKeyPair)
 
 TEST (DelegatedPOW, SignMessage)
 
 TEST (DelegatedPOW, VerifySignature)
 

Variables

std::vector< std::string > keypair = crypto::create_ed25519_keypair()
 
std::string privateKey = boost::algorithm::unhex(keypair[0])
 
std::string publicKey = boost::algorithm::unhex(keypair[1])
 
std::string validSignature = crypto::sign_message(message, privateKey)
 
std::string invalidSignature = crypto::sign_message(message, keypair[0])
 
std::string blankInvalidSignature = crypto::sign_message(message, "")
 

Function Documentation

◆ message()

std::string message ( "Message requiring signing"  )
Here is the caller graph for this function:

◆ TEST() [1/3]

TEST ( ed25519_signature  ,
CreateKeyPair   
)

Definition at line 16 of file delegated_pow.cpp.

17 {
18  ASSERT_EQ(keypair.size(), 2);
19  ASSERT_EQ(keypair[0].size(), 64);
20  ASSERT_EQ(keypair[1].size(), 64);
21  ASSERT_EQ(privateKey.size(), 32);
22  ASSERT_EQ(publicKey.size(), 32);
23 }
std::vector< std::string > keypair
std::string publicKey
std::string privateKey
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956

◆ TEST() [2/3]

TEST ( DelegatedPOW  ,
SignMessage   
)

Definition at line 25 of file delegated_pow.cpp.

26 {
27  ASSERT_EQ(validSignature.size(), 64);
28  ASSERT_EQ(invalidSignature.size(), 0);
30 }
#define ASSERT_EQ(val1, val2)
Definition: gtest.h:1956
std::string invalidSignature
std::string blankInvalidSignature
std::string validSignature

◆ TEST() [3/3]

TEST ( DelegatedPOW  ,
VerifySignature   
)

Definition at line 32 of file delegated_pow.cpp.

33 {
40 }
std::string unusedMessage("Unused message")
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
std::string publicKey
std::string privateKey
bool verify_signature(const std::string &message, const std::string &publicKey, const std::string &signature)
Definition: crypto.h:380
std::string message("Message requiring signing")
std::string invalidSignature
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
std::string validSignature
Here is the call graph for this function:

◆ unusedMessage()

std::string unusedMessage ( "Unused message )
Here is the caller graph for this function:

Variable Documentation

◆ blankInvalidSignature

std::string blankInvalidSignature = crypto::sign_message(message, "")

Definition at line 14 of file delegated_pow.cpp.

◆ invalidSignature

std::string invalidSignature = crypto::sign_message(message, keypair[0])

Definition at line 13 of file delegated_pow.cpp.

◆ keypair

std::vector<std::string> keypair = crypto::create_ed25519_keypair()

Definition at line 7 of file delegated_pow.cpp.

◆ privateKey

std::string privateKey = boost::algorithm::unhex(keypair[0])

Definition at line 8 of file delegated_pow.cpp.

◆ publicKey

std::string publicKey = boost::algorithm::unhex(keypair[1])

Definition at line 9 of file delegated_pow.cpp.

◆ validSignature

std::string validSignature = crypto::sign_message(message, privateKey)

Definition at line 12 of file delegated_pow.cpp.