Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python reference to auditably generate shares #59

Closed
wants to merge 35 commits into from

Conversation

BenWestgate
Copy link
Contributor

@BenWestgate BenWestgate commented Aug 15, 2023

Work-in-Progress attempts to close #57 and its summary #64. I can review the whole thread before finalizing to be sure we didn't miss anything in this reference.

Tasklist:

  • Implement secure shuffle for index selection.

  • Add padding bits ECC.

  • Generate payloads from user and app entropy.

  • Convert BIP32 fingerprint to bech32 for default identifiers.

  • Allow identifier customization.

  • Generate shares for fresh master seeds.

  • Generate shares for existing master seeds.

  • Generate shares for sub-threshold codex32 sets.

  • Derive shares for complete threshold codex32 sets.

  • Use 8-bit samples for shuffler tags.

  • Input custom identifier, k and n to key derivation.

  • Set default identifier at master seed generation.

  • Create standardized "entropy header" with fixed fields (length, k, id) to avoid ambiguity.

  • Use entropy header in PBKDF and HMAC inputs.

  • Encrypt bech32 fingerprints with unique_string for reshare idents.

  • Use hardware manufacturer + S/N or install date to set initial re-share counter value with hash.

  • Generate unique_token by monotonic counter incrementing from initial re-share value.

  • Consider using unique_token LSB as padding over ECC to reduce ident reuse.

  • Regenerate shares for existing master seeds.

  • Regenerate shares for partial codex32 sets.

  • Provide comprehensive documentation.

The following tasks require review first:

  • Polish key derivation parameters based on feedback.
  • Document importance that unique_string is unique, memorable or written down and NOT private.
  • Document that implementations should, if possible, store a list of previously generated or imported identifiers to help users avoid reuse.
    • Document risks sub-threshold reshare misuse.
  • Implement error correction/detection for default identifiers (requires confirmation that I've set it optimally)
  • Implement ECC padding error detection. (requires confirmation it's optimal)

Draft Proposal for Electronic Implementations:

The new file begins with a python reference for importing and decoding codex32 backups, followed by functions useful for generating new backups.

Shuffle Functions:

Two shuffle functions are provided as candidates. One utilizes a custom hmac-sha256 construction, while the other employs ChaCha20. Both methods sample their keystream for unique bytes and then perform sorting.

Key Derivation:

Pay special attention to the salts, info, message and whether all of the info in them is public enough, complete, unique as possible, inputs are "parsible" and in a logical arrangement, 64-bits entropy if possible etc.

For HMAC:
Ensure keys are strong and a fixed length <= block size of hash. That message, which may be of any length, is less private than the key.

@BenWestgate BenWestgate changed the title Rough Draft of Generate Shares: fresh master seed, existing master seed [WIP] Python reference to generate shares: fresh master seed and existing master seed Aug 21, 2023
@BenWestgate BenWestgate changed the title [WIP] Python reference to generate shares: fresh master seed and existing master seed [WIP] Python reference to generate deterministic auditable shares Aug 21, 2023
@BenWestgate BenWestgate changed the title [WIP] Python reference to generate deterministic auditable shares [WIP] Python reference to auditably generate shares Aug 21, 2023
BenWestgate and others added 3 commits August 25, 2023 03:18
Generate shares gets entropy from a provided master xprv, or derives that master xprv from a provided codex32 secret in existing string list.

Shuffle uses chacha20 and 1 byte samples.

Generate shares always produces shares first.

Default identifier is bip32 fingerprint in bech32.

PEP8 Docstrings added for all my functions
@BenWestgate BenWestgate marked this pull request as ready for review August 25, 2023 23:26
@BenWestgate
Copy link
Contributor Author

@apoelstra @roconnor-blockstream this auditable electronic share generation design is ready for review.

@BenWestgate
Copy link
Contributor Author

Also closes #64 which is a summary of #57 featuring in line code from this PR.

@BenWestgate BenWestgate changed the title [WIP] Python reference to auditably generate shares Python reference to auditably generate shares Aug 26, 2023
forgot to assign relabeled strings to existing_codex32_strings.
info was being passed as a string but needed to be bytes. tmp_id is a better name than new_id, relabel new shares (there is never relabeling if existing shares were passed)
@apoelstra
Copy link
Contributor

@BenWestgate heads up that I am probably going to be unavailable for the coming week. I had a baby last Sunday and I've been taking some time off :).

@BenWestgate
Copy link
Contributor Author

BenWestgate commented Sep 4, 2023 via email

@BenWestgate
Copy link
Contributor Author

BenWestgate commented Aug 23, 2024

Due to the messy diff and lack of review. I'm going to close this PR and I will make a new one that attempts to close #64 and #57.
As well as demonstrate implementation of some optional features from our discussions such as compactly QR encoding codex32 strings and the "Passphrase derived share".

I'll also write a draft update to docs/wallets.md for codex32 backup generation at the same time.
That will also function to high level document the code to help review.

@apoelstra
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recommendations for Auditable Electronic Codex32 Implementations
2 participants