public void TryRetrieveIntIndexTest() { PrettyName alpha0 = new PrettyName("alpha", 0); PrettyName alpha1 = new PrettyName("alpha", 1); EqualityMap map = new EqualityMap(); Assert.AreEqual(0, map.CountEquationAndExponentIndices); Assert.AreEqual(0, map.CountPrettyName); // add double indexes with pretty name alpha0 and alpha1 int actualIndex; for (int dlIndex = 0; dlIndex < 10; ++dlIndex) { for (int baseIndex = 0; baseIndex < 10; ++baseIndex) { DoubleIndex di0 = new DoubleIndex(dlIndex, baseIndex); DoubleIndex di0clone = new DoubleIndex(dlIndex, baseIndex); map.Add(alpha0, di0); Assert.IsTrue(map.TryRetrieveIntIndex(di0, out actualIndex)); Assert.AreEqual(0, actualIndex, "could not retrieve correct index for di0"); Assert.IsTrue(map.TryRetrieveIntIndex(di0clone, out actualIndex)); Assert.AreEqual(0, actualIndex, "could not retrieve correct index for di0clone"); DoubleIndex di1 = new DoubleIndex(dlIndex + 100, baseIndex); DoubleIndex di1clone = new DoubleIndex(dlIndex + 100, baseIndex); map.Add(alpha1, di1); Assert.IsTrue(map.TryRetrieveIntIndex(di1, out actualIndex)); Assert.AreEqual(1, actualIndex, "could not retrieve correct index for di1clone"); Assert.IsTrue(map.TryRetrieveIntIndex(di1clone, out actualIndex)); Assert.AreEqual(1, actualIndex, "could not retrieve correct index for di1clone"); } } }
public void EQEndToEndTest1() { // create two pedersen commitments to 1 DLRepOfGroupElement[] dlarray = new DLRepOfGroupElement[2] { new PedersenCommitment(_parameters.FieldZq.One, _parameters), new PedersenCommitment(_parameters.FieldZq.One, _parameters) }; PrettyName alpha = new PrettyName("alpha", 0); DoubleIndex d1 = new DoubleIndex(0, 0); // dlarray[0].BaseAtIndex(0) DoubleIndex d2 = new DoubleIndex(1, 0); // dlarray[1].BaseAtIndex(0) EqualityMap map = new EqualityMap(); map.Add(alpha, d1); map.Add(alpha, d2); int index; Assert.IsTrue(map.TryRetrieveIntIndex(d1, out index)); Assert.AreEqual(0, index); Assert.IsTrue(map.TryRetrieveIntIndex(d2, out index)); Assert.AreEqual(0, index); ProverEqualityParameters peParameters = new ProverEqualityParameters( dlarray, map, _parameters); EqualityProof proof = new EqualityProof(peParameters); Assert.IsTrue(proof.Verify(peParameters)); }