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 PartialTx from data sent by a sender (not yet completed by the receiver). public static PartialTx build_partial_tx( ulong receiveAmount, BlindingFactor blindSum, Transaction transaction ) { return(new PartialTx { Amount = receiveAmount, BlindSum = HexUtil.to_hex(blindSum.Key.Value), Tx = HexUtil.to_hex(Ser.Ser_vec(transaction)) }); }
/// Reads a partial transaction into the amount, sum of blinding /// factors and the transaction itself. public static (ulong amount, BlindingFactor blinding, Transaction tx) read_partial_tx( Keychain keychain, PartialTx partialTx ) { var blindBin = HexUtil.from_hex(partialTx.BlindSum); var blinding = BlindingFactor.from_slice(keychain.Secp, blindBin); var txBin = HexUtil.from_hex(partialTx.Tx); Transaction transaction; using (var ms = new MemoryStream(txBin)) { transaction = Ser.Deserialize(ms, Transaction.Empty()); ; } return(partialTx.Amount, blinding, transaction); }
public Signiture Sign_with_blinding(Message msg, BlindingFactor blinding) { var sig = Secp.Sign(msg, blinding.Key); return(sig); }
/// Sets a known excess value on the transaction being built. Usually used in /// combination with the initial_tx function when a new transaction is built /// by adding to a pre-existing one. public static Append with_excess(this Context build, BlindingFactor excess) { return(new Append(build.Tx, build.Sum.add_blinding_factor(excess.Clone()))); }