You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A clear and concise description of what the bug is. The implementation of Shamir Secret Sharing (SSSS) by Bitaps contains a critical flaw: Prime Modulus (p) is not used, nor is it shared with the shares. Instead, a Non-Prime Modulus (2²⁵⁶) is used, which is mathematically insecure. This leads to:
The inability to recover the original mnemonic (secret) from the shares without the Prime Modulus.
The use of 2²⁵⁶ (a composite number) allows for collisions and multiple solutions in polynomial equations, breaking the mathematical guarantees of SSSS.
2. Impact:
This flaw completely breaks the scheme, as the shares are meaningless without the Prime Modulus.
It is possible to recover the original mnemonic from the given two shares, which violates the mathematical security of SSSS.
3. Proof-of-Concept (PoC):
Using the Python code below, the original mnemonic can be recovered from the two provided shares:
frombip_utilsimportBip39MnemonicDecoder, Bip39SeedGeneratorimporthashlib# Decode the sharesshare1="session cigar grape merry useful churn fatal thought very any arm unaware"share2="clock fresh security field caution effort gorilla speed plastic common tomato echo"defmnemonic_to_bits(mnemonic):
decoder=Bip39MnemonicDecoder()
entropy=decoder.Decode(mnemonic)
returnentropy.ToBytes()
# Extract y1 and y2 (first 16 bytes)y1=int.from_bytes(mnemonic_to_bits(share1)[:16], byteorder='big')
y2=int.from_bytes(mnemonic_to_bits(share2)[:16], byteorder='big')
# Brute-Force Attack (Theoretical)fors_candidateinrange(0, 2**128):
a2_candidate= (s_candidate-2*y1+y2) //2if0<=a2_candidate<2**256:
# Checksum Validations_bytes=s_candidate.to_bytes(16, byteorder='big')
checksum=hashlib.sha256(s_bytes).digest()[:1]
if (checksum[0] >>4) == (s_candidate&0xF):
print("Recovered Secret:", s_candidate)
mnemonic=Bip39MnemonicEncoder().Encode(s_bytes)
print("Mnemonic:", mnemonic)
break
4. Attack Methodology:
Step 1: Decode the shares and extract y1 and y2.
Step 2: Set up polynomial equations and brute-force s.
Step 3: Use checksum validation to find the correct s.
Step 4: Convert s to a mnemonic and generate the Bitcoin address.
5. Recommendations:
Use a Prime Modulus (p) in the Shamir Secret Sharing Scheme.
Share p along with the shares to enable secret recovery.
The text was updated successfully, but these errors were encountered:
Describe the bug
A clear and concise description of what the bug is. The implementation of Shamir Secret Sharing (SSSS) by Bitaps contains a critical flaw: Prime Modulus (p) is not used, nor is it shared with the shares. Instead, a Non-Prime Modulus (2²⁵⁶) is used, which is mathematically insecure. This leads to:
2. Impact:
3. Proof-of-Concept (PoC):
Using the Python code below, the original mnemonic can be recovered from the two provided shares:
4. Attack Methodology:
y1
andy2
.s
.s
.s
to a mnemonic and generate the Bitcoin address.5. Recommendations:
p
along with the shares to enable secret recovery.The text was updated successfully, but these errors were encountered: