Categorygithub.com/reznik99/go-dcc
modulepackage
0.2.0
Repository: https://github.com/reznik99/go-dcc.git
Documentation: pkg.go.dev

# README

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

GO-DCC

A simple library to View, Generate and Verify EU-DCC / Vaccine Passes
Explore the docs »

Report Bug · Request Feature

About This Package

Product Name Screen Shot

This package offers simple API calls to Decode, Encode and Verify Vaccine Passes.
APIs are subject to changes as improvements are made.

Getting Started

Prerequisites

Go get the module to import it into your project

  1. Download package
    go get -u github.com/reznik99/go-dcc
    

Usage

Below is some examples of how you can use this package, without explicit error handling for simplicity's sake

  1. To generate a Vaccine Pass using data from data.json

    import (
        "github.com/reznik99/go-dcc"
    )
    
    func main() {
         // Base64 of first 8 bytes in Signer Certificate
         kid := "dy8HnMQYOrE="
    
         // Generate or load Signer Key
         privKey, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
    
         // Generate/Sign Vaccine Pass and save as QR code
         dcc.GenerateQR(privKey, kid, "/path/to/data.json", "/path/to/new-pass.png")
    
         // Generate/Sign Vaccine Pass Raw string "HC1:..."
         dcc.Generate(privKey, kid, "/path/to/data.json")
    }
    
  2. To validate/verify a Vaccine Pass

    import (
        "github.com/reznik99/go-dcc"
    )
    
    func main() {
         // Parse Raw Vaccine Pass
         _, rawMsg, _ := dcc.Parse("/path/to/mypass.txt")
         // Parse QR Code Vaccine Pass
         _, rawMsg, _ := dcc.ParseQR("/path/to/mypass.png")
    
         // Verify Vaccine Pass signature. note: currently slow! This will fetch the PEM Signer Certificates and KIDs
         valid, _ := dcc.Verify(rawMsg)
         
         fmt.Printf("Vaccine Pass Valid: %t\n", valid)
    }
    
  3. To decode/read a Vaccine Pass

     import (
         "fmt"
         "github.com/reznik99/go-dcc"
         "github.com/ethereum/go-ethereum/common/hexutil"
     )
    
     func main() {
         // Parse Raw Vaccine Pass
         payload, _, _ := dcc.Parse("/path/to/mypass.txt")
         // Parse QR Code Vaccine Pass
         payload, _, _ := dcc.ParseQR("/path/to/mypass.png")
    
         // Print contents to STDOUT
         prettyDCC, _ := json.MarshalIndent(payload, "", "	")
         fmt.Printf("Headers:   %v\n", rawMsg.Headers)
         fmt.Printf("Payload:   %s\n", prettyDCC)
         fmt.Printf("Signature: %s\n", hexutil.Encode(rawMsg.Signature))
     }
    

Example JSON data file

    {
        "name": "JOHN",
        "surname": "DOE",
        "dob": "1996-06-06",
        "issuerCountry": "NZ",
        "issuer": "Ministry of Health, NZ",
        "vaccinationDate": "2021-10-21",
        "doses": 2
    }

For more examples, please refer to the Documentation

(back to top)

Roadmap

  • Decode/Read EU DCC certs
  • Encode/Generate EU DCC certs (Valid schema but not valid signature obviously)
  • Verify/Validate EU DCC certs (This is not working quite yet)
  • Improve KID and Signer Certificate fetching logic or allow user to specify values for performance.

See the open issues for a full list of proposed features (and known issues).

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Francesco Gorini - [email protected] - https://francescogorini.com

Project Link: https://github.com/reznik99/go-dcc/

(back to top)

# Functions

Generates Vaccine Passport with json data read from 'dataPath' and returns raw Vaccine Pass string as `HC1:...`.
Generates Vaccine Passport with json data read from 'dataPath' and writes the Vaccine Pass as a QR code file at 'outputPath'.
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.
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.
Verify a Vaccine Passport's signature, it reads the *cose.Sign1Message parameter and returns the status and/or error.

# Variables

No description provided by the author
No description provided by the author
Biontech Manufacturing GmbH.
No description provided by the author
No description provided by the author
SARS-CoV-2 mRNA vaccine.

# Structs

DCC Payload data to be read from file.
DCC (Digital Covid Certificate) Top Level CBOR structure Section 3.3.1 at https://ec.europa.eu/health/sites/default/files/ehealth/docs/digital-green-certificates_v1_en.pdf.
No description provided by the author
No description provided by the author
No description provided by the author
DCC Payload for Vaccination group type of HCERT.