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");
                }
            }
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((int)StepType * 397) ^ PrettyName.GetHashCode());
     }
 }
        public int CompareTo(object obj)
        {
            if (obj is OrganizerEntry other)
            {
                if (Number != other.Number)
                {
                    return(Number - other.Number);
                }

                return(PrettyName.CompareTo(other.PrettyName));
            }

            return(1);
        }
        public void MapAddCountTest()
        {
            PrettyName alpha0 = new PrettyName("alpha", 0);
            PrettyName alpha1 = new PrettyName("alpha", 1);
            PrettyName beta0  = new PrettyName("beta", 0);
            PrettyName beta1  = new PrettyName("beta", 1);

            EqualityMap map = new EqualityMap();

            Assert.AreEqual(0, map.CountEquationAndExponentIndices);
            Assert.AreEqual(0, map.CountPrettyName);

            // add double indexes with pretty name alpha0
            int expectedDoubleIndexCount = 0;

            for (int dlIndex = 0; dlIndex < 10; ++dlIndex)
            {
                for (int baseIndex = 0; baseIndex < 10; ++baseIndex)
                {
                    map.Add(alpha0, new DoubleIndex(dlIndex, baseIndex));
                    ++expectedDoubleIndexCount;
                    Assert.AreEqual(expectedDoubleIndexCount, map.CountEquationAndExponentIndices);
                    Assert.AreEqual(1, map.CountPrettyName);
                }
            }

            // add double indexes with pretty name alpha1
            map.Add(alpha1, new DoubleIndex(10, 0));
            ++expectedDoubleIndexCount;
            Assert.AreEqual(expectedDoubleIndexCount, map.CountEquationAndExponentIndices);
            Assert.AreEqual(2, map.CountPrettyName);

            map.Add(beta0, new DoubleIndex(10, 1));
            ++expectedDoubleIndexCount;
            Assert.AreEqual(expectedDoubleIndexCount, map.CountEquationAndExponentIndices);
            Assert.AreEqual(3, map.CountPrettyName);

            map.Add(beta1, new DoubleIndex(10, 2));
            ++expectedDoubleIndexCount;
            Assert.AreEqual(expectedDoubleIndexCount, map.CountEquationAndExponentIndices);
            Assert.AreEqual(4, map.CountPrettyName);
        }