@@ -127,7 +127,7 @@ def e91_protocol(n_bits: int = 2000) -> dict:
127127 # Sift for generating the secret key.
128128 # The key is formed when Alice and Bob choose compatible bases.
129129 # Here, compatible means A2/B1 or A3/B2, where angles are identical.
130- alice_key , bob_key = [], []
130+ alice_key , bob_key = [], []
131131 for i in range (n_bits ):
132132 is_a2b1 = alice_chosen_bases [i ] == "A2" and bob_chosen_bases [i ] == "B1"
133133 is_a3b2 = alice_chosen_bases [i ] == "A3" and bob_chosen_bases [i ] == "B2"
@@ -138,7 +138,12 @@ def e91_protocol(n_bits: int = 2000) -> dict:
138138 # Sift for the CHSH inequality test (Eve detection).
139139 # We use four specific combinations of bases for the test:
140140 # a = A1, a' = A3 | b = B1, b' = B3
141- chsh_correlations = {"ab" : [], "ab_" : [], "a_b" : [], "a_b_" : []}
141+ chsh_correlations : dict [str , list [int ]] = {
142+ "ab" : [],
143+ "ab_" : [],
144+ "a_b" : [],
145+ "a_b_" : [],
146+ }
142147
143148 for i in range (n_bits ):
144149 # Convert results {0, 1} to {-1, 1} for calculating correlation.
@@ -159,9 +164,9 @@ def e91_protocol(n_bits: int = 2000) -> dict:
159164 chsh_correlations ["a_b_" ].append (product )
160165
161166 # Calculate the expectation value (average correlation) for each combination.
162- e = {}
167+ e : dict [ str , float ] = {}
163168 for key , values in chsh_correlations .items ():
164- e [key ] = np .mean (values ) if values else 0
169+ e [key ] = np .mean (values ) if values else 0.0
165170
166171 # Calculate the S-value: S = e(a,b) - e(a,b') + e(a',b) + e(a',b')
167172 s_value = e ["ab" ] - e ["ab_" ] + e ["a_b" ] + e ["a_b_" ]
0 commit comments