aboutsummaryrefslogtreecommitdiff
path: root/src/signer/noscrypt_signer.cpp
diff options
context:
space:
mode:
authorLibravatar buttercat1791 <mjjurkoic@gmail.com>2024-05-18 15:44:35 -0500
committerLibravatar buttercat1791 <mjjurkoic@gmail.com>2024-05-18 15:44:35 -0500
commit6c47d55f41143ecaac283edd7bb9dfba735e50bd (patch)
treea961fe5be6fe603bb58363f921b00bf8545bca36 /src/signer/noscrypt_signer.cpp
parentcc62edbea123e64cc7bc8145721c97359249f64c (diff)
Define constructor for noscrypt signer
Diffstat (limited to 'src/signer/noscrypt_signer.cpp')
-rw-r--r--src/signer/noscrypt_signer.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/signer/noscrypt_signer.cpp b/src/signer/noscrypt_signer.cpp
index 4e5fa2a..e53dd57 100644
--- a/src/signer/noscrypt_signer.cpp
+++ b/src/signer/noscrypt_signer.cpp
@@ -11,6 +11,28 @@ namespace signer
class NoscryptSigner : public INostrConnectSigner
{
public:
+ NoscryptSigner(shared_ptr<plog::IAppender> appender)
+ {
+ // Set up the logger.
+ plog::init(plog::debug, appender.get());
+
+ // Set up the noscrypt library.
+ this->context = make_shared<NCContext>();
+ uint8_t randomEntropy[NC_CONTEXT_ENTROPY_SIZE];
+
+ random_device device;
+ mt19937 seed(device());
+ uniform_int_distribution<int> distribution(1, NC_CONTEXT_ENTROPY_SIZE);
+ generate_n(randomEntropy, NC_CONTEXT_ENTROPY_SIZE, [&]() { return distribution(seed); });
+
+ NCInitContext(context.get(), randomEntropy);
+ };
+
+ ~NoscryptSigner()
+ {
+ NCDestroyContext(context.get());
+ };
+
void receiveConnection(string connectionToken) override
{
// Receive the connection token here.
@@ -29,6 +51,9 @@ public:
{
// Sign the event here.
};
+
+private:
+ shared_ptr<NCContext> context;
};
} // namespace signer
} // namespace nostr