Skip to content

Commit

Permalink
adding nip06 examples to the README
Browse files Browse the repository at this point in the history
  • Loading branch information
Anderson-Juhasc authored and fiatjaf committed May 27, 2024
1 parent 97d838f commit faa1a9d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```js
Expand Down

0 comments on commit faa1a9d

Please sign in to comment.