You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You want to know which shop/zipcode is closest to your own zipcode, without telling the website where you live.
Note
The zipcode is not an appropriate application of FHE because the list of zipcodes is not private data, so instead of running an encrypted computation on the zipcode of the user, one could just send the whole zipcode list to the user, and let the user do the computation client/user-side, e.g. using javascript in the browser. However, this was an interesting case to learn about how the FHE would work in code.
Approach/Idea using Paillier cryptosystem
Create the list of distances to the zipcodes.
pass the encrypted zipcode, encrypted 1, and encrypted 0 into the function.
Compute differences between the incoming zipcodes and the shop zipcodes.
Then subtract 1 from all distances until subtractedDistance equals the encrypted 0.
Doubts
Can one derive the incoming zipcode based on the existing list of zipcodes?
Perhaps the randomness implies the subtractedDistance value of zero is different than the incoming encrypted 0 value.
First draft outline
funcmain() {
// Assuming you have the Paillier public keyn, g, lambda, mu:=keygen.GetKeys()
// Encrypt zipcodeszipcodeList:= []int{12345, 56789, 98765}
encryptedZipcodes:=encryptZipcodes(zipcodeList, pubKey)
// Given zipcode XX:=54321encryptedX:=encryptNumber(X, pubKey)
// Compute encrypted distancesencryptedDistances:=computeEncryptedDistances(encryptedZipcodes, encryptedX, pubKey)
// Find the minimum distanceminimumDistance, _:=findMinimumDistance(encryptedDistances, pubKey)
// Decrypt minimum distance to get plaintext distanceplaintextDistance, _:=pubKey.Decrypt(minimumDistance)
// Retrieve closest zipcodeclosestZipcode:=decryptClosestZipcode(encryptedDistances, minimumDistance, pubKey)
fmt.Printf("Closest Zipcode to %d: %d (Distance: %d)\n", X, closestZipcode, plaintextDistance)
}
The text was updated successfully, but these errors were encountered:
Context
You want to know which shop/zipcode is closest to your own zipcode, without telling the website where you live.
Note
The zipcode is not an appropriate application of FHE because the list of zipcodes is not private data, so instead of running an encrypted computation on the zipcode of the user, one could just send the whole zipcode list to the user, and let the user do the computation client/user-side, e.g. using javascript in the browser. However, this was an interesting case to learn about how the FHE would work in code.
Approach/Idea using Paillier cryptosystem
Create the list of distances to the zipcodes.
pass the encrypted zipcode, encrypted 1, and encrypted 0 into the function.
Compute differences between the incoming zipcodes and the shop zipcodes.
Then subtract 1 from all distances until subtractedDistance equals the encrypted 0.
Doubts
Can one derive the incoming zipcode based on the existing list of zipcodes?
Perhaps the randomness implies the subtractedDistance value of zero is different than the incoming encrypted 0 value.
First draft outline
The text was updated successfully, but these errors were encountered: