public BlindingFactor Blind_sum(BlindSum blindSum) { var posKeys = blindSum.PositiveKeyIds.Select(Derived_key).ToList(); var negKeys = blindSum.NegativeKeyIds.Select(Derived_key).ToList(); posKeys.AddRange(blindSum.PositiveBlindingFactors.Select(pbf => pbf.Key)); negKeys.AddRange(blindSum.NegativeBlindingFactors.Select(nbf => nbf.Key)); var blinding = Secp.blind_sum(posKeys.ToArray(), negKeys.ToArray()); return(BlindingFactor.New(blinding)); }
/// Builds a new transaction by combining all the combinators provided in a /// Vector. Transactions can either be built "from scratch" with a list of /// inputs or outputs or from a pre-existing transaction that gets added to. /// /// Example: /// let (tx1, sum) = build::transaction(vec![input_rand(4), output_rand(1), /// with_fee(1)], keychain).unwrap(); /// let (tx2, _) = build::transaction(vec![initial_tx(tx1), with_excess(sum), /// output_rand(2)], keychain).unwrap(); public static (Transaction.Transaction transaction, BlindingFactor blindingFactor) Transaction(Func <Context, Append>[] elems, Keychain keychain) { var tx = Core.Transaction.Transaction.Empty(); var sum = BlindSum.New(); var ctx = new Context(keychain, tx, sum); foreach (var elem in elems) { var append = elem(ctx); tx = ctx.Tx = append.Transaction.Clone(); sum = ctx.Sum = append.Blind; } var blindSum = ctx.Keychain.Blind_sum(sum); var msg = Message.from_slice(TransactionHelper.kernel_sig_msg(tx.Fee, tx.LockHeight)); var sig = ctx.Keychain.Sign_with_blinding(msg, blindSum); tx.ExcessSig = sig.serialize_der(ctx.Keychain.Secp); return(tx, blindSum); }
public Context(Keychain keychain, Transaction.Transaction tx, BlindSum sum) { Keychain = keychain; Tx = tx; Sum = sum; }
public Append(Transaction.Transaction transaction, BlindSum blind) { Transaction = transaction; Blind = blind; }