Пример #1
0
 public void SignatureNormalize()
 {
     using (var secp256k1 = new Secp256k1())
     {
         Span <byte> secretKey = "e815acba8fcf085a0b4141060c13b8017a08da37f2eb1d6a5416adbb621560ef".HexToBytes();
         Assert.False(secp256k1.SignatureNormalize(secretKey, secretKey));
     }
 }
Пример #2
0
        /// <summary>
        /// Check whether a signature is normalized (lower-S).
        /// </summary>
        /// <param name="vchSig"></param>
        /// <returns></returns>
        public static bool CheckLowS(ReadOnlySequence<byte> vchSig)
        {
            var sig = new byte[64];
            var input = vchSig.ToSpan();

            using (var secp256k1 = new Secp256k1()) {

                if (!secp256k1.SignatureParseDerLax(sig, input)) return false;
                return !secp256k1.SignatureNormalize(Span<byte>.Empty, input);
            }
        }
Пример #3
0
        /// <summary>
        /// Check whether a signature is normalized (lower-S).
        /// </summary>
        /// <param name="vchSig"></param>
        /// <returns></returns>
        public static bool CheckLowS(ReadOnlyByteSequence vchSig)
        {
            var sig   = new byte[64];
            var input = (ReadOnlyByteSpan)vchSig;

            using var library = new Secp256k1();
            if (!library.SignatureParseDerLax(sig, input))
            {
                return(false);
            }
            return(!library.SignatureNormalize(Span <byte> .Empty, input));
        }