Tuesday, November 15, 2016

End to end encryption

WhatsApp recently added end-to-end encryption to its app, for increased security. But, what exactly is it? Let's take a very simple example to see how it works. Consider two users, Alice and Bob.
Assume Alice wants to send Bob a message, which is 24.

Alice and Bob both generate a pair of "keys"; for simplicity and explanation in this example, we'll consider keys as arithmetic operations.

So the two keys that they generate are called public and private keys; public keys are visible to everyone, while only the user knows his private key.

These work in pairs, so something encrypted with a user's public key can be decrypted with his private key, and vice-versa.

So let's say Alice's "keys" (or arithmetic operations in this example) are as follows: her public "key" is "*2" or multiply by 2 operation. Therefore, her private "key" will be "/2" or the divide by 2 operation. In real life, deciphering the private key from the public one isn't easy.

For Bob, let's assume his private "key" to be "*3" and his public "key" to be "/3".
Now, Alice wants to send the message "24" to Bob. What she does is she encrypts it with her private key and his public key, so that Bob can decrypt it with her public key and his private key. The public keys are stored in a global directory, so anyone can access them.
So, Alice encrypts 24 with her private key; so, 24 becomes 12, and then she further encrypts this with his public key; so, 12 becomes 4.

Bob, on receiving the message, first decrypts it with her public key; so, becomes 8. Then, he decrypts that with his private key. So 8 becomes 24, which was the original message.

Hope that was a good explanation. Leave your thoughts in the comments!

Machine Learning Project

Hey guys! I have a couple of interesting Machine Learning ideas that I thought of quite a while ago, and I'm happy to say I'm implementing one of those as my ML class project. As you know, Machine Learning involves giving the computer some data which it can use to 'learn' a model. This model can then be used for a variety of applications. The most interesting one I heard of from my professor is texture stitching.

Texture stitching involves taking the same thumbnail and repeating it over and over to form a nice, large texture. You may have seen the abstract wallpapers here and there, like the brick wall. Apparently that's not a picture of a whole wall, but rather a small piece repeated several times. The ML model learns the image and tries to stitch in a way where that fact is not obvious. And we have seen the results, they're quite breathtaking.

Anyway, back to my project ideas. So I have two, one which I call Y U No Reply, and another which I call Spirited.

Y U No Reply: In this one, the user downloads a Chrome extension, which tracks their email activity. This data is uploaded to a server, where a model is trained for every specific user. Now on the user side, say someone I want to email has downloaded the extension. I want to find out when the best time to email them is, to get a quick response. So in addition to the Chrome extension, there will be a web app which can display information about user email patterns. So I enter their email ID into the web app, and it gives me a bunch of statistics, including when the best time to email them is and if I email them right now, how much time they will take to reply.

Spirited: This is one I started developing in a hackathon, and am now refining and improving as my class project. This is a browser/Chrome extension that guesses your mood based on the websites you're browsing and how quickly you're switching/closing/opening tabs. This uses the circumplex mood model, where you can plot the user's mood as a point on the Pleasure-Activity axes. For example, high pleasure and low activity means calm and relaxed. High activity and low pleasure means stress, which might mean the user is under a deadline. So based on the mood, we train a model which predicts the user mood at different times of the day. Based on when they open the browser, the model will make a prediction for, say, the next hour, and create a playlist from the user's library that will supplement the mood.
For example, for a calm mood, the model would play slow songs, while for an under-the-deadline situation it would play an upbeat song (assuming the user wants to be listening to music under pressure), which is proven to increase productivity.

So as you can see, the applications of ML are endless. It is an emerging field and is capturing the attention of researchers everywhere. I find it fascinating because of what all you can do with it.

Sunday, November 13, 2016

Ricoh Theta S

I have begun (unofficially) working on my thesis, and got a chance to tinker around with a piece of technology I had never heard of before: a 360 degree camera, or 360 camera for short. The one I am using is the Ricoh Theta S, which is a sleek, upright camera. It has two 180 degree lenses on its two opposite sides. These two capture two separate 180 degree images, and the driver that we install on the computer stitches them into one, large, panoramic, 360 degree image. The clarity on this image is better than I expected: I could examine a spot on my desk where someone had spilled something.


If you observe carefully, you'll see two distinct stitch lines; that's where the driver (Theta UVC Blender) comes into play. Note: On the far right, you can see the white spot I was talking about.

Now this has exciting applications. What I am using it right now for is Virtual Reality, or VR for short. This image looks stunning in a VR headset. There were some problems getting a stream set up from the Ricoh Theta S to a Google Cardboard (inexpensive yet high quality VR headset). I set up a server on my DigitalOcean droplet. On that I configured nginx (pronounced engine x) to use as an RTMP (Real Time Messaging Protocol) streaming service. But the problem with this was the lag. To put things in perspective, when I waved at the camera, it took 6 seconds for the viewer to see that I was waving. This would not work. The project I am working on requires the stream to be real time (Obviously, there will be some lag, but it needs to be reduced to a negligible value).

Finally, after days of research, I stumbled upon HugVR, a neat little website that lets you stream live from 360 cameras. To view this in VR, all I did was open the browser on the phone (the one used in the Cardboard), select the Google Cardboard view (this website has an option, just like YouTube), and view my stream in real time. The best part was the fact that the image was navigable. Earlier, when I set up the server myself, the image was a wide panorama, which was a little overwhelming. In the latter example, however, It is limited to 135 degrees (I think), and to view other parts of the image you have to turn your head, just like you would have to in real life.

To conclude this article, the combination of the Ricoh Theta S , the Google Cardboard, and HugVR works like a charm. I'm definitely going to be using this in my project and will explore more in the future.