示例#1
0
 def test_math(self):
     # first check some of the math...
     self.assertTrue(
         shamirsecret._multiply_polynomials([1, 3, 4], [4, 5]) ==
         [4, 9, 31, 20])
     self.assertTrue(
         shamirsecret._full_lagrange([2, 4, 5], [14, 30, 32]) ==
         [43, 168, 150])
示例#2
0
文件: old.py 项目: altoplano/PHC
import shamirsecret
a = shamirsecret._full_lagrange([2,4,5],[14,30,32])
print a
 def test_math(self):
   # first check some of the math...
   self.assertTrue(shamirsecret._multiply_polynomials([1,3,4],[4,5]) == [4,9,31,20])
   self.assertTrue(shamirsecret._full_lagrange([2,4,5],[14,30,32]) == [43, 168, 150])
import shamirsecret

#  Basic tests for this module.   Should output nothing on success.

# first check some of the math...
assert(shamirsecret._multiply_polynomials([1,3,4],[4,5]) == [4,9,31,20])
assert(shamirsecret._full_lagrange([2,4,5],[14,30,32]) == [43, 168, 150])

s = shamirsecret.ShamirSecret(2,'hello')
a=s.compute_share(1)
b=s.compute_share(2)
c=s.compute_share(3)


# should be able to recover from any two...
t = shamirsecret.ShamirSecret(2)
t.recover_secretdata([a,b])

t = shamirsecret.ShamirSecret(2)
t.recover_secretdata([a,c])

t = shamirsecret.ShamirSecret(2)
t.recover_secretdata([b,c])

# ... or even all three!
t = shamirsecret.ShamirSecret(2)
t.recover_secretdata([a,b,c])



示例#5
0
文件: old.py 项目: danik310/PHC
import shamirsecret

a = shamirsecret._full_lagrange([2, 4, 5], [14, 30, 32])
print a