{"id":20773410,"url":"https://github.com/rust-italia/dgc","last_synced_at":"2025-07-26T20:35:47.572Z","repository":{"id":43694880,"uuid":"380576769","full_name":"rust-italia/dgc","owner":"rust-italia","description":"A parser and validator for the EU Digital Green Certificate (dgc) a.k.a. greenpass","archived":false,"fork":false,"pushed_at":"2022-02-23T11:29:17.000Z","size":3618,"stargazers_count":27,"open_issues_count":12,"forks_count":11,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-07-06T16:17:34.484Z","etag":null,"topics":["base45","cbor","certificate","cose","cwt","dgc","eu","europe","green","greenpass","parser","qrcode","rust","rust-crate","rust-library","validator"],"latest_commit_sha":null,"homepage":"https://github.com/rust-italia/dgc","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rust-italia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-26T18:59:16.000Z","updated_at":"2025-06-03T10:13:04.000Z","dependencies_parsed_at":"2022-09-16T18:50:25.884Z","dependency_job_id":null,"html_url":"https://github.com/rust-italia/dgc","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/rust-italia/dgc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-italia%2Fdgc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-italia%2Fdgc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-italia%2Fdgc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-italia%2Fdgc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-italia","download_url":"https://codeload.github.com/rust-italia/dgc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-italia%2Fdgc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267228949,"owners_count":24056373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["base45","cbor","certificate","cose","cwt","dgc","eu","europe","green","greenpass","parser","qrcode","rust","rust-crate","rust-library","validator"],"created_at":"2024-11-17T12:25:40.908Z","updated_at":"2025-07-26T20:35:47.524Z","avatar_url":"https://github.com/rust-italia.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dgc\n\n\u003cimg src=\"https://github.com/rust-italia/dgc/raw/main/dgc-rust-logo.svg\" alt=\"DGC rust library logo\" width=\"300\"\u003e\n\n[![Test](https://github.com/rust-italia/dgc/actions/workflows/Test.yml/badge.svg)](https://github.com/rust-italia/dgc/actions/workflows/Test.yml)\n[![codecov](https://codecov.io/gh/rust-italia/dgc/branch/main/graph/badge.svg?token=4CNbvgaDc1)](https://codecov.io/gh/rust-italia/dgc)\n[![crates.io badge](https://img.shields.io/crates/v/dgc.svg)](https://crates.io/crates/dgc)\n[![Documentation](https://docs.rs/dgc/badge.svg)](https://docs.rs/dgc)\n[![dependency status](https://deps.rs/repo/github/rust-italia/dgc/status.svg)](https://deps.rs/repo/github/rust-italia/dgc)\n\nA parser and validator for the **EU Digital Green Certificate (dgc)** a.k.a. _greenpass_ 📲✅\n\n  - **Parses** the text content of a European Digital Green Certificate (dgc or greenpass) and extract the embedded data\n  - Uses a **Trustlist** of **public keys** and **Elliptic Curve** cryptography to be able to validate the signature of a given certificate\n  - It's tested against 500+ certificates from the [official testing dataset](https://github.com/eu-digital-green-certificates/dgc-testdata)\n  - It offers a **minimal and easy to use API**\n  - The certificate data can be easily serialized/deserialized for ease of testing and reporting\n  - It embeds the [official **valueset**](https://github.com/ehn-dcc-development/ehn-dcc-schema/) so that internal IDs (diseases, result types, countries, testing authorities, etc.) can be easily expanded to their descriptive equivalents\n  - It reports errors for all fallible operations minimising the opportunity for panicking\n  - Offers utilities for easily populate a Trustlist from various types of keys and apis\n\n\n## Usage\n\nTo install the latest version of `dgc`, add this to your Cargo.toml:\n\n```toml\n[dependencies]\ndgc = \"*\"\n```\n\n\n## Dgc in action\n\nThis library tries to address 2 main use cases:\n\n### 1. Decode a certificate without validating its signature\n\n```rust\nlet raw_certificate_data = \"HC1:NCF:603A0T9WTWGSLKC 4K694WJN.0J$6C-7WAB0XK3JCSGA2F3R8PP4V2F35VPP.EY50.FK8ZKO/EZKEZ96LF6/A6..DV%DZJC0/D5UA QELPCG/DYUCHY83UAGVC*JCNF6F463W5KF6VF6IECSHG4KCD3DX47B46IL6646H*6MWEWJDA6A:961A6Q47EM6B$DFOC0R63KCZPCNF6OF63W5$Q6+96/SA5R6NF61G73564KC*KETF6A46.96646B565WEC.D1$CKWEDZC6VCS446$C4WEUPC3JCUIA+ED$.EF$DMWE8$CBJEMVCB445$CBWER.CGPC4WEOPCE8FHZA1+9LZAZM81G72A62+8OG7J09U47AB8V59T%6ZHBO57X48RUIY03XQOK*FZUNM UFY4D5C S3R9UW-2R*4KZJT5M MIM:03RMZNA LKTO34PA.H51966PS0KAP-KLPH.Q6$KSTJ0-G658RL5HR1\";\nlet certificate_container = dgc::decode(raw_certificate_data).expect(\"Cannot parse certificate data\");\nprintln!(\"{:#?}\", certificate_container);\n```\n\n\n### 2. Decode a certificate and validate the signature against a trustlist\n\n```rust\nlet raw_certificate_data = \"HC1:NCF:603A0T9WTWGSLKC 4K694WJN.0J$6C-7WAB0XK3JCSGA2F3R8PP4V2F35VPP.EY50.FK8ZKO/EZKEZ96LF6/A6..DV%DZJC0/D5UA QELPCG/DYUCHY83UAGVC*JCNF6F463W5KF6VF6IECSHG4KCD3DX47B46IL6646H*6MWEWJDA6A:961A6Q47EM6B$DFOC0R63KCZPCNF6OF63W5$Q6+96/SA5R6NF61G73564KC*KETF6A46.96646B565WEC.D1$CKWEDZC6VCS446$C4WEUPC3JCUIA+ED$.EF$DMWE8$CBJEMVCB445$CBWER.CGPC4WEOPCE8FHZA1+9LZAZM81G72A62+8OG7J09U47AB8V59T%6ZHBO57X48RUIY03XQOK*FZUNM UFY4D5C S3R9UW-2R*4KZJT5M MIM:03RMZNA LKTO34PA.H51966PS0KAP-KLPH.Q6$KSTJ0-G658RL5HR1\";\n// This is a X509 certificate that contains a Public Key\nlet signature_certificate = \"MIIDujCCAaKgAwIBAgIIKUgZWBL1pnMwDQYJKoZIhvcNAQELBQAwZjELMAkGA1UEBhMCRlIxHTAbBgNVBAoTFElNUFJJTUVSSUUgTkFUSU9OQUxFMR4wHAYDVQQLExVGT1IgVEVTVCBQVVJQT1NFIE9OTFkxGDAWBgNVBAMTD0lOR1JPVVBFIERTYyBDQTAeFw0yMTA2MDIxMjE0MDBaFw0yMTA5MDIxMjE0MDBaMEAxCzAJBgNVBAYTAkZSMREwDwYDVQQKDAhDRVJUSUdOQTEeMBwGA1UEAwwVQ0VSVElHTkEgLSBURVNUIERHQyAxMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAETdygPqv/l6tWFqHFEIEZxfdhtbrBpDgVjmUN4CKOu/EQFwkVVQ/4N0BamwtI0hSnSZP72byk6XqpMErYWRTCbKNdMFswCQYDVR0TBAIwADAdBgNVHQ4EFgQUUjXs7mCY2ZgROQSsw1CN0qM4Zj8wHwYDVR0jBBgwFoAUYLoYTllzE2jOy3VMAuU4OJjOingwDgYDVR0PAQH/BAQDAgeAMA0GCSqGSIb3DQEBCwUAA4ICAQAvxuSBWNOrk+FRIbU42tnwZBllUeNH7cWcrYHV0O+1k3RbpvYa0YE2J0du301/a+0+pqlatR8o8Coe/NFt4/KSu+To+i8uZXiHJn2XrAZgwPqqTvsMUVwFPWhwJpLMCejmU0A8JEhXH7s0BN6orqIH0JKLpl0/MdVviIUksnxPnP2wdCtz6dL5zKhi+Qt8BFr55PL1dvuWxnuFOsKr89MqaexQVe/WvKhG5GXBaJFDbp4USVX9Z8vwp4SfEs5nh0ti0M2fyGrpfPvWWFra/qoRGAUJEPHHPMqZT45c1rXo12+cpme2CYM4rsliQsaqdH462p7YNNI5reBC+WHhzGr9FGq9yZ1gu/yhz1cJxNwE5gsBTWnJmSnRE75lYj1a/GAb+9wfABd1Vx68Fnww3Ngp8lG2T1vEWhwQusj/OmloVbqjJiCi6PcZ1/OSTbx58Zv9ySwDd3QGxPygfMy87FuhT6iWlPv57qTMrgtEjq89J8v3WnReAhp12ru5ehN2Zv0ZkO1Of0H3yxNBsvfHUgpgwsRn4zjLVbkU+a3hr4famOThmB1X0tuikY0mbNtVejPGS0qCgeLgj8ILlUrRtsW4R6WzZdIsz7H9AYnpyZbdMPsa856xBR9s0+AzguJI9kkJxvVcpR//GiXMhs0EdgWj2rouOEPZiFNdWpVRrxv/kw==\";\n\n// We create a new Trustlist (container of \"trusted\" public keys)\nlet mut trustlist = dgc::TrustList::default();\n// We add the public key in the certificate to the trustlist\ntrustlist\n    .add_key_from_certificate(signature_certificate)\n    .expect(\"Failed to add key from certificate\");\n\n// Now we can validate the signature (this returns)\nlet (certificate_container, signature_validity) =\n    dgc::validate(raw_certificate_data, \u0026trustlist).expect(\"Cannot parse certificate data\");\n\nprintln!(\"{:#?}\", \u0026certificate_container);\n\n// Checks the validity of the signature\nmatch signature_validity {\n    dgc::SignatureValidity::Valid =\u003e println!(\"The certificate signature is Valid!\"),\n    e =\u003e println!(\"Could not validate the signature: {}\", e),\n}\n```\n\n\n### Other examples?\n\nTo get started using `dgc`, see the [`examples`](https://github.com/rust-italia/dgc/tree/main/dgc/examples) or the [docs](https://docs.rs/dgc).\n\nIf you clone the repository locally, you can easily run the example files with:\n\n```bash\ncargo run --example \u003cname of example file\u003e\n```\n\n## Italian support\n\nDo you need support for Italian validation rules? Check [`dgc-italy-core`](https://github.com/rust-italia/dgc/tree/main/dgc-italy-core)!\n\n\n## Data structure\n\nThe information is stored inside a certification in a multi-layered format.\n\nThis library tries to find a compromise between making the information as accessible as possible and respecting the original structure of\nthe raw data.\n\nThe following diagram represents how the information is organised once a certificate has been decoded:\n\n[![Dgc data organisation diagram](https://github.com/rust-italia/dgc/raw/main/docs/certificate_structure.svg)](https://github.com/rust-italia/dgc/raw/main/docs/certificate_structure.svg)\n\n\n## FAQ\n\n### Is it legal to use this library?\n\nYou can certainly use this library to look into your own personal DGC (or the ones provided in the [official test dataset](https://github.com/eu-digital-green-certificates/dgc-testdata)).\n\nIf you are trying to use this library to look into certificates of arbitrarty individuals, you need to be aware that you will have access to privacy-sensitive personal information. Privacy-related regulation might limit you or prevent you from using this library (or the data acquired through this library). It is recommended to consult the relevant legal sources and authorities for any significant production use case.\n\nNote that this software is licensed under [MIT license](https://github.com/rust-italia/dgc/blob/main/LICENSE) and it is provided \"as is\". The authors of this library take no responsibility on any issue (especially legal ones) that might arise from using this library or the data acquired through it.\n\n\n## Contributing\n\nEveryone is very welcome to contribute to this project.\nYou can contribute just by submitting bugs or suggesting improvements by\n[opening an issue on GitHub](https://github.com/rust-italia/dgc/issues).\n\n\n## License\n\nLicensed under [MIT License](https://github.com/rust-italia/dgc/blob/main/LICENSE). © Luciano Mammino + Rust Italia.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-italia%2Fdgc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-italia%2Fdgc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-italia%2Fdgc/lists"}