# How Public Key Cryptography works? (RSA algorithm)

Public-key Cryptography is asymmetric meaning the key used for encryption cannot be used for decryption. There is a pair of keys, if the message is encrypted with one key, then the other is required for decryption.

## How Public-key Cryptography works conceptually?

Let’s say Alice and Bob want to exchange messages in a secure way. To do it using Public key cryptography, each party needs to have a public key and a private key. Keys are just big numbers. The public key is shared openly, known to everyone, while the private key is kept a secret. The two keys are linked in the sense that message encrypted with one key can only be decrypted with the other, but it is almost impossible to work out the private key from the public key.

To send a message across to Bob, Alice will encrypt the message with his private key. Upon receiving the message Bob will decrypt it with Alice’s public key. This will confirm that the message has really come from Alice. It solves the authenticity problem and is also called Digital Signature. For efficiency purposes, a digital signature is created by encrypting the hash of the message with the private key rather than the whole text.

But as Alice’s public key is available to everyone, the communication is not confidential. Anyone can decrypt the message and read it. To make it confidential, Alice can first sign the message using Digital Signature with his private key and then encrypt it with Bob’s public key. This will ensure that the message can only be decrypted by Bob with his private key and then the digital signature can be verified with Alice’s public key. This assures both confidentiality and authenticity.

## How it work technically or mathematically?

To demonstrate the working of Public Key Cryptography using RSA algorithm, I have created a page that generates the public and private keys using given prime numbers and encrypts/decrypts the message. It shows all the formulas and steps involved.

## Why does it work?

I will address two separate questions here. Please go through the workings of RSA here before going further.

Why private key cannot be worked out from the public and decrypted message?

The public key is actually a pair of two numbers: E and N, the same goes for the private key: D and N. N is common between the two keys, while E and D are unique to the public and private keys respectively. As the formulas show, there is no way to figure out D from E directly. The only way is to factorize N into two prime numbers and then calculate D. Because the factorization of a very large number into its prime factors takes a very long time to compute, it is not possible to break the encryption in a reasonable amount of time.

Why do asymmetric keys to give desired results?

To understand why RSA gives us correct results, why asymmetric keys work, I will direct you to an excellent article here.

# Calculate Modular Exponentiation (PowerMod) in Javascript (a^p % n)

Computing PowerMod is required for implementing public-key cryptography as it is used to encrypt and decrypt data. Calculating it by regular arithmetic (i.e. calculating pth power of a) doesn’t work with large numbers used for encryption. That’s where PowerMod helps, it calculates the result by keeping the numbers significantly small and within range of the integer data type.

There are different algorithms for calculating PowerMod. Following is based on the pseudocode from Wikipedia, it is called ‘Right-to-left binary method’.

```// calculates   base^exponent % modulus
function powerMod(base, exponent, modulus) {
if (modulus === 1) return 0;
var result = 1;
base = base % modulus;
while (exponent > 0) {
if (exponent % 2 === 1)  //odd number
result = (result * base) % modulus;
exponent = exponent >> 1; //divide by 2
base = (base * base) % modulus;
}
return result;
}
```

# Installing Visual Studio Code (VSCode) on Manjaro linux

It will be a two-step process. First, we will install Yaourt, then use it to install VS Code.

### Installing Yaourt

Edit Pacman configuration file to include the repository for Yaourt

`\$ sudo nano /etc/pacman.conf`

Add the following lines at the end of the file and save it

```[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/\$arch```

Now refresh the repository database and install Yaourt

`\$ sudo pacman -Sy yaourt`

### Installing VS Code

Yaourt makes installing VS Code pretty easy, we just have to execute the following command.

`\$ sudo yaourt visual-studio-code-bin`

# Noteworthy Articles on Philosophy of Mind

