Пример #1
0
        /// <summary>
        /// Builds the receiver.
        /// </summary>
        /// <returns>The receiver.</returns>
        public CoinService BuildReceiver()
        {
            using (var secp256k1 = new Secp256k1())
                using (var pedersen = new Pedersen())
                {
                    var naTOutput = NaT(Output());
                    var blind     = DeriveKey(naTOutput);

                    byte[] blindSum = new byte[32];

                    try
                    {
                        blindSum = pedersen.BlindSum(new List <byte[]> {
                            blind, blind
                        }, new List <byte[]> {
                        });
                    }
                    catch (Exception ex)
                    {
                        logger.LogError($"Message: {ex.Message}\n Stack: {ex.StackTrace}");
                        throw ex;
                    }

                    var commitPos = Commit(naTOutput, blind);
                    var commitNeg = Commit(0, blind);

                    Stamp(GetNewStamp());
                    Version(-1);

                    mintedCoin     = BuildCoin(blindSum, commitPos, commitNeg, true);
                    receiverOutput = new ReceiverOutput(Output(), commitPos, blindSum);
                }

            return(this);
        }
Пример #2
0
        /// <summary>
        /// Builds the receiver.
        /// </summary>
        /// <returns>The receiver.</returns>
        public (ReceiverOutput, CoinDto) BuildReceiver()
        {
            ReceiverOutput receiver = null;
            CoinDto        coin     = null;

            using (var secp256k1 = new Secp256k1())
                using (var pedersen = new Pedersen())
                {
                    var blind    = DeriveKey(Output());
                    var blindSum = pedersen.BlindSum(new List <byte[]> {
                        blind, blind
                    }, new List <byte[]> {
                    });
                    var commitPos = Commit((ulong)Output(), blind);
                    var commitNeg = Commit(0, blind);

                    Stamp(GetNewStamp());
                    Version(-1);

                    coin     = BuildCoin(blindSum, commitPos, commitNeg, true);
                    receiver = new ReceiverOutput(Output(), commitPos, blindSum);
                }

            return(receiver, coin);
        }
Пример #3
0
 /// <summary>
 /// Clears the change, imputs, minted coin, outputs, password, receiver output, stamp and version cache.
 /// </summary>
 public void ClearCache()
 {
     change = 0;
     Input(0);
     mintedCoin = null;
     Output(0);
     Password(null);
     receiverOutput = null;
     Stamp(string.Empty);
     Version(0);
 }