How to know the average without disclosing the salaries?


  • Banned

    Hi everyone, I have been working on a project related to development and want to know your views on the average without disclosing the salaries. I am also very curious about various other programming quries because I also got stuck in some coding issues, that is why I am looking for such a platform where the evolving community can help me to resolve my queries.


  • Moderators

    @kyleflores You cannot calculate average of something you do not have. How should it be possible? So, you need to get the salaries, sum them and divide the sum by their count. You just do not show the salaries to the user of your application :-) Where are the salaries stored? Who enters them?



  • I heard there are cryptographic hashes which satisfy hash(v1)+hash(v2)+...+hash(vn) = hash(v1+v2+...+vn) so in theory you can get the sum of the salaries without knowing each individual salary, on the other hand a hash of a salary is quite prone to be brute forced...


  • Moderators

    @VRonin But hash(v1+v2+...+vn) is not the same as (v1+v2+...+vn)/n, right?



  • that is correct but there was a way to get back (v1+v2+...+vn) (and since n is known, the average) from the hash without brute forcing it. Unfortunately I'm not math savvy enough to shed more color




Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.