feat: a recovery code derives 24 words, and through them a profile (recovery-code-v3, Phase 2)
The code's 32-byte key is BIP39 entropy. Its words go to PhraseKeys as they stand, so a code is a phrase in another notation. Three codes are pinned to their words, npub and profile id, cross-checked by an independent stdlib-only derivation in docs/scripts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ed706d5f80
commit
a14dcc9c26
4 files changed
+232
No files matched your search
+24
@@ -0,0 +1,24 @@
|
||||
package mobi.giza.compose.identity.recoverycode
|
||||
|
||||
import fr.acinq.bitcoin.MnemonicCode
|
||||
import fr.acinq.phoenix.utils.MnemonicLanguage
|
||||
|
||||
/**
|
||||
* What a recovery code derives: twenty-four words, and from them everything a phrase does.
|
||||
*
|
||||
* The code's root key is read as BIP39 entropy -- thirty-two bytes and their eight checksum
|
||||
* bits are exactly twenty-four words -- and the words go to `PhraseKeys` as they stand: the
|
||||
* empty passphrase, BIP32, NIP-06's path for the nostr key and `m/50'/0'` for the profile id.
|
||||
* So a code is a 24-word phrase in another notation, its words typed into any NIP-06 client
|
||||
* land on the npub Giza shows, and every path a phrase will ever have, a code has too.
|
||||
*
|
||||
* The words do not give the code back: the HMAC under [RecoveryCode.rootKey] runs one way.
|
||||
* See docs/recovery-code-v3.md, "The one decision". `RecoveryCodeKeysTest` pins three codes
|
||||
* to their words, npub and id, cross-checked against docs/scripts/recovery-code-keys.py.
|
||||
*/
|
||||
object RecoveryCodeKeys {
|
||||
|
||||
/** The 24 words [code] is. */
|
||||
fun words(code: RecoveryCode): List<String> =
|
||||
MnemonicCode.toMnemonics(code.rootKey().toByteArray(), MnemonicLanguage.English.wordlist())
|
||||
}
|
||||
Reference in new issue
Block a user