Bob, Alice, an iPadOS and the Apple Pencil

Yesterday I was down in Plymouth to do a PhD Viva. And so, while many people have a sleep on flights, or have a few drinks, I find that…

Bob, Alice, an iPadOS and the Apple Pencil

Can I replace paper and a pen, and still doodle?

Yesterday I was down in Plymouth to do a PhD Viva with a brilliant student. And so, while many people have a sleep on flights, or have a few drinks, I find that the time spent traveling is some of the most constructive thinking time that I have. Much of my time is often spend interacting with others or in creating presentations for lectures, but on a flight I can focus. On the way to my destination, I am often finishing off the work I to do, but on the way back I am free to investigate new things. Without learning new things, we will fossile our knowledge, and never innovate and discover new things. It is the reason we do research, and to enquire and probe.

For the past few weeks, I have wanted to try out working with iPad OS and the Apple Pencil, and see if I could work without the use of my trusty notebook and pen. While the mechanical things of checking Twitter and email are all easy to replace, the more creative side is not quite as automatically. And so, if you are interested, here’s my basic setup:

I have a fold-back keyboard, and which I can switch-off, and where the on-screen keyboard come into play, but if I need a physical keyboard, it is there. The genius lies in iPadOS and the Apple Pencil. For the first time, I can lay windows beside each other, and lay my hand on the screen. I know I can do this on many other systems, including on my smart phone, but for the first time, with iPadOS, it all feels right. It is a strange feeling to lay your palm on the screen, and still write. And, for the Apple Pencil, I stick it back into its holder, and it charges itself. Fantastic! And, I used my iPad for a whole day yesterday, and still today it has enough battery to go another full day. I never worry about finding a charging point with the iPad, whereas running Visual Studio on my Mac, I would have to charge it to 100% before I went on the flight.

Goodbye to my paper notepad?

So as I left my home, I said goodbye to my notebook, and grabbed the PhD thesis — I still prefer to work on paper copies with that — and my iPad. Then on the way back, I settled myself down with my iPad and fired up the Kindle app and Microsoft OneNote:

The Apple Pencil must be one of the best things that Apple has ever done. I feels like a pen, and writes like a pen, and the ink on paper just looks like it does on paper.

A bit of public key on an iPad

And so, I find Lattice cryptography fasinacting, and want to illustrate it in an easy way. One of the simple ways to start the learning process is to do a little bit of Congruential Public Key, and where Bob and Alice can exchange a message using public key encryption. And so after understanding the theory, I fired up Pythonista on my iPad, and by the time I arrived back in Edinburgh, I had Bob and Alice exchanging secret messages, all without my notebook and my laptop.

Here’s what I ended up with:

Congruential Public Key

Alice picks f and g and a large prime number q. Then calculates:

h=f^{−1}g (mod q)

Alice’s public key is (h,q). Bob takes a message (m) and picks a random number (r) and ciphers with:

e=rh+m (mod q)

Alice decrypts with:

a=fe

b=f^{−1}a (mod g)

and where is the deciphered message.

This works because the value of a is:

a=fe(modq)=f(rh+m)(modq)=frh+fm(modq)=frf^{−1}g+fm(modq)

Now if q is large, and much larger than the value of a), the value of a

will be:

a=rg+fm

Now b is the deciphered message:

b=f^{−1}a (mod g)

= f^{−1}(rg+fm)(mod g)

=f^{−1}rg+f^{−1}fm)(mod g)

Now the f^{-1}rg (mod g) part will be zero as we have a multiple of g and take the mod g operation. So we get:

b=f^{−1}fm (mod g)=m (mod g)

And if g is larger than m we just get the message back. Here is the code I produced:

Conclusions

Your brain is the most amazing machine on the planet. It is often the most under-used machine on the planet. It needs exercise, so please give it some time to think about things, and learn something new. Go give it some quality time.

For me, it is on the train or on a flight, but for you, it is likely to be somewhere else. So, try and find that special time, and force yourself to learn something new.

For me, I’m a doodler — and always have been — and I need to sketch things to learning them. In meetings I will often doodle as I listen to things around me. And so I have carried around my paper notepad to do this, but I find it difficult to go back to it. With iPadOS I can now pull up my books (I will never let go of books as the core source of knowledge), and — side-by-side — do my doodles — and then run some Python code. This is how I want to work. You might say that a touch pad laptop does this, but I just don’t like touching the screen or writing on it. For me iPadOS and the Apple Pencil is the most natural thing I’ve found. Matched with OneNote, and side-by-side windows is where I want to be. But for running Microsoft Visual Studio, it still has to be my Mac for that.

Last thing … how do I replace my Post-it notes on a PhD thesis:

You may exercise your body, but remember to give your brain some quality time. And for the PhD Viva, it was great:

References

[1] Hoffstein, J., Pipher, J., Silverman, J. H., & Silverman, J. H. (2008). An introduction to mathematical cryptography (Vol. 1). New York: springer