A computer-implemented method comprising: generating, by each client of a plurality of clients, a client public and private key pair; sending, by each client of the plurality of clients to a server, the respective client public key; distributing, by the server to each client of the plurality of clients, all the client public keys; encrypting, by each client of the plurality of clients, a data value using a common public key for threshold additive homomorphic encryption; encrypting, by each client of the plurality of clients, a binary representation of the data value using its own client public key; receiving, by the server from each client of the plurality of clients, the encrypted data value and the encrypted binary representation of the data value; distributing, by the server for each pair of clients comprising a generator client and an evaluator client, the received encrypted binary representation of the data value of the generator client to the evaluator client for evaluating comparison of values; running, by each pair of clients of the plurality of clients, a Damgard, Geisler and Kroigaard - DGK - comparison protocol using the encrypted binary representation of the data value of the generator client, thereby obtaining a comparison result; encrypting, by each pair of clients of the plurality of clients, the comparison result using the common public key; receiving, by the server, the encrypted comparison results from each pair of clients of the plurality of clients in response to the distribution of the received encrypted binary representations of the data values; homomorphically determining, by the server, a ciphertext encrypting the rank of each client's data value using the encrypted comparison results; computing a ciphertext encrypting the median of the data values; and initiating, by the server using the clients, a threshold decryption to generate a final result; wherein the plurality of clients can communicate only through the server. generating, by each client of a plurality of clients, a client public and private key pair; sending, by each client of the plurality of clients to a server, the respective client public key; distributing, by the server to each client of the plurality of clients, all the client public keys; encrypting, by each client of the plurality of clients, a data value using a common public key for threshold additive homomorphic encryption; encrypting, by each client of the plurality of clients, a binary representation of the data value using its own client public key; receiving, by the server from each client of the plurality of clients, the encrypted data value and the encrypted binary representation of the data value; distributing, by the server for each pair of clients comprising a generator client and an evaluator client, the received encrypted binary representation of the data value of the generator client to the evaluator client for evaluating comparison of values; running, by each pair of clients of the plurality of clients, a Damgard, Geisler and Kroigaard - DGK - comparison protocol using the encrypted binary representation of the data value of the generator client, thereby obtaining a comparison result; encrypting, by each pair of clients of the plurality of clients, the comparison result using the common public key; receiving, by the server, the encrypted comparison results from each pair of clients of the plurality of clients in response to the distribution of the received encrypted binary representations of the data values; homomorphically determining, by the server, a ciphertext encrypting the rank of each client's data value using the encrypted comparison results; computing a ciphertext encrypting the median of the data values; and initiating, by the server using the clients, a threshold decryption to generate a final result; wherein the plurality of clients can communicate only through the server. <EOS>