fix(shamir): position-based polynomial evaluation; uniform coefficient sampling - #74
Open
DaBaoAgent wants to merge 1 commit into
Open
fix(shamir): position-based polynomial evaluation; uniform coefficient sampling#74DaBaoAgent wants to merge 1 commit into
DaBaoAgent wants to merge 1 commit into
Conversation
…t sampling __shamirFn used q.indexOf(a) to derive the exponent, which returns the first occurrence of a value and corrupts evaluation whenever coefficients repeat. Evaluate with Horner's method, using the coefficient position as the exponent (issue bitaps-com#73). __split_secret forced all coefficients distinct from each other and from the secret byte (while (q.includes(w))), violating Shamir's perfect- secrecy guarantee by sampling without replacement: for t=3 exactly 3 values per byte are rejected (256 -> 253 candidates), leaking ~0.272 bits across 16 bytes and breaking down at t >= 30. Coefficients are now sampled uniformly i.i.d. from GF(256). Adds regression tests: position-based evaluation with repeated coefficients, and round-trips at thresholds up to 100.
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.
Fixes #73
Bug
__shamirFnusedq.indexOf(a)to derive each coefficient's exponent.indexOfreturns the first occurrence of a value, so whenever coefficient values repeat the wrong exponent is used and evaluation is corrupted.To paper over that,
__split_secretforced all coefficients to be distinct from each other and from the secret byte viawhile (q.includes(w)). This samples coefficients without replacement, violating the uniform i.i.d. sampling Shamir's perfect-secrecy proof requires:t = 3, exactly 3 values per byte are rejected (256 → 253 candidates) → ~0.272 bits of entropy leaked across 16 bytes.tand causes total breakdown att >= 30.Fix
__shamirFn: evaluate with Horner's method, using the coefficient position as the exponent — identical results for distinct coefficients (verified), correct results for repeated ones.__split_secret: remove the rejection filter; coefficients are now sampled uniformly i.i.d. from GF(256), as required by the security proof.Verification
npm test(full suite): 86 passing, 0 failing (includes the existing Secret splitting test, 2000+ iterations).