From 6c47d55f41143ecaac283edd7bb9dfba735e50bd Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Sat, 18 May 2024 15:44:35 -0500 Subject: Define constructor for noscrypt signer --- src/signer/noscrypt_signer.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/signer') 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 appender) + { + // Set up the logger. + plog::init(plog::debug, appender.get()); + + // Set up the noscrypt library. + this->context = make_shared(); + uint8_t randomEntropy[NC_CONTEXT_ENTROPY_SIZE]; + + random_device device; + mt19937 seed(device()); + uniform_int_distribution 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 context; }; } // namespace signer } // namespace nostr -- cgit