Example #1
0
        public static byte[] EncodeSignature(ECDSA_SIG signature)
        {
            byte[] result;
            using (var ms = new MemoryStream())
            {
                StreamOp.WriteBytes(ms, ref signature.R);
                StreamOp.WriteBytes(ms, ref signature.S);
                result = StreamOp.SaveStreamToRaw(ms);
            }

            return(result);
        }
Example #2
0
        public static bool DecodeSignature(byte[] rawSignature, out ECDSA_SIG signature)
        {
            signature = CT_TECDSA_SIG_Nul;
            using (var ms = new MemoryStream())
            {
                StreamOp.LoadStreamFromRaw(ms, rawSignature);
                ms.Position = 0;
                if (StreamOp.ReadBytes(ms, ref signature.R) < 0)
                {
                    return(false);
                }
                if (StreamOp.ReadBytes(ms, ref signature.S) < 0)
                {
                    return(false);
                }
                if (ms.Position < ms.Length)
                {
                    return(false);                         // Invalid position
                }
            }

            return(true);
        }
Example #3
0
 internal static void ToSerialized(ref byte[] result, Stream stream) => StreamOp.WriteBytes(stream, ref result);
Example #4
0
 internal static int FromSerialized(ref byte[] result, Stream stream, int checkLength = 0) =>
 StreamOp.ReadBytes(stream, ref result, checkLength);