Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateSemaphore(longTermOraclePublicKey, semaphore *[32]byte) *[32]byte
- type Oracle
- func (self *Oracle) Generate(startTime, ratchetTime, timeToExpire int64) error
- func (self *Oracle) PublicKeys() (longTerm, shortTerm *[32]byte)
- func (self *Oracle) ReceiveMsg(d []byte) ([]byte, error)
- func (self *Oracle) Restore(longTermKey, timeLockKey memprotect.Element, timeToExpire int64) error
- func (self *Oracle) Save() (longTermKey, timeLockKey memprotect.Element)
- func (self *Oracle) TimelockKeys(count int) (*types.RatchetPublicKey, error)
- type OracleFuture
- type OracleMessage
- type OracleMessageContainer
- type SetSemaphoreMsg
- type ShareMsg
- type ShortTermKeyFactory
Constants ¶
MaxShareSize is the maximum size of an embedded share
const OracleMessageEncType = 0xf0
const OracleMessageEnvelopeType = 1020
const OracleMsgContainerTypeID = 1080
const OracleMsgTypeID = 1098
const OracleResponseMessageType = 1021
const SetSemaphoreMsgTypeID = 1001
ShareMsgDecryptBufferSize is the size of the decryption buffer
ShareMsgEncryptBufferSize is the size of the encryption buffer
ShareMsgPadSize is the size to which the ShareMsg will be padded
ShareMsgSize is the size of an encrypted ShareMsg
Variables ¶
var ( ErrTimePolicy = errors.New("oracle: Time policy") ErrSignalSet = errors.New("oracle: Signal is set") ErrWrongResponseKey = errors.New("oracle: Wrong response key") ErrUnhandledMessageType = errors.New("oracle: Unhandled message type") )
var ErrBufferSize = errors.New("messages: Buffer size too small")
Functions ¶
func GenerateSemaphore ¶
Types ¶
type Oracle ¶
type Oracle struct {
// contains filtered or unexported fields
}
func NewOracle ¶
func NewOracle(storage *signalstore.Store, engine memprotect.Engine, exportEngine ...memprotect.Engine) *Oracle
NewOracle
func (*Oracle) Generate ¶
Generate new oracle keys. Ratchet starts with startTime and refreshes with ratchetTime. timeToExpire determines the lifetime of the shortTermKey.
func (*Oracle) PublicKeys ¶
func (*Oracle) ReceiveMsg ¶
ReceiveMsg receives and processes a message to the oracle.
func (*Oracle) Restore ¶
func (self *Oracle) Restore(longTermKey, timeLockKey memprotect.Element, timeToExpire int64) error
func (*Oracle) Save ¶
func (self *Oracle) Save() (longTermKey, timeLockKey memprotect.Element)
func (*Oracle) TimelockKeys ¶
func (self *Oracle) TimelockKeys(count int) (*types.RatchetPublicKey, error)
type OracleFuture ¶
type OracleFuture struct { Message []byte // The encrypted oracle message URL []byte // The URL to which the message is sent ResponsePrivateKey []byte // The private key required to decrypt the response SingleResponsePrivatKey []byte // Single-use response decryption key. // contains filtered or unexported fields }
OracleFuture contains the information required to send and receive an oraclemessage exchange.
func (*OracleFuture) Receive ¶
func (self *OracleFuture) Receive() ([]byte, error)
type OracleMessage ¶
type OracleMessage struct { OracleURL []byte // URL where the Oracle listens. LongTermOraclePublicKey [32]byte // The long-term oracle public key. TimelockPublicKey [32]byte // Timelock key to use, ignore if all zeros. TestSemaphores [3][32]byte // Test these for non-existence SetSemaphores [3][32]byte // Set these ValidFrom int64 // Decrypt only after ValidTo int64 // Decrypt only before ResponsePublicKey [32]byte // The public key to which to encrypt the response }
OracleMessage contains the data of an oracle message. Exported fields must be set.
func (*OracleMessage) Encrypt ¶
func (self *OracleMessage) Encrypt(containerKey []byte, memEngine memprotect.Engine) (oracleContainer []byte, err error)
Encrypt an OracleMessage. It returns the encrypted container of the oracle message. It takes care of generating the correct semaphores from the given values. The container will be encrypted to containerKey.
type OracleMessageContainer ¶
type OracleMessageContainer struct { ValidFrom int64 // Message is valid from ValidTo int64 // Message is valid to OracleLongTermKey []byte // Long Term public key of oracle ResponsePublicKey []byte // Public key of message ResponsePrivateKey []byte // The private key required to decrypt the response OracleURL []byte // The URL to which the message is sent OracleMessage []byte // The encrypted oracle message }
OracleMessageContainer contains an oracle message.
func (*OracleMessageContainer) Decrypt ¶
func (self *OracleMessageContainer) Decrypt(key, d []byte) (*OracleMessageContainer, error)
Decrypt an OracleMessageContainer.
func (*OracleMessageContainer) Send ¶
func (self *OracleMessageContainer) Send(key, d []byte, stkf ShortTermKeyFactory, memEngine memprotect.Engine) (*OracleFuture, error)
Send an oracle message from a container.
type SetSemaphoreMsg ¶
SetSemaphoreMsg sets a semaphore between SetFrom and SetTo.
func (*SetSemaphoreMsg) Marshal ¶
func (self *SetSemaphoreMsg) Marshal(out []byte) []byte
Marshal SetSemaphoreMsg. If out ==nil, a new output slice will be allocated.
func (*SetSemaphoreMsg) Unmarshal ¶
func (self *SetSemaphoreMsg) Unmarshal(d []byte) (r *SetSemaphoreMsg, remainder []byte, err error)
Unmarshal SetSemaphoreMsg. If receiver is nil, a new receiver is created. Otherwise the receiver is used.
type ShareMsg ¶
type ShareMsg struct {}
ShareMsg contains a share of the secret.
func (*ShareMsg) Decrypt ¶
Decrypt an encrypted sharemessage. buf, if not nil, will be used for buffering. To securely decrypt, the receiver should have the Share element set to a byteslice large enough to contain the share data. This will prevent allocation.
func (*ShareMsg) Encrypt ¶
Encrypt a sharemessage. Key is the symmetric key to encrypt to. buf is used as buffer for marshalling and buf2 for encryption if it is not nil. Otherwise a new slice will be allocated.
type ShortTermKeyFactory ¶
ShortTermKeyFactory returns the short term key for an oracle url.