Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best way to validate public key #93

Open
dskvr opened this issue Jan 20, 2023 · 2 comments
Open

Best way to validate public key #93

dskvr opened this issue Jan 20, 2023 · 2 comments

Comments

@dskvr
Copy link
Contributor

dskvr commented Jan 20, 2023

Finding the need to validate public keys. Due to the two formats, curious if there is an existing, fool-proof (or suggested) method for validating pubkeys before I write my own.

@fiatjaf
Copy link
Collaborator

fiatjaf commented Jan 20, 2023

Hmm, I don't know, I think you should parse them and check if they are 32 bytes, no?

key.match(/^[a-f0-9]{64}$/) || nip19.decode(key).type === 'npub' || nip19.decode(key).type === 'nprofile'

@bilalanees98
Copy link

@dskvr did you ever figure out a way?

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

No branches or pull requests

3 participants