/// <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)); }
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))); }
public FiniteFieldElement <DomainType> Add( FiniteFieldElement <DomainType> other) { return(Algebra.Add(this, other)); }
public void AddTest1() { Algebra al = new Algebra(); Assert.Equal(2, al.Add(1, 1)); }
public void AddTestMax() { Algebra al = new Algebra(); Assert.Equal(Math.Pow(2, 32) - 2, al.Add(int.MaxValue, int.MaxValue)); }
public void AddTest3() { Algebra al = new Algebra(); Assert.Equal(2 << 10, al.Add(2 << 9, 2 << 9)); }
public void AddTest2() { Algebra al = new Algebra(); Assert.Equal(3, al.Add(1, 2)); }