entities

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package entities contains database entities and helpers on these entities.

Index

Constants

This section is empty.

Variables

View Source
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

func GetIndexOfSigner(promise *cAPI.Promise, hash []byte) (uint32, error)

GetIndexOfSigner : determines the index of the specified signer's hash in the array of signers' hashes.

func GetPromiseProfile

func GetPromiseProfile(promise *cAPI.Promise) (uint32, uint32, uint32, error)

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

func IsIndexValid(promise *cAPI.Promise) (uint32, error)

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

func IsPlatformSealValid(promise *cAPI.Promise) bool

IsPlatformSealValid : verifies that the specified promise contains the expected information signed by the platform.

func IsPromiseFromAtoB

func IsPromiseFromAtoB(promise *cAPI.Promise, from, to []byte, at uint32) bool

IsPromiseFromAtoB : determines if the specified promise, supposedly from 'A' to 'B' was indeed created by 'A' for 'B'.

func IsSignatureUUIDValid

func IsSignatureUUIDValid(promise *cAPI.Promise) (bool, bson.ObjectId)

IsSignatureUUIDValid : verifies that the specified promise has a valid bons.ObjectId hex, and returns the ObjectId if true.

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

func ArePromisesValid(promises []*cAPI.Promise) (bool, []*Promise)

ArePromisesValid : determines if the specified promises contains coherent information wrt the ASSUMED TESTED platform signed information.

func IsPromiseValid

func IsPromiseValid(promise *cAPI.Promise) (bool, *Promise)

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

func NewPromise(recipientIndex, senderIndex, sequenceIndex uint32) *Promise

NewPromise : creates a new Promise with the specified fields

func (*Promise) Equal added in v0.2.0

func (p1 *Promise) Equal(p2 *Promise) bool

Equal : determines if the two specified promises share the same information, without considering the bson object id.

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

func AreSignersHashesValid(promise *cAPI.Promise) (bool, []Signer)

AreSignersHashesValid : verifies that all the specified hashes are valid (see function IsSignerHashValid). Returns a new array of Signers.

func IsPromiseSignedByPlatform

func IsPromiseSignedByPlatform(promise *cAPI.Promise) (bool, bson.ObjectId, []Signer)

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

func IsSignerHashValid(hash []byte) (bool, *Signer)

IsSignerHashValid : verifies that the specified array of bytes is a correct SHA-512 hash. Returns a new Signer with the specified hash.

func NewSigner

func NewSigner(hash []byte) *Signer

NewSigner : creates a new Signer with the specified hash

The specified hash validity is not checked in this function (see function IsValidSignerHash)

Jump to

Keyboard shortcuts

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