Help us shape the future of Go! Take the 2026 Go Developer Survey

dipp

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2019 License: MIT Imports: 4 Imported by: 0

README

Data Integrity Proof Protocol middleware in Go

Simple protocol to provide your users with irrefutable proofs of the output of your service.

Integrate middleware

Example:

router := http.NewServeMux()
// Add routes to router

secret := "this is a randomly generated secret that is at least 32 bytes long"

_ = http.ListenAndServe(":8080", dipp.NewProofMiddleware(secret, router))

Then ask your users to add this header to their request:

X-Data-Integrity-Proof: true

and they will receive an X-Data-Integrity-Proof hash back in the response headers.

Note: this will not work on websocket streams.

Validation

When you receive report of faulty data, users can provide the proof you gave them, with the payload they received.

Use the provided dipp-checker tool to do validation, which you can install with:

go get github.com/eoscanada/dipp/cmd/dipp-checker

and run as:

dipp-checker \
    "this is a randomly generated secret that is at least 32 bytes long" \
    "the-proof-provided-by-the-user-in-hexadecimal" \
    ./path/to/payload.file

to validate integrity.

Initial work

The dfuse.io platform started this initiative alongside its Data Integrity Bounty Program.

See https://hackerone.com/dfuse-io for details.

LICENSE

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashMac

func HashMac(secret string, payload []byte) string

func NewProofMiddleware

func NewProofMiddleware(secret string, handler http.Handler) http.Handler

func NewProofMiddlewareFunc added in v0.1.1

func NewProofMiddlewareFunc(secret string) func(http.Handler) http.Handler

Types

type ProofMiddleware

type ProofMiddleware struct {
	// contains filtered or unexported fields
}

ProofMiddleware will hash the response and add a header. NOTE that this middleware will break Trailers added by calling code, after their WriteHeader() call.

func (*ProofMiddleware) ServeHTTP

func (m *ProofMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ProofWriter

type ProofWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func (*ProofWriter) Write

func (w *ProofWriter) Write(data []byte) (int, error)

func (*ProofWriter) WriteHeader

func (w *ProofWriter) WriteHeader(code int)

Directories

Path Synopsis
cmd
dipp-checker command
dipp-demo command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL