Cryptography
Keys and addresses
Public Key Cryptography and Cryptocurrency




Back to the bookFor example, the multiplication of two prime numbers sounds very trivial. However, in the case where you get a number such as 8,018,009, finding the two prime numbers that lead to that number is no longer that simple.❗ However, this is also a trapdoor function. Given the fact that one of the prime numbers is 2003, we can easily find the other by dividing 8018009 / 2003 = 4003In Ethereum (as mentioned in previous slides in this repository), assymetric cryptography is used. A pair of private : public key is used. Furthermore, the public key represents an address (or the accound handle). The private key contains the access to any ether in the account and to authentication over any smart contracts owned by the account.❗ The private key controls the access by being a unique piece when needed to create digital signatures. Those digital signatures are used to "sign" transactions and to spend any funds from the account. The digital signatures also act as a proof of authentication when it comes down to smart contracts or transaction owners.
Digital signaturesDigital signatures can be used to sign any messages. For Ethereum transactions, the details of the transaction are the message itself.❗ A transaction is basically a request to access a particular account on the Ethereum network in order to move funds or to interact with a contract.❗ When a transaction is made (sent) on the Ethereum blockchain, it needs to be sent together with a digital signature. With the help of assymetric cryptography (or in this case elliptic curves), anyone can verify that the details of the transaction are valid (authentic) with only the public key. The private key remains secret and does not get exposed to anyone.❗ Important note ❗ - In Ethereum there is no encryption at all. All of the messages/transactions on the Ethereum blockchain can be read/viewed by everyone. Private keys are used to create a digital signature which is used only to verify the validity and authenticity of the owner/contents of a transaction/message.
Cryptographic hash functions❗ Hash functions are a one way mathematical functions where a given input gets changed by addition, swapping and other operations.❗ Hash functions are used in Ethereum to determine the address given a public key.Hash functions are very important in cryptography as they are a way to get a unique identifier that is impossible to guess or to bruteforce. Hash functions have some very important properties, which are the following:Deterministic: The same hash function input should always lead to the same output.Collision resistant: The function should be with a one to one mapping. This means that given an input x, there is only one output y.Avalanche effect: A small change in the input results in a completely different hashThe hash output should be irreversible.Used in message integrity, digital fingerprints, unique identifiers, authentication (password hashing)Ethereum uses keccak-256 for its hash function. An easy way to test what function you are currently using is to do the null input test:Keccak256("")=c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470SHA3("")=a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a
Ethereum addressesIn essence, the Ethereum addresses are the last 20 byts of keccak256(public key)In the early stages of Ethereum, the address formats was something that got overlooked and a lot of funds were lost due to the fact that people were mispelling it and there was no checksumLater on, a standard is involved (namely EIP-55) which basically a backward-compatible comparison which allows for capitalization to be ignored. (meaning it is case insensitive.)
Last updated