Core usage examples for shamir_ss package
from shamir_ss import generate_text_shares, reconstruct_text_secret
def main():
secret = "My top secret"
# Split into 5 shares (threshold=3)
shares = generate_text_shares(secret, 3, 5)
# Reconstruct with 3 shares
reconstructed = reconstruct_text_secret(shares[:3])
print(reconstructed)
if __name__ == "__main__":
main()
My top secret
from shamir_ss import generate_text_shares, reconstruct_text_secret
def main():
secret = "My top secret"
# secp256k1 prime (Bitcoin's curve)
new_prime = 2**256 - 2**32 - 2**9 - 2**8 - 2**7 - 2**6 - 2**4 - 1
shares = generate_text_shares(secret, 3, 5, prime=new_prime)
reconstructed = reconstruct_text_secret(shares[:3], prime=new_prime)
print(reconstructed)
if __name__ == "__main__":
main()
Using prime (bit length: 256, chunk size: 32 bytes) Split text into 1 chunks. Generating 5 shares with a threshold of 3... Processing chunk 1/1... Successfully generated all shares. Reconstructing from 3 shares. Prime bit length: 256, chunk size: 32 bytes Reconstructing 1 chunks... Chunk 1/1... All chunks reconstructed. Decoding text... My top secret
from shamir_ss import generate_text_shares, reconstruct_text_secret
def main():
secret = "My top secret"
# With debug output
shares = generate_text_shares(secret, 3, 5, verbose=True)
reconstructed = reconstruct_text_secret(shares[:3], verbose=True)
print(reconstructed)
if __name__ == "__main__":
main()
Using prime (bit length: 127, chunk size: 16 bytes) Split text into 2 chunks. Generating 5 shares with a threshold of 3... Processing chunk 1/2... Processing chunk 2/2... Successfully generated all shares. Reconstructing from 3 shares. Prime bit length: 127, chunk size: 16 bytes Reconstructing 2 chunks... Chunk 1/2... Chunk 2/2... All chunks reconstructed. Decoding text... My top secret