Here I am putting together a list of articles / resources on ‘Philosophy of Mind’ which I found worth reading:

 Title Minding Matter Subtitle The closer you look, the more the materialist position in physics appears to rest on shaky metaphysical ground. Author Adam Frank (Professor of Astronomy at the University of Rochester in New York) Date 13-Mar-2017 (reviewed on 20-Mar-2017) Excerpts “the unresolved democracy of quantum interpretations means that our current understanding of matter alone is unlikely to explain the nature of mind. It seems just as likely that the opposite will be the case.” My summary The traditional conception of matter being fundamentally made up of tiny particles is replaced with a much more puzzling quantum world. The objective access to reality is lost in probability waves, essential uncertainties and the role of observer. There are various competing interpretations of this quantum weirdness presenting us with totally different views of reality. For instance, one of the interpretations posits existence of infinitely many parallel universes to account for the observer effect. All this shows that we have a very little grasp on the real nature of matter. In such a situation to claim that consciousness is entirely material (or physical) doesn’t explain much.
 Title The Dark Secret at the Heart of AI Subtitle No one really knows how the most advanced algorithms do what they do. That could be a problem. Author Will Knight Date 11-Apr-2017 (reviewed on 25-Apr-2017) Excerpts We can build these models, but we don’t know how they work. It might be part of the nature of intelligence that only part of it is exposed to rational explanation. Some of it is just instinctual. How well can we get along with machines that are unpredictable and inscrutable? My summary AI systems based on neural networks are probabilistic. Trained on a huge amount of data, they store relations between inputs and outputs in the form of neural networks. Given a new input, they predict the output which can go beyond the human capability of finding patterns. But AI systems cannot explain why they gave a particular output, they don’t reason like humans. Their inability to provide reasoning for their decisions is a problem that limits their utility and their ability to work together with human experts. As AI systems don’t reason, they may produce strange outputs at times, see ‘There’s a Bit of a Flaw in the Way Artificial Intelligence Is Being Developed‘ (adversarial examples), ‘AI Can Be Fooled With One Misspelled Word‘ and ‘How Cellphone Camera Images Can Fool Machine Vision’.
 Title Is consciousness just an illusion? Subtitle The cognitive scientist Daniel Dennett believes our brains are machines, made of billions of tiny “robots” – our neurons, or brain cells. Is the human mind really that special? Author Anna Buckley, Daniel Dennett Date 04-Apr-2017 (reviewed on 05-Apr-2017) Excerpts In an infamous memo written in 1965, the philosopher Hubert Dreyfus stated that humans would always beat computers at chess because machines lacked intuition. Daniel Dennett disagreed. A few years later, Dreyfus rather embarrassingly found himself in checkmate against a computer. We’re not just are robots. We’re robots, made of robots, made of robots. Pressing icons on our phones makes us feel in control. We feel in charge of the hardware inside. But what we do with our fingers on our phones is a rather pathetic contribution to the sum total of phone activity. And, of course, it tells us absolutely nothing about how they work. Human consciousness is the same, says Dennett. “It’s the brain’s ‘user illusion’ of itself,” he says. Descartes grossly underestimated machines. Alan Turing set him right. My summary Humans are just machines, albeit complex. And consciousness is an illusion.
 Title Daniel Dennett’s Science of the Soul Subtitle A philosopher’s lifelong quest to understand the making of the mind Author Joshua Rothman Date 27-Mar-2017 (reviewed on 07-Apr-2017) Excerpts A running joke among people who study consciousness is that Dennett himself might be a zombie. (“Only a zombie like Dennett could write a book called ‘Consciousness Explained’ that doesn’t address consciousness at all,” the computer scientist Jaron Lanier has written.) Along with Richard Dawkins, Sam Harris, and the late Christopher Hitchens, Dennett is often cited as one of the “four horsemen of the New Atheism.” Chalmers accused Dennett and the Physicalists of focusing on the “easy problems” of consciousness—questions about the workings of neurons or other cognitive systems—while ignoring the “hard problem.” Since then, the “hard problem” has been a rallying cry for those philosophers who think that Dennett’s view of the mind is incomplete. Dennett said, “that you can’t name a kind of experiment that would get at ‘first-personal data,’ or ‘experiences.’ That’s all I ask—give me a single example of a scientifically respectable experiment!” My summary More biographical, but does go into how Dennett explains consciousness away. Also describes a showdown between Chalmers and Dennett that happened a few years ago. Dennett argues that if a machine is so sophisticated that you fall in love with it like you do with a human, not then you will consider the machine as conscious. Author’s mother had a stroke last year and she lost many of her mental abilities. It seems to the author that she is now “sort of” conscious which makes more sense from Dennett’s perspective. That consciousness is not a light switch, rather it is layers of functions or interconnecting sub-systems.
 Title Is The Universe Conscious? Author Marcelo Gleiser Date 12-Jul-2017 (reviewed on 20-Jul-2017) My summary Author explores the idea that universe might itself be consciousness, in the sense that it has a direction and purpose. There seems to be a progression from sub atomic particles to molecules to stars to living things to humans. Panpsychism, idea that mind is everywhere, has found quite a few proponents like David Chalmers. This idea was an essential part of ancient belief systems. Mysteries of Quantum Mechanics are invoked in support of panpsychism, though there are no real grounds for it.
 Title Pain in the Machine (video) Subtitle Pain leads to empathy and self-preservation: should we make robots ‘feel’ it? Date 17-Jul-2017 (reviewed on 17-Jul-2017) Excerpts Evolutionarily, pain exists to warn of potentially harmful and dangerous things in the environment, allowing us and other creatures to learn, respond and ultimately survive. Pain also triggers an emotional response in humans, which links the physical and the emotional experience in ways that are difficult to tease apart, though it does seem that empathy is one result of the emotional component of pain. For decades, scientists and researchers have constructed computers to mimic human neural networks. Recently, some advanced robots have been designed with self-preservation mechanisms that vaguely replicate a pain response. So to what extent should robots share in human pain? Combining interviews with experts from the University of Cambridge and elsewhere, together with clips from amusingly relevant science-fiction films and TV shows, Pain in the Machine explores whether there is a sense in which robots could come to experience pain, and probes the practical and ethical implications of equipping the next generation of robots with such a capacity. My summary Prof. Peter Robinson (Professor of Computer Technology at University of Cambridge) says that we are a lot like machines but this analogy has limits. And to explain the rest, people come up with various ideas, but professor Peter finds the religious explanation that god created us and endowed us with these faculties to be simpler. Rest of the experts mostly take a physicalist point of view, though few mention that there is no way to know whether a machine is conscious.
 Title Papineau vs Dennett: a philosophical dispute Author Daniel Dennett and David Papineau, Introduction by Tim Crane Date 2-Aug-2017 (reviewed on 5-Aug-2017) My summary This is a debate between the two about the latest Book by Dennett (From Bacteria to Bach and Back) and Papineau’s review titled ‘Competence without comprehension‘. Both are materialists philosophers so it might be puzzling to know that they differ. Time Crane summaries their debates as follows: “There were two main lines of criticism in Papineau’s review: one concerns Dennett’s doubts about explicit understanding or “comprehension”; the other concerns his views about consciousness. On comprehension, Dennett maintains that much animal and indeed human behaviour displays “competence without comprehension”, achieving ends without the subject’s understanding why. In a similar vein, he holds that human cultures can develop blindly, due to the natural selection of the “informational viruses” that Richard Dawkins has labelled “memes”, including some of the greatest products of human culture (hence Bach and bacteria). Papineau argues that Dennett fails to justify his downgrading of animal intelligence or his exclusion of deliberate design from cultural innovation, and hence that Dennett does not take sufficiently seriously the widespread role of intelligent insight. On consciousness, Papineau takes issue with Dennett’s view that consciousness is a kind of illusion (“illusionism”) and argues that materialists should have no difficulty accepting the reality of consciousness – the difficulty is finding the material basis of this reality in the brain.”
 Title If I teleport from Mars, does the original me get destroyed? Author Charlie Huenemann (Professor of philosophy at Utah State University) Date 01-Aug-2017 (reviewed on 01-Aug-2017) My summary If a replica of me is created which is exactly same down to the last atom, would I be in two places at the same time. Obviously, this assumes that we are made up of matter only (cells, neurons etc.), there is no ghost in the machine. This thought experiment raises doubt about our sense of self and makes the Author think that there is no inner, substantive me (or soul). Our bodies are going through change all the time and sense of self is an illusion created by our minds amidst this change. If a replica is created, both of them will have an illusion of self and there is no me anyway.
 Title Can Integrated Information Theory Explain Consciousness? Author John Horgan (Science Journalist) Date 01-Dec-2015 (reviewed on 03-Sep-2017) My summary The author holds a position called Mysterianism that the hard problem of consciousness cannot be solved. Panpsychism strikes him as self-evidently foolish, even though Chalmers and Koch take it seriously. IIT Postulate called ‘exclusion’ proposes the components of a system may have non-zero phi but they are not consciousness because the phi of the entire system exceeds that of its components, resulting in suppression of components’ consciousness. So a group of people communicating obsessively with each other might result in them losing their consciousness as the group itself becomes conscious. Scott Aaronson, a critic of IIT, says that Phi may be a necessary condition for consciousness but not sufficient.  IIT “unavoidably predicts vast amounts of consciousness in physical systems that no sane person would regard as particularly ‘conscious’ at all: indeed, systems that do nothing but apply a low-density parity-check code, or other simple transformations of their input data.  Moreover, IIT predicts not merely that these systems are ‘slightly’ conscious (which would be fine), but that they can be unboundedly more conscious than humans are.” John Searle in his review of Koch’s book complained that IIT depends on a misappropriation of the concept of information. “you can’t explain consciousness by saying it consists of information, because information exists only relative to consciousness”.
 Title Does Consciousness Cause Quantum Collapse? Author Kelvin McQueen Date 01-Aug-2017 (reviewed on 15-Aug-2017) My summary The author describes the double split experiment and how the reality is explained by two different laws: Schrodinger’s equation and collapse postulate. Schrodinger’s equation enables us to calculate the exact state of the system, it’s wavefunction, while collapse postulate is probabilistic. Which of the two laws governs the physical state depends on whether the system is measured or not. This is the measurement problem at the heart of Quantum Physics. One way to understand measurement puzzle is to consider it as effects of conscious observer, it is proposed by some physicists (many-worlds being another popular explanation). With this unsolved mystery about the possible role of consciousness in physical laws, the Causal Closure argument doesn’t look conclusive. To explore the possible role of Consciousness in Quantum Physics, Author proposes to devise experiments based on Integrated Information Theory of Consciousness. If IIT is true, such experiments should tell us whether its Consciousness that causes the collapse of the wavefunction.
 Title What if consciousness is not what drives the human mind? Author David A Oakley, Peter Halligan Date 22-Nov-2017 (reviewed on 22-Nov-2017) My summary The article proposes Epiphenomenalism. Consciousness can be divided into Personal Awareness and Contents of Consciousness (thoughts, beliefs, sensations etc.). Personal Awareness doesn’t create, cause or choose our beliefs, feelings or perceptions. Instead, the contents of consciousness are generated by fast, efficient non-conscious systems in our brains. A subset of our experiences, emotions, thoughts, and beliefs form a personal narrative. Personal Awareness has no control over Personal Narrative. Mood, thoughts and perception can be profoundly altered using Hypnosis which by-passes consciousness. Experience of consciousness is a passive accompaniment to non-conscious processes, much the same way as rainbows are to meteorological phenomena.

