A computer implemented method of determining whether a first secret and a second secret, stored in a memory of a first device and the memory of a second device, respectively, are the same or not, without disclosing the secret stored in the first device to the second device or to any third party, the method comprising following steps, wherein:
- which of the first device and second device should start the exchange is determined by means of a random decision and wherein a commitment scheme is used to ensure fairness of the random decision;
- the first device picks a random number RA, encrypts the random number RA using a public key PUB of the second device, adds the value of a secret SA of the first device, and sends a first result K of these steps to the second device;
- the second device receives the first result K, subtracts a secret SB of the second device, and performs a decryption of a result of the subtraction, using a private key PRB of the second device, the decryption resulting in a decrypted result L;
- the second device applies a one-way function H on the decrypted result L and sends a second result M of the application of the one-way function to the first device;
- the first device applies said one-way function H to the random number RA;
- the first device receives the second result M and verifies whether the received second result M equals a result of applying said one-way function H to the random number RA;
- and
- wherein the first device and second device each comprise a processor, a non-transitory computer readable medium, and a transceiver.