Sunday, 19 May 2019

Internet Protocols

Basically protocols are the backbone of how the internet works. The thing is that protocols are what you could consider to be a set of standards that everybody follows. I'm not sure if law is the way that you could describe it, procedure is probably a better word. Look, you could do things differently if you really wanted to but in the end your system, unless it is adopted by everybody, simply won't work. You get that in a corporate or office environment - the company has their specific procedures, and if you don't follow those procedures it isn't as if you are going to cause any actual damage, it is just that things won't get done as efficiently as normal - actually, that is probably a bad example considering some company's protocols are pretty poorly designed and implemented, but I hope you understand what I mean - it is more procedure as opposed to law.

The internet has actually been around for quite a while - dating back to 1969 when the United States Department of Defense wanted to develop a way to have computers speak to each other. Actually, the whole idea was to create a system where information could be distributed across a whole region and that the connections would provide a system of redundancy. You could say that it was to create something that could provide a failsafe against a nuclear attack, meaning that if one node was taken out, there would not only be backups, but the other nodes could continue to speak with each other and share information.

From this comes the TCP/IP protocols, or more specifically the Transport Control Protocol/Internet Protocol, and it is this that we will be looking at over these various posts. Mind you there are other protocols out there, but TCP/IP is the standard that basically our world wide web uses to enable you to order a pizza from that really awesome pizza shop on the other side of town (though whether they will actually deliver it to you is another story). Another protocol, UDP, or User Datagram Protocol, is also commonly used, but this protocol really only comes into play when we are doing something like a Facebook Live, namely because it is much more concerned with speed as opposed to accuracy.

Networks

In a nutshell a network is a collection of nodes that are connected by communication links. A node could basically be anything - well not anything because I'm not sure if you could turn a pineapple tree into a node, though honestly, with this internet of things revolution going on, pretty much anything is possible these days. However, in the traditional sense, a node could be anything computer related, such as a computer, a printer, or even a remote storage device. However, as mentioned, this revolution with the internet of things does mean that there are going to be many, many more devices being added to the network in the coming years.

So, we can split networks into three types: Local Area Networks (LAN), Medium Area Networks (MAN), and yes, Wide Area Networks (WAN). Local Area Networks really only exist within an organisation, and are probably referred to as being the Intranet, particularly if you are working for a largish company, as I used to. Generally LANs require access, whether it being physically present within the location, or being invited to use it from the outside. LANs tend to be connected to each other through the use of VPNs, or Virtual Private Networks. This is why many companies are now able to offer the ability for their employees to work from home. Mind you, these VPNs can actually be ridiculously slow at times.

Medium Area Networks sort of sit in the middle ground between the LAN and the WAN. The one major thing with regards to these networks (and this applies to LANs as well) is that they are incredibly fast. Sure, it may sound as if the internet in your local area may be a MAN, but the thing is that they don't actually rely upon the services of the local telephone company. One of the reasons is that with everybody using the service then congestion can be pretty high (try using the wi-fi in a hotel and you will know what I mean). They can be public networks, but can also be private, and generally appear in large corporations or even government entities. For instance, that free wi-fi that the local council offers is probably a MAN.

Finally we have the WAN, which could basically be the internet itself. Yet it might not actually be the case, because these networks are so huge that the mind itself boggles. For instance, the network used by a multi-national corporation could quite easily be a WAN. The thing with WANs is that they don't necessarily provide connection to the nodes across the internet - they might actually have their own private connections that they use, whether it be cable or even satellite (though satellite isn't all that reliable, you know, sunspots and all that).

So, these are the three network types, so let's finish off by looking at the OSI model.

Open Systems Interconnection (OSI) Model

The OSI model was created by the International Standards Organisation as a framework for providing a way for computers to be able to communicate with each other. The model works on the principle that each of the layers has its own functions to perform, and that any changes that occur in one layer will not concern any of the other layers. Basically, the layers will pass a packet down through them, and each of the layers add their own header until such a time that it is sent across the internet. Each of the layers are basically not concerned with what as gone on above, or what will go on below - they are only interested in the functions that occur in their own layer.

As data is passed down through a layer, the layer will add its own header to it, and when the receiver receives the data, each of the layers will strip off the header associated with it and then pass the data up to the next layer, until it reaches the top. Basically each layer relies on the lower layers to perform the more primitive functions, while each of the layers also provides services to the next higher layer. This diagram from my lecture notes may help explain it:

So, let us now go over each of the layers:

Application Layer: this is basically where the program that you are utilising sits. Say, you are sending an email, then the email program is what sits at the application layer, as does the browser that you may be using it through.

Presentation Layer: The data is turned into a human readable form in this layer, though on the way down it is where it is packaged into machine readable form. You could say it is also translation, but it also works to make it pretty. This layer is also where data is compressed to make it's journey across the internet much faster, and more efficient.

Session Layer: This is where each of the sessions are opened, maintained, and closed. It is probably not all that noticeable these days, but back when I was younger, when we would log onto a computer using programs like Telnet, these functions that opened a connection between my computer and the university server occurred at the session layer. In fact, I was doing this much more recently, when I would mount the server onto my computer to enable me to work on my assignments without having to download and upload on a way too regular basis.

Transport Layer: Now, this is where we start to get into the actual communication aspect of the internet. Where as the session layer establishes the connection, the transport layer is where the connection is maintained. Also, it is here that the data is divided into packets to be passed down through to the lower layers, and then across the internet.

Network Layer: It is here that the decisions are made as to where the packets are sent. Basically when a packet hits a node it is passed up to this layer where the ultimate destination is read, and it is then determined which node the packet will then be passed on to.

Data Link Layer: One of the problems with passing data through the internet is that they don't always arrive in the same way that they were sent. This layer is where the error control is handled and it is here where the package is determined whether there is an error or not. This layer is also where the medium access control is located, or the MAC address (more on that later, but every device has its own, unique MAC address).

Physical Layer: Needless to say this is where all of the wires and radio waves are located. However it is more than that because it is here where the transmission medium is decided, and also where the bits are translated into signals, whether it be a radio wave, or simply being passed through a copper, or optical wire.

Source: Understanding the Seven Layers of Computer Networking
The thing is that networks are incredibly complicated beasts, and are made up of routers, software, packages, links, and lots and lots of other things. This is why protocols are required because without them nothing would happen, and nothing would be passed through to another. As such, we wouldn't be able to book the doggy hotel for our pets, or order that drone from an electronics firm. For the internet to work, there needs to be co-operation.

So, this is where the TCP/IP model comes into play. While it is similar to the OSI model, there are new differences. TCP/IP is responsible for adding headers to data and to the packets. However, TCP is only implemented in the end systems, namely your computer and that Google server that you might be accessing to perform your search. The IP however is responsible for getting the data from one end system to the other, and is applied not only in the end systems, but also in all the routers in between. So, the TCP passes the data down to the IP and the IP passes it down to the network. The TCP will add a TCP header, which will turn the data into a TCP segment, and the IP will add an IP header to turn it into an IP datagram. Finally the network will add a network header to turn it into a network packet, which is then sent into the wild world of the internet.

This following diagram will explain the relationship to the two models.

So, that is the basics of the internet protocols. Next we will look at data transmission and sampling.

Creative Commons License
Internet Protocols by David Alfred Sarkies is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Saturday, 11 May 2019

Bestriding the World - Julius Caeser


Well, it seems that I simply cannot get away from watching Shakesperian plays, even if the production is, in my opinion, somewhat sub-par. I am starting to understand why a friend of my really hates going to Australian theatre. Okay, being a regular attendee at theatres of Broadway, and regularly traveling to the United States to go to Shakespeare festivals probably does that to you, and while I have never been to the States, I have been to London, and seen performances in the West End and at the Globe and honestly, these more modern adaptations are really starting to get to me.

I'm not necessarily talking about where the take the play and thrust it into a modern setting, as was the case with Ian McKellan's Richard III and Ralph Fiennes' Coriolanus. Even that version of Macbeth that I refer to as 'Macbeth with Machine Guns' where the quote 'til Birnam Wood remove to Dunsinae' was interpreted as a B-double pulling a trailer full of logs crashing through the gate of some drug lord's manner, only changed the setting as opposed to the actual style. However, as I sat in my seat, with a beer on my hand, watching this latest rendition of Julius Caesar, I could not help but feel that the director has decided to merge classical Shakespeare with modern dance.

Don't get me wrong, I absolutely love the play Julius Caeser, with the lines 'Cry havok and let slip the dogs of war' and 'friends, Romans, countrymen, lend me your ears', and in a way this production very much captialised upon these famous phrases. For instance, when Caeser turns around to see a dagger in Brutus' hand, he pauses, and says 'et tu Brutae'. With Mark Antony's speech, we have a raucous crowd banging on the walls after a rousing oration delivered by Brutus, only to be silenced with the magical words that come out of Mark Antony's mouth. Of course, we even have the beautiful oration delivered by Mark Antony, how he dares not malign Brutus and the other conspirators, but slowly wins them around by reminding them of what Caeser did for them, and that the whole idea of Brutus being an honourable man really means absolutely nothing.


Yet there was something wrong, something that seems to be moving away from the traditional style of play, even the minimalist style that must have been how they were originally performed (well, not quite considering even back in Shakespeare's day, elaborate sets and costumes were still very much the norm - Crash Course has an excellent series on the history of Theatre that is currently running). Sure, the play was very much minimalist with only a single prop on stage that would be moved slightly as the scene changed (it was a billboard on one side, and a pulpit on the other). Yet the actors basically wore modern clothes, and modern music would play in the background, and of course there was this interpretive dance that seemed to be performed as the conspirators piled onto Caeser.

While I would normally give a bit of a background, I don't think that really needs to be done with regards to Caeser. Anyway, I have written another post on this very play, based on another version performed by the Royal Shakespeare Company. Then there is the version from the Globe that is sitting in my cabinet waiting for a time when I can actually get around to watching it, so it isn't one of those plays that is rarely performed. However, I do wonder if there is really all that much more that I can actually say about it, at least more than I could write that hasn't already been said in two blog posts. Yet that is the beauty of Shakespeare - there is always something new to be discovered, something new to be explored, such as the garden in Hamlet that I never picked up previously.

However, as for Caeser's life, here is a great video I found on Youtube, presented by one of the platform's great presenters - Simon Whistler:



Okay, there really isn't much in the way of indepth analysis of the man, just an outline of his life, and not much in the way of the legacy that he left, but they still give us a pretty decent outline of who he was, and I even learnt a number of things about Caeser that I never realised, such as the phrase 'Veni, Vidi, Vici' wasn't said after he conquered Gaul but rather after he put down a rebellion in Asia Minor. Still, this does provide us with a pretty interesting background to the man.

Beware the ides of March

Honestly, despite the fact that Caeser basically dies halfway through the play doesn't mean that he is relegated to the outer wings - he dominates the play from beginning to end. In fact the play is divided into two parts, the first being the conspirators plotting to bring about his downfall, and the second part being his friends seeking revenge for his murder. In fact it seems as if Caeser himself doesn't make all that many appearances in the play, except for the middle where he is led by Crassus from his house to the Senate, and then murdered in the Senate. Yet the play focuses upon this one man almost like a laser light - there are no side plots, no other characters playing around outside of the main focus of his murder - the play is about Julius Caeser and the one person that we are constantly focusing on is Julius Caeser. Even when he isn't on stage, he is still the main focus of the play.

Which is interesting in this particular production since in the original, just prior to the battle, the ghost of Caeser makes an appearance. However in this production the ghost doesn't enter and leave, but he remains right through to the end, even being given speaking parts. In fact the downfall of both Brutus and Crassus are done in sight of the ghost, and even speaking with the ghost. Interestingly, where Brutus stabs Caeser, in the end Brutus holds out his dagger to Caeser so that Caeser may stab him, despite the fact that Caeser is dead.


Then we can't forget the scene where he is offered the crown three times, and rejects the crown three times. That is not played in front of us, but behind the scenes. All we get is a retelling of the events by one of the conspiritors, and another retelling by Mark Antony at the funeral oration. Okay, we hear shouts from outside, but we do not see it. This is an interesting tactic that Shakespeare uses because when we compare the two accounts of the event they couldn't be any different. Mark Anthony does not mention that Caeser had a fit after the third time he was offered the crown, nor does he make mention of the suggestion that Caeser, every time the crown was offered to him, was less reluctant to take it. In a way, looking back at that scene, it makes us cast doubt on the conspirator's account.

He Stride's the World like a Collossus

Isn't it interesting that it is Brutus that is portrayed as the bad guy here, and not Crassus, despite the fact that it is Crassus that is clearly the leader of the conspirators. In a sense, while Crassus could be considered a villain, Brutus is still a traitor, and the worse kind if Dante is to be believed. However, we will get to Brutus soon enough because I really want to say a few things about Crassus here, since he seems to be one of those characters that is particularly important, but seems to fall into Brutus' shadow.

This is not surprising considering that Crassus is one of the patricians, or the old guard to put it another way. He is basically one of the wealthy elite, and like all conservatives, doesn't want to give too much power to the dirty masses (though remembering that this is Rome, so when we talk about dirty masses, we are talking about the poorer citizens - slaves don't count). Yet he is right about Caeser because Caeser is an autocrat. He really doesn't like ruling with anybody, one of the things about the Roman Republic was the desire not to return to the days of the kings, even though that was something like 400 years ago at this stage.


