public static bool TryRecover(Context ctx, SecpRecoverableECDSASignature recoverableSig, ReadOnlySpan <byte> msg32, out ECPubKey?pubkey)
        {
            if (recoverableSig == null)
            {
                throw new ArgumentNullException(nameof(recoverableSig));
            }
            ctx ??= Context.Instance;
            GE     q;
            Scalar r, s;
            Scalar m;
            int    recid;

            if (msg32.Length != 32)
            {
                throw new ArgumentException(paramName: nameof(msg32), message: "msg32 should be 32 bytes");
            }

            (r, s, recid) = recoverableSig;
            VERIFY_CHECK(recid >= 0 && recid < 4);              /* should have been caught in parse_compact */
            m = new Scalar(msg32, out _);
            if (secp256k1_ecdsa_sig_recover(ctx.EcMultContext, r, s, out q, m, recid))
            {
                pubkey = new ECPubKey(q, ctx);
                return(true);
            }
            else
            {
                pubkey = null;
                return(false);
            }
        }
 public static bool TryCreateFromCompact(ReadOnlySpan <byte> in64, int recid, out SecpRecoverableECDSASignature?sig)
 {
     sig = null;
     if (SecpECDSASignature.TryCreateFromCompact(in64, out var compact) && compact is SecpECDSASignature)
     {
         sig = new SecpRecoverableECDSASignature(compact, recid);
         return(true);
     }
     return(false);
 }
 public bool TrySignRecoverable(ReadOnlySpan <byte> msg32, INonceFunction?nonceFunction, out SecpRecoverableECDSASignature?recoverableSignature)
 {
     if (msg32.Length != 32)
     {
         throw new ArgumentException(paramName: nameof(msg32), message: "msg32 should be 32 bytes");
     }
     if (this.TrySignECDSA(msg32, nonceFunction, out int recid, out SecpECDSASignature? sig) && sig is SecpECDSASignature)
     {
         recoverableSignature = new SecpRecoverableECDSASignature(sig, recid);
         return(true);
     }
     recoverableSignature = null;
     return(false);
 }