Skip to content

fix: validate Shamir threshold parameters#6

Open
JasonZhouPW wants to merge 1 commit into
BitgesellOfficial:masterfrom
JasonZhouPW:fix/shamir-threshold-validation
Open

fix: validate Shamir threshold parameters#6
JasonZhouPW wants to merge 1 commit into
BitgesellOfficial:masterfrom
JasonZhouPW:fix/shamir-threshold-validation

Conversation

@JasonZhouPW
Copy link
Copy Markdown

Summary

  • reject Shamir split requests with thresholds below 2
  • reject impossible splits where total shares is less than the threshold
  • add regression coverage for invalid threshold/total combinations

Why

Before this change, split_secret(0, total, secret) or split_secret(1, total, secret) could create shares that directly expose the secret or cannot be restored by restore_secret. Requests such as threshold > total also appeared to succeed but could not satisfy the requested recovery threshold.

Validation

  • RED before fix: focused importlib regression expected ValueError and failed because invalid parameters were accepted
  • GREEN after fix: focused importlib regression passes
  • valid shamir split/restore cases OK
  • PYTHONPYCACHEPREFIX=/private/tmp/pycache python3 -m py_compile pybgl/functions/shamir.py pybgl/test/shamir.py
  • git diff --check

Note: python3 -m unittest pybgl.test.shamir -q still fails in this local checkout before loading tests because the native _sha3_hash extension is not built. This is unrelated to this pure-Python Shamir validation change.

Bounty context: submitted for the Bitgesell improvement/PR bounty program (#81 / #39). Preferred payout if approved: USDC/USDT on EVM-compatible rails; details can be provided privately.

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.

1 participant