tcn

package
v0.0.0-...-79e4f8a Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The CoEpi symptom self-report format, version 1
	CoEpiV1Code = 0x0
	// The CovidWatch test data format, version 1
	CovidWatchV1Code = 0x1
	// ITOMemoCode is the code that marks a report as an ito report in the
	// memo.
	ITOMemoCode = 0x2
	// ReportMinLength is the minimum length of a TCN report (with memo data
	// of length 0) in bytes.
	ReportMinLength = 70
)

Describes the intended type of the contents of a memo field.

View Source
const (
	// SignedReportMinLength defines a signed report's minimum length in bytes
	SignedReportMinLength = ReportMinLength + ed25519.SignatureSize
)

Variables

View Source
var HTCKDomainSep = []byte("H_TCK")

HTCKDomainSep is the domain separator used for the TCK domain-separated hash function.

View Source
var HTCNDomainSep = []byte("H_TCN")

HTCNDomainSep is the domain separator for the TCN domain-separated hash function.

Functions

This section is empty.

Types

type Report

type Report struct {
	RVK      ed25519.PublicKey
	TCKBytes [32]byte
	J1       uint16
	J2       uint16
	MemoType uint8
	MemoData []uint8
}

Report represents a report as described in the TCN protocol: https://github.com/TCNCoalition/TCN#reporting

func GetReport

func GetReport(data []byte) (*Report, uint16, error)

GetReport inteprets data as a report and returns it as a parsed structure.

func (*Report) Bytes

func (r *Report) Bytes() ([]byte, error)

Bytes converts r to a concatenated byte array represention.

func (Report) TemporaryContactNumbers

func (r Report) TemporaryContactNumbers() (map[uint16]TemporaryContactNumber, error)

TemporaryContactNumbers returns a slice over all temporary contact numbers included in the report.

type ReportAuthorizationKey

type ReportAuthorizationKey struct {
	RAK ed25519.PrivateKey
	RVK ed25519.PublicKey
}

ReportAuthorizationKey authorizes publication of a report of potential exposure.

func NewReportAuthorizationKey

func NewReportAuthorizationKey() (*ReportAuthorizationKey, error)

NewReportAuthorizationKey initialize a new report authorization key from a random number generator.

func (*ReportAuthorizationKey) CreateReport

func (r *ReportAuthorizationKey) CreateReport(memoType uint8, memoData []uint8, j1, j2 uint16) (*Report, error)

CreateReport creates a report of potential exposure.

Inputs

- `memoType`, `memoData`: the type and data for the report's memo field. - `j_1 > 0`: the ratchet index of the first temporary contact number in the report. - `j_2`: the ratchet index of the last temporary contact number other users should check.

Notes

Creating a report reveals *all* temporary contact numbers subsequent to `j_1`, not just up to `j_2`, which is included for convenience.

The `memo_data` must be less than 256 bytes long.

Reports are unlinkable from each other **only up to the memo field**. In other words, adding the same high-entropy data to the memo fields of multiple reports will cause them to be linkable.

func (*ReportAuthorizationKey) CreateSignedReport

func (r *ReportAuthorizationKey) CreateSignedReport(memoType uint8, memoData []uint8, j1, j2 uint16) (*SignedReport, error)

CreateSignedReport creates a signed exposure report, whose source integrity can be verified to produce a `Report`.

func (*ReportAuthorizationKey) InitialTCK

func (r *ReportAuthorizationKey) InitialTCK() (*TemporaryContactKey, error)

InitialTCK computes the initial temporary contact key derived from this report authorization key. Note: this function returns `tck_1`, the first temporary contact key that can be used to generate tcks.

type SignedReport

type SignedReport struct {
	*Report
	// This is an ed25519 signature in byte array form
	// The ed25519 package returns a byte array as the signature
	// here: https://golang.org/pkg/crypto/ed25519/#PrivateKey.Sign
	Sig []byte
}

SignedReport contains a report and the corresponding signature. The client sends this to the server.

func GenerateSignedReport

func GenerateSignedReport(rak *ed25519.PrivateKey, report *Report) (*SignedReport, error)

GenerateSignedReport signs a report with rak and returns the signed report.

func GetSignedReport

func GetSignedReport(data []byte) (*SignedReport, error)

GetSignedReport interprets data as a signed report and returns it as a parsed structure.

func (*SignedReport) Bytes

func (sr *SignedReport) Bytes() ([]byte, error)

Bytes converts sr to a concatenated byte array representation.

func (*SignedReport) Verify

func (sr *SignedReport) Verify() (bool, error)

Verify checks the source integrity of this report.

type TemporaryContactKey

type TemporaryContactKey struct {
	Index    uint16
	RVK      ed25519.PublicKey
	TCKBytes [32]byte
}

TemporaryContactKey is a ratcheting key used to derive temporary contact numbers.

func (*TemporaryContactKey) Ratchet

func (tck *TemporaryContactKey) Ratchet() (*TemporaryContactKey, error)

Ratchet the key forward, producing a new key for a new temporary contact number.

func (*TemporaryContactKey) TemporaryContactNumber

func (tck *TemporaryContactKey) TemporaryContactNumber() (*TemporaryContactNumber, error)

TemporaryContactNumber computes the temporary contact number derived from this key.

type TemporaryContactNumber

type TemporaryContactNumber [16]uint8

TemporaryContactNumber is a pseudorandom 128-bit value broadcast to nearby devices over Bluetooth.

func (TemporaryContactNumber) ToString

func (tcn TemporaryContactNumber) ToString() string

ToString dumps TCN to string

Jump to

Keyboard shortcuts

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