Simple One time Pad Probability We have a one time pad where:


We have 8 bits. probability that a bit=0 is p.
The key is common for all 8 bits. It can have a value of 0 or 1 with equal probability.
After applying the XOR operation we take the encrypted result that has n zeros and 8-n ones.


What I am asked to do is calculate the probability that the key used is 0.

Until now I am thinking like this:

There are 2 events: 

EventA. We have k zeros in the original 8 bits

EventB. We have k zeros in the encrypted data.

P(A) can be calculated from the binomial distribution
P(B) = 2P(A)
I am searching the probability P(key=0|P(B)).

Is my thinking correct until now? How can i procede from there?
Assume the message is an $n$-bit string with each bit drawn independently with $P(0) = p$.

Let $A$ be the event that the key bit is $0$.

Let $B$ be the event that there are $k$ zeroes in the ciphertext.

Then $P(A) = \frac{1}{2}$ and $P(B) = \frac{1}{2}{{n}\choose{k}}\left(p^k(1-p)^{n-k} + p^{n-k}(1-p)^{k}\right)$, since with equal probability we had $k$ zeroes or $n-k$ zeros in the message.

$P(B | A) = {{n}\choose{k}}p^k(1-p)^{n-k}$ since this occurs exactly when the message originally had $k$ zeros

Then $P(A | B) = \frac{P(A)P(B | A)}{P(B)} = \frac{p^k(1-p)^{n-k}}{p^k(1-p)^{n-k} + p^{n-k}(1-p)^k}$