public TaprootSignature SignTaprootKeySpend(uint256 hash, TaprootSigHash sigHash) { if (hash == null) { throw new ArgumentNullException(nameof(hash)); } return(Key.SignTaprootKeySpend(hash, PubKey.MerkleRoot, sigHash)); }
public TaprootSignature(SchnorrSignature schnorrSignature, TaprootSigHash sigHash) { if (!TaprootExecutionData.IsValidSigHash((byte)sigHash)) { throw new ArgumentException("Invalid hash_type", nameof(sigHash)); } if (schnorrSignature == null) { throw new ArgumentNullException(nameof(schnorrSignature)); } SigHash = sigHash; SchnorrSignature = schnorrSignature; }
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 TaprootSignature SignTaprootKeySpend(uint256 hash, uint256?merkleRoot, TaprootSigHash sigHash) { return(SignTaprootKeySpend(hash, merkleRoot, null, sigHash)); }
public TaprootSignature SignTaprootKeySpend(uint256 hash, TaprootSigHash sigHash = TaprootSigHash.Default) { return(SignTaprootKeySpend(hash, null, sigHash)); }