def share(self, secret, threshold, points): coef = [secret] coef += [self.random.randitem() for j in range(threshold-1)] p = Polynomial(list(reversed(coef))) shares = [(pt, p.evaluate(pt)) for pt in points] return shares
def test_Polynomial_evaluate_ValueIsCorrect(self): p = Polynomial([3, 5, 78, 2]) value = p.evaluate(3) self.assertEquals(value, 362)