ZeroDivisionError: float division by zero

Hi,
I am using the ChipWhisperer-Lite and the CW305 target board for my experiment and I installed ChipWhisperer 5.5 directly (no VM). The setup of AES on the CW305 with ChipWhisperer-Lite is working fine for me. However, using the same scope settings, I got the ZeroDivisionError If I am running the following script for my own crypto algorithm: SHAKE. How to capture the power traces without this error?
j = 0
while j < (N_traces):

            # Generate 256-bit random number
            if i == 0 or i == 1:
                    random(0)
            else: 
                    random(12)

            scope.arm()
                            
            # SHA3-256 using Random_seed
            SHAKE(32, 896, 0)
            # Call SHAKE to write 3744 bytes
            SHAKE(3744, 100, 896)
            # Matrix A generated
            vecmult(100, 100, 900)  

            # Trigger 
            target.fpga_write(target.REG_USER_LED, [0x01]) 
         
            vecmult(164, 256, 900)                
            vecmult(228, 412, 900)
                            
            ret = scope.capture()
            if ret:
                print("Capure timeout")
                continue
            wave = scope.get_last_trace()               
            traces.append(wave)    
            print("Trace %d" % j)
            j += 1  

Error message:
---- Collecting Power Traces for Set 0 ----
Traceback (most recent call last):
File “D:\NIST_PQC_Project\PQC_ChipWhispererBoard\Park_SABER\Python_Saber\Test2.py”, line 274, in
ret = scope.capture()
File “d:\chipwhisperer5_64\git\home\portable\chipwhisperer\software\chipwhisperer\capture\scopes\OpenADC.py”, line 346, in capture
return self.qtadc.capture(self.adc.offset, self.clock.adc_freq, self.adc.samples)
File “d:\chipwhisperer5_64\git\home\portable\chipwhisperer\software\chipwhisperer\capture\scopes_qt.py”, line 110, in capture
timeout = self.sc.capture(offset, adc_freq, samples)
File “d:\chipwhisperer5_64\git\home\portable\chipwhisperer\software\chipwhisperer\capture\scopes_OpenADCInterface.py”, line 2024, in capture
cap_delay = (7.37E6 * 4 * samples) / (adc_freq * 24400)
ZeroDivisionError: float division by zero


def SHAKE(num_bytes, OP2, OP1):
“”"
num_bytes: Number of bytes
OP2: Address of Destination
OP1: Address of Random seed

    """

I’m pretty sure this is a bug that was fixed in subsequent releases; can you see if
upgrading to 5.5.2 fixes the issue?

Jean-Pierre

Thanks, Jean. the problem is resolved.

How to save the power traces as a .csv file?
ret = scope.capture()
if ret:
print(“Capure timeout”)
continue
wave = scope.get_last_trace()
traces.append(wave)
num_points = len(wave)
newarr = wave.reshape(wave, num_points)
np.savetxt(’./Power_Traces_TVLA/set0.csv’, newarr, delimiter = ‘,’)

I got the following error when I am running the above commands:

newarr = wave.reshape(wave, num_points)
TypeError: only integer scalar arrays can be converted to a scalar index

I’m not sure what you’re trying to do here? The problem is with your Python syntax on wave.reshape(wave...).

Maybe what you want is this?

newarr = wave.reshape((num_points, 1))