NIP-06 の実装方法 (*0)

- BIP-39 にてニーモニック(= entropy) を生成

- 256 bit (32 byte)の疑似乱数を生成 (entropy と呼ぶ)

- entropy からニーモニックに変換

- entropy とニーモニックは1対1に相互に変換可能(Reversible, base2048 相当なので)

- BIP-32 にて entropy から Nostr 秘密鍵を導出

- entropy をシードとしてマスターキーを生成 (*1) (*2)

- マスターキーから Nostr 用の秘密鍵を導出 (*3) (*4)

- ここで導出しているので Nostr 秘密鍵から元の entropy = ニーモニックに変換することは出来ない

- (*0) https://github.com/nostr-protocol/nips/blob/master/06.md

- (*1) https://github.com/paulmillr/scure-bip32/blob/2274f2f42c5382dd08aab747ba7c8686322e706d/index.ts#L89

- (*2) https://bips.xyz/32#master-key-generation

- (*3) https://github.com/paulmillr/scure-bip32/blob/2274f2f42c5382dd08aab747ba7c8686322e706d/index.ts#L174

- (*4) https://bips.xyz/32#child-key-derivation-ckd-functions

- 実装例

- https://github.com/susumuota/nostr-keyx/blob/main/bin/genkey.ts

- https://github.com/v0l/snort/pull/425/files

https://scrapbox.io/nostr/s_ota にメモを書いているのでまとまったら NIP-06 に写しておきます。

Reply to this note

Please Login to reply.

Discussion

No replies yet.