All problems
Perfect Secrecy Check
Problem
Return True when the channel p(c|m), passed as pcm[m][c], equals the ciphertext prior pc for every message and ciphertext within a tolerance of 1e-9. That equality is exactly Shannon's condition for perfect secrecy.
Hint
The ciphertext distribution must not depend on the message at all.
Test cases
case 1
in: [[[0.5,0.5],[0.5,0.5]],[0.5,0.5]]
expected: true
case 2
in: [[[1,0],[0.5,0.5]],[0.5,0.5]]
expected: false
case 3
in: [[[0.25,0.75],[0.25,0.75]],[0.25,0.75]]
expected: true
case 4
in: [[[1,0],[1,0]],[1,0]]
expected: true
Starter codePython
def perfect_secrecy_holds(pcm, pc):
# Your code here
pass4 test cases · run your code against them in the editor