Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ChipWhisper TVLA在站点包中有错误_Python_Bokeh_Holoviews_Side Channel Attacks - Fatal编程技术网

Python ChipWhisper TVLA在站点包中有错误

Python ChipWhisper TVLA在站点包中有错误,python,bokeh,holoviews,side-channel-attacks,Python,Bokeh,Holoviews,Side Channel Attacks,我试图在我的FPGA板上使用ChipWhisper提供的TVLA评估。(克隆)他们为加密验证提供了PA_TVLA_1-执行的_TVLA_测试。ipynbJupyterplaybook。我对其进行了修改,以初始化FPGA,但流程的其余部分是相同的,即捕获跟踪并分析它们 进行分析和排除错误的代码 import holoviews as hv hv.extension('bokeh') import numpy as np import scipy import scipy.stats projec

我试图在我的FPGA板上使用ChipWhisper提供的TVLA评估。(克隆)他们为加密验证提供了
PA_TVLA_1-执行的_TVLA_测试。ipynb
Jupyterplaybook。我对其进行了修改,以初始化FPGA,但流程的其余部分是相同的,即捕获跟踪并分析它们

进行分析和排除错误的代码

import holoviews as hv
hv.extension('bokeh')
import numpy as np
import scipy
import scipy.stats

project = cw.open_project('projects/MyProject.cwp')
fixedpy = [0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90]

testouts = []
num_traces = len(project.traces)
num_points = len(project.waves[0])
print(num_traces, num_points)
curve = hv.Curve([])

def do_the_ttvla(project, ntraces=-1):
    global curve, line
    if ntraces == -1:
        ntraces = int(num_traces / 2)
        
    if ntraces * 2 > num_traces:
        raise ValueError("Invalid ntraces")
    for g in range(0, 2):
        group = [(list(project.textins[i]) == fixedpy) for i in range(g*ntraces, g*ntraces+ntraces)]
        trace = np.zeros((ntraces, num_points))

        for n in range(g*ntraces, g*ntraces+ntraces):
            trace[n - g*ntraces][:] = project.waves[n]
                
        testout = welch_ttest(group, trace)
        curve *= hv.Curve(testout)
        testouts.extend(testout)
        
    curve *= hv.Path([(0, -4.5), (num_points, -4.5)]).opts(color="black") * \
    hv.Path([(0, 4.5), (num_points, 4.5)]).opts(color="black")

def welch_ttest(group, traces):
    import warnings
    # Compute Welch's t-statistic at each point in time
    # Here, group[] must only contain booleans (True/False)
    traces_true = traces[np.where(np.array(group))]
    traces_false = traces[np.where(~np.array(group))]
    
    if len(traces_true) == 0:
        traces_true  = np.array([[np.nan for _ in range(len(traces[0]))]])
    if len(traces_false) == 0:
        traces_false = np.array([[np.nan for _ in range(len(traces[0]))]])
    
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        ttrace = scipy.stats.ttest_ind(traces_true, traces_false, axis=0, equal_var=False)[0]
        
    return np.nan_to_num(ttrace) 
    
do_the_ttvla(project)
(curve).opts(height=600, width=600)
运行此代码时,会出现以下错误:

WARNING:param.BokehRenderer: Use method 'params' via param namespace 
WARNING:param.BokehRenderer:Use method 'params' via param namespace 

---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
<ipython-input-14-8f71252adeef> in <module>
     53     return np.nan_to_num(ttrace)
     54 
---> 55 do_the_ttvla(project)
     56 (curve).opts(height=600, width=600)

<ipython-input-14-8f71252adeef> in do_the_ttvla(project, ntraces)
     29 
     30         testout = welch_ttest(group, trace)
---> 31         curve *= hv.Curve(testout)
     32         testouts.extend(testout)
     33 

~/.local/lib/python3.7/site-packages/holoviews/core/overlay.py in __mul__(self, other)
     41             return NotImplemented
     42 
---> 43         return Overlay([self, other])
     44 
     45 

~/.local/lib/python3.7/site-packages/holoviews/core/overlay.py in __init__(self, items, group, label, **params)
    141         self.__dict__['_group'] = group
    142         self.__dict__['_label'] = label
--> 143         super(Overlay, self).__init__(items, **params)
    144 
    145     def __getitem__(self, key):

~/.local/lib/python3.7/site-packages/holoviews/core/dimension.py in __init__(self, items, identifier, parent, **kwargs)
   1327         if items and all(isinstance(item, Dimensioned) for item in items):
   1328             items = self._process_items(items)
-> 1329         params = {p: kwargs.pop(p) for p in list(self.params().keys())+['id', 'plot_id'] if p in kwargs}
   1330 
   1331         AttrTree.__init__(self, items, identifier, parent, **kwargs)

~/.local/lib/python3.7/site-packages/param/parameterized.py in inner(*args, **kwargs)
   1328                 get_logger(name=args[0].__class__.__name__).log(
   1329                     WARNING, 'Use method %r via param namespace ' % fn.__name__)
-> 1330             return fn(*args, **kwargs)
   1331 
   1332         inner.__doc__= "Inspect .param.%s method for the full docstring"  % fn.__name__

~/.local/lib/python3.7/site-packages/param/parameterized.py in params(cls, parameter_name)
   2765     @Parameters.deprecate
   2766     def params(cls,parameter_name=None):
-> 2767         return cls.param.params(parameter_name=parameter_name)
   2768 
   2769     @classmethod

~/.local/lib/python3.7/site-packages/param/parameterized.py in params(self_, parameter_name)
   1422         superclasses.
   1423         """
-> 1424         pdict = self_.objects(instance='existing')
   1425         if parameter_name is None:
   1426             return pdict

~/.local/lib/python3.7/site-packages/param/parameterized.py in objects(self_, instance)
   1511         if instance and self_.self is not None:
   1512             if instance == 'existing':
-> 1513                 if getattr(self_.self, 'initialized', False) and self_.self._instance__params:
   1514                     return dict(pdict, **self_.self._instance__params)
   1515                 return pdict

~/.local/lib/python3.7/site-packages/holoviews/core/tree.py in __getattr__(self, identifier)
    254             sanitized = identifier
    255 
--> 256         if sanitized in self.children:
    257             return self.__dict__[sanitized]
    258 

... last 1 frames repeated, from the frame below ...

~/.local/lib/python3.7/site-packages/holoviews/core/tree.py in __getattr__(self, identifier)
    254             sanitized = identifier
    255 
--> 256         if sanitized in self.children:
    257             return self.__dict__[sanitized]
    258 

RecursionError: maximum recursion depth exceeded in comparison
project.waves[0]
的内容,其中waves是

project.textins[0]

[218  57 163 238  94 107  75  13  50  85 191 239 149  96  24 144]
cw
对象作为
import ChipWhisper as cw
导入,并且是ChipWhisper库的一部分。它在这里的功能是允许将已捕获的跟踪加载到一组阵列中。

pip安装--升级HoloView
修复了该问题

对于面临错误的VM用户来说,这个将不起作用:Jupyter将在引导时崩溃。
我建议下载页面上的“chipWhisper.Jupyter.holoviews.7z”虚拟机(版本标记为5.5)。

警告表明
param
holoviews
库不匹配;我建议从pyviz频道将两者更新为最新版本(
conda update-c pyviz holoviews param
)。该错误似乎是库本身的问题,但如果没有可复制的示例,则很难确定。如果更新库后错误仍然存在,您能否从
cw
对象中提取数据,缩短并简化它,并使用提供的数据更新示例,使其能够自行运行?否则,任何人都很难帮助您调试。@JamesA.Bednar我已经添加了变量内容,并通过conda an pip进行了安装,但Jupyter在运行时仍会出错。除非您上面包含的脚本实际上可由其他人运行,否则任何人都无能为力!但这只是一个虚拟机,对吗?这对本地安装有什么帮助?oops没有注意到您没有使用本地安装。。。您安装了哪个版本的HoloView?如果它不是1.14.3,你能安装这个版本并让我知道吗?它是
1.12.3
,所以我明天会更新它并报告它是否有效。(我之前已经尝试过
pip升级
pip安装——升级holoviews
有效。由于您提供了答案,请编辑您的答案以包含此内容,以便我可以接受并投票
[ 0.015625   -0.00585938 -0.00097656  0.00878906  0.015625   -0.12402344
-0.11132812 -0.05664062 -0.00097656 -0.09863281 -0.06640625 -0.00976562
 0.03613281 -0.08007812 -0.06542969 -0.01660156  0.02050781 -0.10351562
-0.08105469 -0.02734375  0.02246094 -0.09765625 -0.07324219 -0.01855469
 0.02832031 -0.09082031 -0.06933594 -0.01757812  0.02832031 -0.08789062
-0.06542969 -0.015625    0.02832031 -0.09179688 -0.06933594 -0.01855469
 0.02734375 -0.09765625 -0.06933594 -0.01855469  0.02929688 -0.09667969
-0.06933594 -0.01660156  0.03222656 -0.0859375  -0.05566406 -0.01171875
 0.03417969 -0.10058594 -0.07421875 -0.02246094  0.02636719  0.03125
 0.04882812  0.05078125  0.04980469  0.         -0.00488281 -0.00195312
 0.01269531 -0.00878906  0.00097656  0.01464844  0.03027344  0.00390625
 0.00683594  0.015625    0.02539062 -0.01074219 -0.00683594  0.0078125
 0.02246094 -0.00585938  0.          0.01269531  0.02441406 -0.00390625
-0.00195312  0.01269531  0.02148438 -0.00195312  0.00292969  0.01464844
 0.02441406 -0.0078125  -0.00292969  0.00976562  0.02050781 -0.00488281
-0.00195312  0.01171875  0.02148438 -0.00878906 -0.00488281  0.00683594
 0.02246094 -0.00097656  0.00683594  0.01660156  0.02441406 -0.01171875
-0.00585938  0.00488281  0.02050781 -0.00878906  0.          0.01074219
 0.02539062 -0.00390625  0.00195312  0.00976562  0.02246094 -0.0078125
-0.00097656  0.00878906  0.02050781 -0.00878906 -0.00390625  0.00683594
 0.02148438 -0.00683594  0.          0.00976562  0.02246094 -0.01269531
-0.00488281  0.00683594  0.02148438]
[218  57 163 238  94 107  75  13  50  85 191 239 149  96  24 144]