Add Shamir secret sharing helpers for scalar polynomials#214
Merged
Conversation
This PR makes creating and restoring secret backups easier to work on by adding convenient Shamir secret sharing functionality. Changes: - Add `generate_shamir_sharing_poly` to create polynomial with secret at x=0 - Add `trusted_dealer_shamir_sharing` that returns an iterator of shares - Update `interpolate_and_eval_poly_at_0` docs to clarify it reconstructs secrets - Add comprehensive tests including proptest for random testing The trusted_dealer_shamir_sharing function splits a secret into n shares with a threshold, returning (share_index, share_value) pairs as an iterator for memory efficiency. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes creating and restoring secret backups easier by adding Shamir secret sharing functionality to the polynomial module.
Changes
generate_shamir_sharing_polyto create polynomial with secret at x=0trusted_dealer_shamir_sharingthat returns an iterator of sharesinterpolate_and_eval_poly_at_0docs to clarify it reconstructs secretsExample Usage
Abridged conversation transcript
Human: Ok can you review the currently staged changes.
Assistant: [Reviews staged changes showing new Shamir secret sharing functions: generate_shamir_sharing_poly, trusted_dealer_shamir_sharing, and updated docs for interpolate_and_eval_poly_at_0]
Human: I think from trusted_dealer_shamir_sharing we can just return an impl Iterator
Assistant: You're right! [Modifies function to return iterator instead of Vec]
Human: cool before making a PR to fix that can you make a quick PR to fix that format warning. about format_code_in_doc_comments.
Assistant: [Creates PR #213 to remove format_code_in_doc_comments from rustfmt.toml]
Human: Before we do that can you make a proptest that tests doing trusted_dealer_shamir_sharing and then reconstruction.
Assistant: [Creates comprehensive proptest in tests/poly.rs that tests reconstruction with random secrets, various thresholds, and different numbers of shares]
Human: oh I wonder what the type parameter for trusted dealer sharing is actually there for.
Assistant: [Examines code and finds unused type parameter
Z: ZeroChoicethat was declared but never used in the function]Human: I think remove it
Assistant: [Removes unused type parameter from function signature and updates tests]
Human: cool. Make a PR. Attach a summary of this conversation to it. Note at the beginning that the purpose was to make creating and restoring secret backups easier to work on.
🤖 Generated with Claude Code