public void TestField_Mult() { Assert.Equal(9, HashiCorpShamir.Mult(3, 7)); Assert.Equal(0, HashiCorpShamir.Mult(3, 0)); Assert.Equal(0, HashiCorpShamir.Mult(0, 3)); }
public void TestPolynomial_Eval() { var p = HashiCorpShamir.MakePolynomial(42, 1); Assert.Equal(42, p.Evaluate(0)); // out := p.evaluate(1) // exp := add(42, mult(1, p.coefficients[1])) // if out != exp { // t.Fatalf("bad: %v %v %v", out, exp, p.coefficients) // } var ret = p.Evaluate(1); var exp = HashiCorpShamir.Add(42, HashiCorpShamir.Mult(1, p.Coefficients[1])); Assert.Equal(ret, exp); }