Fix #70: Add threshold validation to __restore_secret - #71
Open
sysop1984 wants to merge 1 commit into
Open
Conversation
The __restore_secret function performed Lagrange interpolation unconditionally over whatever shares were supplied. When fewer than threshold shares were provided, it silently returned a wrong secret with no error, leading to loss of access in wallet-recovery use cases. This fix adds a required threshold parameter and validates that at least threshold shares are present before performing interpolation. Fixes: bitaps-com#70
Author
Reward AddressPlease send the 0.1 BTC bug bounty to:
This address is specified in issue #70. Thank you for the bounty opportunity. |
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
Fixes #70 — Silent Recovery of Wrong Secret With Fewer Than Threshold Shares
Problem
The
__restore_secretfunction insrc/functions/shamir_secret_sharing.jsperformed Lagrange interpolation unconditionally over whatever shares were supplied. When fewer thanthresholdshares were provided, it silently returned a wrong secret with no error.For a wallet-recovery use case, this is a serious security defect: a user may believe they have recovered their seed phrase when they have not, leading to irrecoverable loss of funds.
Fix
Added a required
thresholdparameter and validation that at leastthresholdshares are present before performing interpolation:Testing
__restore_secret(shares)without threshold throws a clear error__restore_secret(shares, threshold)with insufficient shares throws a clear error__restore_secret(shares, threshold)with sufficient shares works correctlyBounty
This PR addresses the bug described in issue #70, which is eligible for the 0.1 BTC bounty: "Any bug in the implementation of the presented secret sharing scheme that can lead to loss of access and the inability to recover the original mnemonic phrase."
Reward address:
bc1q4szfp7e44rvvedyvxvypuwhtrch68zg0gcsf9jFixes: #70