Skip to content

reznik99/go-dcc

Repository files navigation

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 - goras.francesco@gmail.com - https://francescogorini.com

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

(back to top)

About

EU Digital Covid Certificate utilities in Go [Create, Validate and Parse Green-Pass/EU-DCC]

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages