Things you need to know about Ethereum

Ethereum is an open software platform based on blockchain technology that enables developers to build and deploy decentralized applications.

Like Bitcoin, Ethereum is a distributed public blockchain network. Although there are some significant technical differences between the two, the most important distinction to note is that Bitcoin and Ethereum differ substantially in purpose and capability. Bitcoin offers one particular application of blockchain technology, a peer to peer electronic cash system that enables online Bitcoin payments. While the Bitcoin blockchain is used to track ownership of digital currency (bitcoins), the Ethereum blockchain focuses on running the programming code of any decentralized application.

In the Ethereum blockchain, instead of mining for bitcoin, miners work to earn Ether, a type of crypto token that fuels the network. Beyond a tradeable cryptocurrency, Ether is also used by application developers to pay for transaction fees and services on the Ethereum network.

The thing that makes Ethereum special, as opposed to other cryptocurrency that uses blockchain technology, is that you can actually execute code on the blockchain in this same distributed way. So now, instead of just using the blockchain as a glorified ledger, you can do something like specify conditions under which a person will be paid, and once those conditions are met the money will automatically go to the person without any outside interference. People call these chunks of code ‘smart contracts’.

Smart contracts are self-executing contracts with the terms of the agreement between buyer and seller being directly written into lines of code. The code and the agreements contained therein exist across a distributed, decentralized blockchain network.Smart contracts help you exchange money, property, shares, or anything of value in a transparent, conflict-free way while avoiding the services of a middleman.

Because the rules are so secure and easy to follow, even simple devices like phones or locks can be programmed to obey what everyone has agreed to. And the way of doing this is strong enough that attackers or malfunctioning computers can’t break the rules that have been set up. So people can feel secure using Ethereum for billions of dollars, controlling ownership of their cars and houses, or other valuable things. But if there’s a situation where you want to keep track of something, and it would be a problem if someone could hack or manipulate the results, it’s a good bet that Ethereum can help! The results will look like regular websites or mobile apps, but will be completely uncheatable.  As long as it’s built right, not even the person who makes the app will have the power to break the rules they agreed to.

Proof of work :

Proof of work is a core component in the verification and generation process (mining) of Bitcoin and other alternative cryptocurrencies. It functions as a process to show that work or effort has been expended to achieve a desired set of data.Bitcoin and other cryptocurrency uses the Hash Cash function as its proof of work. Producing this proof of work involves finding valid solutions to complex mathematical problems through a series of random trial and error (brute-force) attempts using computational power.Proof-of-Work happens through miners trying to solve exceptionally difficult math problems. Finding a solution is basically a guessing game, but checking if a solution is correct is easy.

The fact that you need a serious amount of computing power, more than the average person could afford, or would even be able to work with, means the mining community is getting smaller and more exclusive. This goes against the idea of decentralization, and could potentially lead to a 51% attack. A 51% attack is when a miner, or more likely a mining pool, controls 51% of the network’s computational power. With that ability, they could invalidate valid transactions and double spend funds.That’s where PoS could really help.

Proof of Stake:

PoS happens by a miner putting up a stake, or locking up an amount of their coins, to verify a block of transactions. The cryptographic calculations in PoS are much simpler for computers to solve: you only need to prove you own a certain percentage of all coins available in a given currency. For example, if you somehow owned 2% of all Ether (ETH), you’d be able to mine 2% of all transactions across Ethereum.

Even if someone owned 51% of a digital currency, it would not be in their interest to attack something in which they have a majority share. According to game theory, those with a larger stake in a cryptocurrency should want to maintain a secure network. Any attack would only serve to destabilize the digital currency, diminishing the value of their stake.PoS would be a more fair system than PoW, as technically anyone could become a miner.

PoS offers a linear scale regarding the percentage of blocks a miner could confirm, since it’s based on that person’s stake in the cryptocurrency.

Tutorial on Ether Mining:

You can refer the below videos to gain a knowledge on ethermining.

  1. How to Mine Ether on Your PC

https://www.youtube.com/watch?v=K3AVeIJPQUc

  1. How To Mine Ethereum with (Nvidia or AMD) in Windows 10

https://www.youtube.com/watch?v=C4796i0Xt38

Convert HTML table tags to CSV using javascript

Recently, I was working in an old Coldfusion environment and I wanted to export a data from a database to CSV.

Instead of writing CSV parsing in Coldfusion I used this Javascript code.

function downloadCSV(csv, filename) {
    var csvFile;
    var downloadLink;

    // CSV file
    csvFile = new Blob([csv], {type: "text/csv"});

    // Download link
    downloadLink = document.createElement("a");

    // File name
    downloadLink.download = filename;

    // Create a link to the file
    downloadLink.href = window.URL.createObjectURL(csvFile);

    // Hide download link
    downloadLink.style.display = "none";

    // Add the link to DOM
    document.body.appendChild(downloadLink);

    // Click download link
    downloadLink.click();
}


HTML Code and Calling the above function
I displayed the data from table in a web page and called this function
I set text color as white.
setTimeout(function(){
exportTableToCSV('support_request.csv');
document.getElementById("table").style.visibility="hidden";
 }, 1000);

I agree. this is an indirect approach but this will be useful when your data is less than 1 MB and when working with old programming language or frameworks like Coldfusion, Adobe, COBOL 🙂

Reference: https://www.codexworld.com/export-html-table-data-to-csv-using-javascript/

 

What is bitcoin?

Bitcoin is a worldwide cryptocurrency and digital payment system called the first decentralized digital currency, as the system works without a central repository or single administrator. The system is peer-to-peer, and transactions take place between users directly, without an intermediary. These transactions are verified by network nodes and recorded in a public distributed ledger called a blockchain. Bitcoins are created as a reward for a process known as mining. They can be exchanged for other currencies, products, and services.

In simple bitcoin can be explained as below,

Bitcoin is a type of cryptocurrency in which balances are kept using public and private “keys,” which are long strings of numbers and letters linked through the mathematical encryption algorithm that was used to create them. The public key (comparable to a bank account number) serves as the address which is published to the world and to which others may send bitcoins. The private key (comparable to an ATM PIN) is meant to be a guarded secret, and only used to authorize Bitcoin transmissions.

Here is how a bitcoin transaction is processed:

1) Payers initiate a bitcoin payment using “wallet” software.

2) This and other pending transactions are broadcast on the global bitcoin network.

3) Once every ten minutes or so, “miners”, specialised computers (or groups of computers) on this network, collect a few hundred transactions and combine them in a “block”.

4) In order to mine a block and validate the transaction, miners compete to solve a difficult mathematical equation (a “hash function”). The miner that solves the equation first further processes the block and broadcasts this “proof-of-work” to the bitcoin network.

5) The other miners check the proof-of-work and the validity of the transactions. If they approve, the winning miner gets a reward of 25 newly minted bitcoin (about $9,800/bitcoin at current prices), which is the incentive for miners to provide computing power. Adjusting the difficulty of the puzzle ensures that the supply of new bitcoins remains steady.

6) The mined block is added to the “blockchain”, a big, unbreakable ledger that lives on the bitcoin network and serves as a record of all transactions.

7) The payee can use his wallet software to see whether the bitcoin have arrived.

A Basic program that illustrates Smart Contracts in Ethereum

A Basic Solidity contract to identify the account address

pragma solidity ^0.4.0;
contract Myaddress{

address mine;
function Myaddress() public{
}

function show_address() public returns (address){
mine=msg.sender;
return (mine);
}
}

This is the best possible beginner code to understand smart contract. In the first line
pragma solidity ^0.4.0;
pragma is a preprocessor and and it tells us the compiler version is 0.4.0
Just like creating class and objects in Java and other programming languages you can create contract using

contract <contract-name>{
..
}

Address type is a base for all contracts and it holds 20 byte value.

Example
address x=0x72ba7d8e73fe8eb666ea66babc8116a41bfb10e2;

Execute the above simple contract in the Inbrowser Solidity IDE.

https://remix.ethereum.org/

Run the program by selecting Run option in the right menu and click create object to initiate the contract.
In the log message you can see the current address of your account number.

Solidity log messages

Basics of Cryptography for Beginners

As we all know, a block-chain is a decentralized and distributed digital ledger that is used to record transactions across many computers so that the record cannot be altered retroactively without the alteration of all subsequent blocks and the collusion of the network. This allows the participants to verify and audit transactions inexpensively.

