Showing posts with label public. Show all posts
Showing posts with label public. Show all posts

Tuesday, 6 November 2018

Public key Cryptography

For blockchains validation and verification, two techniques are used predominantly.
These are Hashing and Asymmetric key Encryption.

Blockchain security domain, 4 topics:
  1. Public key cryptography
  2. Secure Hashing
  3. Transaction Integrity
  4. Block Integrity

We will describe the concept of asymmetric key encryption.
Then hashing and what hashing algorithms are used by Blockchain. Then explain Techniques which use these algorithms to manage the integrity of the transaction and blockchain

Public Key Cryptography

Blockchain participants are not known to each other. Participants can join and leave the chain as they wish. They cannot be identified with conventional means like Driver's License.  In this context, how do you identify the participants?
How do you authorize the transactions? How do you detect the forged or faulty transactions?

This can be accomplished using public key cryptography algorithm.
Let us first understand simple key encryption. The same key is used for encryption and decryption, therefore it is called simple key encryption.
For example: Caesar Encryption
Alphabets in a message are shifted by a fixed number of positions. This number is called a key.
Consider the message: I AM GOING
Encrypted: G CO IQGPI
Letters shifted by 2 positions. Hence the key is 2.

Drawbacks: 1. Even the encryption key or mechanism is much more complex, it is easier to derive the secret key from the encrypted data.
  1. The key distribution to other participants is a challenge.
These challenges grow in magnitude in case of blockchains where participants are unknown to each other.


Solution to these issues: Public key encryption
  1. Two keys instead of a single key. These keys form a public key and private key pair.
  2. Public keys are published. Private keys are kept safe and secret using a passphrase.
  3. When a data is encrypted with a private key, it can be decrypted by a corresponding public key and vice versa.

Example of public key encryption: Popular implementation: RSA algorithm (Rivest Shamir Adelman)
It is used in an application for password less user authentication like in Amazon Virtual machine access.

But Blockchains need more secure algorithms. So it uses  Elliptic Curve Cryptography (ECC). Both Bitcoin and Ethereum use these algorithms to generate the blockchain. ECC is stronger than RSA.
256 bits ECC key pair is ~ (equivalent in strength) to 3072 bits RSA key pair


Monday, 14 January 2013

Why Public Static Void Main ? - Java Code

We are so much habitual now to begin our code with public static void main(). Because we were taught to do so. Being taught that this is the entry point for our java program to execute, however are we aware what does it actually means??
Plenty of other questions which came into my mind:
1. Why public static void main()
2. Whats the meaning of each one of the individual keyword?
3. What if I don't use it?
4. Is there any other way to start the program execution?
5. How does JVM knows, "i need to start from here..."?
6. Can we shuffle the keywords?
  and so on....

Well answering to each one of the above, lets begin.

We structure our complete code into classes and objects(instance of those classes), that's what java says to do. Now we write a program say xyz, create a public class for it XYZ and define a public static void main(String args[]) method in the class.

The first thing to know is public static void main () aka psvm() is a method signature with an Array of String type as an argument. The method signature is
[access modifier] [return type] method_name (Argument_List)

Secondly, its a must to use this signature because JVM looks for this signature to begin execution. If it is not able to find the above signature an exception is thrown. Note this is the only way to begin the program execution and nothing else would work.

public is an access modifier, which tells compiler that any class or object can access this method.
or simply, Access is granted to anybody. Making the main method public is necessary so that anyone (object) can access the method.

static.. Please remember in java we need an object reference to call any class method. I mean instantiating the class. Now do we have any object before beginning the program. No we don't. So how we are going to begin with. Static keyword before a field or method describes that no instance or object reference is required to access that field/mehtod().

void.. Simply means no return by the method
Note : there's a difference between null returned and void.

main.. As we all know, method name defined by java.
main is different from Main as java is case sensitive. Further main() is pre-defined mehtod where as you can create your own method Main() / Main(x) or anything.