# MOOC Review: The Biology of Consciousness by Christof Koch

Consciousness is one of the top puzzles of modern science and philosophy. Everything we study in science is objective and has physical properties, but consciousness seems to be an exception. It is subjective, it feels like something to be conscious. Each conscious agent has private, privileged access to his own inner experience which is not available to others. A person can report his pain, but we cannot see his pain and analyze it like a material thing. But mysteriously still, the mental and physical can interact, we can tamper with consciousness by tampering with a person’s physical brain.

The great mystery has me hooked for quite some time and I have been reading books by leading philosophers like Dennett, Thomas Nagel, Chalmers and Searle. This course is a bit different, more scientific than philosophical. It is a short introduction to the biology of Consciousness along with a brief primer about Integrated Information Theory.

The course, called Master Class, is offered by World Science U. I am a big fan of the content they offer, in particular, on Physics. The quality of their courses with animations and interactive content is just amazing.

Following are some of the topics covered by Professor Christof Koch:

• Why is consciousness a mystery to modern science?
• Understand what we mean by Consciousness
• Neural Correlates of Consciousness
• Integrated Information Theory of Consciousness

# Connecting Hyper-V Virtual Machine to Wireless network and Internet on Windows 10

Connecting Hyper-V virtual machines to the wireless network adapter can be a painful experience. I was wondering why it is so hard and poorly documented. As explained here, probably the reason is that the product is primarily targeted for servers where we always have wired networks.

