Skip to content

Implementation of gmaxwell's suggestion of proving account balances

License

Notifications You must be signed in to change notification settings

fudong1127/proveit

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prove It!

This is a basic implementation of gmaxwell's suggestion of proving account balances documented here: https://iwilcox.me.uk/v/nofrac

This will work for any CryptoCurrency that is based off the Bitcoin protocol.

Basic Docs

To install the project just use:

pip install proveit

You will need to provide the HashTree class with a list of customer accounts and hashes with which to create a glorified Merkle tree.

The hashes should probably just be hashfunction(customer_id + salt), or something of the like.

Basic Usage

from proveit import *

customers = [ Node(123, 'unique identifier, preferably hashed'), Node(456, 'unique identifier2, preferably hashed as well')]

hashtree = HashTree(customers)

Now you've generated a hashtree where any customer can validate that you've included their balance into your total.

All you need to do to provide them with the relevant information follows:

info = hashtree.GetInfoFromHash('unique identifier, preferably hashed')

This provides (Account Value, Identifier, root hash, Hash Tree)

Now anyone can verify this section of the Merkle tree using the following function.

ValidateNode(Node(info[0], info[1]), info[2], info[3])

To add the CryptoCurrency portion of the account verification, use the following code, inserting your own RPC information as required.

coin = Coin(host, port, user, password)

ValidateBalance(coin, Decimal("<insert balance you wish to prove>"), message="Validation message that gives your customers confidence")

This will give you a list of signed messages, for at least the amount that you wish to verify (if you have a sufficient balance), and for the amount in your wallet, if you don't have a sufficient balance.

In practice, you can likely get away with something approximating the following since there is a default message that includes a timestamp.

ValidateBalance(coin, hashtree.GetTotal())

If you see any problems or have an suggestions, please raise an issue or (better yet!) submit a pull request!

Cheers,

Nick

About

Implementation of gmaxwell's suggestion of proving account balances

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published