public void EqualsTest() { BigInt a = new BigInt("489a03c58dcf7fcfc97e99ffef0bb4634", 16); BigInt b = new BigInt("510c6972d795ec0c2b081b81de767f808", 16); Assert.IsFalse(a.Equals(b)); Assert.IsTrue(a.Equals(a)); }
public void BigInt_TypedEquals_ComparesDifferentInstances() { BigInt value10 = BigInt.FromInt(10); BigInt value10_ = BigInt.FromInt(10); BigInt value20 = BigInt.FromInt(20); BigInt value1 = BigInt.FromInt(1); Assert.IsTrue(value10.Equals(value10)); Assert.IsTrue(value10.Equals(value10_)); Assert.IsFalse(value10.Equals(value20)); Assert.IsTrue(value1.Equals(BigInt.One)); }
public void BigInt_UntypedEquals_ComparesObjectsWithInstances() { BigInt value10 = BigInt.FromInt(10); BigInt value10_ = BigInt.FromInt(10); BigInt value20 = BigInt.FromInt(20); BigInt value1 = BigInt.FromInt(1); Assert.IsFalse(value10.Equals((object)null)); Assert.IsFalse(value10.Equals((object)"some text")); Assert.IsTrue(value10.Equals((object)value10)); Assert.IsTrue(value10.Equals((object)value10_)); Assert.IsFalse(value10.Equals((object)value20)); Assert.IsTrue(value1.Equals((object)BigInt.One)); }
protected override IDataItem TestFunc(IDataItem p1, IDataItem p2) { var u = p1.ToUBigInt().Value; var v = p2.ToBigInt().Value; var w = BigInt.Equals(u, v); return(new UInt32DataItem(w ? 1U : 0U)); }
private Point SimpleMultiply(Point p, BigInt k) { if (!(this.field.IsValidElement(p.X)) || !(this.field.IsValidElement(p.Y)) ) { throw new ArgumentException("The input point must be taken over the field."); } if (p.IsInfinity()) { return(p); } if (k.Equals(BigInt.ZERO)) { return(Point.INFINITY); } if (k.Equals(BigInt.ONE)) { return(p); } if (k.Signum() == -1) { k = k.Abs(); p = this.Negate(p); } sbyte[] ba = k.ToByteArray(); int degree = ByteArrayUtil.DegreeOf(ba) - 1; Point x = p; for (int i = degree; i >= 0; i--) { x = this.Dbl(x); if (ByteArrayUtil.GetBitByDegree(i, ba)) { x = this.Add(p, x); } } return(x); }
//multiplication using Jacobian coordinates public JacobPoint JMultiplyMut(Point p, BigInt k) { if (!(this.field.IsValidElement(p.X)) || !(this.field.IsValidElement(p.Y))) { throw new ArgumentException("The input point must be taken over the field."); } if (p.IsInfinity()) { return(this.AToJ(p)); } if (k.Equals(BigInt.ZERO)) { return(JacobPoint.INFINITY); } if (k.Equals(BigInt.ONE)) { return(this.AToJ(p)); } if (k.Signum() == -1) { k = k.Abs(); p = this.Negate(p); } //byte [] ba =k.toByteArray(); int degree = k.BitLength() - 2; JacobPoint result = this.AToJ(p); for (int i = degree; i >= 0; i--) { this.JDblMut(result); if (k.TestBit(i)) ///AQUI TE QUEDASTE IMPLEMENTAR TESTBIT { this.JAddMut(result, p); } } return(result); }
public override bool Equals(Object obj) { //this could fail if (this == obj) { return(true); } if (obj == null) { return(false); } //if ( != obj.getClass()) // return false; JacobPoint other = (JacobPoint)obj; if (x == null) { if (other.x != null) { return(false); } } else if (!x.Equals(other.x)) { return(false); } if (y == null) { if (other.y != null) { return(false); } } else if (!y.Equals(other.y)) { return(false); } if (z == null) { if (other.z != null) { return(false); } } else if (!z.Equals(other.z)) { return(false); } return(true); }
public void BigInt_Equals_ComparesValuesAndIgnoresPrecision() { BigInt valueA10 = BigInt.FromInt(10); BigInt valueA10_ = BigInt.FromInt(10, 5); BigInt valueA20 = BigInt.FromInt(20); BigInt valueA20_ = BigInt.FromInt(20, 5); BigInt valueB10 = BigInt.FromInt(10); BigInt valueB10_ = BigInt.FromInt(10, 5); BigInt valueB20 = BigInt.FromInt(20); BigInt valueB20_ = BigInt.FromInt(20, 5); Assert.IsTrue(valueA10 == valueA10_); Assert.IsTrue(valueA10 == valueA10_); Assert.IsFalse(valueA10 == valueA20); Assert.IsFalse(valueA10 == valueA20_); Assert.IsTrue(valueA10 == valueB10); Assert.IsTrue(valueA10 == valueB10_); Assert.IsFalse(valueA10 == valueA20); Assert.IsFalse(valueA10 == valueA20_); Assert.IsFalse(valueA10 != valueA10_); Assert.IsFalse(valueA10 != valueA10_); Assert.IsTrue(valueA10 != valueA20); Assert.IsTrue(valueA10 != valueA20_); Assert.IsFalse(valueA10 != valueB10); Assert.IsFalse(valueA10 != valueB10_); Assert.IsTrue(valueA10 != valueA20); Assert.IsTrue(valueA10 != valueA20_); Assert.IsTrue(valueA10.Equals(valueA10_)); Assert.IsTrue(valueA10.Equals(valueA10_)); Assert.IsFalse(valueA10.Equals(valueA20)); Assert.IsFalse(valueA10.Equals(valueA20_)); Assert.IsTrue(valueA10.Equals(valueB10)); Assert.IsTrue(valueA10.Equals(valueB10_)); Assert.IsFalse(valueA10.Equals(valueA20)); Assert.IsFalse(valueA10.Equals(valueA20_)); }
public void EqualsTest() { Assert.IsTrue(a.Equals(a)); Assert.IsFalse(a.Equals(b)); }