コード例 #1
0
 /// <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));
 }
コード例 #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)));
 }
コード例 #3
0
 public FiniteFieldElement <DomainType> Add(
     FiniteFieldElement <DomainType> other)
 {
     return(Algebra.Add(this, other));
 }
コード例 #4
0
        public void AddTest1()
        {
            Algebra al = new Algebra();

            Assert.Equal(2, al.Add(1, 1));
        }
コード例 #5
0
        public void AddTestMax()
        {
            Algebra al = new Algebra();

            Assert.Equal(Math.Pow(2, 32) - 2, al.Add(int.MaxValue, int.MaxValue));
        }
コード例 #6
0
        public void AddTest3()
        {
            Algebra al = new Algebra();

            Assert.Equal(2 << 10, al.Add(2 << 9, 2 << 9));
        }
コード例 #7
0
        public void AddTest2()
        {
            Algebra al = new Algebra();

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