Implement NIP-19 bech32-encoded private and public keys

https://github.com/nostr-protocol/nips/blob/master/19.md
This commit is contained in:
Wilson Silva
2023-11-20 09:59:27 +07:00
parent 3fffcd1a4e
commit 3520cf8219
58 changed files with 1189 additions and 104 deletions

View File

@@ -98,11 +98,17 @@ client = Nostr::Client.new
# a) Use an existing keypair
keypair = Nostr::KeyPair.new(
private_key: 'your-private-key',
public_key: 'your-public-key',
private_key: Nostr::PrivateKey.new('your-hex-private-key'),
public_key: Nostr::PublicKey.new('your-hex-public-key'),
)
# b) Or create a new keypair
# b) Or build a keypair from a private key
keygen = Nostr::Keygen.new
keypair = keygen.get_key_pair_from_private_key(
Nostr::PrivateKey.new('your-hex-private-key')
)
# c) Or create a new keypair
keygen = Nostr::Keygen.new
keypair = keygen.generate_keypair