Git Product home page Git Product logo

tron-proof's Introduction

tron-proof

This is a merkle-proof package that supports tron transaction proofs.

Installation

go get github.com/arberiii/tron-proof

Usage

client := service.NewGrpcClient("grpc.trongrid.io:50051")
client.Start()

block := client.GetBlockByNum(17318273)
client.Conn.Close()
var hashes [][]byte
for _, tx := range block.Transactions {
    rawData, err := proto.Marshal(tx)
    if err != nil {
        t.Fatal(err)
    }
    h256h := sha256.New()
    h256h.Write(rawData)
    hash := h256h.Sum(nil)

    hashes = append(hashes, hash)
}

m := tron.CreateMerkleTree(hashes)
log.Println(m.Root())

// Generate proof for transaction number 0
proof := m.GenerateProof(0)
if !tron.VerifyProof(hashes[0], m.Root(), proof) {
    t.Errorf("merkle proof of transaction %d is not correct", 0)
}

tron-proof's People

Contributors

arberiii avatar

Watchers

James Cloos avatar  avatar  avatar

tron-proof's Issues

Proving State

Your work so far in this repository creates merkle proofs for transactions.

However, i think it would be worthwhile to extend this to merkle proofs of state.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.