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.
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.