Public / Private Key Cryptography is the core that allows the Internet to function. If I must use the metaphor from IT Crowd – if there is any “Internet Box” – it is the hash & crypto math.
Use Cases
HTTPS / SSL
HTTPS/SSL allows any user to communicate with the servers – with a lot less chance of getting listened to or hacked. This opens the door for money transfer, commerce and many more use cases that require high security. After Snowden revealed that the secret agencies are spying and collecting data from all of us, the big internet companies forced on everybody – to use https. This does not secure the servers or the (mobile) devices, but – at least – while in transit – the information is encrypted.
Authentication (Universal Electronic Signatures)
You request Electronic Signatures from authorized and licensed certificate authorities. You give them a public key that you control and they sign it. The signatures usually have with some additional metadata for identification – like citizen or corporation ID. Countries will generally want to control the people, so if someone does something fishy – his or her access may be revoked. With such tool – individuals or companies may interact with the local governments, banks, courts and other institutions in a digital way – online. This saves time & money and increases security for the hard working people.
Authorization (JWT)
Applications don’t want the users to enter their credentials on every request. The old way of authorization are cookies. There is a second generation – using temporary tokens. They are generated and verified using cryptographic math. This minimizes the hits to the databases for authorization purposes. Using a key registered in a blockchain is the latest way I’ve seen.
DNS
DNS are like the electronic signatures – public keys – signed by centrally controlled authorities licensed by the Internet Working Group. The metadata in these signatures is the domain name. This is how a server verifies that it has name. If there was no DNS, no everyday user will use the Internet. Good luck – making your grandma remember IP addresses.
Application Stores
In identical manner – the Android, Apple, Amazon, Samsung, Ubuntu’s Snap, Russian alternative of play – all use digital signatures. If someone is doing something bad, the centralised software systems have a switch to revoke apps. It is simple update – making the key that have signed an app not accepted.
Security
SSL transits the information encrypted. Applications that have high requirements for security add one more – custom layer with Encryption.
Cryptocurrencies
The core of the cryptocurrencies are the hash and public-private key math – that powers the rest of the internet. A crypto wallet – without the blockchain is just simple pair of unbound public-private key. This is a big different from the DNS, JWT, SSL and the other Internet Powering tools. The most important feature is – there is no central authority that may stop writing a record in the blockchain. Anybody could create independent public-private key and do something – as long as the protocol is followed.
Basic Example in Java
//definition
public class NewKey {
public static KeyPair getNewKey() throws NoSuchAlgorithmException {
KeyPairGenerator generator = KeyPairGenerator.getInstance(“RSA”);
generator.initialize(2048);
KeyPair pair = generator.generateKeyPair();
return pair;
}
}
//usage
KeyPair pair = NewKey.getNewKey();
DateFormat sdf = new SimpleDateFormat(“hh_mm_ss”);
Date date = new Date();
Files.write(new File(sdf.format(date) + “privatekey.txt”).toPath(),
Base64.getEncoder().encode(pair.getPrivate().getEncoded()), StandardOpenOption.CREATE_NEW);
Files.write(new File(sdf.format(date) + “publickey.txt”).toPath(),
Base64.getEncoder().encode(pair.getPublic().getEncoded()), StandardOpenOption.CREATE_NEW);
And this is how you create new public/private key in Java. The thing is – for now – it is of no use for anybody. Integrating into an app or some public blockchain will make it useful.
Java & Dart (Flutter) Example
TODO