Notebooks input limit?

hello again. So I recorded 700 traces with my oscilloscope, downloaded the data and turned them into numpy arrays. With the exception, that each trace has 250k instead of 20k points. I recorded a project with my CWPRO, then I went to the directory and replaced the recorded traces with my own numpy array. Then I reopened the project in my notebook using open_project() function to reload the traces with the new exchanged ones. Sadly when I try to analyze them with CWAnalyzer or Lascar I get an error. Following one comes from CWAnalyzer:

<chipwhisperer.analyzer.attacks.cpa_new.CPA object at 0x000002AA3C14B788>
project     = <chipwhisperer.common.api.ProjectFormat.Project object at 0x000002AA3C0C48C8>
leak_model  = <chipwhisperer.analyzer.attacks.models.AES128_8bit.AES128_8bit object at 0x000002AA3C14B748>
algorithm   = <chipwhisperer.analyzer.attacks.cpa_algorithms.progressive.CPAProgressive object at 0x000002AA3C1566C8>
trace_range = [0, 700]
point_range = [0, 250002]
subkey_list = range(0, 16)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-6fbf55483bd2> in <module>
      5 attack = cwa.cpa(project, leak_model)
      6 print(attack)
----> 7 results = attack.run(cwa.get_jupyter_callback(attack))

c:\chipwh~1\cw\home\portable\chipwhisperer\software\chipwhisperer\analyzer\attacks\cpa_new.py in run(self, callback, update_interval)
    164         self.algorithm.setStatsReadyCallback(callback)
    165         self.algorithm.addTraces(self.get_trace_source(), self.trace_range,
--> 166                                  None, pointRange=self.point_range)
    167         return self.results
    168 

c:\chipwh~1\cw\home\portable\chipwhisperer\software\chipwhisperer\analyzer\attacks\cpa_algorithms\progressive.py in addTraces(self, traceSource, tracerange, progressBar, pointRange)
    237                     if (self.stats.simple_PGE(bnum) != 0) or (skipPGE == False):
    238                         bptrange = pointRange
--> 239                         (data, pbcnt) = cpa[bnum].oneSubkey(bnum, bptrange, traces, tend - tstart, textins, textouts, knownkeys, progressBar, cpa[bnum].modelstate, pbcnt)
    240                         self.stats.update_subkey(bnum, data, tnum=tend)
    241                     else:

c:\chipwh~1\cw\home\portable\chipwhisperer\software\chipwhisperer\analyzer\attacks\cpa_algorithms\progressive.py in oneSubkey(self, bnum, pointRange, traces_all, numtraces, plaintexts, ciphertexts, knownkeys, progressBar, state, pbcnt)
     58             # print "%d - %d (%d %d)" % (pointRange[0], pointRange[1], padbefore, padafter)
     59 
---> 60         self.sumtq += np.sum(np.square(traces), axis=0, dtype=np.float64)
     61         self.sumt += np.sum(traces, axis=0)
     62         sumden2 = (np.square(self.sumt) - self.totalTraces * self.sumtq)

TypeError: ufunc 'square' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Do you have an idea what should I change to make it work? I would like to stick to this method for now

Hi,

My guess is that your traces are in an incorrect data type. If you run project.waves[0].dtype, what type are your traces in?

Alex

dtype(‘<U8’)

What would be the right datatype?

uint8 should work fine, though you probably want to cast to uint16, since you might overflow on the square. Can you check project.waves to make sure there’s no non numbers in it?

I converted the numpy array into float64 just as the normal cw waves are, I checked the waves and some contain “8e-06”, will it still interprete this as a number?

It runs with float64, although I occured new problems (the attack doesnt work).