/// <summary>
 /// Adds a <see cref="CryptoGroupElement{TScalar, TElement}"/> to the current instance following
 /// the addition law of the associated group.
 /// </summary>
 /// <param name="element">The <see cref="CryptoGroupElement{TScalar, TElement}"/> to add.</param>
 /// <returns>
 /// The <see cref="CryptoGroupElement{TScalar, TElement}"/> that is the group addition
 /// result of the values of <c>this</c> and <c>element</c>.
 /// </returns>
 public CryptoGroupElement <TScalar, TElement> Add(CryptoGroupElement <TScalar, TElement> element)
 {
     if (Algebra != element.Algebra)
     {
         throw new ArgumentException("Added group element must be from the same group!", nameof(element));
     }
     return(new CryptoGroupElement <TScalar, TElement>(Algebra.Add(Value, element.Value), Algebra));
 }
Ejemplo n.º 2
0
 public FiniteFieldElement <IntegerType> Add(
     FiniteFieldElement <IntegerType> element_0,
     FiniteFieldElement <IntegerType> element_1)
 {
     return(new FiniteFieldElement <IntegerType>(this, Algebra.Modulo(Algebra.Add(element_0.Value, element_1.Value), Prime)));
 }
Ejemplo n.º 3
0
 public FiniteFieldElement <DomainType> Add(
     FiniteFieldElement <DomainType> other)
 {
     return(Algebra.Add(this, other));
 }
Ejemplo n.º 4
0
        public void AddTest1()
        {
            Algebra al = new Algebra();

            Assert.Equal(2, al.Add(1, 1));
        }
Ejemplo n.º 5
0
        public void AddTestMax()
        {
            Algebra al = new Algebra();

            Assert.Equal(Math.Pow(2, 32) - 2, al.Add(int.MaxValue, int.MaxValue));
        }
Ejemplo n.º 6
0
        public void AddTest3()
        {
            Algebra al = new Algebra();

            Assert.Equal(2 << 10, al.Add(2 << 9, 2 << 9));
        }
Ejemplo n.º 7
0
        public void AddTest2()
        {
            Algebra al = new Algebra();

            Assert.Equal(3, al.Add(1, 2));
        }