Professional Documents
Culture Documents
SUBMITTED BY
SPONSERED BY
PERSISTENT SYSTEMS PVT.LTD.
CERTIFICATE
to my satisfaction and submitted the same during the academic year 2015-
2016 towards the partial fulfillment of degree of Bachelor of Engineering
in Computer Engineering of Pune University under the Department of
Computer Engineering , Maharashtra Institute of Technology, Pune.
Keywords:
Decentralized Ledger System, Contract Management, Blockchain.
ACKNOWLEDGEMENT
We take this opportunity to express our sincere appreciation for the cooperation
given by Prof. Mrs. V. Y. Kulkarni, HOD (Department of Computer Engineer-
ing) and a special mention for all the motivation and support.
We are deeply indebted to our guide Prof. Pradnya Kulkarni for completion
of this seminar work for which she has guided and helped us by going out of the way.
For all efforts behind the Project report, we would also like to express our sincere
appreciation to staff of Department of Computer Engineering, Maharashtra Institute
of Technology Pune, for their extended help and suggestions at every stage.
Neha Mishra
Priya Bhardwaj
Omkar chintalwar
Swapnil Pardeshi
i
Contents
2 FUTURE ENHANCEMENT 34
ii
3 CONCLUSION 35
BIBLIOGRAPHY 36
iii
List of Figures
iv
List of Tables
1
Chapter 1
SOFTWARE REQUIREMENT
SPECIFICATION
2
1.2. LITERATURE SURVEY
DIGITAL CONTRACT MANAGEMENT SYSTEM USING BLOCKCHAINS
be simpler. Moreover, laws and regulations could be programmed into the blockchain
itself, so that they are enforced automatically. In other situations, the ledger can act
as legal evidence for accessing (or storing) data, since it is (computationally) tamper-
proof.
At the end of the business day, the user‘s end terminal submits all of the final
transactions for the day to the bank in a batch, and the banks all trade transactions
in a batch, and money is sent between banks. This is the process that takes a couple
of days, and after this happens, the transaction moves from pending transactions into
the regular transactions area. Most of the time, the pending transaction and the final
transaction are the same. However, there are cases where it is different.
With a credit account, the fact that the final amount is not known for a few
days is no big deal: if the user doesn‘t have any money in the account, and if he ends
up spending more than he has, then the bank will let the user take some time coming
up with the money at a cost.
With a debit card tied to user‘s checking account, the transaction is handled
the same way, as far is the user‘s end terminal is concerned. However, user‘s bank
is not going to run the risk of user overdrawing his checking account. They also are
not going to run the risk of user withdrawing money from his account that is needed
to cover pending transactions. So they usually treat these pending transactions as
final transactions, deducting the pending transaction from user‘s account balance im-
mediately. When the final transaction comes through, they adjust the transaction,
and user‘s balance goes up or down accordingly. This is one of the big drawbacks
to using a debit card. If a bad pending transaction comes through, you are out this
money until it gets straightened out. This same system is implemented in contract
management legder system. This system is a centralized system. Hence, making the
transaction processing slow.
We are developing a ledger system that would be decentralized, hence, making the
transactions faster and safer. This goal has been achieved by using the concept of
blockchain.
The core advantages of the block chain architecture include the following:
The ability for any node that is well-connected to other nodes to determine, with
a reasonable level of certainty, whether a transaction does or does not exist in
the confirmed data set.
The ability for any node that creates a transaction to, after a certain period of
confirmation time, determine with a reasonable level of certainty whether the
transaction is valid, able to take place, and become final (i.e. that there were
no conflicting transactions confirmed into the block chain elsewhere that would
make the transaction invalid, such as the same currency units ”double-spent”
somewhere else).
Faster execution time i.e. the time taken in transfering money digitally now will
decrease.
2. Store the user‘s order whether it is buy, sell or cancel stock transactions.
– They create the system using blockchains and analyse customer feedbacks.
– They should be knowledgeable about end users.
User :
– User should be able to fill in the login and transaction details correctly.
– They need not to be knowledgeable about the internal working of blockchain.
2. The ledger system decentralization does not depend on the type whether it is
branch by branch or city by city.
1.4.6 SCOPE
We describe what features are in the scope of the software and what are not in
scope of the software to be developed.
1. Increase in security
A centralized asset ledger is a list of transactions that is controlled by a single
entity, such as a bank statement. The bank has total control over which trans-
actions are posted on the ledger. For example they can fine you and directly
take money away from you without your consent. This is a danger of centralized
ledgers because if the entity-in-charge has malicious intent, it can do some seri-
ous damage to its clients. The answer to this problem is a decentralized ledger.
Without a central entity, there is no one capable of cheating the system and
transactions will be entered in an honest manner.
3. Faster transactions
Presently, a normal digital transaction takes about 2 to 3 days to complete.
But by using the concept of blockchain in contract management system we can
reduce this transaction time into much lesser period.
Autonomy means that after it is launched and running, a contract and its ini-
tiating agent need not be in further contact.
Smart contracts are decentralized in that they do not subsist on a single cen-
tralized server; they are distributed and self-executing across network nodes.
for instance, a file or set of files. Nodes further up in the tree are the hashes of their
respective children. For example, in the picturehash 0is the result of hashing the
result of concatenatinghash 0-0andhash 0-1. That is,hash 0 = hash( hash 0-0 + hash
0-1 )where + denotes concatenation.
Most hash tree implementations are binary (two child nodes under each node)
but they can just as well use many more child nodes under each node.
Usually, acryptographic hash function such asSHA-2is used for the hashing.
If the hash tree only needs to protect against unintentional damage, much less se-
curechecksumssuch asCRC scan be used.
In the top of a hash tree there is atop hash(orroot hashormaster hash). Before
downloading a file on a p2p network, in most cases the top hash is acquired from a
trusted source. When the top hash is available, the hash tree can be received from
any non-trusted source, like any peer in the p2p network. Then, the received hash
tree is checked against the trusted top hash, and if the hash tree is damaged or fake,
another hash tree from another source will be tried until the program finds one that
matches the top hash.
Overlay Network:
Nonce:
Hashing:
Nonces are used inproof-of-work systemsto vary the input to a cryptographic hash
functionso as to obtain a hash for a certain input that fulfills certain arbitrary condi-
tions. In doing so, it becomes far more difficult to create a ”desirable” hash than to
verify it, shifting the burden of work onto one side of a transaction or system.
Theblockchain hashing algorithm can be tuned to an arbitrary difficulty by chang-
ing the required minimum/maximum value of the hash for reducing the number of
blocks created for each transaction. This is likewise achieved by forcing to add nonce
values to the value being hashed to change the hash algorithm output.
1.5.3 Blockchain:
Eachblockin the chain contains a reference to the previous block in the chain (that
is thePrev Hashin the picture) and some additional information which makes up the
content of the block. The link to the previous block is what makes it a chain:given
a block you can find all the information in all the previous blocks that led to this
one, right back to whats called the genesis block, the very first one in the chain.
Up to this point, blocks do not provide any added synchronization on top of the
individual transactions. This changes when the blocks are chained together, creating
a chronological order over the blocks and therefore about the transactions contained
within them. The blocks are organized in a directed tree. Each block contains a
reference to a previously found block. The block b referenced by a block bl is called
its parent. The transitive closure of this relation gives its ancestors. The root block
in the tree is the genesis block, which is hardcoded into the clients. This block is an
ancestor of all blocks by definition. The blockchain is defined as the longest path
from any block to the genesis block. The distance between a block b and the genesis
is referred to as its block height hb. The genesis block therefore has height hg = O.
The block with maximal height, i.e., the block that is furthest away from the genesis
block is referred to as blockchain head, with height hhead. We use the notation Bh
to reference the set of blocks at height h. Since to include a reference to the parent
block, that parent block‘s identity (its hash) has to be known, the child block must
have been found after the parent. The chaining is used to assign a chronological order
to the transactions: transactions in lower height blocks have been verified before
transactions in higher blocks. As only blocks appearing in the blockchain will be
rewarded with newly minted coins that are accepted by other users, miners will always
attempt to find a block that builds on the current blockchain head. Building on an
earlier block would require the resulting branch to become longer than the currently
longest branch, i.e., the blockchain, to be rewarded.
Storage
A block in blockchain
A block has a header and a list of transactions (they are theTx0,Tx1Tx3in the
picture of the blockchain). The header includes: a pointer to the previous block
(Prev Hashin the picture a summary of the transactions the block contains (techni-
cally, the Merkle hashof those transactions, theTx Rootin the picture) a timestamp
that indicates when the block was created, a proof of the work that went into creating
the block (Noncein the picture) a timestamp server: itprovides irrefutable evidence
that the data in a block existed at a particular time. The actualtimestampgiven in a
particular block isnt necessarily to-the-second accurate. In fact theres nothing stop-
ping the timestamp of a particular block being before the timestamp of the previous
block. If a block is in the blockchain, what is guaranteed is: the block was added at
most two hours before its timestamp. The block before this block in the chain existed
at the time the block was created. This block was added to the chain before the next
block in the chain existed. The data in this block existed at the time the block was
created. Thehash of the header of the block, incorporating each of these pieces of
information, becomes the identifier for the block which is used by the next block in
the chain. Every node in the network can add blocks to the chain. Every node is sent
the data that needs to go into the blocks (the transactions). Every node can package
up that data into a block that links back to the last block in the chain that they are
aware of. And every node can then transmit that block to the rest of the network to
assert this is the new chain.
So what stops this being a completely chaotic situation where every node is adding
blocks at the same point in the chain at the same time, forking it willy-nilly? What
ensures that the nodes in the network have a consistent, consensus view of what the
blockchain holds? The first barrier is that nodes all operate under a set of protocol
rulesthat determine what a valid block looks like. These rules include ensuring that
each transaction is a valid transaction: that it is spending money that actually exists
There is a node and a whole bunch of transactions that has to be put together
into a block to add to the chain. The hash of the previous block in the chain is
known. Then calculate the Merkle hash for the transactions to be put in the block.
The time is known. But what is not known, and what has to be to worked out, iswhat
nonce will result in the header of the new block having a hash that starts with lots
of zeros. Now, the way thathashing works means that there is no way a node can
algorithmically compute what nonce is going to give the block this magic property.
Different nonces have to be tried.
Thecurrent probabilityof managing to get a nonce that works per attempt is about
1 in a sextillion (102̂1,about the number of grains of sand on all the beaches in the
world). Specialised hardware performs at 1000 GH (giga-hashes), which means it
tries about one trillion (101̂2) nonces each second. So nodes have to work really hard
to create valid blocks. They have to try lots and lots and lots of different nonces,
calculating lots and lots and lots of hashes. A valid block, whose hash begins with
lots of zeros, is proof that the node that created it did lots of work, hence the nonce
is sometimes called aproof of work. The number of zeros that a blocks hash has to
start with, or the target number that it has to be below, determines the difficulty of
creating a new block, and hence the average time that it will take. The smaller the
target number, the more zeros the hash has to start with, the lower the probability
of hitting on such a hash, and the harder it is to create a new block. The difficulty
of creating a new block is automatically regulatedsuch that no matter how big the
network of nodes gets, and no matter how much compute power they have,it will
always takeabout 10 minutesfor the whole network to find a new block.
Every 2016 blocks, which is about every 2 weeks, a new target number is
calculated based on how long it took to create those 2016 blocks. If it averaged more
than 10 minutes to create them, the target number goes up and the difficulty goes
down; if it took less than 10 minutes to create them, the target number goes down and
the difficulty goes up. So the difficulty adapts andvaries over timebased on the total
compute power of the network. This adaptation does give some limits to the growth
of the blockchain and to the number of transactions the network can handle. A new
block is added roughly every 10 minutes. Each block currently has a maximum size
of 1MB, put in place to limit the amount of data that nodes have to pass around to
stay synchronised. The size of transactions varies, but the commonly quotedmaximum
transaction rateis 7 transactions per second, equivalent to 4200 transactions per block.
It also means thatas the network grows, the total energy consumed grows, but the
output stays the same. Researchers have estimated that the total power consumed
by the Bitcoin network is something in the region of 3GW about the same power
consumption as Ireland.
Weve looked at the large numbers of calculations that nodes have to do in order
to create new blocks. At the time of writing there are estimated to beabout 100,000
nodes. All of them are trying to add new blocks to the chain; about every 10 minutes
one of them will succeed.The work that nodes have to do to create a new block takes
time. This lowers the probability that two blocks are made at the same time, but
its still possible. When this happens, it creates a fork in the blockchain; some nodes
might start building on one of those branches and some on the other. But theprotocol
rulesthat govern how the nodes operate prevent this situation from going on for very
long. Each node keeps track of all the branches, butnodes will only try to extend
the longest branch they know about. (The length isnt determined by the number of
blocks but by the total amount of work that has gone into building the branch, based
on the number of zeros at the beginning of the block hash.)
The transactions in shorter branches arent lost. When a node learns that an-
other branch is longer than the one it has been working on, it checks its current
branch for any transactions that arent in the new branch. These missed transactions
are broadcast to the network again, and incorporated into new blocks on the chain. So
the blocks at the end of the blockchain could be retracted at any time. The network
of nodes will eventually come to a consensus position on which block follows a given
block, but at any one time there might be many branches in operation, potentially in-
cluding different transactions. And some of the transactions that are in the blockchain
currently accepted by a node may eventually turn out to be invalid. If two branches
contain transactions that cannot coexist, one of the transactions will eventually be
refused.This uncertainty about the end of the chain leads to the common rule thata
given transaction isnt confirmeduntil it is at least 6 blocks deep in the chain(ie after
about an hour, given each block takes about 10 minutes to create). This number is
based on understanding what it would take to change the contents of the blockchain.
As weve seen, each block contains a reference to the previous block, and that
reference the hash of the block encodes both the content of the block and the ref-
erence to the previous block. In other words,if you changed the content of a block,
you would change its hash. If you changed its hash, you would need to change the
reference to it in the block after it in the chain. That in turn would change that
blocks hash, which would mean changing the reference in the block after that, and so
on to the end of the chain. So changing the content of a block is hard to do when the
block is followed by other blocks. Once a block is embedded within the chain, you
have to unpick all the following blocks right back to the one you want to change, and
then reconstruct those blocks again. As weve seen, creating a block is hard work: it
takes lots of computational power. But more than that, while you are busy trying
to recreate the chain youve unpicked, the rest of the network is merrily continuing to
add even more blocks to that chain.
The ease with which someone can alter the blockchain depends on the proportion
of the network that they own.Its possible tocalculate the probabilityof someone be-
ing able to alter the blockchain depending on the proportion of the compute power
that they control and the number of blocks back in the chain they are trying to amend.
For example, someone who controlled 20% of the compute power of the network
has a 40% chance of being able to change the last block in the chain, but only a 4%
chance of being able to change a block that is 5 blocks back in the chain. Someone
who controls 10% of the compute power of the network has a less than 0.1% chance
of being able to change a block 6 blocks back in the chain.This last calculation is
the basis for deciding when a transaction is confirmed: even if someone managed to
capture 10% of the compute power of the network, theyd still have less than a 0.1%
chance of altering a block that is 6 blocks deep in the chain. Its judged unlikely that
anyone would capture that much of the network, and theyre still unlikely to succeed
even if they did, so 6 blocks feels like a safe bar for transactions in the network to
need to meet.
In order for the ledger replicas to remain consistent a common order over the
transactions has to be agreed among the nodes. Agreeing on a common order of trans-
actions in a distributed system is not trivial. This problem is solved by tentatively
committing transactions and then synchronizing at regular intervals by broadcasting
a block created by one of the nodes. A block b contains the set of transactions Tb that
the node which created the block has committed since the previous block. The block
is then distributed to all the nodes in the network and each node receiving it will roll
back the tentatively committed transactions since the last block and apply the trans-
actions from the current block. At this point all the nodes have agreed on the validity
of all the transactions in the block. Transactions that were conunitted as part of the
block are confirmed and do not have to be reapplied. The transactions that have been
rolled back will then be validated again and reapplied on top of the new base state.
Transactions that are now invalid because they conflict with transactions committed
as part of the block are discarded. The node that created the block effectively imposes
its view of the changes since the previous block. However, the decisions of the block
creator are limited. The node cannot forge any transactions as long as the under-
lying public-private-key cryptosystem is secure. The block creator may only decide
in which order transactions arrived and whether to include transactions in its block.
To determine which node may impose its view the nodes attempt to find a solution
to a proof-of-work with a given probability of success. The proof-of-work consists in
finding a byte string, called nonce, that combined with the block header results in a
hash 1-lb with a given number of leading zero-bits, or target. As cryptographic hashes
are one-way functions, finding such a nonce can only be done by actually calculating
the hash of the block for all possible nonces until a valid solution is found. It is
therefore difficult to find an input that produces a solution, but straight forward to
verify it. The nonce is part of the block so that nodes receiving it can verify that the
creator solved the proof-of-work. The hash 1-lb is also used as the block‘s identity.
The target is determined via consensus by all nodes in order to achieve an average of
one result every 10 minutes in the entire network and is adjusted every 2016 blocks,
which should occur once every 14 days in expectation. Nodes attempting to find a
solution to the proof-of-work are often called miners. To incentivize miners, the node
finding a block receives a reward in the form of newly minted bitcoins, i.e., it may
include a transaction that has no inputs but may specify outputs for a predetermined
number of coins into the block. This reward transaction is only valid if it appears in
the block and is the only exception to the rule that the sum of a transaction‘s outputs
has to be smaller or equal to the sum of the transaction‘s inputs.
Should block bh be on the same branch as the newly found blockchain head bh‘ it will
retrieve all intermediate blocks on the branch and apply their changes incrementally.
On the other hand, should bh, be part of another branch, i.e., bh is not an ancestor
of bh” then they share a COlmnon ancestor. Since bh, is on a longer chain than bh it
becomes the new blockchain head, therefore the node has to revert all changes down
to the common ancestor and apply the changes in the branch of bh‘. A blockchain
fork may be prolonged by the partitions of the network finding more blocks Bh+l,
Bh+2, ... building on their respective blockchain heads. Eventually one branch will
be longer than the other branches, and the partitions that did not adopt this branch
as theirs will switch over to this branch. At this point the blockchain fork is resolved
and the ledger replicas are consistent up to the blockchain head. The blocks discarded
by the blockchain resolution are referred to as orphan block. Every transaction can be
invalidated if a longer chain that started below the block including the transaction is
created. If a single entity could control a majority of the computational power on the
network, and thus be able to find blocks faster than the rest of the network combined,
it could revert any transaction. If an attacker attempts to revert a transaction that
was included in block bh it would create a new transaction that conflicts with the
original transaction and include it into a block bh‘ with hi ¡ h. The attacker would
then proceed to create blocks on top of bh‘ until this new chain overtakes the original
blockchain and thus becomes the new blockchain. One may argue that the existence of
blockchain forks is the very reason that transactions are never definitively committed.
The tight coupling between blocks and the validity of a transaction not only slows
down the confinnation time of a transaction but also limits the confirmation to be a
probabilistic statement about the validity.
3. Database Mysql
1.8 DESIGN
1.8.1 UML DIAGRAMS
UML diagrams consists of following diagrams:
1. Use-Case Diagram
2. Activity Diagram
3. State Diagram
4. Component Diagram
5. Class Diagram
7. Deployment Diagram
8. Sequence Diagram
Use-Case Diagram
Use case diagram shows the overall functionality of the system. In our system there
are three use case diagrams.
1. Developer :
They create the system using blockchains and analyse customer feedbacks.
They should be knowledgeable about end users.
2. User :
User should be able to fill in the login and transaction details correctly.
They need not to be knowledgeable about the internal working of blockchain.
Activity Diagram
In activity diagram the overall flow of the system is shown. It contains the following
sequence of action.
State diagram
State machine diagram capture the behavior of the software system. State ma-
chines can be used to model the behavior of a class or an entire application
Component diagram
Class diagram
Class diagram are the most common diagram found in modeling object oriented
systems. A class diagram shows set of classes interface and collaboration and their
relationships.
Package diagram
A package diagram is a UML diagram composed only of package and the depen-
dencies between them. A package is a UML construct that enables you to organize
model elements such as use cases or classes into groups.Package are depicted as file
folders and can be applied on any UML diagrams.
The package diagram shows that our system uses five main packages i.e. cus-
tomer data, portfolio info, Order detail, Transaction and logging info package. The
customer data package is using the services offered by the portfolio info package and
the portfolio info is using the services offered by order detail. Order detail is using the
services offered by transaction and transaction is accessing the logging information
from logging info package.
Deployment diagram
A deployment diagram in the UML serves to model the physical deployment of ar-
tifacts on deployment target. Deployment diagram shows the allocation the artifacts
to nodes according to deployment defined between them. Deployment of an artifact
to a node is indicated by placing the artifact inside the node. Instances of nodes are
used in deployment diagram to indicate the multiplicity of nodes.
FUTURE ENHANCEMENT
2. The system can be updated more frequently by changing the updation time of
formation of a block in blockchain.
3. One issue is the proliferation of blockchains, and that with so many different
blockchains in existence, it could be easy to deploy the resources to launch a
51-percent attack on smaller chains.This can be cured in future.
34
Chapter 3
CONCLUSION
35
Bibliography
[3] Guy Zyskind, Oz Nathan, Tel-Aviv, Alex ‘Sandy‘ Pentland, ”Decentralizing Pri-
vacy: Using Blockchain to Protect Personal Data”, IEEE CS Security and Privacy
Workshops , 2015
[4] Daniel Kraft, NAWI Graz, ”Difficulty Control for Blockchain-Based Consensus
Systems”, Springer, March 2015
[5] Jay Kishigami, Shigeru Fujimura, Hiroki Watanabe, Atsushi Nakadaira, Akihiko
Akutsu, ”The Blockchain-based Digital Content Distribution System”, IEEE Fifth
International Conference on Big Data and Cloud Computing, 2015
36