backend

package
v0.0.0-...-3e9f3e9 Latest Latest
Warning

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

Go to latest
Published: May 23, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TableCENKeys stores the mapping between CENKeys and CENReports.
	TableCENKeys = "CENKeys"

	// TableCENKeys stores the mapping between CENKeys and CENReports.
	TableCENReport = "CENReport"

	// TCNReports is the only table for TCN
	TableTCNReport = "TCNReport"

	// Default Conn String
	DefaultConnString = "root:CoEpi@/conn"
)

Variables

This section is empty.

Functions

func Computehash

func Computehash(data ...[]byte) []byte

Computehash returns the hash of its inputs

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend holds a client to connect to the BigTable backend

func NewBackend

func NewBackend(mysqlConnectionString string) (backend *Backend, err error)

NewBackend sets up a client connection to BigTable to manage incoming payloads

func (*Backend) ProcessCENReport

func (backend *Backend) ProcessCENReport(cenReport *CENReport) (err error)

ProcessCENReport manages the API Endpoint to POST /cenreport

Input: CENReport
Output: error
Behavior: write report bytes to "report" table; write row for each CENKey with reportID

func (*Backend) ProcessGetCENKeys

func (backend *Backend) ProcessGetCENKeys(timestamp uint64) (cenKeys []string, err error)

ProcessGetCENKeys manages the GET API endpoint /cenkeys

Input: timestamp
Output: array of CENKeys (in string form) for the last hour

func (*Backend) ProcessGetCENReport

func (backend *Backend) ProcessGetCENReport(cenKey string) (reports []*CENReport, err error)

ProcessGetCENReport manages the POST API endpoint /cenreport

Input: cenKey
Output: array of CENReports

func (*Backend) ProcessGetTCNReport

func (backend *Backend) ProcessGetTCNReport(intervalNumber string, intervalLength string) (reportStrings []string, err error)

ProcessGetTCNReport manages the GET API endpoint /v4/tcnreport

Input: intervalNumber, intervalLength
Output: array of TCNReports, already encoded as base64, in a list

func (backend *Backend) ProcessGetTCNReport(intervalNumber string, intervalLength string) (reports []*TCNReport, err error)

func (*Backend) ProcessTCNReport

func (backend *Backend) ProcessTCNReport(tcnReportString []byte, tcnRVK []byte) (err error)

ProcessTCNReport manages the API Endpoint to POST /v4/tcnreport

Input: TCNReport, rvk
Output: error
Behavior: write report bytes to "report" table

type CENReport

type CENReport struct {
	ReportID        string `json:"reportID,omitempty"`
	Report          []byte `json:"report,omitempty"`  // this is expected to be a JSON blob but the server doesn't need to parse it
	CENKeys         string `json:"cenKeys,omitempty"` // comma separated list of hex AES-128 Keys
	ReportMimeType  string `json:"reportMimeType,omitempty"`
	ReportTimeStamp uint64 `json:"reportTimeStamp,omitempty"`
}

CENReport payload is sent by client to /cenreport when user reports symptoms

func GetSampleCENReportAndCENKeys

func GetSampleCENReportAndCENKeys(nKeys int) (cenReport *CENReport, cenKeys []string)

GetSampleCENReportAndCENKeys generates a CENReport and an array of CENKeys (in string form)

type TCNReport

type TCNReport struct {
	Report []byte // this is a blob ; parsing done only for signature validation on POST
}

raw bytes of appropriate sizes rvk32 tck32 j1 j2 TLV* sig64 rvk || tck_{j1-1} || le_u16(j1) || le_u16(j2) || type || memo || sig

Jump to

Keyboard shortcuts

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