Yet is it right for Crassus to act the way that he does. In a way it is politics, but then again there is this idea that if there is a threat to liberty then violence is a legitimate means in which to maintain that liberty. However, sometimes I feel that the word Freedom is tossed around so much that it's meaning has become lost in the mists of history. What exactly is freedom, and what type of freedom are people talking about - freedom from government interference in our lives, freedom to live the lifestyle that we desire to live, or freedom for business to do business without the government getting in the way. When the conspirators painted 'Freedom' on the board in Caeser's blood after the assassination, I could not help but think that it was a loaded word.

Yet Caeser was an autocrat - there is no denying that. It does not matter whether you are supported by the people or not, and autocrat is still an autocrat. Yet, no matter what the laws say, I still don't think murdering somebody can be justified, no matter what tradition says. Yet this seems to be what Shakespeare is getting at here, because throughout most of his plays, the usurpers never come out on top. This is the case here because the play does not end with Caeser's death, the play ends with the death of the conspirators.

I should say something about Brutus though, however I have already spoken at length about him in my previous blog post. Sure, he is the tragic figure of the play, being torn between his friendship with Caeser and to the legacy of his ancestors. However, he has gone down in history as being one of the greatest of traitors. Dante puts him at the bottom layer of hell along with Judas Iscariot. It is not that be betrayed his country, it is that be betrayed his friend, and not only that, but he even went as far as murdering him. No wonder Brutus couldn't sleep afterwards. In way the name Marcus Brutus is also synonymous with Benedict Arnold.

Friend's, Roman's, Countrymen

And I will finish this off by speaking something of Mark Antony. It is interesting how he is portrayed in this play when in reality Antony was little more than a thug. Sure, I doubt we can really trust Cicero's second Phillipic, which really goes to town on Mark Antony, but I still remember watching a television series on this turbulent period, and Mark Antony really wasn't portrayed in all that great a light. However, Shakespeare doesn't seem to be too concerned about that, instead painting him as a loyal side kick, and one who goes to extreme lengths to revenge his friend's death.

I note that Augustus (actually Octavius) appears in the second half of the play, and accompanies Mark Antony on his crusade against the conspirators. However, he is still playing a minor part at this stage. There is no indication of the power he is to obtain once he disposes of Mark Antony and names himself as Imperator. Here it seems to be taking the position of Antony's side kick, but that isn't all that surprising considering that it was Antony's brilliant speech that rallied the people of Rome to his side. In fact it did much more than that, considering that Shakespeare throws in that scene where the poet Casca is murdered simply for having the same name as a conspirator.

Yet I still can't get it out of my head that Mark Antony is nowhere near as glamorous as he is made out to be here. He isn't a hero, he's a thug, one who almost ran Rome into the ground in Caeser's absence. Okay, it has been over twenty Years since I've read Cicero's Phillipic (actually probably not that long, but it has been a long time), and I suspect that there just might be a lot of truth in what Cicero has to say.

Creative Commons License

Bestriding the World - Julius Caeser by David Alfred Sarkies is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. This license only applies to the text and any image that is within the public domain. Any images or videos that are the subject of copyright are not covered by this license. Use of these images are for illustrative purposes only are are not intended to assert ownership. If you wish to use this work commercially please feel free to contact me

Saturday, 4 May 2019

Digital Signatures

You know, I must be getting old because I was about to open this post with the words 'back in the day'. The thing is though that I'm not really all that sure if signatures are used as much as they used to be used. These days when it comes to banking transactions we have Personal Identification Numbers, but when I was younger what we had were this little squiggles that we would put at the bottom of a paper as a way so saying either 'I wrote this' or 'I assent to this'. Actually, having been over seas, I have noticed that for some reason when I pay using a credit card I still have to sign the little piece of paper that is spat out of the machine as a means of confirming that I assent to this transaction.

However the problem is that signatures can be forged. The other problem is that when somebody signs something the signature might not be exactly the same, and depending on the person who is requesting the signature, they might either make you jump through hoops to prove that you are who you say you are, or they might handover $1000.00 to the guy who stole your card because, well, they are simply too lazy to check.

So, how does that apply to computer security you ask? Well, we have signatures in the digital world as well, known as digital signatures, and they work similarly to the encryption techniques we looked at previously. However, there is a slight difference. Were a message is encrypted using a public key, and decrypted using a private key, the digital signature is signed using a private key, and verified using a public key. Basically, like the signature that I carried on about above, a digital signature is a means of verifying that you have assented, or sent, something. In fact, that pin number you have to remember for your bank card could quite well be the private key that is used to generate a digital signature that authenticates the purchase, or withdrawal.

In fact, this diagram from the lecture notes is a good explanation of how it works:

Like real world signatures, only the person to whom the signature relates should be capable of actually generating the signature. Another thing is that the document that is signed is usually placed into the signature in the form of a hash as another means of verification.

