public PromiseClientSession(PromiseParameters parameters, State state) : this(parameters)
        {
            if (state == null)
            {
                return;
            }
            InternalState = Serializer.Clone(state);
            if (InternalState.Commitments != null)
            {
                _Hashes = new HashBase[InternalState.Commitments.Length];
                int fakeI = 0, realI = 0;
                for (int i = 0; i < _Hashes.Length; i++)
                {
                    HashBase hash = null;
                    if (InternalState.FakeIndexes != null && InternalState.FakeIndexes.Contains(i))
                    {
                        hash = new FakeHash(_Parameters)
                        {
                            Salt = InternalState.FakeSalts[fakeI++]
                        };
                    }
                    else
                    {
                        hash = new RealHash(InternalState.Cashout, InternalState.EscrowedCoin)
                        {
                            FeeVariation = InternalState.FeeVariations[realI++]
                        };
                    }

                    hash.Index      = i;
                    hash.Commitment = InternalState.Commitments[i];
                    _Hashes[i]      = hash;
                }
            }
        }
Exemplo n.º 2
0
 public FakeHash(PromiseParameters parameters)
 {
     if (parameters == null)
     {
         throw new ArgumentNullException(nameof(parameters));
     }
     Parameters = parameters;
 }
Exemplo n.º 3
0
 public PromiseServerSession(State state, PromiseParameters parameters) : this(parameters)
 {
     if (state == null)
     {
         throw new ArgumentNullException(nameof(state));
     }
     InternalState = state;
 }
Exemplo n.º 4
0
 public PromiseServerSession(PromiseParameters parameters)
 {
     if (parameters == null)
     {
         throw new ArgumentNullException(nameof(parameters));
     }
     _Parameters   = parameters;
     InternalState = new State();
 }
Exemplo n.º 5
0
        private HashBase[][] _Hashes; // The list of Hashes (Beta_i in the paper)

        public PromiseClientSession(PromiseParameters parameters, State state) : this(parameters)
        {
            if (state == null)
            {
                return;
            }
            InternalState = Serializer.Clone(state);
            if (InternalState.Commitments != null)
            {
                _Hashes = new HashBase[parameters.PaymentsCount][];
                for (int i = 0; i < _Hashes.Length; i++)
                {
                    _Hashes[i] = new HashBase[InternalState.Commitments[i].Length];
                    int fakeJ = 0, realJ = 0;
                    for (int j = 0; j < _Hashes[i].Length; j++)
                    {
                        HashBase hash = null;
                        if (InternalState.FakeColumns != null && InternalState.FakeColumns.Contains(j))
                        {
                            hash = new FakeHash(parameters)
                            {
                                Salt = InternalState.Salts[i][fakeJ++]
                            };
                        }
                        else
                        {
                            hash = new RealHash(InternalState.Cashout, InternalState.EscrowedCoin)
                            {
                                FeeVariation = InternalState.FeeVariations[i][realJ++]
                            };
                        }
                        hash.Index      = j;
                        hash.Commitment = InternalState.Commitments[i][j];
                        _Hashes[i][j]   = hash;
                    }
                }
            }
        }
 public PromiseClientSession(PromiseParameters parameters = null)
 {
     _Parameters   = parameters ?? new PromiseParameters();
     InternalState = new State();
 }
 public FakeHash(PromiseParameters parameters)
 {
     Parameters = parameters ?? throw new ArgumentNullException(nameof(parameters));
 }
Exemplo n.º 8
0
 public PromiseClientSession(Network network, PromiseParameters parameters = null)
 {
     _Network      = network;
     _Parameters   = parameters ?? new PromiseParameters();
     InternalState = new State();
 }