public Boolean ContainsAPUF(ArbiterPUF aPUFModel)
        {
            Boolean containsPUFInstance = false;

            if (NoisyAPUFList.Contains(aPUFModel) == true)
            {
                containsPUFInstance = true;
            }
            return(containsPUFInstance);
        }
Exemplo n.º 2
0
        public object Clone()
        {
            ArbiterPUF aPUFCopy = new ArbiterPUF(Weight); //Automatically clones the weights in the constructor

            //Other variables must be set manually
            aPUFCopy.BitNumber         = BitNumber;
            aPUFCopy.WeightMean        = WeightMean;
            aPUFCopy.WeightVariance    = WeightVariance;
            aPUFCopy.NoiseMean         = NoiseMean;
            aPUFCopy.NoiseVariance     = NoiseVariance;
            aPUFCopy.MajorityVoteCount = MajorityVoteCount;
            return(aPUFCopy);
        }
Exemplo n.º 3
0
 //Default constructor
 public XORArbiterPUF(int numPUFIN, int bitNum, double aPUFMean, double aPUFVar)
 {
     //set the input variables
     BitNumber       = bitNum;
     NumPUF          = numPUFIN;
     MeanForAPUF     = aPUFMean;
     VarianceForAPUF = aPUFVar;
     ArbiterPUFArray = new ArbiterPUF[NumPUF];
     //Initialize the arbiter PUF array
     for (int i = 0; i < NumPUF; i++)
     {
         ArbiterPUFArray[i] = new ArbiterPUF(bitNumber, MeanForAPUF, VarianceForAPUF);
     }
 }
Exemplo n.º 4
0
 //Copy constructor
 public XORArbiterPUF(int numPUFIN, int bitNum, double[][] weightsIN, double aPUFMean, double aPUFVar, double noiseMeanAPUFIN, double noiseVarianceAPUFIN)
 {
     //set the input variables
     BitNumber            = bitNum;
     NumPUF               = numPUFIN;
     MeanForAPUF          = aPUFMean;
     VarianceForAPUF      = aPUFVar;
     NoiseMeanForAPUF     = noiseMeanAPUFIN;
     NoiseVarianceForAPUF = noiseVarianceAPUFIN;
     ArbiterPUFArray      = new ArbiterPUF[NumPUF];
     //Initialize the arbiter PUF array
     for (int i = 0; i < NumPUF; i++)
     {
         ArbiterPUFArray[i] = new ArbiterPUF(weightsIN[i], NoiseMeanForAPUF, NoiseVarianceForAPUF);
     }
 }
Exemplo n.º 5
0
        //Takes in weights, phi challenges and target response bits, gives average error of APUF model
        public double ObjFunValueOfInverseModel(double[] weightVector, double[][] phiChallenges, double[][] targets)
        {
            int        sampleNumber = phiChallenges.Length; //Number of challenge-response pairs (number of training samples)
            ArbiterPUF aPUFModel    = new ArbiterPUF(weightVector);
            double     error        = 0;

            for (int currentSample = 0; currentSample < sampleNumber; currentSample++)
            {
                double currentTarget = targets[currentSample][0];
                double modelOutput   = aPUFModel.ComputeResponse(phiChallenges[currentSample]);
                if (modelOutput == currentTarget)
                {
                    error++;
                }
            }
            error = error / (double)sampleNumber; //Give the average error
            return(error);
        }
Exemplo n.º 6
0
 //Constructor that only takes a 1D double
 public XORArbiterPUF(int bitNum, double[] allAPUFWeights)
 {
     //set the input variables
     BitNumber       = bitNum;
     NumPUF          = (int)Math.Floor((double)allAPUFWeights.Length / ((double)bitNumber + 1)); //find the number of APUFs
     ArbiterPUFArray = new ArbiterPUF[NumPUF];
     //Fill in the APUF array
     for (int i = 0; i < NumPUF; i++)
     {
         //Extract the weights from the double array
         double[] currentAPUFWeights = new double[BitNumber + 1];
         int      indexer            = i * (bitNumber + 1);
         for (int j = 0; j < currentAPUFWeights.Length; j++)
         {
             currentAPUFWeights[j] = allAPUFWeights[indexer];
             indexer++;
         }
         ArbiterPUFArray[i] = new ArbiterPUF(currentAPUFWeights);
     }
 }
