public ECPubKey Tweak(ReadOnlySpan <byte> tweak32) { if (processed_nonce) { throw new InvalidOperationException("This function can only be called before MusigContext.Process"); } if (is_tweaked) { throw new InvalidOperationException("This function can only be called once"); } if (tweak32.Length != 32) { throw new ArgumentException(nameof(tweak32), "The tweak should have a size of 32 bytes"); } scalar_tweak = new Scalar(tweak32, out int overflow); if (overflow == 1) { throw new ArgumentException(nameof(tweak32), "The tweak is overflowing"); } var output = aggregatePubKey.AddTweak(tweak32); internal_key_parity = pk_parity; pk_parity = output.Q.y.IsOdd; is_tweaked = true; tweakedPubKey = output; return(output); }