aboutsummaryrefslogtreecommitdiff
path: root/src/signer/noscrypt_signer.cpp
diff options
context:
space:
mode:
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