There are a few ways of generating a digital signature, but we will only look at two of them: RSA and El-Gamal (though this will be the theoretical math component - I'll run through all of what we have done here in a more practical way in a later post, using the Linux terminal of course). Of course, the process in generating a signature is as follows:

  • Sender sets the parameters and generates the public and private keys
  • Sender uses the private key to sign the message
  • Receiver uses the public key to verify the message

RSA Signatures

So, we have a situation where Captain Ed Mercer wants to send an order to the crew of the Orville. Now, as a part of the protocol Ed must sign all of the orders using his digital signature. So, first of all, Ed picks two prime numbers p=17 and q=11. He then generates n by the following method: n=p*q = 187. Ed then calculates φ(n) = (p-1)*(q-1) = 160. Finally Ed picks a number e that is co-prime with φ(n) and that 1 <e < φ(n). Being co-prime, as we remember, means that GCD(φ(n),e) = 1, so Ed picks e=7.



Now that we have all the numbers, Ed sends the public key n and e to the crew of the Orville. Ed then generates the private key d, where d*e = 1 mod φ(n). In this instance d=23, which he retains.

Ed signs the message m=33 as follows:

s = md mod n = 3323 mod 187 = 11.

Now that Ed has his signature, he signs his order and sends it to the crew of the Orville.

Commander Kelly Greyson, who happens to be Ed's 2IC, receives the signed message, and must now verify the message. She does so as follows:

m' = se mod n = 117 mod 187 = 88.

So, the order has been verified, so Kelly passes the order on to the crew.

El-Gamal

Well, it turns out that central command has decided that using RSA for a signature isn't all that secure, and since they are a military outfit, they decided that they will use El-Gamal instead.

So, in this instance, Ed the prime p=11 and the generator g=2, and the private key parameter x=8. Ed then generates the public key y using the following:

y=gx mod p = 28 mod 11 = 3.

Now that Ed has the public key, he sends it through to the Orville.

For the private key, Ed needs to select k where 1 ≼ k  ≼ p-2 where k is co-prime with p-1, or GCD(k,p-1) = 1. Ed decides that k=9 satisfies this criteria. However, it isn't over yet because Ed now needs to generate r as follows:

r=gk mod p = 29 mod 11 = 6

And then sign the message m=5:

s= k-1 (m - x*r) mod (p-1) = 9-1 (-43) mod (10) = 3.

Now that he has the signature s=3, he sends the order to the Orville.

Once again, Kelly receives the order and must verify that it comes from Ed. She does so as follows:

v = gm mod p = 25 mod 11 = 10
w = yr * rs mod p = 38 * 63 mod 11 = 10.

Now, to verify the message, v must equal w, ie: v=w. In this case v=10 and w=10, so the signature has been authenticated.



Now, the reason this provides integrity is because the message m and the signature s are sent together. Now, if the message fails but the signature is okay, then the message has been tampered with, however if the message is okay, but the signature fails, then the signature has been tampered with.

Another thing that signatures provide is non-repudiation. Basically since you are the only one who has the private key, then if you sign a message and send it out you can't then go back on your word. This makes it better than a physical signature, particularly with regards to the concerns over such a signature being forged - in this instance the only way for somebody to forge your signature is to steal your private key.

However, it should be pointed out that we shouldn't be using the same key pair to sign and authenticate a message, and also encrypt the said message. The reason for this is that our hacker could trick us into decrypting a message. For instance, if our hacker sends us a message that they intercepted and requests that it be signed, since we are signing with the private key, we might also be decrypting the message, which means that when we return the message it will actually be plain text.

Digital Certificates

These are certificates that are issues by a trusted third party, such as Verisign. The certificate basically guarantees your authenticity, and in fact are used on a lot of websites. Basically if the certificate is valid, then your browser will allow you to access the site, but if it isn't valid then it was kick up a stick and refuse access (though you can always override it, but not always).

The digital certificate must have the name of the holder, and a public key, but to be helpful it should also be signed by the trusted third party. Beyond that the certificate can pretty much hold anything, though if it has too much information on it, then if any of that information changes a new certificate needs to be issued.


Creative Commons License

This work by Digital Signatures is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Based on a work at http://www.sarkology.net/. This license only applies to the text and any image that is within the public domain. Any images or videos that are the subject of copyright are not covered by this license. Use of these images are for illustrative purposes only are are not intended to assert ownership. If you wish to use this work commercially please feel free to contact me

Sunday, 28 April 2019

Intro to Data Comms

The proper title of this subject is Data Communications and Net-centric computing, and a lot of people shortened the title to DCNC. Honestly, I didn't particularly think all that much about that, so instead I simply referred to it as data comms. Anyway, you know how we seem to magically be able to connect to a computer on the other side of the world and be able to access the information on that computer almost instantaneously. Well, this subject is designed to actually demystify all of that technobabble and actually demonstrate how it is done. Mind you, one of the reasons that we are able to access Netflix has more to do with there being a server here in Australia as opposed to actually downloading the information directly from the United States. One of the reasons that this isn't all that feasible, despite this information traveling at, or at least pretty close to, the speed of light has something to do with there not actually being a direct cable between Australia and the US.

Here is a map of where all of the submarine cables are located across the world that enable us to be interconnected in a way that we haven't been before. Oh, and before you ask, satellite transmission is so painfully slow that we simply don't bother with it, despite the fact that once again the signals travel at, or at least pretty close to, the speed of light.


Bell's Invention

So, let's consider a little history here. Sure, we could say that Alexander Graham Bell 'invented' the telephone, but honestly, people were sending messages electronically long before he made that famous call to the guy in the next room. The thing is that before the telephone there was the telegraph, which was used to transmit messages across long distances. Before that, with the exception of the Greeks (or was it the Persians) using bonfires to transmit messages, the fastest way to send a message from one place to another was by horse. Actually, the United States had this method known as the Pony Express, where a rider would ride a certain distance, and when he reached a checkpoint, he would hand the parcel to a much more rested horse and rider. Still, that was a pretty slow way of transmitting messages.

Now we have the telephone. The way the telephone works (and after I discovered this I can never look at that device the same again) is that there is a diaphragm in the speaker that vibrates when you speak. The vibration then causes a circuit to connect, though the strength of the circuit will depend upon the strength of the diaphragm hitting the circuit. This is how our voice is modulated into an electronic signal. The signal then travels down a wire, through a system known as the PTSN, or public telephone switching network, to the destination. The electric pulses will then hit a magnet which will grow strong and weak based upon the strength of the signal hitting it. This magnet will cause another diaphragm to vibrate, and this vibration, not surprisingly, produces sound. In fact the sound that is produced is a replication of the sound that was originally spoken into the telephone.

The other thing is how the telephone actually knows where to connect to. Well, originally you would have to dial the switch board and tell the operator who you wanted to connect to. When I was young we had these rotary phones, and later push button phones (which is why we use the term 'to dial a number', and the term 'ring' comes from the fact that a bell in the phone would ring when we called somebody - much different to the Beyonce that comes out of our modern phones). Each of the numbers would take a certain amount of time for the dial to return to its previous spot, and that length would tell the operator, and later the computer, the number that was requested. Put them all together and you get a telephone number. This was similar to the push button phones, except each of the buttons would send a signal down the line that was slightly different to the others. When the signal reached the exchange, the computer would interpret these signals and work out the number that was wanted.

Another thing with the phone number is that it is divided into sections - take this phone number 08 8245 2212. The first two digits is the area code (this is an Australian phone number), and tells the exchange which state they want. The next four numbers (originally it was three, but we run out of numbers so added another number to the front) tells the exchange what exchange is wanted. The last for digits is the actual number of the phone that is being dialed.

The thing is that this world is analog in nature, but computers, or at least the computers that we are currently using, really only understand the world as a series of 0s and 1s (or ons and offs, or true and false, but you get the idea). So the trick here is basically attempting to translate what is in effect analog, or continuous, into digital, or discrete.



Sine Waves

So, this is a sine wave, or more appropriately a sinusoidal wave.


I would have pulled the pictures from the notes to show how the sine wave comes from a circle, that is pulled apart and then placed along an axis (which is what is above) but the video below is so much better.


So, the sine wave is basically a continuous line that goes up and down. The wave is made up of a crest, the section above the x-axis, which is the time axis, and the trough which is the area below the x-axis. The peak to peak amplitude is the distance from the bottom of the trough to the top of the peak, and one whole cycle, namely the amount of time it takes for the wave to go to each of the peak and the trough and back to its original position (even if the original position is at one of the peaks) is known as the wavelength.

A sine wave can be rendered mathematically as follows:

x(t) = A.sin(2.π.f.t + φ)

Now, we can reduce that by including the angular frequency, which is:

ω = 2.π.f

so, the formula becomes:

 x(t) = A.sin(ω.t + φ)

The following values are as follows:

A = amplitude
f = frequency
t= time (in seconds) 
φ = phase (in radians)
ω= angular momentum
Π = pi, a constant, of 3.14 (though it is an irrational number, meaning that it goes on forever).

So, the amplitude is the y-axis, and is usually measured in volts.
The frequency is measured as the number of wavelengths in one second. The phase is determined by how far along the x-axis the intersection is (that is where the amplitude is 0). A phase of 0 is where the wave starts at t=0 and A=0 (and goes up)..

Let us put that into practice by looking at some sine waves:

So, looking at this we can see that the peak of the waves (or both of them) is 2, so A=2. It takes 100 ms to complete one entire wavelength, so that means that there are 10 waves in a second, so the frequency is 10. With regards to the red wave, the wave begins at t=0, so the phase is 0. The angular momentum, which is 2πf is 2* 3.14*10 = 62.8.

So, plotting the red wave into the formula, we get v1(t) = 2sin(62.8t), and φ=0.

Now that we have the details of the first, red, wave we can calculate the details of the second wave. To do that we need to work out the change, so:

φ = -2π 🛆t/T

Now, 🛆t is the change, and T is the time for one wave length we can work out the change, namely because we have a reference point, so 🛆t = 70-50 = 20. T=100, and we can convert 2π into degrees easily enough, since it will be 360o. So, we have φ = -360*20/100 = -7200/100 = -72o. So, we now know that the phase is -72 degrees.

This, the mathematical formula for our second wave is v2(t) = 2 sin(62.8t - 72).

Now that we have played around with a hypothetical sine way, let us take this into the real world and work out the instantaneous voltage of power supply in Australia. Now, we have two types: AC, or alternating current, and DC, or direct current. Direct current doesn't change (and operates at 230v) so at any point along the time axis the instantaneous voltage will always be 230v.




For alternating current, that is somewhat different. The frequency is 50 hz (that is 50 cycles per second). However, the voltage is 230v, though this isn't the peak voltage, but the root mean square. To find the peak voltage, we use the following equation:

Vp = Vrms(√2/2)

Yep, we have that ugly number there. So, Vp = 230*(√2/2) which gives us approximately 325 volts.

Now that we have the amplitude, we can plug all the values in.

V(t) = 325 sin (314t)

The phase is 0, so all we need to do to work out the instantaneous voltage is add in the time.

At 0s, V(t) = 325 sin (314*0) = 0v.

At 10ms, V(t) = 325 sin ([314rad/s][0.01s]) =  -200V

Anyway, enough of this and lets move onto something different, namely Internet Protocols.
Creative Commons License

Intro to Data Comms by David Alfred Sarkies is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. This license only applies to the text and any image that is within the public domain. Any images or videos that are the subject of copyright are not covered by this license. Use of these images are for illustrative purposes only are are not intended to assert ownership. If you wish to use this work commercially please feel free to contact me

Monday, 22 April 2019

Live, Die, Repeat - The Edge of Tomorrow

Edge of Tomorrow

2014
Emily Blunt, Tom Cruise
Directed by: Doug Liman
IMDB: 7.9/10 Rotten Tomatoes: 90%

This film actually has two names, and I'm not sure why they changed its name to Live, Die, Repeat so late in the piece (namely when the Blue-Ray was released) especially since I didn't actually have a problem with the original name (though there are probably reasons that I am not aware of that prompted the change). Okay, it is a Tom Cruise movie, and while I would generally say that I basically tolerate him, he still seems to find himself in some really cool movies, such as this one.

Anyway, the movie is based on a Manga comic, which in turn is based on a Japanese short novel called All You Need is Kill. The story line is basically the same, but there are a number of differences, such as the novel being set in Japan (and Florida), and the aliens looking, well, rather dull in the novel. If there is one thing that is really cool about aliens in Hollywood, and that is that they can make them look really cool, and they definitely do this here. In fact as time moves on the aliens seems to become much more, well, alien, which I think is a good thing, but then again we can probably thank CGI for that.


Synopsis

So, I would basically call this film 'Ground-hog Day with Guns' though that is probably putting it lightly. I'm sure (or I hope we are) familiar with that awesome 80s film where Bill Murry lives the same day over and over again, until he realises that he is, well, basically a jerk, and changes. This isn't so much the case with this film though. Well, sort of. The film opens with Tom Cruise, or Major Cage, landing in London. He is a PR rep for the American Army and he has been loaned to the British Army for their operations (though the army is known here as the United Defense Force).

What has happened is that a meteor has struck the Earth near Hamburg and released a horde of Aliens across Europe. They have basically decimated the continent and are now preparing to cross the Channel and invade London. However, a young cadet has recently proved her worth in the battle of Verdun, and the humans are lead to believe that they may have a chance at beating these aliens. So, they form a huge invasion force, and decide to strike at the coast of France. The problem is that this invasion is a complete failure, the force is completely destroyed, and the next day the aliens invade London.



Well, this is where the interesting part of the film comes in, sort of. Cruise is ordered to go and do his PR on the beachhead, which he objects to, says a few things to the General who is a little upset, busts him down to private, and throws him into the fray. Well, while he may be a major, the one thing that he doesn't have is combat skills, so he lands up on the beach with no idea on how to operate his weapon, and is eventually killed by one of the aliens. However, before he is killed, he managed to wound the alien (he works out how to use the weapon), and is splattered with the alien's blood. He then wakes up, in the morning, and discovers that he is repeating the entire day.

Anyway, before I continue, here is the trailer, for those who are interested.


Normandy All Over Again

I guess the thing that stood out in this film at first was that even from the trailers it was very clear that the beach landing was representative of the Normandy landings during World War II. Actually, when we have a look at the map of the region that the aliens have conquered, it also appears to be reflective of what was conquered during World War II. This is interesting because many of the great wars of Europe have all had the goal of turning Europe into a Fortress, or at least this was what happened during the Napoleonic Wars, and also World War II. There has been a lot said about how England was protected by her moat, and in many cases she was. Theoretically she has not been successfully invaded since the conquests of William. Okay, there was the Glorious Revolution of 1689, but one can argue that the reason this invasion was a success had more to do with the Dutch being invited by the English, or at least the English who didn't particularly like the Stewarts, to come and take the crown.

Yet the opposite is also true. Both Napoleon and Hitler worked the fact that once they had control of Europe, they could pretty much prevent the English from establishing a foothold. Sure, Napoleon was also attempting to starve English commercialism by denying them any European markets, and technically this was also the case with Napoleon. Notice how that the English landings in both wars occurred after the respective dictators failed campaign against the Russians. In fact, it was only after Napoleon was routed in Russia that the tables finally turned against them. As for the Nazi's, while the invasion was a success (and technically it was a two pronged invasion as the Allies were also invading from the Mediterranean since Italy was the weakest link, but even then this involved a rather difficult invasion of Morocco) it certainly didn't come without a huge cost.

The best map I could find, but not really representative.
I guess this is reflective of the difficulties that the UDF is facing in the film in that the Aliens have pretty much conquered Europe, and this invasion is a last ditch effort to attempt to turn the tide. Well, they have also been heartened by an apparent victory in Verdun, which has created its own problems, but it has been suggested in the film that this was actually a set up by the aliens to attempt to lure all of the UDF troops into France for one final victory.

Another thing, London has always been pictured as the last outpost of civilisation in such times. In fact, it is interesting that Orwell, in 1984, has Airstrip One, or the British Isles, as a separate from Eurasia. It is almost as if Britain, once the centre of an empire, has now become an outpost of the Anglo-American empire. In a way this seems to be the way it stands now. There actually seems to be much more in common between the British and the Americans (and in turn the Australians) than is the case in Europe. The fact that both countries seem to be attempting to dismantle their public healthcare systems in favour of an American style private healthcare system seems to reflect that (though apparently there still isn't such a thing as a private hospital in England).

The Fifth Dimension

Okay, my Dad, who happens to have studied physics at university (and has a doctrate in the subject) really doesn't think all that much on this idea that there are more dimensions beyond the main three. While I'm not so much a physicist, I can sort of understand where he is coming from, particularly since much of these ideas are speculative, and really only exist to attempt to solve problems that many of the modern theories have created. In a way I can appreciate this, since we are basically speculating when it comes to the idea of string theory and all that. Anyway, apparently there are something like ten dimensions, and this video, if you can get your head around the concepts, and attempts to explain them.

Anyway, for our purposes we will only be looking at two of these dimensions, namely the forth and the fifth, namely because they tend to be linked (well, sort of). If time happens to be the forth dimension, the probability turns out to be the fifth. Basically this means that if one were to travel back in time (if it is possible in the first place), and changes something (and the fact that one has traveled back in time pretty much suggests that everything has been changed anyway), then a completely different time line peels off. Basically the fifth dimension is inhabited by the infinite numbers of different universes that have been created by the infinite numbers of different choices that people have made.
A cube with 5 dimensions
So, what has happened in the film is that the aliens have this ability to be able to travel in the fifth dimension, meaning that they are able to see all of the different outcomes of all of the different choices, and pretty much travel along the path that leads to the best outcome for them. However, there is a bit of a catch, because if this was the case, then why haven't the aliens pretty much annihilated the Earth in the time between the initial landing, and this invasion. Surely they know the best path to take, so why haven't they taken it?

The idea is that the aliens are able to reset each of the days, and make different choices, and this has pretty much made them unbeatable. Once again, there is this idea of not knowing which timeline we are traveling down, and it seems that the aliens have already reset the days enough so that we are pretty much trapped in one strand of the dimension. However, the aliens didn't realise that a human could become infected with their blood, and suddenly also be able to reset the day.

Breaking the Fifth Dimension

Okay, there is a video that goes into a lot more details on the problems with the film than I do, but then again this guy does use an awful lot of sarcasm in his Youtube videos.


However, I guess if we took this too seriously, and followed some of these ideas, then we probably wouldn't actually have a film. However, if the aliens are able to see the various courses of history, then surely they would have seen the chance that one of the humans would become infected and also start repeating days, and acted to prevent this. Of course, they might have known this, but then had issues with actually finding a timeline where this doesn't actually happen so as to avoid it. Maybe this is why only two people actually became infected as opposed to a lot more. In fact, maybe this is the soft underbelly of the aliens that needs to be exploited.

Not surprisingly, nobody actually believes Cage, or his friend, that what is happening is actually happening. Then again, she is also under-estimating Cage's PR skills, as is the case in the various other scenes where he is able to get his way into the general's office, and then get the device off of him. Yet there is also another slight problem, because if this day is now pretty much set, meaning that every time Cage dies, he goes back to the beginning of this one day, then quite possibly everything happens in way it is supposed to happen, with the exception of the various choices that Cage and his partner are able to make.

In a way time has now been set, yet once one understands what is happening, one is suddenly free to make alternate suggestions that will basically change the course of history. Foreknowledge is a very, very powerful thing. Except there is one little catch - that alien that Cage killed is still on that beach, and Cage knows exactly where that alien is, so why hasn't he used that knowledge to then infect his partner in crime, and then in turn the other guys in his platoon (particularly the guy that insists on going into battle naked, with the exception of his power armour).



Well, maybe the problem is that it won't actually work. You see, if the day resets for Cage, then all of a sudden he is back to square one, which means his partner, or anybody else in the squad, are also back to square one. Sure, in their timeline, both them, and Cage, are affected, but that is a timeline that has now broken off from the current Cage's timeline, and he simply can't traverse the fifth dimension - he is only stuck in a continual time loop. In fact he can't even traverse the forth dimension, with the exception of being able to loop back to the beginning of that single day.

Yet, this could be easily changed by infecting everybody in the group at the same time, including reinfecting Cage himself. However, the problem then arises that, well, they happen to be in the middle of a war zone, and these aliens, the Mimics, really don't seem to be the types of creatures that can easily be captured. Yet, one would think that maybe, just maybe, Cage could see the alternates to where he is able to actually capture the alpha, and then do his magic trick. Then again, there simply may not be enough time to do so. I guess that even with the infinite about of probabilities that the fifth dimension opens up, there are still some restrictions that are in place and there are certain impossible things that cannot occur.

Still, there would be some cool thing about being able to live in a repeated day, over and over again, yet I guess, like Bill Murray in Groundhog Day, that it gets to a point where you are literally driven insane so you steal the groundhog and drive off the cliff in a ute.

Edge of Tomorrow Poster: Wikipedia.
Mimic: Aliens.fandom 

 
Creative Commons License

Live, Die, Repeat - The Edge of Tomorrow by David Alfred Sarkies is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. This license only applies to the text and any image that is within the public domain. Any images or videos that are the subject of copyright are not covered by this license. Use of these images are for illustrative purposes only are are not intended to assert ownership. If you wish to use this work commercially please feel free to contact me

Sunday, 14 April 2019

Using the Cloud - Preserving Privacy

One thing is that many of us really don't see much beyond the time when we enter our username and password into a website and then go about our normal business. Sure, every so often we hear about how a website has been hacked and data stolen, but generally many of us don't give much of a thought about how, or even if, our data is secure. This is very much the case now with the cloud, particularly since the cloud is able to provide much more computing power, at a much cheaper price, than either our personal desktops, or even the company server. However, while the cloud might be pretty powerful, we need a way of being able to use it while maintaining the privacy of our information.

However privacy goes much further beyond making sure that people we don't want looking at our Facebook statuses and updates don't (though the solution to that is to basically not post anything at all) and to real information that many of us wouldn't want being made public - such as our medical records or our financial situation. The is where the concept of privacy preserving computations come into play. The thing with privacy is that if it is breached it could be used to commit fraud, or even worse, particularly if your medical records somehow land up in the hands of, say, your employer (who really should be allowed to have access to it anyway).

The other thing is that we have these companies that mine data - Facebook is a classic example. As one person suggested, if you are getting a service for free, then the product is you. The thing with this data mining is that it can be used to generate targeted advertising, or even worse. For instance, with the amount of personal information many of us post on Facebook, it is scarily easy for somebody to assume our identity. However, many applications are very data heavy, and need extra computing power to process the information, but the problem is that the cloud simply cannot be trusted. As such we need a way of using the cloud, while maintaining our privacy.


So, basically we simply can't use the cloud to perform its functions on unsecured data because, well, there are privacy issues to take into account, and honestly, if the data is unsecured then pretty much anybody can look at it. However, we can't just encrypt the data because when it is encrypted then we simply are unable to do anything with it, except maybe to unencrypt it. So, what we need is a way to perform these functions and to perform them in the way that the data is, and remains, secure. The thing is that if we are encrypting the data, and then performing the operations on the data, it is also going to take longer, and require more power, so we will also need a way to distribute this workload.

What we thus need is a way to encrypt the data, send it into the cloud, have the cloud perform the function on the data, and then either return the result to us, or forward it to the third party. Now, we will basically be looking at how we can perform addition and multiplication, namely because all of mathematics boils down to these two concepts - well not quite because multiplication is actually a form of addition, though since we have methods of securely performing multiplication, we can include that as well.

Homomorphism

So, homomorphism is what is known in algebra as a structure preserving map, or in computer science the word algorithm is probably a better way of describing it. So, we have partially homomorphic proceedures, but we don't as yet have a full-homomorphic proceedure. For instance, RSA and El-Gamal can perform multiplication, but not addition while Pallier can perform addition, but not multiplication (which sort of doesn't really make sense since multiplication is basically an extension of addition). However, even if we did have a fully homomorphic proceedure, the problem would be the speed at which the operation is performed. The more complicated the operation, then the slower the procedure takes to complete. Actually, we do have some fully homomorphic schemes, but that are so slow that we might as well not bother with them and simply do the procedure by hand.

RSA Multiplication

Okay, let us have a look at some of these procedures in operation, beginning with RSA, which happens to be the easiest.

So, we have M1 = 3 and M2 = 4, and we want to multiply these numbers together. So, the public key n=33 and e = 7 and the private key d=3 are generated. Now that we have these, it is time to encrypt the message:

C1 = M1e mod n =  37 mod 33 = 9.
C2 = M2e mod n =  47 mod 33 = 16.

So, now that the values are encrypted, they are sent to the cloud where the numbers are multiplied, producing the answer 144. This is then sent to the receiver (whether it be the original computer or not), where the answer will be decrypted.

MA = CAd mod n = 1443 mod 33 = 12


El-Gamal Multiplication

Okay, that we pretty easy, but now it is time to move it up a notch and have a look at another process, this time using El-Gamal:

So, first of all we select a prime number, p, which in this situation will be 2879. We then select the generator g, which is 2585. Then we select the secret key x=47 and from there generate y, which is:

y= Gx mod p = 258547 mod 2879

The numbers that we want to add are then sent to two different servers (I never said that this was going to be easy) where the random numbers are chosen. Server 1 chooses r1 = 154 and Server 2 chooses r2 =96. They then encrypt m1= 5 and m2=6 as follows:

C11 = gr1 mod p = 2585154 mod 2879 = 1309
C12 = m1*yr1 mod p = 5*2585154 mod 2879 = 199

On server 2, we do a similar thing:

C21 = gr2 mod p = 258596 mod 2879 = 1138
C22 = m2*yr2 mod p = 6*258596 mod 2879 = 2433

Now that we have encrypted the data they are then sent into the cloud to perform the calculation.

C3 = C11*C21 mod p = 1309*1138 mod 2879 = 1199
C4 = C12*C22 mod p = 199*2433 mod 2879 = 495

Now that the functions have been performed we note that we still have two numbers, when in reality we are only looking for one. Well, obviously this isn't quite over, so we need to do something else. However this isn't done in the cloud, but rather it is performed on the client computer.

C4 mod p  = 495 mod 2879       = 30
C3x mod p    119947 mod 2879

So, MA = 30, which we will note is the correct answer.

If you thought that was a little complicated, let us move on to the final one, and that is addition with Pallier:

Pallier Addition

Well, we have the two numbers M1=4 and M2=1. Now for this to work we need some other numbers, so if you refer back to the post on Pallier, you will see how we derived them, but so as not to go over old ground, we will simply produce them as follows: p=5, q=7, n=35, 入 = 12, g=164, and μ = 23. We also need two random numbers, so we have r1=6 and r2=17.

Now, we encrypt the numbers using gmrn mod n2. This produces C1=416 and C2=127.

Now that we have encrypted the numbers, we can send them into the cloud to add them. Well, we aren't actually adding them, rather we are multiplying them, so C1*C2 = 416*127 = 52832, and this number is then sent to the receiver (whoever that may be) to be decoded.

So, by using the formula m = L(cλ mod n2)*μ mod n, where L(u) = (u-1)/n, we come back to the value of 5, which is 4+1.

In Action - E-Voting

Well, e-voting seems to be pretty controversial, particularly by the people who support the losing candidate. However, this is one area where this concept works, and that is the secure addition of numbers. Basically, when the vote is cast, it is sent into the cloud where the results are all compiled, and this is then sent down to the voting authority who will decrypt the data and thus produce the result. The thing is that because computers really are mysterious entities that seem to do things out of sight of prying eyes, people do get concerned over the authenticity of the result. For instance, here in Australia, votes are counted manually, and scrutineers from the various parties will be in the room making sure that the right vote for the right candidate is counted - this is something that isn't all that possible when it comes to electronic voting, though some would argue that this removes the need for scrutineers since ambiguity is something that can be done away with - you either push one button, or the other, you can't just sort of push it, but not.


In our example, we will have two candidates, say Hillary Clinton and Donald Trump. Well, in this instance we will only have five voters, just for simplicity's sake. Now, each of the votes is represented by a 4 bit number, so if you vote for Clinton, your vote will be 0100, which if you vote for Trump, your vote will be 0001. Now, When these votes are cast, they will be encrypted, and sent to the cloud where they are all added together. 


Basically, each of the voters has a private number, which is used to encrypt the vote. Once encrypted, the votes are collated in the cloud using the Pallier encryption system above, and the answer is then sent to the voting authority, where the result is decrypted. In this example, the result comes back as 14. Now, that doesn't actually mean anything, that is until we turn it into binary: 1110, which is then split in two to produce 11 for Hillary, and 10 for Donald. Thus Hillary got three votes while Donald only got two.

Well, we could easily say that Hillary was the winner, except that in the United States the election is determined by the electoral collage and not by a simple majority, so despite the fact that Hillary got more votes, Donald still wins because, well, that's just the way things happen.

There are other applications as well, such as electronic meter reading for electricity usage. Normally some guy just comes along, opens up a cabinet at the side of the house, reads the meter, makes a note of the reading, and then moves on. This method means that electricity usage can be monitored and read across the entire day, and we can also get more accurate readings and indications of usage. However, this type of information we don't want people to get hold of, because electricity usage charts can give people a pretty good idea of when somebody will be home, and when they won't.

Consider another option - say you have multiple bank accounts, and funds spread out across these accounts. Say then that you want to purchase something, and while you have the funds, you don't have the funds in a single account. As such, this system can access the bank accounts and tally up all of the amounts and then determine whether you have enough to purchase the item, all in the while not actually knowing how much is in each of the accounts.

This could so be used to store biometric data for security, or even protecting your location through the use of the GPS system (since all phones these days are GPS equipped). So, as you can see, this whole concept of being able to perform calculations in the cloud, or in fact doing anything in the cloud, requires there to be strong security, and in a way it does actually go beyond simply adding two numbers together.


Creative Commons License

Using the Cloud - Preserving Privacy by David Alfred Sarkies is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. This license only applies to the text and any image that is within the public domain. Any images or videos that are the subject of copyright are not covered by this license. Use of these images are for illustrative purposes only are are not intended to assert ownership. If you wish to use this work commercially please feel free to contact me