Documentation ¶
Overview ¶
Package entities contains database entities and helpers on these entities.
Index ¶
- Variables
- func GetIndexOfSigner(promise *cAPI.Promise, hash []byte) (uint32, error)
- func GetPromiseProfile(promise *cAPI.Promise) (uint32, uint32, uint32, error)
- func IsIndexValid(promise *cAPI.Promise) (uint32, error)
- func IsPlatformSealValid(promise *cAPI.Promise) bool
- func IsPromiseFromAtoB(promise *cAPI.Promise, from, to []byte, at uint32) bool
- func IsSignatureUUIDValid(promise *cAPI.Promise) (bool, bson.ObjectId)
- type AbortedSigner
- type ArchivesManager
- func (manager *ArchivesManager) AddPromise(promise *Promise)
- func (manager *ArchivesManager) AddToAbort(signerIndex uint32)
- func (manager *ArchivesManager) AddToDishonest(signerIndex uint32)
- func (manager *ArchivesManager) ContainsSignature(signatureUUID bson.ObjectId) (present bool, archives *SignatureArchives)
- func (manager *ArchivesManager) HasReceivedAbortToken(signerIndex uint32) bool
- func (manager *ArchivesManager) HasSignerPromised(signer uint32) bool
- func (manager *ArchivesManager) InitializeArchives(promise *cAPI.Promise, signatureUUID bson.ObjectId, signers *[]Signer) error
- func (manager *ArchivesManager) WasContractSigned() (bool, []byte)
- type Promise
- type SignatureArchives
- type Signer
- func AreSignersHashesValid(promise *cAPI.Promise) (bool, []Signer)
- func IsPromiseSignedByPlatform(promise *cAPI.Promise) (bool, bson.ObjectId, []Signer)
- func IsRequestValid(ctx context.Context, promises []*cAPI.Promise) (valid bool, signatureUUID bson.ObjectId, signers []Signer, senderIndex uint32)
- func IsSignerHashValid(hash []byte) (bool, *Signer)
- func NewSigner(hash []byte) *Signer
Constants ¶
This section is empty.
Variables ¶
var AuthContainer *security.AuthContainer
AuthContainer is global for performance reasons; singleton is not a problem. This variable should be loaded by dfsst/server package.
Functions ¶
func GetIndexOfSigner ¶
GetIndexOfSigner : determines the index of the specified signer's hash in the array of signers' hashes.
func GetPromiseProfile ¶
GetPromiseProfile : retrieves the indexes of the recipient and sender in the array of signers' hashes, and the index of the promise. If the specified promise is not valid wrt to it's index and sender, returns an error.
func IsIndexValid ¶
IsIndexValid : determines if the index field of the promise is valid wrt the sender hash and the sequence, and returns it.
func IsPlatformSealValid ¶ added in v0.3.0
IsPlatformSealValid : verifies that the specified promise contains the expected information signed by the platform.
func IsPromiseFromAtoB ¶
IsPromiseFromAtoB : determines if the specified promise, supposedly from 'A' to 'B' was indeed created by 'A' for 'B'.
Types ¶
type AbortedSigner ¶
type AbortedSigner struct { ID bson.ObjectId `key:"_id" bson:"_id"` // Internal id of an AbortedSigner SignerIndex uint32 `key:"signerIndex" bson:"signerIndex"` // Index of the signer in the signers set AbortIndex uint32 `key:"abortIndex" bson:"abortIndex"` // Index in the sequence where the signer contacted the ttp and recieveed an abort token }
AbortedSigner : represents a signer who was sent an abort token
func NewAbortedSigner ¶
func NewAbortedSigner(signerIndex, abortIndex uint32) *AbortedSigner
NewAbortedSigner : creates a new AbortedSigner with the specified fields
type ArchivesManager ¶
type ArchivesManager struct { DB *mgdb.MongoManager Archives *SignatureArchives }
ArchivesManager : handles the structure of a SignatureArchives, with functions suited for the TTP resolve protocol.
func NewArchivesManager ¶
func NewArchivesManager(db *mgdb.MongoManager) *ArchivesManager
NewArchivesManager : create a new archivesManager, with the specified mgdb manager, but doesn't initialize the signatureArchives. (see function 'InitializeArchives').
func (*ArchivesManager) AddPromise ¶
func (manager *ArchivesManager) AddPromise(promise *Promise)
AddPromise : adds the specified promises to the list of received promises of the SignatureArchives. If we have already a promise from this client, does not add it.
func (*ArchivesManager) AddToAbort ¶
func (manager *ArchivesManager) AddToAbort(signerIndex uint32)
AddToAbort : adds the specified signer to the aborted signers of the signatureArchives. If the signer is already present, does nothing.
func (*ArchivesManager) AddToDishonest ¶
func (manager *ArchivesManager) AddToDishonest(signerIndex uint32)
AddToDishonest : adds the specified signer to the dishonest signers of the signatureArchives. If the signer is already present, does nothing.
func (*ArchivesManager) ContainsSignature ¶
func (manager *ArchivesManager) ContainsSignature(signatureUUID bson.ObjectId) (present bool, archives *SignatureArchives)
ContainsSignature : checks if the specified signatureUUID matches a SignatureArchives in the database. If it exists, returns it.
func (*ArchivesManager) HasReceivedAbortToken ¶
func (manager *ArchivesManager) HasReceivedAbortToken(signerIndex uint32) bool
HasReceivedAbortToken : determines if the specified signer has already been sent an abort token in the specified signatureArchives.
func (*ArchivesManager) HasSignerPromised ¶
func (manager *ArchivesManager) HasSignerPromised(signer uint32) bool
HasSignerPromised : determines if the specified signer has promised to sign at least one time.
func (*ArchivesManager) InitializeArchives ¶
func (manager *ArchivesManager) InitializeArchives(promise *cAPI.Promise, signatureUUID bson.ObjectId, signers *[]Signer) error
InitializeArchives : if an entry in the database for this signature exists, retrieves it, otherwise creates it.
This function should only be called after function IsRequestValid.
func (*ArchivesManager) WasContractSigned ¶
func (manager *ArchivesManager) WasContractSigned() (bool, []byte)
WasContractSigned : determines if the ttp already generated a signed contract for this signatureArchives, and returns it if true.
type Promise ¶
type Promise struct { ID bson.ObjectId `key:"_id" bson:"_id"` // Internal id of a Promise RecipientKeyIndex uint32 `key:"recipientKeyIndex" bson:"recipientKeyIndex"` // Index of the hash of the recipient's certificate in // the `Signers` field of the enclosing SignatureArchives (identical to the one in the signers hashes array of the incoming promises) SenderKeyIndex uint32 `key:"senderKeyIndex" bson:"senderKeyIndex"` // Index of the hash of the sender's certificate in // the `Signers` field of the enclosing SignatureArchives (identical to the one in the signers hashes array of the incoming promises) SequenceIndex uint32 `key:"sequenceIndex" bson:"sequenceIndex"` // Sequence index of the promise }
Promise : represents a valid promise
func ArePromisesValid ¶
ArePromisesValid : determines if the specified promises contains coherent information wrt the ASSUMED TESTED platform signed information.
func IsPromiseValid ¶
IsPromiseValid : determines if the specified promise contains coherent information wrt the ASSUMED TESTED platform signed information. ie: the sender and recipient's hashes are correct
the index of the promise coresponds to an expected message from the sender in the signed sequence
If true, returns a new promise entity
func NewPromise ¶
NewPromise : creates a new Promise with the specified fields
type SignatureArchives ¶
type SignatureArchives struct { ID bson.ObjectId `key:"_id" bson:"_id"` // Internal id of a SignatureArchives - The unique signature identifier Sequence []uint32 `key:"sequence" bson:"sequence"` // Signing sequence Signers []Signer `key:"signers" bson:"signers"` // List of signers TextHash []byte `key:"textHash" bson:"textHash"` // Small hash of the contract Seal []byte `key:"seal" bson:"seal"` // Seal provided by the platform to authentify the context ReceivedPromises []Promise `key:"receivedPromises" bson:"receivedPromises"` // Set of valid received promises (1 by sender) AbortedSigners []AbortedSigner `key:"abortedSigners" bson:"abortedSigners"` // Signers that were sent an abort token DishonestSigners []uint32 `key:"dishonestSigners" bson:"dishonestSigners"` // Indexes of the signers that were evaluated as dishonest SignedContract []byte `key:"signedContract" bson:"signedContract"` // Signed contract resulting of the signing process }
SignatureArchives : represents the valid archives related to a signature process
func NewSignatureArchives ¶
func NewSignatureArchives(signatureUUID bson.ObjectId, sequence []uint32, signers []Signer, textHash, seal []byte) *SignatureArchives
NewSignatureArchives : creates a new SignatureArchives with the specified parameters
func (*SignatureArchives) ContainsSigner ¶ added in v0.3.0
func (archives *SignatureArchives) ContainsSigner(hash []byte) (bool, uint32)
ContainsSigner : determines whether or not the specified signer is one of the signers, and also returns the sequence id of said signer.
type Signer ¶
type Signer struct { ID bson.ObjectId `key:"_id" bson:"_id"` // Internal id of a Signer Hash []byte `key:"hash" bson:"hash"` // The SHA-512 hash of the signer's certificate }
Signer : represents a signer for the TTP
func AreSignersHashesValid ¶
AreSignersHashesValid : verifies that all the specified hashes are valid (see function IsSignerHashValid). Returns a new array of Signers.
func IsPromiseSignedByPlatform ¶
IsPromiseSignedByPlatform : determines if the specified promise contains valid information, correctly signed by the platform, and returns the signatureUUID if true.
func IsRequestValid ¶
func IsRequestValid(ctx context.Context, promises []*cAPI.Promise) (valid bool, signatureUUID bson.ObjectId, signers []Signer, senderIndex uint32)
IsRequestValid : determines if there are no errors in the received request. ie: the information signed by the platform in the received promises is valid and consistent
the sender of the request is present amongst the signed signers of the promises
func IsSignerHashValid ¶
IsSignerHashValid : verifies that the specified array of bytes is a correct SHA-512 hash. Returns a new Signer with the specified hash.