コード例 #1
0
        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));
        }
コード例 #2
0
 /// 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))
     });
 }
コード例 #3
0
        /// 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);
        }
コード例 #4
0
        public Signiture Sign_with_blinding(Message msg, BlindingFactor blinding)
        {
            var sig = Secp.Sign(msg, blinding.Key);

            return(sig);
        }
コード例 #5
0
 /// 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())));
 }