Exemplo n.º 7
0
 public IPUF(int xNumPUFIN, int yNumPUFIN, int bitNum, double aPUFMean, double aPUFVar)
 {
     //set the input variables
     BitNumber        = bitNum;
     NumPUFX          = xNumPUFIN;
     NumPUFY          = yNumPUFIN;
     MeanForAPUF      = aPUFMean;
     VarianceForAPUF  = aPUFVar;
     ArbiterPUFArrayX = new ArbiterPUF[xNumPUFIN];
     ArbiterPUFArrayY = new ArbiterPUF[yNumPUFIN];
     //Initialize the X arbiter PUF array
     for (int i = 0; i < NumPUFX; i++)
     {
         ArbiterPUFArrayX[i] = new ArbiterPUF(bitNumber, MeanForAPUF, VarianceForAPUF);
     }
     //Initialize the Y arbiter PUF array
     for (int i = 0; i < NumPUFY; i++)
     {
         ArbiterPUFArrayY[i] = new ArbiterPUF(bitNumber + 1, MeanForAPUF, VarianceForAPUF); //note this has one more bit than the X PUFs
     }
 }
 //Add a noisy APUF to the contributing list
 public void AddNoisyAPUF(ArbiterPUF aPUFIN)
 {
     NoisyAPUFList.Add(aPUFIN);
 }
Exemplo n.º 9
0
        //This is a version to match Ha's noise, not sure if right
        public static void GenerateReliabilityTrainingDataHaWay(XORArbiterPUF xPUF, int numberOfMeasurements, double[][] trainingData, double[][] trainingReliability, Random randomGenerator)
        {
            int trainingSize = trainingData.Length;
            int bitNum       = xPUF.BitNumber;

            //pregenerate training data inputs
            double[] noisyAPUFWeight1 = new double[bitNum + 1];
            double[] noisyAPUFWeight2 = new double[bitNum + 1];
            double[] sumOfResponses   = new double[trainingSize];
            for (int i = 0; i < trainingSize; i++)
            {
                trainingData[i] = GenerateRandomPhiVector(bitNum, randomGenerator);
            }

            for (int m = 0; m < numberOfMeasurements; m++) //Ha's way is flipped
            {
                double[] noiseAPUF1 = new double[bitNum + 1];
                double[] noiseAPUF2 = new double[bitNum + 1];
                for (int i = 0; i < noiseAPUF1.Length; i++)
                {
                    noiseAPUF1[i] = GenerateRandomNormalVariable(0, 0.1, randomGenerator);
                    noiseAPUF2[i] = GenerateRandomNormalVariable(0, 0.1, randomGenerator);
                }
                double[] originalAPUFWeight1 = xPUF.GetAllGroundTruthWeights()[0];
                double[] originalAPUFWeight2 = xPUF.GetAllGroundTruthWeights()[1];
                //Combine the noisy and original weights
                for (int i = 0; i < noisyAPUFWeight1.Length; i++)
                {
                    noisyAPUFWeight1[i] = originalAPUFWeight1[i] + noiseAPUF1[i];
                    noisyAPUFWeight2[i] = originalAPUFWeight2[i] + noiseAPUF2[i];
                }
                ArbiterPUF aNoisy1 = new ArbiterPUF(noisyAPUFWeight1);
                ArbiterPUF aNoisy2 = new ArbiterPUF(noisyAPUFWeight2);

                //Compute for each sample
                for (int i = 0; i < trainingSize; i++)
                {
                    int cc     = aNoisy1.ComputeResponse(trainingData[i]);
                    int ccc    = aNoisy2.ComputeResponse(trainingData[i]);
                    int result = aNoisy1.ComputeResponse(trainingData[i]) ^ aNoisy2.ComputeResponse(trainingData[i]);
                    sumOfResponses[i] = sumOfResponses[i] + result;
                }
            }

            //Last compute the reliability
            for (int i = 0; i < trainingSize; i++)
            {
                trainingReliability[i] = new double[1];
                //trainingReliability[i][0]= Math.Abs(numberOfMeasurements / 2.0 - (sumOfResponses[i] / (double)numberOfMeasurements));
                trainingReliability[i][0] = Math.Abs(numberOfMeasurements / 2.0 - (sumOfResponses[i]));
            }

            //for (int i = 0; i < trainingSize; i++)
            //{
            //    double sumOfResponses = 0;
            //    //trainingData[i] = GenerateRandomPhiVector(bitNum);
            //    trainingData[i] = GenerateRandomPhiVector(bitNum, randomGenerator);
            //    for (int m = 0; m < numberOfMeasurements; m++)
            //    {
            //        double randomNoise
            //        sumOfResponses = sumOfResponses + aPUF.ComputeNoisyResponse(trainingData[i]); //sum the measurements
            //    }
            //    trainingReliability[i] = new double[1];
            //    //trainingReliability[i][0] = sumOfResponses / (double)numberOfMeasurements;
            //    trainingReliability[i][0] = Math.Abs(numberOfMeasurements / 2.0 - (sumOfResponses / (double)numberOfMeasurements));

            //}
        }
Exemplo n.º 10
0
        //Use Ha's method to attack XOR APUF with the absolute objective function
        public static void AttackXORAPUFwithAbsoluteMethod()
        {
            //Generate a noisy PUF
            int    bitNum = 64;
            int    pufNum = 2;
            int    numberOfMeasurements = 5; //I am guessing this, no clue
            double aPUFMean             = 0.0;
            double aPUFVar       = 1.0;
            double aPUFMeanNoise = 0.0;
            double aPUFNoiseVar  = aPUFVar / 10.0;

            //Create the XOR APUF
            XORArbiterPUF xPUF = new XORArbiterPUF(pufNum, bitNum, aPUFMean, aPUFVar, aPUFMeanNoise, aPUFNoiseVar);
            //Generate training data (reliability information)
            int             trainingSize    = 30000; //fix back
            int             testingSize     = 10000;
            int             attackRepeatNum = 15;
            ParallelOptions options         = new ParallelOptions {
                MaxDegreeOfParallelism = 10
            };

            //make independent copies in memory
            XORArbiterPUF[] xArray = new XORArbiterPUF[attackRepeatNum];
            for (int i = 0; i < xArray.Length; i++)
            {
                xArray[i] = (XORArbiterPUF)xPUF.Clone();
            }
            double[][] solutionList = new double[attackRepeatNum][];

            //Two different objective functions, one for CMA-ES, the other to test the final model accuracy
            ObjectiveFunctionResponse rObj = new ObjectiveFunctionResponse();

            //ObjectiveFunctionReliabilityStandard[] sObjArray = new ObjectiveFunctionReliabilityStandard[attackRepeatNum];
            ObjectiveFunctionReliabilityAbsolute[] sObjArray = new ObjectiveFunctionReliabilityAbsolute[attackRepeatNum];

            for (int i = 0; i < sObjArray.Length; i++)
            {
                sObjArray[i] = new ObjectiveFunctionReliabilityAbsolute();
            }

            Parallel.For(0, attackRepeatNum, a =>
            {
                //for (int a = 0; a < attackRepeatNum; a++)
                //{
                Random randomGenerator         = new Random((int)DateTime.Now.Ticks); //remove the dependences for parallelization
                int dimensionNumber            = bitNum + 1;
                double[][] trainingData        = new double[trainingSize][];          //these will be phi vectors
                double[][] trainingReliability = new double[trainingSize][];
                //DataGeneration.GenerateReliabilityTrainingDataHaWay(xArray[a], numberOfMeasurements, trainingData, trainingReliability, randomGenerator);
                DataGeneration.GenerateReliabilityTrainingData(xArray[a], numberOfMeasurements, trainingData, trainingReliability, randomGenerator);

                //Generate the first solution randomly for CMA-ES
                double[] firstSolution = new double[bitNum + 1];
                for (int i = 0; i < firstSolution.Length; i++)
                {
                    //firstSolution[i] = AppConstants.rx.NextDouble();
                    firstSolution[i] = randomGenerator.NextDouble();
                }
                Console.Out.WriteLine("Data generation for core " + a.ToString() + " complete. Beginning CMA-ES");
                CMAESCandidate solutionCMAES = CMAESMethods.ComputeCMAES(dimensionNumber, sObjArray[a], trainingData, trainingReliability, firstSolution, randomGenerator);
                double[] solution            = solutionCMAES.GetWeightVector();
                solutionList[a] = solution; //store the solution in independent memory
                                            // }
            });

            //Just see if we can recover the 0th APUF
            //ArbiterPUF aPUF = xPUF.GetAPUFAtIndex(0);
            //Testing data can be in form of response because we don't care about the reliability
            double[][] accMeasures = new double[solutionList.Length][];
            for (int i = 0; i < solutionList.Length; i++)
            {
                accMeasures[i] = new double[pufNum];
            }

            Random randomGenerator2 = new Random((int)DateTime.Now.Ticks);

            for (int j = 0; j < pufNum; j++)
            {
                ArbiterPUF aPUF            = xPUF.GetAPUFAtIndex(j);
                double[][] testingData     = new double[testingSize][]; //these will be phi vectors
                double[][] testingResponse = new double[testingSize][];
                DataGeneration.GenerateTrainingData(aPUF, testingData, testingResponse, randomGenerator2);
                for (int i = 0; i < solutionList.Length; i++)
                {
                    accMeasures[i][j] = 1.0 - rObj.ObjFunValue(solutionList[i], testingData, testingResponse);
                    Console.Out.WriteLine("The accuracy for PUF " + j.ToString() + " " + accMeasures[i][j].ToString());
                }
                //Ground truth sanity check
                double gca = 1.0 - rObj.ObjFunValue(aPUF.GetGroundTruthWeight(), testingData, testingResponse);
                Console.Out.WriteLine("The ground truth accuracy for PUF " + j.ToString() + " " + gca.ToString());
            }
            int k = 0;
        }