The working process involves 3 components:

1) Cryptography

2) A distributed network with a shared ledger

3) Record-keeping and security.

Now, lets see about the first component ‘ Cryptography’ in detail.

Cryptography:

Cryptography is the science concerned with the study of secret communication. Cryptography is the study and practice of encrypting and decrypting. It allows people to better understand the encryption practices of others.

Cryptography is basically a method of storing and transmitting data in a particular form so that only those for whom it is intended can read and process it. A plain-text [data to be transmitted] is converted into cipher text [data that is transmitted] through encryption process and received again as plain-text through decryption process. People practicing cryptography are known as cryptographers.

So, the two main process involved in Cryptography are ‘Encryption’ and ‘Decryption’. From the above block diagram, you can clearly understand that the process of converting plain-text to cipher-text is Encryption and vice versa is Decryption.

Before understanding about Encryption and Decryption, you should be aware of these keywords.

1. Cipher

2. Encoding

3. Decoding

Cipher:

During Encryption,an algorithm is performed on plain text to convert it to cipher text. This algorithm is known as cipher. A cryptographic key is mandatory to run cipher. The combination of cryptographic key and cipher is Encryption.

Encoding and Decoding:

Encoding should not be confused with Encryption. In Encryption ,our main aim is to hide/conceal the data. But its not so in encoding.

Encoding is basically a process of converting data into a format that can be understood and used by the external sources for storage/processing/compilation/execution so on. Encoding converts body of information from one form to another form with the help of codes. Code is the system of symbol, sign or letters used to represent the secret meaning. The type of code used for converting characters is known as American Standard Code for Information Interchange (ASCII), the most commonly used encoding scheme for files that contain text.

Decoding is a process of interpretation of the encoded data. Decoding converts the encoded data to readable form to be used at the receiver end.

For example,at radio station audio analog signals are encoded to digital signals for easy transmission and less storage. At home, the radio decodes the signals back to wonderful audio.

Encryption/Decryption:

Now as we are clear about cipher and encoding, let’s check out about encryption.

If we want transfer a large amount of cash money from one place to another, then what we will do? In order to protect it from robbers on the way, we put the cash in a suitcase and lock it with key. When we reach the desired place, we unlock the suitcase with the same key and give the cash.

This process is known as Encryption. To hide the data from unconcerned persons/systems, the data is encoded with a key and transmitted. At the receiver end, the cipher is decrypted with the key to receive the data.

There are two types of Encryption.

 1. Symmetric/Private Key Encryption

2. Asymmetric/Public Key Encryption.

Symmetric/Private Key Encryption:

It is conventional method. The above said example is symmetric encryption. In symmetric encryption, a secret key is shared by both communicating parties. It needs less computation power. But the secret key shared between the two parties should be done in a secured way. Hence,the algorithm or cipher should be very strong.

There are two major threats to this type. Brute force or cryptanalysis.

Brute force is a method (computer) to find all possible combinations and eventually determine the plaintext message. It is hacking the key.

Cryptanalysis is a form of attack that attacks the characteristics of the algorithm to deduce a specific plaintext or the key used. One would then be able to figure out the plaintext for all past and future messages that continue to use this compromised setup. It is hacking the cipher.

Asymmetric/Public Key Encryption:

In public key  encryption, two keys are used. One is public key and other is private key. Both are asymmetric but are mathematically-related. One to encrypt the message and the other to decrypt it. These two keys combine to form a key pair. Encryption strength is directly tied to key size and doubling key length delivers an exponential increase in strength, although it does impair performance. But it needs more computation power.

The hash function is used to index the original value or key and then used later each time the data associated with the value or key is to be retrieved. Thus, hashing is always a one-way operation.

The best-known use of public key cryptography is Digital Signatures.

What is Blockchain ?

What is blockchain?

A blockchain facilitates secure online transactions. It is a continuously growing list of records which are linked and secured using cryptography. The records are termed as blocks and each block is linked to a previous block, hence the name blockchain.

A blockchain is a decentralized and distributed digital ledger that is used to record transactions across many computers so that the record cannot be altered retroactively without the alteration of all subsequent blocks and the collusion of the network. This allows the participants to verify and audit transactions inexpensively.

Process

The working process involves 3 components:

