harbor run -t LiteCoder/shamir-aes-treasure-decryptharbor download LiteCoder/shamir-aes-treasure-decryptReconstruct an AES-256 key from Shamir's Secret Sharing shares and use it to decrypt an encrypted treasure file.
pycryptodome for AES, a Shamir's Secret Sharing library, or a custom implementation)/app/app/shares.json — Contains 5 Shamir's Secret Sharing shares (3-of-5 threshold scheme)/app/treasure.enc — AES-256-CBC encrypted file (binary)/app/treasure_decrypted.txt — The decrypted plaintext contentshares.json format:
{
"threshold": 3,
"total_shares": 5,
"prime_hex": "<hex string of the prime modulus used in the scheme>",
"shares": [
{"index": 1, "value_hex": "<hex string>"},
{"index": 2, "value_hex": "<hex string>"},
{"index": 3, "value_hex": "<hex string>"},
{"index": 4, "value_hex": "<hex string>"},
{"index": 5, "value_hex": "<hex string>"}
]
}
threshold: minimum number of shares needed to reconstruct the secret (always 3)total_shares: total number of shares (always 5)prime_hex: the prime modulus used for finite-field arithmetic, encoded as a hex stringindex (1-based integer, the x-coordinate) and a value_hex (the y-coordinate as a hex string)treasure.enc format:
/app/shares.json and select any 3 of the 5 shares.prime_hex. Use Lagrange interpolation to recover the secret (the constant term of the polynomial) from any 3 shares./app/treasure.enc, extract the 16-byte IV from the first 16 bytes, and the ciphertext from the remaining bytes./app/treasure_decrypted.txt./app/treasure_decrypted.txt must contain the exact decrypted plaintext (UTF-8 encoded, no extra trailing newlines or whitespace beyond what was in the original plaintext).prime_hex value from shares.json as the modulus for Lagrange interpolation — do not assume a fixed prime.