Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
quantumlayer.go 1.42 KiB
// This package aims at emulating a quantum link and is extendable to different models
// One can use most of the sourc code of emu-prng and reuse it.
// To add a different quantum module one should only modify the GenerateRandomNumbers function

package quantumlayer

type QuantumLayerBulkKey struct {
	BulkKeyId     int64   // the unique ID of this bulk of keys
	BulkKeyLength int     // the length, counted in bytes, of bulkKey
	BulkKey       *[]byte // the bulk key
}

type QuantumLayer interface {
	PowerOn(...string)                              // switch on the quantum layer element
	PowerOff()                                      // switch off the quantum layer element
	AddPeer()                                       // Adds a Quantum Layer Peer to the peer list
	RemovePeer()                                    // Remmoves a Quantum Layer Peer to the peer list
	GetLocalQLPort()                                // Returns the information about the local quantum layer IP and port
	GetKeyBatchPeer() (QuantumLayerBulkKey, error)  // retrieve the bulk key received from peer
	GetKeyBatchLocal() (QuantumLayerBulkKey, error) // retrieve  the bulk key generated locally
	GenerateRandomNumbers() []byte                  // generate a number of random numbers
}

type NumberLayer interface {
	GetBatch() []byte // allows to retrieve the current available batch of numbers
	GetBulk() (QuantumLayerBulkKey, error)
	receiveNumbers(chan []byte)
}