Example #1
0
 /// <summary>
 /// Encodes the curve point in a byte buffer.
 /// </summary>
 /// <param name="encoding">The encoding scheme used to encode the point in the buffer.</param>
 /// <returns>Byte buffer containing the encoded curve point.</returns>
 public byte[] ToBytes(PointEncoding encoding = PointEncoding.Compressed)
 {
     using (var ctx = BigNumberContextHandle.Create())
     {
         int    requiredBufferLength = ECPointHandle.ToByteBuffer(_ecGroup, Handle, encoding, null, ctx);
         byte[] buffer       = new byte[requiredBufferLength];
         int    writtenBytes = ECPointHandle.ToByteBuffer(_ecGroup, Handle, encoding, buffer, ctx);
         Debug.Assert(writtenBytes == requiredBufferLength);
         return(buffer);
     }
 }