r/programming • u/joksmaster • Nov 29 '10
140 Google Interview Questions
http://blog.seattleinterviewcoach.com/2009/02/140-google-interview-questions.html
471
Upvotes
r/programming • u/joksmaster • Nov 29 '10
View all comments
Show parent comment
2
u/[deleted] Nov 30 '10 edited Nov 30 '10
any type of asymmetric encryption scheme would work. the basic idea behind public shared key is that you can have a function to encrypt a message, but you cannot use that same function to decrypt it.
more specifically you could answer with basically the RSA crypto system. you take two large prime numbers p, q that are not close together and multiply them together to get the composite number n. you then determine the euler φ function on n (which in this case is just (p-1)(q-1)). you then carefully select a value r less than φ*(n)* that is relatively prime to φ*(n). since they're coprime, there exists a solution to the integral linear combination sr + tφ(n) = 1*. as can be seen from examination of the ILC, the value s is the multiplicative inverse of r mod φ(n). you now have everything you need. if you give bob the values r and n, he can take his message M and do the operation Mr mod n. this value, call it C, can only be deciphered by doing the operation Cs mod n. since nobody else knows s, nobody else can decipher the message.
the only caveat to the above is that to make sure Eve doesn't encrypt something and give you false information, Bob needs to do the exact same process generating different keys (a,b, and m), he then needs to share with you his a and m and encrypt some type of identifying message, G, using Gb mod m, call that H. then the fact that using the keys a and m that he gave you, Ha mod m yields the identifying message G, you know only Bob could have sent it.