Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Bug in Private Key Encoding/Decoding handling #56

Open
ajx42 opened this issue Apr 19, 2023 · 2 comments
Open

Bug in Private Key Encoding/Decoding handling #56

ajx42 opened this issue Apr 19, 2023 · 2 comments

Comments

@ajx42
Copy link

ajx42 commented Apr 19, 2023

It seems the following (pool.SecretKey) expects an encoded key string. Currently, we are decoding the key string before setting it here.
https://github.com/fiatjaf/noscl/blob/master/nostr.go#L40-L42

image

It gets fixed with the following patch, i.e. if we set Config.PrivateKey to the raw (encoded) string.
ajx42@f10c434

A related problem is the following, which the above patch also fixes:
showPublicKey is passing the already decoded key to getPubKey: https://github.com/fiatjaf/noscl/blob/master/key.go#L55
There is this older PR that fixes this issue at another place #50

Currently we get this:
image

I can go ahead and fix it if it's okay. Feel free to assign me. I am trying to learn about this codebase, so happy to help.

@ajx42 ajx42 changed the title Bug in noscl showPublicKey Bug in Private Key Encoding/Decoding handling Apr 19, 2023
@PlebeiusGaragicus
Copy link

I'm confused how noscl is storing the private key inside config.json.

{
  "relays": {},
  "following": {},
  "privatekey": "\ufffdnT\ufffd\ufffd3XX\r\ufffd\ufffdLC\ufffd\ufffd\ufffdQz\ufffd\ufffd\ufffd\ufffdA\ufffd={z\ufffd\ufffd\u0016:"
}

This encoding makes no sense to me. It was set via noscl set private d26e5491ab337f58580db8994c43b3a28d517ae1fbf9f341ab3d7b7aa38d163a

I'm missing something.

@PlebeiusGaragicus
Copy link

Figured it out - I was using HEAD on this project. I guess the same bug is the reason for this issue.

I just ran noscl using go install github.com/fiatjaf/noscl@latest and it worked fine. config.json is just storing the hex version.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants