pypuf
pypuf copied to clipboard
Attack functions throwing float error
I have tried multiple attacks and values for the parameters and can't seem to get them to work using my own recorded data. the data has been changed to be {-1,1} for the CRPs but the only attack that doesn't throw this error is LMN
Check if your CRPTrain
object actually only contains -1 and 1. The error message hints that there is a 0.5, which could mean that something got wrong when converting the data from 0/1 to +-1.
Thank you so much for your reply. I took a look and the two arrays that make up the CRP object have only 1 and -1, unless numpy.unique is not an adequate way to check this. However with checking the actual CRP object, is there a convenient way to iterate through and verify the data? Apologies in advanced, it's late here and I am relatively new to python.
To check this on CRPTrain
, use np.unique(CRPTrain.challenges)
and np.unique(CRPTrain.responses)
.
Can you create a minimal example that I can run? Also, please provide your pypuf and tensorflow versions.
I have poked around this attack a little bit and found it did work on simulated CRPs, but not on real CRPs that are shipped with pypuf. I traced the error back to the datatype in which the responses are supplied and was able to circumvent the problem:
import numpy as np
import pypuf.simulation, pypuf.io
import pypuf.attack
crps = pypuf.io.MTZAA20.xor_arbiter_puf_4_xor
#crps.responses = crps.responses.astype(np.float64) # this line fixes an error similar to yours
attack = pypuf.attack.LRAttack2021(crps, seed=3, k=4, bs=1000, lr=.001, epochs=100)
attack.fit()
Please let me know if changing the response data type also fixes your problem.
changing the type to float64 worked! Thank you