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

feat: implemented nip04 #1777

Merged
merged 9 commits into from
Dec 2, 2022
Merged

feat: implemented nip04 #1777

merged 9 commits into from
Dec 2, 2022

Conversation

reneaaron
Copy link
Contributor

Describe the changes you have made in this PR

Implement NIP04: encrypt & decrypt

Link this PR to an issue [optional]

#1730

Type of change

  • feat: New feature (non-breaking change which adds functionality)

@reneaaron reneaaron linked an issue Nov 25, 2022 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Nov 25, 2022

🚀 Thanks for the pull request!

Here are the current build files for testing:

Download and unzip the file for your browser. Refer to the readme for detailed install instructions.

Don't forget: keep earning sats!

Copy link
Collaborator

@bumi bumi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dropped some questions.


encrypt(pubkey: string, text: string) {
const key = secp256k1.getSharedSecret(this.getPrivateKey(), "02" + pubkey);
const normalizedKey = Buffer.from(key.slice(1, 33));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this doing?
should this be a compressed key?
https://www.npmjs.com/package/@noble/secp256k1#getsharedsecretprivatekeya-publickeyb

isCompressed = false determines whether to return compact (33-byte), or full (65-byte) key

@@ -36,6 +42,35 @@ class Nostr {
event.sig = signature;
return event;
}

encrypt(pubkey: string, text: string) {
const key = secp256k1.getSharedSecret(this.getPrivateKey(), "02" + pubkey);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this 02?

reneaaron and others added 2 commits November 28, 2022 11:34
Co-authored-by: Michael Bumann <hello@michaelbumann.com>
Co-authored-by: Michael Bumann <hello@michaelbumann.com>
@escapedcat escapedcat merged commit e32de12 into master Dec 2, 2022
@escapedcat escapedcat deleted the feature/nostr-nip04 branch December 2, 2022 08:36
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

Successfully merging this pull request may close these issues.

nostr: encrypt & decrypt
3 participants