To connect the VM to the wireless network, we have to create a virtual switch. There are two types of virtual switches: Internal and External. I initially managed to get it to work with the internal switch, but it stopped working after some time. External Virtual Switch has more chances of working based on what I gathered from blogs on this topic. It did work for me but after some effort as I was getting the following error:

`Error applying virtual switch properties changes (catastrophic failure)`

I was able to overcome this by running the following on Command Prompt (Admin Mode).

`netcfg -d`

Please run this command at your own risk as it will reset your host network connections. You will be disconnected from network and security key will be required for reconnection.

After resetting the network connections using above command, I followed the steps for creating external switch and it worked.

#### Internal Virtual Switch

Internal switch configuration requires minimum changes to the host network settings and it doesn’t expose your guest machine to the internet. But it may or may be work for your system configuration.

Another way of making internal switch work is described here, but it didn’t work for me.

#### External Virtual Switch

The external option requires more changes to the network settings. Instructions for setting up external virtual switch can be found here.

# Mind Mate: Taking Notes with rich text support

Today, I released a new version (0.4) of Mind Mate on GitHub. The chief improvement is the rich text editing capabilities for notes as demonstrated below.

When the focus is inside Note Editor, the ribbon switches to following Contextual tab.

If the cursor is inside a table, ‘Table Tools’ contextual tab becomes available.

