Documentation ¶
Index ¶
- Constants
- Variables
- type FingerMismatchError
- type Generation
- type Key
- type KeyPiece
- type KeyStateMachine
- func (ksm *KeyStateMachine) GetCurrentGeneration() int64
- func (ksm *KeyStateMachine) GetInProgressGenertion() int64
- func (ksm *KeyStateMachine) GetNodes(generation int64) ([]string, error)
- func (ksm *KeyStateMachine) NeedsReplication(uuid string, generationNumber int64) bool
- func (ksm *KeyStateMachine) NewGeneration(newNode string) (generationNumber int64, peers []string, err error)
- func (ksm *KeyStateMachine) NodeInGeneration(generationNumber int64, nodeID string) bool
- func (ksm *KeyStateMachine) OwnerComplete(ownerID string, generation int64) error
- func (ksm *KeyStateMachine) Serialise(writer io.Writer) error
- func (ksm *KeyStateMachine) SerialiseToPFSDir() error
- func (ksm *KeyStateMachine) Update(req *pb.KeyStateCommand) error
- func (ksm *KeyStateMachine) UpdateFromStateFile(filePath string) error
Constants ¶
const KsmFileName string = "key_state"
KsmFileName stores the name of the file used to store the key state (duh)
const PrimeSize int = 320 // 40 bytes
PrimeSize determines the size of the prime number to be used when creating the key
Variables ¶
var ErrGenerationDeprecated = errors.New(
"given generation was created before the current generation was set")
ErrGenerationDeprecated is self explanatory. Just read it.
Functions ¶
This section is empty.
Types ¶
type FingerMismatchError ¶
FingerMismatchError is rained when the key fingerprint does not match
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 }
Generation stores the information about specific key generation.
func (*Generation) AddCompleteNode ¶
func (g *Generation) AddCompleteNode(ownerID string)
AddCompleteNode to the generation
func (*Generation) AddElement ¶
func (g *Generation) AddElement(elem *keyStateElement)
AddElement to the generation
func (*Generation) RemoveCompleteNode ¶
func (g *Generation) RemoveCompleteNode()
RemoveCompleteNode from the generation
func (*Generation) RemoveElement ¶
func (g *Generation) RemoveElement()
RemoveElement fromm the generation
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key contains the full key together with its fingerprint
func GenerateKey ¶
GenerateKey creates a new key of the specified size. If the size does not equal 16, 24 or 32, an error is returned
func NewKey ¶
NewKey generates a new key from a set of bytes. If the number of bytes does not equal 16, 24 or 32, an error is returned
func RebuildKey ¶
RebuildKey from a set of KeyPieces. This function will succeed iff len(pieces) >= requiredPieces from the Generate function.
func (Key) GetFingerprint ¶
GetFingerprint returns the fingerprint of the key
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 }
KeyPiece stores the individual information about a piece of the 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 }
KeyStateMachine controls the key state
var StateMachine *KeyStateMachine
StateMachine is an instance of KeyStateMachine
func NewKSM ¶
func NewKSM(pfsDir string) *KeyStateMachine
NewKSM returns a new instantiated KeyStateMachine
func NewKSMFromPFSDir ¶
func NewKSMFromPFSDir(pfsDir string) (*KeyStateMachine, error)
NewKSMFromPFSDir returns a new instantiated KeyStateMachine from the specific paranoid directory
func NewKSMFromReader ¶
func NewKSMFromReader(reader io.Reader) (*KeyStateMachine, error)
NewKSMFromReader returns a new instantiated KeyStateMachine from the io.Reader interface
func (*KeyStateMachine) GetCurrentGeneration ¶
func (ksm *KeyStateMachine) GetCurrentGeneration() int64
GetCurrentGeneration returns the number of the current gen.
func (*KeyStateMachine) GetInProgressGenertion ¶
func (ksm *KeyStateMachine) GetInProgressGenertion() int64
GetInProgressGenertion returns the number of the new upcoming gen. TODO: s/GetInProgressGenertion/GetInProgressGeneration
func (*KeyStateMachine) GetNodes ¶
func (ksm *KeyStateMachine) GetNodes(generation int64) ([]string, error)
GetNodes of the generation. If there is a problem with getting the nodes an error is returned
func (*KeyStateMachine) NeedsReplication ¶
func (ksm *KeyStateMachine) NeedsReplication(uuid string, generationNumber int64) bool
NeedsReplication checks does a new generation have to be created TODO: Make sure this is correct.
func (*KeyStateMachine) NewGeneration ¶
func (ksm *KeyStateMachine) NewGeneration( newNode string, ) ( generationNumber int64, peers []string, err error, )
NewGeneration creates a new generation when a new node is added.
func (*KeyStateMachine) NodeInGeneration ¶
func (ksm *KeyStateMachine) NodeInGeneration(generationNumber int64, nodeID string) bool
NodeInGeneration checks is the specified node in the provided generation
func (*KeyStateMachine) OwnerComplete ¶
func (ksm *KeyStateMachine) OwnerComplete(ownerID string, generation int64) error
OwnerComplete assigns an owner TODO: Make sure this is correct.
func (*KeyStateMachine) Serialise ¶
func (ksm *KeyStateMachine) Serialise(writer io.Writer) error
Serialise to GOB encoding and write to the io.Writer
func (*KeyStateMachine) SerialiseToPFSDir ¶
func (ksm *KeyStateMachine) SerialiseToPFSDir() error
SerialiseToPFSDir as gob and write to file
func (*KeyStateMachine) Update ¶
func (ksm *KeyStateMachine) Update(req *pb.KeyStateCommand) error
Update the KeyStateMachine
func (*KeyStateMachine) UpdateFromStateFile ¶
func (ksm *KeyStateMachine) UpdateFromStateFile(filePath string) error
UpdateFromStateFile updates the KeyStateMachine from a file.