How to find the Hamming distance of two vectors in ciphertext domain?
Hello, I want to know what the specific form of ciphertext is. Can we calculate the number of non-zero elements in the ciphertext vector after subtracting the two encrypted vectors so as to calculate the Hamming distance? Or can we directly use the method in NUMpy to solve the Hamming distance
Finding out if an element is non-zero (i.e. computing f(x) = (x != 0)) can be tricky under encryption. If the vector elements were already binary, then it's very easy, but otherwise, it's definitively an "advanced" thing to do.
Demo_8_HammingDist.py shows how to calculate the hamming distance in a well detailed script. As mentioned by @AlexanderViand , the main requirement is to encode vectors with binary values {0,1}*, in which case you can resort to arithmetic scalar product since XOR(a, b) = a + b - a*b.
Closing with this working example!