internal static void secp256k1_musig_nonce_process_internal( ECMultContext ecmult_ctx, out bool fin_nonce_parity, Span <byte> fin_nonce, out Scalar b, Span <GEJ> aggnoncej, ReadOnlySpan <byte> agg_pk32, ReadOnlySpan <byte> msg) { Span <byte> noncehash = stackalloc byte[32]; Span <GE> aggnonce = stackalloc GE[2]; aggnonce[0] = aggnoncej[0].ToGroupElement(); aggnonce[1] = aggnoncej[1].ToGroupElement(); secp256k1_musig_compute_noncehash(noncehash, aggnonce, agg_pk32, msg); /* aggnonce = aggnonces[0] + b*aggnonces[1] */ b = new Scalar(noncehash); var fin_nonce_ptj = ecmult_ctx.Mult(aggnoncej[1], b, null); fin_nonce_ptj = fin_nonce_ptj.Add(aggnonce[0]); var fin_nonce_pt = fin_nonce_ptj.ToGroupElement(); ECXOnlyPubKey.secp256k1_xonly_ge_serialize(fin_nonce, ref fin_nonce_pt); fin_nonce_pt = fin_nonce_pt.NormalizeYVariable(); fin_nonce_parity = fin_nonce_pt.y.IsOdd; }
internal static GE secp256k1_musig_process_nonces_internal( ECMultContext ecmult_ctx, Span <byte> noncehash, Span <GEJ> summed_noncesj, ReadOnlySpan <byte> combined_pk32, ReadOnlySpan <byte> msg) { Scalar b; GEJ combined_noncej; Span <GE> summed_nonces = stackalloc GE[2]; summed_nonces[0] = summed_noncesj[0].ToGroupElement(); summed_nonces[1] = summed_noncesj[1].ToGroupElement(); secp256k1_musig_compute_noncehash(noncehash, summed_nonces, combined_pk32, msg); /* combined_nonce = summed_nonces[0] + b*summed_nonces[1] */ b = new Scalar(noncehash); combined_noncej = ecmult_ctx.Mult(summed_noncesj[1], b, null); combined_noncej = combined_noncej.Add(summed_nonces[0]); return(combined_noncej.ToGroupElement()); }