public bool CheckTapTweak(TaprootInternalPubKey internalPubKey, uint256?merkleRoot, bool parity)
        {
            if (internalPubKey is null)
            {
                throw new ArgumentNullException(nameof(internalPubKey));
            }

            Span <byte> tweak32 = stackalloc byte[32];

            TaprootFullPubKey.ComputeTapTweak(internalPubKey, merkleRoot, tweak32);
            return(this.pubkey.CheckIsTweakedWith(internalPubKey.pubkey, tweak32, parity));
        }
示例#2
0
        public TaprootSignature SignTaprootKeySpend(uint256 hash, uint256?merkleRoot, uint256?aux, TaprootSigHash sigHash)
        {
            if (hash == null)
            {
                throw new ArgumentNullException(nameof(hash));
            }
            AssertNotDisposed();
            var eckey = _ECKey;

            if (PubKey.Parity)
            {
                eckey = new Secp256k1.ECPrivKey(_ECKey.sec.Negate(), _ECKey.ctx, true);
            }
            Span <byte> buf = stackalloc byte[32];

            TaprootFullPubKey.ComputeTapTweak(PubKey.TaprootInternalKey, merkleRoot, buf);
            eckey = eckey.TweakAdd(buf);
            hash.ToBytes(buf);
            var sig = aux?.ToBytes() is byte[] auxbytes?eckey.SignBIP340(buf, auxbytes) : eckey.SignBIP340(buf);

            return(new TaprootSignature(new SchnorrSignature(sig), sigHash));
        }
 public TaprootFullPubKey GetTaprootFullPubKey(uint256?merkleRoot)
 {
     return(TaprootFullPubKey.Create(this, merkleRoot));
 }
示例#4
0
 public TaprootKeyPair(Key key, TaprootFullPubKey pubKey) : base(key, pubKey)
 {
     Key    = key;
     PubKey = pubKey;
 }