1) cryptography
2) a distributed network with a shared ledger
3) record-keeping and security.

1) cryptography
The main purpose of this component of blockchain technology is to create a secure digital identity reference. Identity is based on possession of a combination of private and public cryptographic keys.

The combination of these keys can be seen as a dexterous form of consent, creating an extremely useful digital signature which was technically known as the hash function.

2) a distributed network with a shared ledger
In its simplest form, a distributed ledger is a database held and updated independently by each participant (or node) in a large network.The distribution is unique: records are not communicated to various nodes by a central authority but are instead independently constructed and held by every node.

Once there is any change in records, the distributed ledger has been updated, and all nodes maintain their own identical copy of the ledger.

3) Record-keeping and security
When cryptographic keys are combined with this network, a super useful form of digital interactions emerges. The process begins with the sender taking their private key, making an announcement of some sort of the transaction that you are sending a sum of the cryptocurrency — and attach it to Receiver’s public key.A block – containing a digital signature, timestamp and relevant information – is then broadcast to all nodes in the network.

The type, amount and verification can be different for each blockchain. It is a matter of the blockchain’s protocol – or rules for what is and is not a valid transaction or a valid creation of a new block. The process of verification can be tailored for each blockchain. Any needed rules and incentives can be created when enough nodes arrive at a consensus on how transactions ought to be verified.

A common conflict is when multiple miners create blocks at roughly the same time.  Because blocks take time to be shared across the network, which one should count as the legit block? In bitcoin, the conflict is resolved by a rule called the “longest chain rule”.The ‘longest chain’ rule broadly says that as a participant, if you see multiple competing valid chains, believe the one with more blocks.

Features :
Trustworthy system:

Data structure build using blockchain allows users to make and verify transactions without a third-party involvement. This strongly reduces the risk of a backdoor transaction and unauthorized intervention.

  1. Transparency:
    The distributed ledger structure gives the control of all their information and transactions to the users. Changes to the public blockchain are accessible to all the members, thus creating a transparent system.
  2. Faster transactions:
    Blockchain transactions can reduce transaction times to minutes and are processed 24/7.
  3. Reduced transaction costs:
    A transaction system builds using blockchain eliminates third-party intermediaries and overhead costs for exchanging assets.
  4. Decentralization
    The greatest characteristic of a blockchain is basically its decentralized network. Decentralized technology allows us to store assets in a distributed network that can be accessed over the Internet.The owner has direct control over their asset through their private key.
  5. Immutability
    Once the data has been written into the blockchain, it is extremely difficult to change it back. It is not truly immutable but, due to the fact that changing data is extremely difficult and almost impossible, this is seen as a benefit to maintaining an immutable ledger of transactions.

Uses
Smart contracts :
Distributed ledgers enable the coding of simple contracts that will execute when specified conditions are met. Ethereum is an open source blockchain project that was built specifically to realize this possibility.

Digital identity :
Blockchain technology empowers consumers to control their own identity and share between trusted entities with their consent. Also, no single institution can compromise a consumer’s identity.

Governance :
By making the results fully transparent and publicly accessible, distributed database technology could bring full transparency to elections or any other kind of poll taking.

Protection of intellectual property :
Smart contracts can protect copyright and automate the sale of creative works online, eliminating the risk of file copying and redistribution.

Blockchain – loyalty and rewards :
Blockchain offers many benefits, including transparency and traceability of transactions. This will help banks and insurers to create a more captivating loyalty and rewards program that fits 24/7 performance management and enhances engagement.

Future Expansion
The Blockchain technology implemented to provide public ledgers for transparency and security, in order to resolve the issue of double billing on Bitcoin, is aggressively being developed for applications such as Bitcoin 2.0 and Ethereum to expand into other diverse fields beyond virtual currency.

Efforts are continuously be made to construct independent networks outside of the Bitcoin network. Recently, aside from the R3 CEV Consortium Private·Permissioned Blockchain, techniques such as Side-chain are being implemented to offer virtual currency and various autonomous asset issuing services.

In addition to competition from Ethereum and others, Bitcoin may soon be challenged by digital currencies issued by central banks. But whether or not Bitcoin itself survives these storms, one thing is clear. Blockchain technology is set to revolutionize international payments.