<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Xin Xin Huang on Medium]]></title>
        <description><![CDATA[Stories by Xin Xin Huang on Medium]]></description>
        <link>https://medium.com/@xinxinhuang?source=rss-79c9e4a33bb8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xLHUXCUj9J5auWO2.</url>
            <title>Stories by Xin Xin Huang on Medium</title>
            <link>https://medium.com/@xinxinhuang?source=rss-79c9e4a33bb8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 13:36:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@xinxinhuang/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[BlockChain and the future of it]]></title>
            <link>https://medium.com/@xinxinhuang/blockchain-and-the-future-of-it-10f512dae1a?source=rss-79c9e4a33bb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/10f512dae1a</guid>
            <dc:creator><![CDATA[Xin Xin Huang]]></dc:creator>
            <pubDate>Sun, 01 Apr 2018 00:02:01 GMT</pubDate>
            <atom:updated>2018-04-01T00:02:01.582Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*9LPwVVSY3_utmyoTKmpQ8g.png" /></figure><p>This is the third blog post of BlockChain, in this blog post I will talk about the future of blockchain base on my research. Hopefully by now, we have some solid understanding of BlockChain, in theory, history and coding wise. In order to understand blockchain fully we must understand the economics reason behind it.</p><p>Before, we getting into the future, we must fully understand it’s past, let’s look back.</p><p>When I started on this topic, I had a question for myself and for my readers. What is the first reaction when you heard of the blockchain? I know my first reaction, it was uncertainty and lots of doubts. Mainly because I did not know what blockchain is, nor how it works. I simply just don’t trust it.</p><p>While during my research of this topic I came across a ted talk by Bettina Warbrug.</p><p>She mention that, in our currently economic system, the fundamental relationship that build upon it is the uncertainty and not be able to trust each other. Because we don’t trust each other, and why should we? We needed third party to act are ledger, institution, platforms in the middle to guarantee these trades. However these service does come with a price, the service fees. These services will help us to lower the uncertainties of these trades, but also increase the cost and time consumed. This idea which inline with, the economist Douglass North’s “New Institutional Economics”, playing with the idea of formal rules and informal constrains that are preferring to the constitutions laws and regulation, back up by informal rules, this can be a very example of BlockChain in its current date, its closely tied with our society today, but loosely manage by the officials. From Bettina’s perspective that BlockChain will be able to push human economic more collateralized and automated. However we are still at the infancy stage of this new technology.</p><p>Alex Tapscott gave a talk “Blockchain Revolutions” at google, some very interesting examples were given. In early days of email transfer was a mess, we weren’t able to guarantee the email will be delivered until SMTP was introduced. However people thought about transfer money like the same way we are delivering emails, problem start to occur, for instance, when we are sending email, we are only sending the copy of the original, we can send as much as we need, but when it comes to values, we need to send the originals, making sure the double spending problem wouldn’t be exist.</p><p>All of these are issues that blockchain was created to solve, such as no middle man, lower transaction cost, trust issues, double spending issues. Decentralizing everything seems like the right answer for our future, or is it.</p><p>The problem with Blockchain, the core existence of Bitcoin can have many problems, some are big.</p><p>The biggest problem is the energy consumption, in order to generate bitcoins we need miners, and miners are expensive on their own, and also draws a lot of power when mining and making transactions. According to researching online, the annually rate of 32 tWh, each bitcoin transaction consumed 250 kWh, this translates to what entire Denmark consumes annually. Rise of the bitcoin prices could wells means rise of power bills as well.</p><p>Graphic card resources. Ever since the rise of the cryptocurrency, graphic cards have been on very high demands, and the demands is continue to rise. Graphic card have already selling at a very high margin, and the high demand for them continues to drive the price higher than ever.</p><p>These problem could also be solved if managed well. For example, In Alex’s talk, he mention that people could use blockchain technology to cover solar energy and sell it as asserts. We can make machine or algorithm that make mining more efficient or like cryptocurrency Ripple, no miners are needed.</p><p>We are at the dawn of the BlockChain technology, most of the use cases are still involved around cryptocurrency, one shall ask, what is the best way to learn about blockchain, I answer would be, through crypto investing, both risky and rewarding at the same time.</p><p>We will just have to wait and see where BlockChain can take us in the future, or start to get involved today.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10f512dae1a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create BlockChain in Java]]></title>
            <link>https://medium.com/@xinxinhuang/create-blockchain-in-java-9d021cb443a7?source=rss-79c9e4a33bb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d021cb443a7</guid>
            <dc:creator><![CDATA[Xin Xin Huang]]></dc:creator>
            <pubDate>Mon, 26 Feb 2018 00:32:58 GMT</pubDate>
            <atom:updated>2018-02-26T00:38:08.641Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*ERHll6IZzuue6Chmzx1_HQ.jpeg" /></figure><p>In the previous blog post I went over some brief history of cryptocurrency, and in more specifically in bitcoin currency. In this blog post, we will be learning about creating a blockchain. We will be looking into coding part of the blockchain in Java. Since we have been learning Java during our year at Sait, hopefully this blog post will help you better understanding blockchain, and how it looks like in codes.</p><p>Before we begin about creating our own blockchain, let’s talk about hashing.</p><p>One of the advantage comes to mine is compression, where hash value can compress a larger volumes of information/data into a shorter string. The result can help us saving time when trying to verify information that previous stored.</p><p>The idea behind hashing is quite simple, we take some something that we understand and readable then process it, and return a completely different set of values, they can be mix of number or alphabet, or mix of both.</p><p>Cryptographic hash function takes data, it can be any content, it can be a set or mixture of different type of values and return a hash code, hash value, which is our key to unlock these data.</p><p>If we try to change the content, the values returns after the hashing will be completely different.</p><p>In blockchain, we call this hashes the digital signature.</p><p>Remember the linked list, double linked list we learned in Java? Now think of this chain replaced as block, all of the block linked to each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RsHut6Rrvq_Wp9Se_WGUoA.png" /></figure><h4>Block // XinBlock</h4><p>This is what a block structure looks like in Java code.</p><pre>        private int index;<br>	private String prevHash;<br>	private String data;<br>	private long timeStamp;<br>	private String hash;<br>        private int nonce;<br><br>	public XinBlock(int index, long timeStamp, String prevHash, String data) <br>       {<br>		this.index = index;<br>		this.prevHash = prevHash;<br>		this.data = data;<br>		this.timeStamp = timeStamp;<br>		nonce = 0;<br>		hash = XinBlock.calHash(this);	<br>	}</pre><p>Let’s take a closer look at all the variables:</p><p><strong>Hash </strong>is our digital signature, the current block, also known as block hash.</p><p><strong>PreviousHash </strong>contains hash of previous block.</p><p><strong>Data </strong>is our content, in the worlds of crypto currency contains transactions.</p><p><strong>TimeStamp </strong>is the time which the block is generated, which taking into account of how the hash is generated.</p><p><strong>Nonce </strong>is the number of times we used to find the correct hash value.</p><p><strong>Digital Signature</strong></p><p>Hash value is uniquely identified by each block, they are the digital signature of that block. By using cryptographic algorithms and the hash function, we will be able to generate a unique hash codes base on the information provided. Hash codes are difficult to decipher unless you know the contents in side. Think of like a lock. A complicated one. Bitcoin uses SHA256, and we will be using the same cryptographic algorithms in our blocks.</p><p>First we need to <em>import java.sercurity.MessageDigest </em>in order to access SHA256 algorithms.</p><p>Then we can create a method to access hash function:</p><pre>public static String calHash(XinBlock xinBlock) {</pre><pre>	if(xinBlock!=null) {<br>		MessageDigest digest = null;<br>		try {<br>		digest = MessageDigest.getInstance(&quot;SHA-256&quot;);<br>		} catch (NoSuchAlgorithmException e) {<br>		return null;<br>		}<br>		String txt = xinBlock.str();<br>		final byte bytes[] = digest.digest(txt.getBytes());<br>		final StringBuilder builder = new StringBuilder();<br>			<br>		for(final byte b:bytes) {<br>			String hex = Integer.toHexString(0xff &amp; b);<br>				<br>				if(hex.length()==1) {<br>					builder.append(&quot;0&quot;);<br>				}<br>				<br>				builder.append(hex);<br>			}<br>			return builder.toString();<br>		}<br>		return null;<br>	}</pre><p>This method basically takes a string value and encrypt it with SHA256 hash function, the value return from this method will be our hash code for the block.</p><p>Our next method is mining blocks:</p><pre>public void mineXinBlock(int level) <br>{<br>  nonce = 0;<br>  while(!getHash().substring(0, level).equals(Util.zeros(level))) <br>       {<br>	  nonce++;<br>	  hash = XinBlock.calHash(this);<br>	}<br>	System.out.println(&quot;block mined.&quot;);<br>}</pre><p>As we can see, the nonce was used in this method, each time we dive into for loop the nonce increased by one, until we find the right hash.</p><p>The level parameter we use here is for setting up the difficulty of the mining process, the higher the number the more computation power is needed.</p><p>By up to day, the bitcoin mining difficult is 3,007,383,866,429.</p><h4>BlockChain // XinChain</h4><p>Next stop, we need a blockchain class, let’s call it xinchina, and its time for our first block.</p><pre>private int level;<br>private List&lt;XinBlock&gt; blocks;<br>	<br>public XinChain(int level) {<br>	this.level = level;<br>	blocks = new ArrayList&lt;&gt;();<br>	//manually creating the first block, the mother.<br>        XinBlock Genesisblock = new XinBlock(0, System.currentTimeMillis(), null, &quot;Genesis Block&quot;);<br>	    Genesisblock.mineXinBlock(level);<br>	    blocks.add(Genesisblock);<br>	}</pre><p>For the XinChain to work, we need a genesis block, which is the first block in the chain, it has no previous block, so we needed to hard code a 0.</p><p>We also need to add blocks, but first the block is a new block and then we can add it to our XinChain.</p><pre>public XinBlock newBlock(String data) {<br>	XinBlock latestBlock = latestBlock();<br>        return new     XinBlock(latestBlock.getIndex()+1,System.currentTimeMillis(),latestBlock.getHash(),data);<br>	}<br>	<br>public void addBlock(XinBlock b) {<br>	if(b!=null) <br>            {<br>		b.mineXinBlock(level);<br>		blocks.add(b);<br>	     }<br>	}</pre><p>These couple of methods are straight forward, we will see how to put them in action later.</p><p>One of most important concept in blockchain is the proof of work. It is used to validate the fidelity and validity of our block chain, and only the longest chain is the valid.</p><pre>//check the blockchain&#39;s first block is the same and consistent <br>public boolean isFirstBlockValid() {<br>		<br>	XinBlock fb= blocks.get(0);<br>		<br>		if(fb.getIndex()!=0) {<br>			return false;<br>		}<br>		<br>		if(fb.getPrevHash()!=null) {<br>			return false;<br>		}<br>		<br>                if(fb.getHash()== null || !XinBlock.calHash(fb).equals(fb.getHash())){<br>			return false;<br>		}<br>		<br>	return true;<br>}</pre><p>Above method is to check the first block, by its index, previous hash, and its own hash, only return true when all above conditions are met.</p><pre>//proof of work the newblock, comparing with previous block length, hash, and current hash</pre><pre>public boolean isValidnewBlock(XinBlock newBlock, XinBlock prevBlock) {</pre><pre>	if(newBlock !=null &amp;&amp; prevBlock !=null) {<br>		if(prevBlock.getIndex()+1 != newBlock.getIndex()) {<br>		   return false;<br>		}<br>		if(newBlock.getPrevHash()==null || !newBlock.calHash(newBlock).equals(newBlock.getHash())) {<br>		   return false;<br>		}<br>		if(newBlock.getHash() == null || !XinBlock.calHash(newBlock).equals(newBlock.getHash())) {<br>		   return false;<br>		}<br>		return true;<br>		}<br>	   return false;<br>	}</pre><p>When a newblock is generated, check the index of the hash, current hash, and previous hash, when these conditions are met, the method will return true.</p><pre>//all the nodes of this blockchain must be valid <br>public boolean isBlockChainValid() {<br>            <br>    if(!isFirstBlockValid()) {<br>	return false;<br>	}<br>		<br>	for(int i=1; i&lt;blocks.size();i++) {<br>		XinBlock currBlock = blocks.get(i);<br>		XinBlock prevBlock = blocks.get(i-1);<br>			<br>		if(!isValidnewBlock(currBlock, prevBlock)) {<br>		return false;<br>		}<br>	}<br>		<br>	return true;<br>		<br>	}</pre><p>Finally we must check all the nodes of this block chain, by incorperating with the first block validation method, and check each block with new block validation method, only return true will above conditions are met.</p><p>At last, we can start mining some blocks.</p><pre>public static void main(String[] args) {<br>	XinChain blockchain = new XinChain(4);<br>		<br>	blockchain.addBlock(blockchain.newBlock(&quot;lets have some xin coins&quot;));<br>	System.out.println(&quot;mining in process..&quot;);<br>		<br>	blockchain.addBlock(blockchain.newBlock(&quot;Xin coin is the next big coin&quot;));<br>	System.out.println(&quot;mining in process..&quot;);<br>		<br>	blockchain.addBlock(blockchain.newBlock(&quot;wow this coin is amazing&quot;));<br>	System.out.println(&quot;mining in process..&quot;);<br>		<br>	System.out.println(&quot;Is the block Chain valide?&quot; + blockchain.isBlockChainValid());<br>	<br>	System.out.println(blockchain);<br>	}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p_-DrzhgiZoc52rM_I5Pwg.jpeg" /><figcaption>Above image shows the result is our XinChain.</figcaption></figure><p>I hope you find some useful informatoin about the BlockChain from my blog post, as we can see the core idea behind this is quite simple, but by no means easy to implements, for example, when starting to create our block chain, our chain will not be long enough to prevent it from being hacked. However as time goes by, more and more computer join this network, the power of the chain is really starting to get stronger.</p><p>I did a little research and twearking to come up with this tutorial, and this tutorial is meant for an easy entry into the BlockChain and help myself to better understanding the blockchain works in the background. This concludes for my second blog post.</p><p>Does BlockChain have a future? Stay turn for the final blog post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d021cb443a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cryptocurrency]]></title>
            <link>https://medium.com/@xinxinhuang/cryptocurrency-bcf2b53627a8?source=rss-79c9e4a33bb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcf2b53627a8</guid>
            <dc:creator><![CDATA[Xin Xin Huang]]></dc:creator>
            <pubDate>Mon, 29 Jan 2018 03:19:22 GMT</pubDate>
            <atom:updated>2018-01-29T03:19:22.104Z</atom:updated>
            <content:encoded><![CDATA[<p>A zero sum game, short introduction of cryptocurrency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*URHqnRXMJeMczHrdZnDleQ.jpeg" /></figure><p>Bitcoin was born in 2009, during a finaincal crisis, a great depression; at that time one bitcoin only worth 50 cents US dollar, not many people knew about it, nor understand its value. Bitcoin went from 1000 to 19,214 at the end of 2017. It’s all over the news and media now. Today let’s take a closer look at this mysterious virtual currency that causing a global phenomenal.</p><h3>Where Does Bitcoin came from?</h3><p>Bitcoin are created by using computation power to solve math problems, the fast computer solve the problem gets rewarded, this is known as Bitcoin mining. Just like a gold mine or diamoind mine, the deeper we go, the harder it gets.</p><h3>What is Bitcoin?</h3><p>To understand what bitcoin is, we have to know who is Satoshi Nakamoto.</p><h4>Satoshi Nakamoto</h4><p>In 2008, a person goes by the web name, Satoshi Nakemato published a white paper, titled, <a href="https://bitcoin.org/bitcoin.pdf"><em>Peer to peer electronic cash system</em></a><em>. </em>He kept this system open sourced, so everything can participating in developing this system and also to keep it transparent to the public. He is also the first person that mined the first 50 bitcoin that got the system going.</p><p>In his paper, he mentioned, in order for this system to work we need following four factors</p><blockquote>Decentralization</blockquote><p>In stead of begin control by the country or govement or bank, where our money is being saved, bitcoin got rid of the middle these men, it created a network of machines that purely processing peer to peer transaction. This a digital ledger: blockchain. Bitcoin does not have a centralized system or cloud based server, that means its always online, it uses everyone power to form this gigatic network.</p><blockquote>Anonymous</blockquote><p>Tired of being watching where you spend your money and being told how to spend them? Goverments and banks are always watching your money, your investments all the time. That is not the case of bitcoin, the identity behind each transaction can be anonymous until both party agree to reavel. You don’t need to verified your identity to trade, it is entirely rely on the system itself.</p><blockquote>0 cost</blockquote><p>Without all the middle man, and double spending system, bitcoin is able to keep the transaction at the minimum cost.</p><blockquote>Controlled supply</blockquote><p>Instead of having unlimited supply of paper cash, bitcoin on the other hand is limited. We can only mine about 21 million bitcoin. Untill today, we have mined about 16 million bitcoins, that about 80% of from the pool, however, according to estimate the last 20% of the bitcoin will take roughly 110 more years to mined. However we can split bitcoin unit to 0.00000001, a hundredth of a millionth.</p><p>In the end, Satoshi is proposing a electrionic transaction network not base on trust but solely the system itself, which are the machines. Today we call it blockchain database.</p><h3>What is Blockchain?</h3><p>Peer to peer has been around since the begin of internet, blockchain untilize this technology to do transaction and create bitcoins. By using math and cryptography, blockchain provides open decentralized database which is transparent and efficient.</p><p>Understand blockchain, we can use the example of double link list, which we learn during last semaster java course. Blockchain stores owers information within a block which is link to another block using hashed keys, this allow it to expand and all the blocks are linked to each other. When a transaction happened, all the blocks that has that transaction party information can help verified the information, these creates an anti-cheat system by having everyone in the game involved.</p><h4>Wallets</h4><p>To keep our vitrual currency we need to have a virtual wallet. These wallets usually have two properties.</p><blockquote>Public key <em>for deposit, for others to send funds to you.</em></blockquote><blockquote>Private key<em> for withdraw, keeping it safe since the security is your own responsiblity.</em></blockquote><h3>Conclusion</h3><p>Our current cash system is goverment by one central bank, and watch by our country and goverment, it is unlimited, over time money will devalue. We use third party to trust and to make transactions. Where as Bitcoin revolutionalized this system by spearding the idea of decentralization. In order to create this, blockchain was introduced and how being use to verified each transactions.</p><p>In the next blog we will dissusing how to create our blockchain by using programming lanauge Java.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcf2b53627a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>