private (Bn128Fp, Bn128Fp2) DecodePair(byte[] input, int offset) { byte[] x = input.Slice(offset + 0, 32); byte[] y = input.Slice(offset + 32, 32); Bn128Fp p1 = Bn128Fp.CreateInG1(x, y); // fail if point is invalid if (p1 == null) { return(null, null); } // (b, a) byte[] b = input.Slice(offset + 64, 32); byte[] a = input.Slice(offset + 96, 32); // (d, c) byte[] d = input.Slice(offset + 128, 32); byte[] c = input.Slice(offset + 160, 32); Bn128Fp2 p2 = Bn128Fp2.CreateInG2(a, b, c, d); // fail if point is invalid if (p2 == null) { return(null, null); } return(p1, p2); }
public void Zero_reused() { Bn128Fp2 p1 = Bn128Fp2.Create(new byte[] { 0 }, new byte[] { 0 }, new byte[] { 0 }, new byte[] { 0 }); // ReSharper disable once EqualExpressionComparison Assert.True(ReferenceEquals(p1.Zero, p1.Zero)); }
public void Equals_works_with_nulls() { Bn128Fp2 bn128Fp2 = new Bn128Fp2(Fp2.One, Fp2.One, Fp2.One); Assert.False(bn128Fp2 == null, "null to the right"); Assert.False(null == bn128Fp2, "null to the left"); Assert.True((Bn128Fp2)null == null, "null both sides"); }
public void Zero_initializes() { Bn128Fp2 p1 = Bn128Fp2.Create(new byte[] { 0 }, new byte[] { 0 }, new byte[] { 0 }, new byte[] { 0 }); Assert.NotNull(p1.Zero); }