mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
adding nip06 examples to the README
This commit is contained in:
committed by
fiatjaf_
parent
97d838f254
commit
faa1a9d556
26
README.md
26
README.md
@@ -194,6 +194,32 @@ declare global {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Generating NIP-06 keys
|
||||||
|
```js
|
||||||
|
import {
|
||||||
|
privateKeyFromSeedWords,
|
||||||
|
accountFromSeedWords,
|
||||||
|
extendedKeysFromSeedWords,
|
||||||
|
accountFromExtendedKey
|
||||||
|
} from 'nostr-tools/nip06'
|
||||||
|
|
||||||
|
const mnemonic = 'zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong'
|
||||||
|
const passphrase = '123' // optional
|
||||||
|
const accountIndex = 0
|
||||||
|
const sk0 = privateKeyFromSeedWords(mnemonic, passphrase, accountIndex)
|
||||||
|
|
||||||
|
const { privateKey: sk1, publicKey: pk1 } = accountFromSeedWords(mnemonic, passphrase, accountIndex)
|
||||||
|
|
||||||
|
const extendedAccountIndex = 0
|
||||||
|
|
||||||
|
const { privateExtendedKey, publicExtendedKey } = extendedKeysFromSeedWords(mnemonic, passphrase, extendedAccountIndex)
|
||||||
|
|
||||||
|
const { privateKey: sk2, publicKey: pk2 } = accountFromExtendedKey(privateExtendedKey)
|
||||||
|
|
||||||
|
const { publicKey: pk3 } = accountFromExtendedKey(publicExtendedKey)
|
||||||
|
```
|
||||||
|
|
||||||
### Encoding and decoding NIP-19 codes
|
### Encoding and decoding NIP-19 codes
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
Reference in New Issue
Block a user