public override void Evaluate(IClassicState state)
        {
            IClassicStateDebugger debuggerData = state.generateClassicDebugger();
            IClassicStateDebugger debuggerElement = ReferenceBasis.getState(ReferenceElement).generateClassicDebugger();

            debuggerData.setValue(debuggerElement.getValue());
        }
        public override void Evaluate(IClassicState state)
        {
            IClassicStateDebugger debugger = state.generateClassicDebugger();
            double random = RandomnessAlgorithmFactory.GetSingleIntenger();

            debugger.setValue(random);
        }
        public override void Evaluate(IClassicState state)
        {
            if (Configuration.NoiseEnabled == false) { return; }

            if (Configuration.NoiseFactor != 0)
            {
                IClassicStateDebugger debugger = state.generateClassicDebugger();
                double value = debugger.getValue();
                double size = RandomnessAlgorithmFactory.GetSingleNormalized() / Configuration.NoiseFactor;
                double random = RandomnessAlgorithmFactory.GetSingleDoubleIntervalByCenter(value, size / 2);
                debugger.setValue(random);
            }
        }
Beispiel #4
0
 // EVENTS
 public void transmitClassic(IProtocolAgent agent, IClassicState state)
 {
     TesterLog("Classic TRANSMISSION " + agent.AgentName);
     TesterLog(state.generateClassicDebugger().FullDebug);
 }
Beispiel #5
0
 public void receiveClassic(IProtocolAgent agent, IClassicState state)
 {
     TesterLog("Classic RECEPTION " + agent.AgentName);
     TesterLog(state.generateClassicDebugger().FullDebug);
 }
 public ClassicStateBasic(IClassicState state)
     : this(state.generateClassicDebugger().getNumLevels(), state.Value)
 {
 }
        private void GENE_SlaveProcessBasisData(IProtocolAgent agent, IClassicState state)
        {
            int receivedPos = Slave.counterReceivedClassic - 1;
                BB84Log("GENE: STEP 2: ", receivedPos, " | Slave State Receive: ", state.generateClassicDebugger().ShortDebug);

                IClassicBit ClassicBit = ClassicDatatypeFactory.generateBit(false);
                ClassicBit.AssociateState(state);
                bool decode = ClassicDatatypeFactory.decodeBitByUsualBasis(ClassicBit);
                BB84Log("GENE: STEP 2: ", receivedPos, " | Slave conversion into Bit: ", decode.ToString());

                // get element
                bool usedBasis = (bool)GENE_slaveUsedBasisCollection[receivedPos];
                //bool decodedBit = (bool)GENE_slaveDecodedBitCollection[receivedPos];

                bool coincidence = (usedBasis == decode);
                if (coincidence)
                { BB84Log("GENE: STEP 2:              =========> Slave found coincidence in Basis at POS: ", receivedPos); }

                // store 'coincidence' pos
                GENE_slaveCoincidences.Add(coincidence);
        }
        private void GENE_MasterProcessCoincidencesData(IProtocolAgent agent, IClassicState state)
        {
            // no hace falta comparar con las bases usadas o datos usadas
                // en este caso solo se transmite si el la estación cliente detecto coincidencia

                int receivedPos = Master.counterReceivedClassic - 1;
                BB84Log("GENE: STEP 3: ", receivedPos, " | Master State Receive: ", state.generateClassicDebugger().ShortDebug);

                IClassicBit ClassicBit = ClassicDatatypeFactory.generateBit(false);
                ClassicBit.AssociateState(state);
                bool decode = ClassicDatatypeFactory.decodeBitByUsualBasis(ClassicBit);
                BB84Log("GENE: STEP 3: ", receivedPos, " | Master conversion into Bit: ", decode.ToString());

                if (decode)
                { BB84Log("GENE: STEP 3:              =========> Master found coincidence in Basis at POS: ", receivedPos); }

                GENE_masterCoincidences.Add(decode);
        }
        private void GENE_EavesdropperProcessCoincidencesData(IProtocolAgent agent, IClassicState state)
        {
            int receivedPos = Eavesdropper.counterReceivedClassic - 1;
                BB84Log("GENE: STEP 3: ", receivedPos, " | Eavesdropper State Receive: ", state.generateClassicDebugger().ShortDebug);

                IClassicBit ClassicBit = ClassicDatatypeFactory.generateBit(false);
                ClassicBit.AssociateState(state);
                bool decode = ClassicDatatypeFactory.decodeBitByUsualBasis(ClassicBit);
                BB84Log("GENE: STEP 3: ", receivedPos, " | Eavesdropper conversion into Bit: ", decode.ToString());

                if (decode)
                { BB84Log("GENE: STEP 3:              =========> Eavesdropper found in Basis coincidence at POS: ", receivedPos); }

                GENE_eavesdropperCoincidences.Add(decode);
        }
        private void CHEC_SlaveProcessCheckValues(IProtocolAgent agent, IClassicState state)
        {
            int receivedPos = Slave.counterReceivedClassic - 1;
                BB84Log("CHEC: STEP 2: ", receivedPos, " | Slave State Receive: ", state.generateClassicDebugger().ShortDebug);

                IClassicBit ClassicBit = ClassicDatatypeFactory.generateBit(false);
                ClassicBit.AssociateState(state);
                bool decode = ClassicDatatypeFactory.decodeBitByUsualBasis(ClassicBit);
                BB84Log("CHEC: STEP 2: ", receivedPos, " | Slave conversion into Bit: ", decode.ToString());

                //// get index
                int index = (int)CHEC_slaveComparisonIndexes[receivedPos];
                BB84Log("CHEC: STEP 2: ", receivedPos, " | Slave stores for checking check POS ", index, " with VALUE ", decode);

                CHEC_slaveComparisonValuesReceived.Add(decode);
        }
        private void CHEC_SlaveProcessCheckPositions(IProtocolAgent agent, IClassicState state)
        {
            int receivedPos = Slave.counterReceivedClassic - 1;
                BB84Log("CHEC: STEP 1: ", receivedPos, " | Slave State Received: ", state.generateClassicDebugger().ShortDebug);

                IClassicBit ClassicBit = ClassicDatatypeFactory.generateBit(false);
                ClassicBit.AssociateState(state);
                bool decode = ClassicDatatypeFactory.decodeBitByUsualBasis(ClassicBit);
                BB84Log("CHEC: STEP 1: ", receivedPos, " | Slave conversion into Bit: ", decode.ToString());

                // store and 'decodedBit'
                CHEC_slaveComparisonSelected.Add(decode);
                if (decode) //seletected
                {
                    CHEC_slaveComparisonIndexes.Add(receivedPos);
                }
        }
 public static IClassicState generateState(IClassicState state)
 {
     IClassicState result = generateState(state.generateClassicDebugger().getNumLevels());
     result.Value = state.Value;
     return result;
 }