Documentation ¶
Index ¶
- Variables
- func TrieKeyEqual(x, y TrieKey) bool
- type BalancedIdentityGenerator
- func (bg *BalancedIdentityGenerator) AddBalanced() (crypto.PrivKey, error)
- func (bg *BalancedIdentityGenerator) AddUnbalanced() (crypto.PrivKey, error)
- func (bg *BalancedIdentityGenerator) Count() int
- func (bg *BalancedIdentityGenerator) Depth() int
- func (bg *BalancedIdentityGenerator) Remove(privKey crypto.PrivKey) error
- type CleaningIDGenerator
- type DelegatedIDGenerator
- type IdentityGenerator
- type TrieKey
- type XorTrie
Constants ¶
This section is empty.
Variables ¶
var HydraIdentityGenerator = NewBalancedIdentityGenerator()
HydraIdentityGenerator is a shared balanced ID generator.
Functions ¶
func TrieKeyEqual ¶
Types ¶
type BalancedIdentityGenerator ¶
BalancedIdentityGenerator is a facility for generating IPFS identities (i.e. IPFS private keys), whose corresponding DHT keys are highly balanced, compared to just generating random keys. Balancing is accomplished using "the power of two choices" paradigm: https://www.eecs.harvard.edu/~michaelm/postscripts/mythesis.pdf
New identities are generated by calling AddBalanced. BalancedIdentityGenerator remembers generated identities, in order to ensure balance for future identities. Generated identities can be removed using Remove.
BalancedIdentityGenerator maintains the invariant that all identities, presently in its memory, form an almost-perfectly balanced set.
func NewBalancedIdentityGenerator ¶
func NewBalancedIdentityGenerator() *BalancedIdentityGenerator
NewBalancedIdentityGenerator creates a new balanced identity generator.
func (*BalancedIdentityGenerator) AddBalanced ¶
func (bg *BalancedIdentityGenerator) AddBalanced() (crypto.PrivKey, error)
AddBalanced generates a random identity, which is balanced with respect to the existing identities in the generator. The generated identity is stored in the generator's memory.
func (*BalancedIdentityGenerator) AddUnbalanced ¶
func (bg *BalancedIdentityGenerator) AddUnbalanced() (crypto.PrivKey, error)
AddUnbalanced is used for testing purposes. It generates a purely random identity, which is not balanced with respect to the existing identities in the generator. The generated identity is stored in the generator's memory.
func (*BalancedIdentityGenerator) Count ¶
func (bg *BalancedIdentityGenerator) Count() int
func (*BalancedIdentityGenerator) Depth ¶
func (bg *BalancedIdentityGenerator) Depth() int
type CleaningIDGenerator ¶ added in v0.2.0
type CleaningIDGenerator struct {
// contains filtered or unexported fields
}
CleaningIDGenerator is an identity generator that provides an extra method to remove all previously generated identities without passing any arguments.
func NewCleaningIDGenerator ¶ added in v0.2.0
func NewCleaningIDGenerator(idgen IdentityGenerator) *CleaningIDGenerator
NewCleaningIDGenerator creates a new delegated identity generator that provides an extra method to remove all previously generated identities without passing any arguments.
func (*CleaningIDGenerator) AddBalanced ¶ added in v0.2.0
func (c *CleaningIDGenerator) AddBalanced() (crypto.PrivKey, error)
AddBalanced stores the result of calling AddBalanced on the underlying identify generator and then returns it.
func (*CleaningIDGenerator) Clean ¶ added in v0.2.0
func (c *CleaningIDGenerator) Clean() error
Clean removes ALL previously generated keys by calling Remove on the underlying identity generator for each key in it's memory.
type DelegatedIDGenerator ¶ added in v0.2.0
type DelegatedIDGenerator struct {
// contains filtered or unexported fields
}
DelegatedIDGenerator is an identity generator whose work is delegated to another worker.
func NewDelegatedIDGenerator ¶ added in v0.2.0
func NewDelegatedIDGenerator(addr string) *DelegatedIDGenerator
NewDelegatedIDGenerator creates a new delegated identity generator whose work is delegated to another worker. The delegate must be reachable on the passed HTTP address and respond to HTTP POST messages sent to the following endpoints: `/idgen/add` - returns a JSON string, a base64 encoded private key. `/idgen/remove` - accepts a JSON string, a base64 encoded private key.
func (*DelegatedIDGenerator) AddBalanced ¶ added in v0.2.0
func (g *DelegatedIDGenerator) AddBalanced() (crypto.PrivKey, error)
AddBalanced generates a balanced random identity by sending a HTTP POST request to `/idgen/add`.
type IdentityGenerator ¶ added in v0.2.0
type IdentityGenerator interface { AddBalanced() (crypto.PrivKey, error) Remove(privKey crypto.PrivKey) error }
IdentityGenerator describes a facility that can generate IPFS private keys.
type TrieKey ¶
type TrieKey []byte
TrieKey is a vector of bits backed by a Go byte slice in big endian byte order and big-endian bit order.