Example #1
0
        public SolverClientSession(SolverParameters parameters, State state) : this(parameters)
        {
            if (state == null)
            {
                return;
            }
            InternalState = state;
            if (InternalState.FakeIndexes != null)
            {
                _PuzzleElements = new PuzzleSetElement[_Parameters.GetTotalCount()];
                int fakeI = 0, realI = 0;
                for (int i = 0; i < _PuzzleElements.Length; i++)
                {
                    PuzzleSetElement element = null;
                    var puzzle = new Puzzle(_Parameters.ServerKey, state.Puzzles[i]);

                    if (InternalState.FakeIndexes.Contains(i))
                    {
                        element = new FakePuzzle(puzzle, state.FakeSolutions[fakeI++]);
                    }
                    else
                    {
                        element = new RealPuzzle(puzzle, state.BlindFactors[realI++]);
                    }
                    element.Index      = i;
                    element.Commitment = state.Commitments[i];
                    _PuzzleElements[i] = element;
                }
            }
        }
Example #2
0
 public SolverClientSession(SolverParameters parameters)
 {
     if (parameters == null)
     {
         throw new ArgumentNullException(nameof(parameters));
     }
     _Parameters   = parameters;
     InternalState = new State();
 }
Example #3
0
 public SolverClientSession(RsaPubKey serverKey)
 {
     if (serverKey == null)
     {
         throw new ArgumentNullException(nameof(serverKey));
     }
     _Parameters   = new SolverParameters(serverKey);
     InternalState = new State();
 }
Example #4
0
 public SolverServerSession(RsaKey serverKey, SolverParameters parameters, State state)
     : this(serverKey, parameters)
 {
     if (state == null)
     {
         return;
     }
     InternalState = state;
 }
Example #5
0
 public SolverServerSession(RsaKey serverKey, SolverParameters parameters)
 {
     parameters = parameters ?? new SolverParameters(serverKey.PubKey);
     if (serverKey == null)
     {
         throw new ArgumentNullException(nameof(serverKey));
     }
     if (serverKey.PubKey != parameters.ServerKey)
     {
         throw new ArgumentNullException($"Private key not matching expected public key: {nameof(serverKey.PubKey)} != {nameof(parameters.ServerKey)}");
     }
     InternalState = new State();
     _ServerKey    = serverKey;
     _Parameters   = parameters;
 }
Example #6
0
 public SolverClientSession(Network network, SolverParameters parameters)
 {
     _Network      = network;
     _Parameters   = parameters ?? throw new ArgumentNullException(nameof(parameters));
     InternalState = new State();
 }