Add key-related functions

This commit is contained in:
Honza Pokorny
2022-01-05 10:16:36 -04:00
committed by fiatjaf
parent 26c3b4aac9
commit 8558025305
4 changed files with 587 additions and 1 deletions

View File

@@ -72,3 +72,18 @@ for status := range statuses {
}
}
```
### Generating a key
``` go
sk, _ := nostr.GenerateKey()
mnemonic, _ := nostr.PrivateKeyAsMnemonic(sk)
fmt.Println("sk:", nostr.PrivateKeyAsHex(sk))
fmt.Println("pk:", nostr.PublicKeyAsHex(sk.PublicKey))
fmt.Println("mnemonic:", mnemonic)
sk2, _ := nostr.PrivateKeyFromMnemonic(mnemonic)
fmt.Println("from mnemonic:", nostr.PrivateKeyAsHex(sk2))
```