public static byte[] EncodePoint(ECPoint Q) { /*if (!Q.isCompressed()) * Q=new ECPoint.F2m(Q.getCurve(),Q.getX(),Q.getY(),true); * * byte[] bytes=Q.getEncoded(); * * if (bytes[0]==0x02) * bytes[bytes.length-1]&=0xFE; * else if (bytes[0]==0x02) * bytes[bytes.length-1]|=0x01; * * return Arrays.copyOfRange(bytes, 1, bytes.length);*/ Q = Q.Normalize(); ECFieldElement x = Q.AffineXCoord; byte[] bytes = x.GetEncoded(); if (!x.IsZero) { ECFieldElement z = Q.AffineYCoord.Divide(x); if (Trace(z).IsOne) { bytes[bytes.Length - 1] |= 0x01; } else { bytes[bytes.Length - 1] &= 0xFE; } } return(bytes); }
public static void WriteECFieldElement(ECFieldElement x, Stream output) { TlsUtilities.WriteOpaque8(x.GetEncoded(), output); }
private void AddFieldElement(IDigest digest, ECFieldElement v) { byte[] p = v.GetEncoded(); digest.BlockUpdate(p, 0, p.Length); }