Why Nostr? What is Njump?
2024-01-16 17:45:46
in reply to

CryptoDrew on Nostr: The pubkey would just be a 32-byte hex-encoded string, which will always be 64 hex ...

The pubkey would just be a 32-byte hex-encoded string, which will always be 64 hex characters in length since 2 hex characters represents 1 byte.

So, pubkey regex is:
[0-9a-fA-F]{64}

For the npub, I believe that is always a consistent length of npub1 + 58 bech32-encoded characters (not bech32m).

So, npub regex is:
npub1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58}

Possible that I am wrong about the public length, but I have yet to come across one of a different length.

Also, validating whether the values decode to a valid secp256k1 key is not something that you could do w/ regex.
Author Public Key
npub1s85qc34eh59hc4j0txry2fl6tuwvjn4x3grl9p593xz2xsds5t5qg4uw34