Skip to content

Commit

Permalink
Comments and parameter changes
Browse files Browse the repository at this point in the history
  • Loading branch information
reznik99 committed Dec 8, 2021
1 parent ab642b6 commit 4e10f00
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
18 changes: 8 additions & 10 deletions dcc-generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import (
// TODO: Temporary hardcoded Key ID
var newZealandKID4 = "dy8HnMQYOrE="

func GenerateQR(inputPath string, outputPath string) error {
// Generates Vaccine Passport with json data read from 'qrPath' and outputs the Pass as a QR code at 'outputPath'
func GenerateQR(qrPath string, outputPath string) error {

raw, err := Generate(inputPath, outputPath)
raw, err := Generate(qrPath)
if err != nil {
return err
}
Expand All @@ -34,9 +35,10 @@ func GenerateQR(inputPath string, outputPath string) error {
return nil
}

func Generate(inputPath string, outputPath string) (dccBase54 string, err error) {
// Generates Vaccine Passport with json data read from 'dataPath' and returns raw Pass string as `HC1:...`
func Generate(dataPath string) (dccBase45 string, err error) {

conf, err := readRaw(inputPath)
conf, err := readRaw(dataPath)
if err != nil {
return
}
Expand Down Expand Up @@ -64,15 +66,11 @@ func Generate(inputPath string, outputPath string) (dccBase54 string, err error)
dccCOSEcompressed := zlibCompress(dccCOSE)

// Encode zlib compressed cose to base45
dccBase45 := base45.EncodeToString(dccCOSEcompressed)
dccBase45 = base45.EncodeToString(dccCOSEcompressed)

// Prepend magic HC1 (Health Certificate Version 1)
dccBase45 = fmt.Sprintf("HC1:%s", dccBase45)
dccBase45 = fmt.Sprintf("%s%s", dccPrefix, dccBase45)

err = ioutil.WriteFile(outputPath, []byte(dccBase45), 0644)
if err != nil {
return
}
return
}

Expand Down
7 changes: 5 additions & 2 deletions dcc-parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import (

var dccPrefix = "HC1:"

func ParseQR(path string) error {
return errors.New("QRCode parsing not yet implemented")
// ParseQR parses a Vaccine Passport, it reads the image file at 'path', decoding the QR code and returns the Pass Payload and Raw COSE message containing headers, payload and signatures
func ParseQR(path string) (payload *DCC, messageRaw *cose.Sign1Message, err error) {
err = errors.New("QRCode parsing not yet implemented")
return
}

// Parse parses a Vaccine Passport, it reads the file at 'path' and returns the Pass Payload and Raw COSE message containing headers, payload and signatures
func Parse(path string) (payload *DCC, messageRaw *cose.Sign1Message, err error) {

// Read vaccine pass
Expand Down
9 changes: 2 additions & 7 deletions dcc-validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@ var (
API_BASE_URL = "https://get.dgc.gov.it/v1/dgc"
)

// Verify verifies a Vaccine Passport, it reads the file of type fileType
func Verify(filePath string) (valid bool, err error) {
// Parse certificate from raw or QR code, returning raw cose and parsed dcc payload
_, raw, err := Parse(filePath)
if err != nil {
return
}
// Verify verifies a Vaccine Passport's signature, it reads the file at 'filePath' and returns the status and/or error
func Verify(raw *cose.Sign1Message) (valid bool, err error) {

// Fetch KIDs to compare
kidsList, err := fetchValidKIDs()
Expand Down
3 changes: 0 additions & 3 deletions dcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ var (
VaccineProduct = "EU/1/20/1528"
VaccineType = "1119349007" // SARS-CoV-2 mRNA vaccine
MarketingAuthorisation = "ORG-100030215" // Biontech Manufacturing GmbH

TypeQRCode = 1
TypeRAWGreepass = 2
)

func generateDCCStruct(name, surname, dob, issuerCountry, issuer, vaccinationDate string, vaccinationDoses int) *DCC {
Expand Down

0 comments on commit 4e10f00

Please sign in to comment.