keyman

package
v0.0.0-...-1a6bc1e Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2017 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const KSM_FILE_NAME string = "key_state"
View Source
const PrimeSize int = 320 // 40 bytes

Variables

View Source
var ErrGenerationDeprecated = errors.New("given generation was created before the current generation was set")

Functions

This section is empty.

Types

type FingerMismatchError

type FingerMismatchError struct {
	ExpectedFingerprint [32]byte
	ActualFingerprint   [32]byte
}

func (*FingerMismatchError) Error

func (e *FingerMismatchError) Error() string

type Generation

type Generation struct {
	//A list of all nodes included in the generation
	Nodes         []string
	CompleteNodes []string
	Elements      []*keyStateElement
}

func (*Generation) AddCompleteNode

func (g *Generation) AddCompleteNode(ownerId string)

func (*Generation) AddElement

func (g *Generation) AddElement(elem *keyStateElement)

func (*Generation) RemoveCompleteNode

func (g *Generation) RemoveCompleteNode()

func (*Generation) RemoveElement

func (g *Generation) RemoveElement()

type Key

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

func GenerateKey

func GenerateKey(size int) (*Key, error)

func NewKey

func NewKey(data []byte) (*Key, error)

func RebuildKey

func RebuildKey(pieces []*KeyPiece) (*Key, error)

Rebuild a Key from a set of KeyPieces. This function will succeed iff len(pieces) >= requiredPieces from the Generate function.

func (Key) GetBytes

func (key Key) GetBytes() []byte

func (Key) GetFingerprint

func (key Key) GetFingerprint() [32]byte

type KeyPiece

type KeyPiece struct {
	Data              []byte
	ParentFingerprint [32]byte // The SHA-256 fingerprint of the key it was generated from.
	Prime             *big.Int // The prime number used in the generation of this KeyPiece.
	Seq               int64    // Where f(Seq) = Data, for some polynomial f
}

func GeneratePieces

func GeneratePieces(key *Key, numPieces, requiredPieces int64) ([]*KeyPiece, error)

Generates numPieces KeyPieces from key. requiredPieces is the number of KeyPieces needed to reconstruct the original key.

type KeyStateMachine

type KeyStateMachine struct {
	CurrentGeneration    int64
	InProgressGeneration int64
	DeprecatedGeneration int64

	// The first index indicates the generation.
	// The second index is unimportant as order doesn't matter there.
	Generations map[int64]*Generation

	// This is, once again, to avoid an import cycle
	PfsDir string

	// Channel is pushed to every time a new generation is created.
	Events chan bool
	// contains filtered or unexported fields
}
var StateMachine *KeyStateMachine

func NewKSM

func NewKSM(pfsDir string) *KeyStateMachine

func NewKSMFromPFSDir

func NewKSMFromPFSDir(pfsDir string) (*KeyStateMachine, error)

func NewKSMFromReader

func NewKSMFromReader(reader io.Reader) (*KeyStateMachine, error)

func (*KeyStateMachine) GetCurrentGeneration

func (ksm *KeyStateMachine) GetCurrentGeneration() int64

func (*KeyStateMachine) GetInProgressGenertion

func (ksm *KeyStateMachine) GetInProgressGenertion() int64

func (*KeyStateMachine) GetNodes

func (ksm *KeyStateMachine) GetNodes(generation int64) ([]string, error)

func (*KeyStateMachine) NeedsReplication

func (ksm *KeyStateMachine) NeedsReplication(uuid string, generationNumber int64) bool

func (*KeyStateMachine) NewGeneration

func (ksm *KeyStateMachine) NewGeneration(newNode string) (generationNumber int64, peers []string, err error)

func (KeyStateMachine) NodeInGeneration

func (ksm KeyStateMachine) NodeInGeneration(generationNumber int64, nodeId string) bool

func (*KeyStateMachine) OwnerComplete

func (ksm *KeyStateMachine) OwnerComplete(ownerId string, generation int64) error

func (*KeyStateMachine) Serialise

func (ksm *KeyStateMachine) Serialise(writer io.Writer) error

func (*KeyStateMachine) SerialiseToPFSDir

func (ksm *KeyStateMachine) SerialiseToPFSDir() error

func (*KeyStateMachine) Update

func (ksm *KeyStateMachine) Update(req *pb.KeyStateCommand) error

func (*KeyStateMachine) UpdateFromStateFile

func (ksm *KeyStateMachine) UpdateFromStateFile(filePath string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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