S.__shamirFn = (x, q) => {
let r = 0;
for (let a of q)
r = S.__GF256_add(r, S.__GF256_mul(a, S.__GF256_pow(x, q.indexOf(a))));
return r;
};
q.indexOf(a) corrupts evaluation when values repeat.
Workaround Creates Vulnerability:
javascript
Run
for (let i = 0; i < threshold - 1; i++) {
do {
if (ePointer >= e.length) { ePointer = 0; e = S.generateEntropy({hex:false}); }
w = e[ePointer++];
} while (q.includes(w)); // Rejects duplicates AND secret byte value
q.push(w);
}
This makes Pr[a_i = s] = 0 and Pr[a_i = a_j] = 0 for i != j - violating uniform i.i.d. sampling required by Shamir's security proof.
Proof of Concept
Using the official challenge shares (Share 1 at x=3, Share 2 at x=15):
Share 1 (x=3): session cigar grape merry useful churn fatal thought very any arm unaware
Share 2 (x=15): clock fresh security field caution effort gorilla speed plastic common tomato echo
For each of the 16 byte positions, enumerate all 256 candidate secret values s, solve for coefficients a1, a2, and reject if a1==s or a2==s or a1==a2.
Result: Exactly 3 values rejected per byte, every time.
plaintext
byte[ 0]: rejected 0x7b, 0xe6, 0xf2
byte[ 1]: rejected 0x46, 0x4d, 0x90
byte[ 2]: rejected 0x5b, 0x7f, 0xdf
byte[ 3]: rejected 0x0b, 0x51, 0xd0
byte[ 4]: rejected 0x84, 0x8c, 0xc9
byte[ 5]: rejected 0x3c, 0xb2, 0xbe
byte[ 6]: rejected 0x82, 0x91, 0xac
byte[ 7]: rejected 0x25, 0x29, 0xcf
byte[ 8]: rejected 0x40, 0x58, 0x8f
byte[ 9]: rejected 0xaf, 0xbc, 0xf2
byte[10]: rejected 0x15, 0xbb, 0xee
byte[11]: rejected 0x59, 0x5d, 0xf6
byte[12]: rejected 0x63, 0x80, 0xeb
byte[13]: rejected 0x02, 0x8f, 0xb9
byte[14]: rejected 0x1a, 0x4e, 0x75
byte[15]: rejected 0x27, 0x31, 0x90
Total: 48/4096 rejected (1.17%)
Entropy loss: 16 x (8 - log2(253)) = 0.272 bits
<html>
<body>
<!--StartFragment--><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><h3 style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);">Entropy Loss Scales Quadratically With Threshold:</h3></div>
Recommended Fix
Fix 1: Use position-based evaluation (Horner's method):
javascript
Run
S.__shamirFn = (x, q) => {
let r = 0;
for (let i = q.length - 1; i >= 0; i--) {
r = S.__GF256_add(S.__GF256_mul(r, x), q[i]);
}
return r;
};
Fix 2: Remove the rejection filter:
javascript
Run
for (let i = 0; i < threshold - 1; i++) {
if (ePointer >= e.length) { ePointer = 0; e = S.generateEntropy({hex:false}); }
q.push(e[ePointer++]); // Uniform i.i.d. sampling - no rejection
}
Reward Address
bc1q4szfp7e44rvvedyvxvypuwhtrch68zg0gcsf9j
Additional Notes
Verified against:
Source code at src/functions/shamir_secret_sharing.js
Live challenge data (Shares 1 & 2 at x=3, x=15)
Confirmed vulnerable code exists in mnemonic-offline-tool/index.html - the actual tool linked from the challenge page
Python pybtc is not affected by this specific issue - it uses enumerate(q) for proper position-based evaluation.
Submitted in good faith for the Bug Bounty program at https://bitaps.com/mnemonic/challenge
<div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: flex; flex: 0 1 auto; flex-direction: column; justify-content: normal; align-items: normal; padding: 0px; margin: 0px 0px 8px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);">Table</div><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><path d="M15.8032 1.79688C18.0431 1.79687 19.1644 1.79648 20.02 2.23242C20.7723 2.6159 21.3847 3.22809 21.7681 3.98047C22.2039 4.83609 22.2036 5.95723 22.2036 8.19727V11.5527C22.2036 13.7928 22.2039 14.9139 21.7681 15.7695L21.6138 16.0449C21.2296 16.6713 20.6783 17.182 20.02 17.5176L19.856 17.5938C19.0321 17.9477 17.9363 17.9521 15.896 17.9521C15.856 18.8717 15.7539 19.4954 15.4868 20.0195L15.3325 20.2949C14.9482 20.9214 14.3972 21.432 13.7388 21.7676L13.5747 21.8438C12.7384 22.203 11.6223 22.2031 9.52197 22.2031H8.19678L6.7124 22.1963C5.5207 22.1775 4.75727 22.1072 4.14404 21.8438L3.97998 21.7676C3.32151 21.432 2.77052 20.9214 2.38623 20.2949L2.23193 20.0195C1.79596 19.1639 1.79639 18.0429 1.79639 15.8027V12.4473C1.79639 10.2071 1.79596 9.08612 2.23193 8.23047C2.6154 7.47796 3.22747 6.86589 3.97998 6.48242C4.62164 6.15548 5.41246 6.07416 6.7124 6.05371L8.104 6.04688C8.14363 5.12787 8.24621 4.50443 8.51318 3.98047C8.89666 3.22805 9.50879 2.61586 10.2612 2.23242C10.9028 1.90565 11.694 1.82416 12.9937 1.80371L14.478 1.79688H15.8032ZM8.19678 8.04688C7.04367 8.04688 6.29861 8.04843 5.73193 8.09473C5.1887 8.13912 4.98706 8.21427 4.88818 8.26465C4.51193 8.45638 4.20589 8.76242 4.01416 9.13867C3.96378 9.23755 3.88863 9.43919 3.84424 9.98242C3.79794 10.5491 3.79639 11.2942 3.79639 12.4473V15.8027C3.79639 16.9558 3.79794 17.7009 3.84424 18.2676C3.88863 18.8108 3.96378 19.0124 4.01416 19.1113C4.20589 19.4876 4.51193 19.7936 4.88818 19.9854C4.98706 20.0357 5.1887 20.1109 5.73193 20.1553C6.29861 20.2016 7.04367 20.2031 8.19678 20.2031H9.52197C10.6751 20.2031 11.4201 20.2016 11.9868 20.1553C12.53 20.1109 12.7317 20.0357 12.8306 19.9854C13.2068 19.7936 13.5129 19.4876 13.7046 19.1113C13.755 19.0124 13.8301 18.8108 13.8745 18.2676C13.9208 17.7009 13.9224 16.9558 13.9224 15.8027V12.4473C13.9224 11.2942 13.9208 10.5491 13.8745 9.98242C13.8301 9.43919 13.755 9.23755 13.7046 9.13867C13.5129 8.76242 13.2068 8.45638 12.8306 8.26465C12.7317 8.21427 12.53 8.13912 11.9868 8.09473C11.4201 8.04843 10.6751 8.04688 9.52197 8.04688H8.19678ZM14.478 3.79688C13.3252 3.79688 12.5798 3.79847 12.0132 3.84473C11.4707 3.88906 11.2685 3.96427 11.1694 4.01465C10.7932 4.20635 10.4872 4.51251 10.2954 4.88867C10.245 4.98755 10.1699 5.18922 10.1255 5.73242C10.1174 5.83197 10.1104 5.93702 10.105 6.04883C11.9635 6.05203 12.9608 6.08602 13.7388 6.48242C14.4913 6.86589 15.1033 7.47796 15.4868 8.23047C15.9228 9.08612 15.9224 10.2071 15.9224 12.4473V15.8027C15.9224 15.8531 15.9214 15.9029 15.9214 15.9521C17.0074 15.952 17.7211 15.95 18.2681 15.9053C18.8109 15.8609 19.013 15.7857 19.1118 15.7354C19.4879 15.5436 19.7942 15.2375 19.9858 14.8613C20.0362 14.7624 20.1114 14.5604 20.1558 14.0176C20.2021 13.4509 20.2036 12.7058 20.2036 11.5527V8.19727C20.2036 7.04419 20.2021 6.29909 20.1558 5.73242C20.1114 5.18955 20.0362 4.98762 19.9858 4.88867C19.7942 4.51255 19.4879 4.2064 19.1118 4.01465C19.013 3.96428 18.8109 3.88912 18.2681 3.84473C17.7015 3.79843 16.9561 3.79688 15.8032 3.79688H14.478Z" fill="currentColor" style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: inline; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"></path></svg></div><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><path d="M20.375 14.8535C20.9273 14.8535 21.375 15.3012 21.375 15.8535V18.5059C21.375 20.1627 20.0319 21.5059 18.375 21.5059H5.625C3.96815 21.5059 2.625 20.1627 2.625 18.5059V15.8535C2.625 15.3012 3.07272 14.8535 3.625 14.8535C4.17728 14.8535 4.625 15.3012 4.625 15.8535V18.5059C4.625 19.0581 5.07272 19.5059 5.625 19.5059H18.375C18.9273 19.5059 19.375 19.0581 19.375 18.5059V15.8535C19.375 15.3012 19.8227 14.8535 20.375 14.8535ZM12.001 1.99219C12.5529 1.99264 13.001 2.44018 13.001 2.99219V13.5146L17.8027 8.71289C18.1932 8.32272 18.8263 8.32274 19.2168 8.71289C19.607 9.10335 19.607 9.73649 19.2168 10.127L12.708 16.6367C12.5207 16.8241 12.2659 16.9295 12.001 16.9297C11.736 16.9297 11.4814 16.824 11.2939 16.6367L4.78418 10.127C4.3938 9.73642 4.3937 9.10336 4.78418 8.71289C5.17469 8.32281 5.80784 8.32265 6.19824 8.71289L11.001 13.5156V2.99219C11.001 2.4399 11.4487 1.99219 12.001 1.99219Z" fill="currentColor" style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: inline; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"></path></svg></div><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><path d="M4.53125 10.1562C5.08353 10.1562 5.53125 10.604 5.53125 11.1562V18.4688H12.8438C13.396 18.4688 13.8438 18.9165 13.8438 19.4688C13.8438 20.021 13.396 20.4688 12.8438 20.4688H5.53125C4.42668 20.4688 3.53125 19.5733 3.53125 18.4688V11.1562C3.53125 10.604 3.97897 10.1562 4.53125 10.1562ZM18.5 3.46875C19.6046 3.46875 20.5 4.36418 20.5 5.46875V12.7812C20.5 13.3335 20.0523 13.7812 19.5 13.7812C18.9477 13.7812 18.5 13.3335 18.5 12.7812V5.46875H11.1875C10.6352 5.46875 10.1875 5.02103 10.1875 4.46875C10.1875 3.91647 10.6352 3.46875 11.1875 3.46875H18.5Z" fill="currentColor" style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: inline; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"></path></svg></div></div></div><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><div messageid="1350461351544593" pluginconfig="[object Object]" style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px 0px 8px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);">
t | Constraints/byte | Entropy loss/byte
-- | -- | --
3 | 3 | 0.017 bits
5 | 10 | 0.058 bits
10 | 45 | 0.279 bits
15 | 105 | 0.762 bits
20 | 190 | 1.956 bits
30 | 256 | 8.000 bits (FULL BREAKDOWN)
</div></div></div></div></div></div><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);">At <code style="color: rgb(0, 0, 0); font: 16px / 24px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: inline; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);">t >= 30</code>, no valid polynomial can exist - the scheme collapses entirely.</div></div><hr style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0); border-width: 0.666667px 0px 0px; border-style: solid; border-color: rgb(0, 0, 0);"><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><h2 style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);">Impact</h2></div><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><ul style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);">
<li style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: list-item; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><strong style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: inline; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);">t = 3 (challenge):</strong> Small leak (~0.27 bits) - insufficient for practical recovery, but violates perfect secrecy</li>
<li style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: list-item; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><strong style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: inline; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);">t >= 15:</strong> Cryptographically meaningful weakening</li>
<li style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: list-item; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><strong style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: inline; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);">t >= 30:</strong> Complete failure - cannot generate valid shares</li>
<li style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: list-item; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><strong style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: inline; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);">General:</strong> Clear deviation from standard Shamir's SSS; coefficient distribution is non-uniform</li>
</ul></div><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);"><div style="color: rgb(0, 0, 0); font: 16px / 24px ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 16px; font-weight: 400; line-height: 24px; text-align: start; white-space: normal; display: block; flex: 0 1 auto; flex-direction: row; justify-content: normal; align-items: normal; padding: 0px; margin: 0px; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box; background-color: rgba(0, 0, 0, 0);">Falls under bounty category: "Any other significant implementation bug."</div></div><!--EndFragment-->
</body>
</html>
Security Disclosure: Biased Polynomial Coefficients in Shamir Secret Sharing
Affected project:
bitaps-com/jsbtcAffected file:
src/functions/shamir_secret_sharing.jsDate: 2026-08-27
Bounty Category: 0.05 BTC+ - "Any other significant implementation bug"
Summary
S.__shamirFnusesq.indexOf(a)to get the exponent, which returns the first occurrence of valuea. If coefficients repeat, the wrong exponent is used. To avoid this,__split_secretforces all coefficients to be distinct from each other and from the secret byte viawhile (q.includes(w)).This violates Shamir's perfect-secrecy guarantee by sampling coefficients without replacement. For
t = 3, exactly 3 values per byte are rejected (256 -> 253 candidates), leaking approximately 0.272 bits of entropy across 16 bytes. The leak grows quadratically with thresholdtand causes total breakdown att >= 30.Root Cause
Bug in __shamirFn: