Error in lab 5_1 under section 1.4.1 LASCAR Quick Setup

Hello, I’m attempting to perform Lab 5_1 - ChipWhisperer CPA Attacks in Practice. However, I seem to be running into an error I can’t quite get past. Section 1.4.1 LASCAR Quick Setup

File “”, line 4
cpa_engines = [CpaEngine(“cpa_%02d” % i, cw_lascar.sbox_HW_gen(i, range(256)) for i in range(16))]
^
SyntaxError: Generator expression must be parenthesized if not sole argument

I think there’s an extra ) at the end of that expression.

Thanks for the report, I’ll get it fixed up.

Alex

That extra ) at the end was added by me because it closes the function CpaEngine()

CpaEngine should be closed before the for i in range(16) basically:

[CpaEngine("cpa" + i, cw_lascar.sbox_HW_gen(i, range(256)))
for i in range(16)]

So that parenthesis should be moved to after range(256)

Alex

Ah, makes sense. Next error I’m getting is from this portion:
cw_lascar.sbox_HW_gen(i, range(256))

It gives me an error:
TypeError: sbox_HW_gen() takes 1 positional argument but 2 were given

Looks like that code got pretty messed up when we moved it from the HWAES tutorial.

Try:

cpa_engines = [CpaEngine("cpa_%02d" % i, cw_lascar.sbox_HW_gen(i), range(256)) for i in range(16)]

I’ll get that fixed up in that notebook for our next release.

Alex