hstools

package
v0.0.0-...-83d0a44 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2016 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	REPLICAS                          = 2
	REND_TIME_PERIOD_V2_DESC_VALIDITY = 24 * 60 * 60 // 86400
)
View Source
const ROUNDS = 100000

The SampleX functions have been replaced by the analytical (not random) XData + AnalyzePartitionData functions

Variables

View Source
var (
	HashringLimit = new(big.Int).Lsh(bigOne, 160)
)

Functions

func Brute

func Brute(targetA, targetB, maxA, maxB Hash, numKeys, numP int,
	log func(v ...interface{})) (a []*rsa.PrivateKey, b []*rsa.PrivateKey)

func ColocatedKeys

func ColocatedKeys(k []byte, keysDB *KeysDB) (coloNum int, ips []string)

func ComputeRendV2DescID

func ComputeRendV2DescID(serviceID string, replica byte, time int64, descCookie string) ([]byte, error)

func FromBase32

func FromBase32(s string) ([]byte, error)

func FromBase64

func FromBase64(s string) ([]byte, error)

func FromHex

func FromHex(s string) ([]byte, error)

func HashToInt

func HashToInt(k Hash) *big.Int

func HashesToIntSlice

func HashesToIntSlice(keys []Hash) []*big.Int

func HourToTime

func HourToTime(h Hour) time.Time

func OnionToDescID

func OnionToDescID(onion string, t time.Time) ([][]byte, error)

func ReadConsensuses

func ReadConsensuses(dir string, since, until Hour) chan *Consensus

ReadConsensuses reads consensus files from a folder structure like DIR/consensuses-2011-02/04/2011-02-04-02-00-00-consensus and sends them on the returned channel. From since to until included.

func Score

func Score(v *big.Int, res *MetricData) int64

func ToBase32

func ToBase32(b []byte) string

func ToHex

func ToHex(b []byte) string

func WritePackedConsensus

func WritePackedConsensus(w io.Writer, c *Consensus) error

Types

type AnalyzedConsensus

type AnalyzedConsensus struct {
	T         Hour
	Distance  *MetricData
	Distance4 *MetricData
}

type Consensus

type Consensus struct {
	Time     Hour
	Filename string
	Error    error
	K        []Hash
	IP       []string
}

func ParseConsensus

func ParseConsensus(filename string) (*Consensus, error)

ParseConsensus parses a consensus file and extracts the HSDir Hashring

type Hash

type Hash [20]byte

func HashIdentity

func HashIdentity(pk rsa.PublicKey) Hash

func IntToHash

func IntToHash(i *big.Int) Hash

func IntsToHashSlice

func IntsToHashSlice(ints []*big.Int) []*Hash

func SHA1

func SHA1(data []byte) *Hash

func (*Hash) Distance

func (a *Hash) Distance(b, d *Hash)

Distance efficiently calculates the difference (b - a) mod 2^160, or distance a -> b on a 20-byte ring and stores it in d. a and b unchanged.

type Hashring

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

func NewHashring

func NewHashring(points []*big.Int) *Hashring

NewHashring returns a Hashring with the given unsorted points.

func RandomHashring

func RandomHashring(entries int) *Hashring

func (*Hashring) Age

func (h *Hashring) Age(p *big.Int, now Hour, keysDB *KeysDB) (Hour, error)

func (*Hashring) AgeData

func (h *Hashring) AgeData(now Hour, keysDB *KeysDB) (res []*PartitionData, err error)

AgeData is not really in use, Age and Longevity are assessed in absolute

func (*Hashring) Colocated

func (h *Hashring) Colocated(p *big.Int, keysDB *KeysDB) int

func (*Hashring) Diff

func (*Hashring) Diff(from, to *big.Int) *big.Int

func (*Hashring) Distance

func (h *Hashring) Distance(p *big.Int) *big.Int

func (*Hashring) Distance4

func (h *Hashring) Distance4(p *big.Int) *big.Int

func (*Hashring) Distance4Data

func (h *Hashring) Distance4Data() (res []*PartitionData)

func (*Hashring) DistanceData

func (h *Hashring) DistanceData() (res []*PartitionData)

func (*Hashring) Fourth

func (h *Hashring) Fourth(p *big.Int) *big.Int

func (*Hashring) Len

func (h *Hashring) Len() int

func (*Hashring) Longevity

func (h *Hashring) Longevity(p *big.Int, now Hour, keysDB *KeysDB) (Hour, error)

func (*Hashring) Next

func (h *Hashring) Next(p *big.Int) *big.Int

func (*Hashring) Next3

func (h *Hashring) Next3(p *big.Int) []*big.Int

func (*Hashring) Prev

func (h *Hashring) Prev(p *big.Int) *big.Int

type Hour

type Hour int32

Hour is just a Unix timestamp divided by 3600, a unique index for an hour

type IPMeta

type IPMeta struct {
	Keys [][]byte
}

type KeyMeta

type KeyMeta struct {
	FirstSeen Hour
	LastSeen  Hour
	IPs       []string
}

type KeysDB

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

func OpenKeysDb

func OpenKeysDb(filename string) (*KeysDB, error)

func (*KeysDB) Close

func (d *KeysDB) Close() error

func (*KeysDB) Lookup

func (d *KeysDB) Lookup(key Hash) (res KeyMeta, err error)

func (*KeysDB) Seen

func (d *KeysDB) Seen(keys []Hash, ips []string, h Hour, wg *sync.WaitGroup)

func (*KeysDB) View

func (d *KeysDB) View(fn func(tx *bolt.Tx) error) error

type MetricData

type MetricData struct {
	Mean   *big.Int
	AbsDev *big.Int
}

func AnalyzePartitionData

func AnalyzePartitionData(data []*PartitionData) *MetricData

func SampleDistance

func SampleDistance(h *Hashring) (res *MetricData)

func SampleDistance4

func SampleDistance4(h *Hashring) (res *MetricData)

type PackReader

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

func NewPackReader

func NewPackReader(filename string) (p *PackReader)

func (*PackReader) Consensus

func (p *PackReader) Consensus() *Consensus

func (*PackReader) Err

func (p *PackReader) Err() error

func (*PackReader) Load

func (p *PackReader) Load() bool

type PackedConsensusHdr

type PackedConsensusHdr struct {
	Time Hour
	Len  int32
}

type PartitionData

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

Jump to

Keyboard shortcuts

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