public void DLGetHashCodeTest() { FieldZqElement[] exponents = StaticHelperClass.GenerateRandomExponents(8, 1); DLRepOfGroupElement dl = new DLRepOfGroupElement(exponents, _parameters[1]); Assert.AreEqual(dl.BaseAtIndex(0).GetHashCode(), dl.GetHashCode()); }
public void BaseAndExponentAtIndexTest() { int replen = 25; for (int paramIndex = 0; paramIndex < _parameters.Length; ++paramIndex) { GroupElement [] bases = StaticHelperClass.GenerateRandomBases(replen, paramIndex); FieldZqElement [] exponents = StaticHelperClass.GenerateRandomExponents(replen, paramIndex); DLRepOfGroupElement dl = new DLRepOfGroupElement(bases, exponents, _parameters[paramIndex].Group); Assert.AreEqual(replen, dl.RepresentationLength, "incorrect representation length"); for (int i = 0; i < replen; ++i) { Assert.AreEqual(bases[i], dl.BaseAtIndex(i), "wrong base"); Assert.AreEqual(exponents[i], dl.ExponentAtIndex(i), "wrong exponent"); } } }
public void BaseConstructorTest() { for (int paramIndex = 0; paramIndex < _parameters.Length; ++paramIndex) { int replen = 10; FieldZqElement[] exponents = StaticHelperClass.GenerateRandomExponents(replen, paramIndex); GroupElement[] bases = StaticHelperClass.GenerateRandomBases(replen, paramIndex); DLRepOfGroupElement dl = new DLRepOfGroupElement(bases, exponents, _parameters[paramIndex].Group); // check bases and exponents got copied correctly, and value was computed correctly GroupElement expectedValue = _parameters[paramIndex].Group.Identity; for (int baseIndex = 0; baseIndex < bases.Length; ++baseIndex) { Assert.AreEqual(bases[baseIndex], dl.BaseAtIndex(baseIndex), "Wrong base"); Assert.AreEqual(exponents[baseIndex], dl.ExponentAtIndex(baseIndex), "wrong exponent"); expectedValue = expectedValue * bases[baseIndex].Exponentiate(exponents[baseIndex]); } Assert.AreEqual(expectedValue, dl.Value, "Incorrect Value"); } }
public void ComputeValueTest() { for (int paramIndex = 0; paramIndex < _parameters.Length; ++paramIndex) { int replen = 10; FieldZqElement[] exponents = StaticHelperClass.GenerateRandomExponents(replen, paramIndex); GroupElement[] bases = StaticHelperClass.GenerateRandomBases(replen, paramIndex); DLRepOfGroupElement actualDL = new DLRepOfGroupElement(bases, exponents, _parameters[paramIndex].Group); GroupElement expectedValue = _parameters[paramIndex].Group.MultiExponentiate(bases, exponents); Assert.AreEqual(expectedValue, actualDL.Value, "different values"); Assert.AreEqual(exponents.Length, actualDL.RepresentationLength, "different number of bases"); for (int baseIndex = 0; baseIndex < actualDL.RepresentationLength; ++baseIndex) { Assert.AreEqual(bases[baseIndex], actualDL.BaseAtIndex(baseIndex), "different base"); Assert.AreEqual(exponents[baseIndex], actualDL.ExponentAtIndex(baseIndex), "different exponent"); } } }