So, following are now supported in Note editor:

• Bold, Italic, Underline and Strikethrough
• Subscript and Superscript
• Text Color and Highlight
• Font Family and Size
• Bullets and Numbered Lists
• Text Alignment and Indent / Outdent
• Clear Formatting
• Insert Table
• Table Tools
• Insert Row (above, below)
• Insert Column (left, right)
• Delete Row, Column or Table
• Move Row (up, down)
• Move Column (left, right)

# BusinessObjects Universe Design Tool: Each calculated column must have an explicit name

In SAP BusinessObjects Universe Design Tool, you might get the following error – “Each calculated column must have an explicit name”.

Each though the query runs fine in the underlying database, but Universe Design Tool doesn’t accept it. The reason is it expects ‘AS’ keyword between the calculated column and it’s alias. So that query should be re-written as:

```select to_char(statusdate, 'DD-MMM-YYYY') as datetext
from person```

# CodeSchool courses on JavaScript Frameworks

CodeSchool is a great site for introductory programming courses. With all guides and practice exercises available right within the browser, it is a hassle-free way to start learning. The design of the site is also very pleasing which enhances the overall experience.

Recently, CodeSchool offered a free weekend pass to all their content. I took the opportunity to brush up my skills on the new version of Angular and also quickly went through the React course.

Course Link: Accelerating through Angular 2

Course Link: Powering Up with React

# Run MySql without installation

I have been looking for a portable version MySql database which I can just copy on my machine and start using with installation. It took a little bit of effort to make it work.

Here are the steps I performed for running MySql without going through installation process (noinstall):

2. Unzip the archive and go to the bin folder.
3. Initialize MySql database: Run the following on Command Prompt (cmd) while being in the bin folder. This creates data folder with database files.
`mysqld --initialize`
`mysqld --console --skip-grant-tables`
5. Reset password for root user
• Run mysql.exe (MySql client) from the bin folder. This will take you to a prompt (mysql>).
• Tell the server to load the grant tables so that account management statements work (They are not loaded due –skip-grant-tables parameter to server).
`mysql> FLUSH PRIVILEGES;`
•

On mysql prompt (mysql>), run the following queries to reset the root password (one of the following will work depending on your version)

• `ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';`
• `SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');`
• ```UPDATE mysql.user SET authentication_string = PASSWORD('MyNewPass') WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;```
6. Restart server in normal mode.
`mysqld --console`
7. Connect using client
`mysql -u root -p`

Enter the password (MyNewPass) when prompted

8. Execute your queries on mysql prompt (mysql>).

Please note that this works for version 5.7, but may or may not apply to other versions.

In order to connect to MySql from the application, download the relevant connector from MySql Connectors. For instance, JDBC driver (connector) for connecting from Java application is available at Connector/J.