nzcovidpass

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

README

Go NZ COVID Pass decoder

A Go library for decoding and verifying NZ COVID Pass

As the NZ COVID Pass spec is very similar to the EU Digital COVID Certificate, this library is adapted from stapelberg/coronaqr

TODO

  • parse https://nzcp.covid19.health.nz/.well-known/did.json for certificates rather than hardcoded string

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDecoder = &Decoder{}

DefaultDecoder is a ready-to-use Decoder.

Functions

This section is empty.

Types

type Decoded

type Decoded struct {
	Vc         verifiedCredential
	NotBefore  time.Time
	Expiration time.Time
}

Decoded is a NZ COVID Pass

func DecodeAndVerify added in v0.1.1

func DecodeAndVerify(qrdata string, certprov PublicKeyProvider) (*Decoded, error)

type Decoder

type Decoder struct {
	Expired func(time.Time) bool
}

Decoder is a NZ COVID Pass decoder.

func (*Decoder) Decode

func (d *Decoder) Decode(qrdata string) (*Unverified, error)

Decode decodes the NZ COVID Pass QR Code data

type PublicKeyProvider

type PublicKeyProvider interface {
	// GetPublicKey returns the public key of the certificate for the specified
	// key identifier (or country), or an error if the public key was not found.
	//
	// Country is a ISO 3166 alpha-2 code, e.g. CH.
	//
	// kid are the first 8 bytes of the SHA256 digest of the certificate in DER
	// encoding.
	GetPublicKey(kid []byte) (crypto.PublicKey, error)
}

PublicKeyProvider is typically implemented using a JSON Web Key Set, or by pinning a specific government certificate.

func NewNZCertificateProvider

func NewNZCertificateProvider() (PublicKeyProvider, error)

func NewNZTestCertificateProvider added in v0.1.3

func NewNZTestCertificateProvider() (PublicKeyProvider, error)

type Unverified

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

Unverified is a NZ COVID Pass that has been decoded but not verified

func Decode

func Decode(qrdata string) (*Unverified, error)

Decode decodes the specified EU Digital COVID Certificate (EUDCC) QR code data.

func (*Unverified) Verify

func (u *Unverified) Verify(certprov PublicKeyProvider) (*Decoded, error)

Verify checks the cryptographic signature and returns the verified data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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