frontier

package module
v0.0.0-...-1a040bd Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package frontier implements frontier sets, the complement of a set of byte strings.

A Frontier is a trie that contains the shortest bytewise prefixes of all strings _not_ in a set. To show in zero knowledge that a given string is not in a Frontier's complement set, build a Merkle hash tree from the prefix strings in the Frontier, then show via a Merkle proof that some prefix of the given string is in that tree.

How it works: Consider the simplified alphabet a,b,c,d, a hypothetical set S of strings in that alphabet, and the corresponding frontier set F representing everything not in S, such that adding a string to S means also excluding it from F. When S is empty, so is F, meaning nothing has been excluded. F contains the empty prefix: the prefix of all strings. Now we add "a" to S. This means removing the empty prefix from F and adding the following:

b, c, d, aa, ab, ac, ad

All strings starting with those prefixes are not in S. If we next add "abc" to S, we must remove "ab" from F and add:

aba, abb, abd, abca, abcb, abcc, abcd

See "Zero Knowledge Sets" by Micali, Rabin, Kilian.

https://people.csail.mit.edu/silvio/Selected%20Scientific%20Papers/Zero%20Knowledge/Zero-Knowledge_Sets.pdf

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Frontier

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

Frontier is a trie that contains the shortest bytewise prefixes of all strings _not_ in a set.

func (*Frontier) Check

func (f *Frontier) Check(str []byte) ([]byte, bool)

Check tells whether str has a prefix in f. It returns the prefix and true if so, false if not.

func (*Frontier) Exclude

func (f *Frontier) Exclude(str []byte)

Exclude adds str to f. (It's called Exclude because this means str is excluded from f's complement set.)

func (*Frontier) MerkleProofTree

func (f *Frontier) MerkleProofTree(hasher hash.Hash, ref []byte) *merkle.Tree

MerkleProofTree produces the a merkle hash tree of an in-order, depth-first walk of the frontier that is able to prove compactly that it contains the given reference string.

func (*Frontier) MerkleTree

func (f *Frontier) MerkleTree(hasher hash.Hash) *merkle.Tree

MerkleTree produces the merkle hash tree of an in-order, depth-first walk of the frontier. This can be used to prove in zero knowledge that a string is not in f's complement set (by proving that a prefix of that string is in f).

func (*Frontier) Walk

func (f *Frontier) Walk(fn func(str []byte))

Walk performs an in-order depth-first traversal of f, calling a callback on each string. The callback must make its own copy of the string if needed; Walk reuses the space on each callback call.

Jump to

Keyboard shortcuts

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