All problems
Side-Channel Leak Bits
Problem
Model a side channel that leaks the given fraction of a secret's bits: return total_bits * leaked_fraction, the number of bits exposed to the attacker.
Hint
Leaking the whole key leaves zero effective security.
Test cases
case 1
in: [128,0.25]
expected: 32
case 2
in: [256,0.5]
expected: 128
case 3
in: [100,0]
expected: 0
case 4
in: [64,1]
expected: 64
Starter codePython
def leaked_bits(total_bits, leaked_fraction):
# Your code here
pass4 test cases · run your code against them in the editor