Pages

  • Sungchul Lee (Big Data and Block Chain Researcher)

    Assistant Professor

    Department of Computer Science

    University of Wisconsin-Whitewater

    lees at uww dot edu

  • Sungchul Lee

    I was born in Seoul, Korea. I received my Ph.D. degree in computer science from the University of Nevada, Las Vegas (UNLV) in 2018. I was one of the members of the Nevada Energy-Water-Environment Nexus Project funded by NSF where I was conducting the data analysis and data security research. My research interests include big data analytics with Hadoop system, secure network protocol design, authentication and access control schemes, block chain and user behavior analysis in Smart Grid environment. I am also investigating navigation and collision avoidance algorithms for Aircraft Systems through simulations studies.I am also working on traumatic brain injury (TBI) research. I made a mobile health (mHealth) real-time system for collecting data from participants, and I have been analyzing the body balance of TBI.

0xbBFCf439678199159ff55B05c597DFb9dce860ed

0xbBFCf439678199159ff55B05c597DFb9dce860ed
Share:

Simple example of Smart Contract with Remix


Online IDE
https://remix.ethereum.org/


pragma solidity ^0.4.0; // like import library

contract unlvcontract{ // class name
    string str="unlv contract";


   //getting string
    function getter() constant returns(string){
         return str;
    }



   //setting test using
    function setter(string newStr){
        str=newStr;
    }

}

The right side of online IDE




Click "Run" tap and "Create" Button.

Using setter button, you can input data.

Getter button is to get the string in the contract.
Share:

BlockChain

Share:

Data Structure for Blockchain

/*
This is simple implementation of blockchain to understand the data structure.

There are two data structures. One is the BlockHeader that contains the version, previous block hash, merkle root hash( Hash tree), timestamp, difficulty of prove and nounce. I will explain the variouable in the next post.

*/


import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class BlockHeader {

private int version;
private byte[] previousBlockHash;
private int merkleRootHash;
private int timestamp;
private int difficultyProve;
private int nonce;

public BlockHeader(byte[] previousBlockHash, Object[] transactions){
this.previousBlockHash = previousBlockHash;
this.merkleRootHash=this.someMethod(transactions);

}
public byte[] toByteArray(){
String tmpStr="";
if(previousBlockHash != null){
tmpStr+=new String(previousBlockHash,0,previousBlockHash.length);

}
tmpStr +=merkleRootHash;
return tmpStr.getBytes(StandardCharsets.UTF_8);

}
private int someMethod(Object[] transations){
return Arrays.hashCode(transations);
}
}

/*
Second data struture is block that contains the block size, block header and a information of transactions and number of transaction.

*/


import java.security.NoSuchAlgorithmException;
import java.security.*;
import java.nio.charset.StandardCharsets;

public class Block {
private int blockSize;
private BlockHeader blockHeader;
private int transactionCount;
private Object[] transactions;
public Block(BlockHeader blockHeader, Object[] transactions){
this.blockHeader=blockHeader;
this.transactions=transactions;
}
public String getBlockHash() throws NoSuchAlgorithmException{
String hash="";
MessageDigest messageDigest=MessageDigest.getInstance("SHA-256");
// byte[] blockHash= messageDigest.digest(blockHeader.toString().getBytes());
messageDigest.update(blockHeader.toString().getBytes());
byte[] blockHash = messageDigest.digest();
StringBuffer sb = new StringBuffer();
for(int i =0;i<blockHash.length;i++){
sb.append(Integer.toString((blockHash[i]&0xff)+0x100,16).substring(1));
}
hash = sb.toString();
return hash;
}

}

/*
Main for test

Just making Hash using previous hash data.
*/


import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;


public class BlockchainDriver {
List<Block>blockchain = new ArrayList<Block>();
public static void main(String[] args) throws NoSuchAlgorithmException{
String[] transactions = {"unlv computer"};
Block genesisBlock=new Block(new BlockHeader(null,transactions),transactions);
System.out.println("Genesis Hash:\t"+genesisBlock.getBlockHash());
//
// transactions[0]="unlv computer";
// genesisBlock = new Block(new BlockHeader(null, transactions),transactions);
// System.out.println("Block Hash:"+genesisBlock.getBlockHash());
//second block
String[] secondTransactions={"UNLV computer store your bitcoin"};
Block secondBlock = new Block(new BlockHeader(genesisBlock.getBlockHash().getBytes(),secondTransactions),secondTransactions);
System.out.println("Second Hash:\t"+secondBlock.getBlockHash());
//Third block
String[] thirdTransactions={"your bitcoin is in UNLV computer"};
Block thirdBlock = new Block(new BlockHeader(secondBlock.getBlockHash().getBytes(),thirdTransactions),thirdTransactions);
System.out.println("Third Hash:\t"+thirdBlock.getBlockHash());
}
}



Share:

Q&A for Data Science

Share:
Powered by Blogger.

Popular Posts