chGoodchild / GLTollGate

6 stars 2 forks source link

Do a proper survey of existing C(++) nostr clients #44

Open chGoodchild opened 3 months ago

chGoodchild commented 3 months ago

It shouldn't be this difficult to get basic features of a nostr client: https://github.com/chGoodchild/GLTollGate/pull/43#issuecomment-2257963973

Perhaps I need to check how others are doing it or just use an existing nostr client written in C(++)

Below are the existing C(++) clients that I found.

TODO, try building and using them. Find out how they generate their respective keys and see if any of their code can be reused.

chGoodchild commented 3 months ago

Nostr_client_relay:

~/nostr_client_relay/src$ grep -r "generate_key"
nostril/nostri.h:  int generate_key(secp256k1_context* ctx, struct key* key, int* difficulty);
nostril/nostri.c:// generate_key
nostril/nostri.c:int generate_key(secp256k1_context* ctx, struct key* key, int* difficulty)
nostril/nostri.c:    if (!generate_key(ctx, &key, difficulty))
nostril/nostril.c:    if (!generate_key(ctx, &key, difficulty))
nostr.cc:    if (!generate_key(ctx, &key, difficulty))
~/nostr_client_relay/src$ grep -r "npub"
~/nostr_client_relay/src$ grep -r "nsec"

Clearly this tool generates a key pair, but it doesn't convert it to the npub and nsec format. Perhaps this is something I should also do. I already have the .pem files and the DER encoded key pairs. If I recall correctly, I even had it represented at a seed phrase at one point. That should be enough to get the secret out of the router. Perhaps I can just let other tools convert the secret to an npub and nsec if / when needed...

Nostro seems useful as a replacement for some or all of TollGateNostrToolkit. I should take a closer look at this:

~/nostr_client_relay/build$ ./nostro --sec c88eb4d229625c3969f4f9c5af9fa094a683588248cce5e3317b827439cb9c1a --content 'hello world' --kind 1
nostro:17:49:30 localhost:8080
nostro:17:49:30 hello world
nostro:17:49:30 c88eb4d229625c3969f4f9c5af9fa094a683588248cce5e3317b827439cb9c1a
nostro:17:49:30 1
[
 "EVENT",
 {
  "content": "hello world",
  "created_at": 1722354570,
  "id": "22de5fb76088c4f1827ada6e695a80ed229b8f14f74c3730c296d2b832f0d597",
  "kind": 1,
  "pubkey": "24b37f5ec0822b014c6ebb425641ac83529d47bce44d70272b3a95cf93f64cc1",
  "sig": "48b3c01aaf612197180b0c9f023d6a1529f7eca843885dcfdb45c6f896fdb91daa85dfcd2afbaf1650d77c33d6c87b8dc5fd994376b1cb259d0b0e01ec8424a1",
  "tags": []
 }
]
nostro:17:49:30 Error: asio.system:111 : Connection refused
nostro:17:49:30 Received 0 messages: