Ask Your Question

Sigurd Meldgaard's profile - activity

2022-09-05 14:09:28 +0200 received badge  Nice Answer (source)
2012-08-04 09:08:18 +0200 received badge  Teacher (source)
2012-08-04 09:08:18 +0200 received badge  Necromancer (source)
2012-06-29 08:35:10 +0200 answered a question how to use the secret perfect shamir in Sage?

You seem to be refering to Shamir Secret Sharing a secret-sharing scheme invented by Shamir: paper here

Described nicely here: http://en.wikipedia.org/wiki/Shamir%2...

The following Sage code works fine to reconstruct the polynomial from the shares:

F = FiniteField(101) # Construct finite field
P = F['x'] # Polynomial ring

# How to use P:
original_polynomial = P("56 + 10x + 5x^2")
# Convert the shares to elements of F (otherwise lagrange_polynomial will fail)
shares = [(F(x), F(y)) for x,y in [(25, 98), (47, 57), (19, 31)]]
# Now lagrange_polynomial works fine
reconstructed_polynomial = P.lagrange_polynomial(shares)

print "Correct reconstruction!" if reconstructed_polynomial == original_polynomial else "Something wrong!"
print "p(x) =", reconstructed_polynomial
print "Secret = p(0) =", reconstructed_polynomial(0)