Skip to content

Commit 4f17a86

Browse files
committed
fix: restored example
1 parent 7694fe9 commit 4f17a86

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

examples/it_data_model.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import cbor2
2+
import os
3+
4+
from pymdoccbor.mdoc.issuer import MdocCborIssuer
5+
6+
PKEY = {
7+
'KTY': 'EC2',
8+
'CURVE': 'P_256',
9+
'ALG': 'ES256',
10+
'D': os.urandom(32),
11+
'KID': b"demo-kid"
12+
}
13+
14+
PID_DATA = {
15+
"org.iso.18013.5.1": {
16+
"expiry_date": "2024-02-22",
17+
"issue_date": "2023-11-14",
18+
"issuing_country": "IT",
19+
"issuing_authority": "Gli amici della Salaria",
20+
"family_name": "Rossi",
21+
"given_name": "Mario",
22+
"birth_date": "1956-01-12",
23+
"document_number": "XX1234567",
24+
"portrait": b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00\x90\x00\x90\x00\x00\xff\xdb\x00C\x00\x13\r\x0e\x11\x0e\x0c\x13\x11\x0f\x11\x15\x14\x13\x17\x1d0\x1f\x1d\x1a\x1a\x1d:*,#0E=IGD=CALVm]LQhRAC_\x82`hqu{|{J\\\x86\x90\x85w\x8fmx{v\xff\xdb\x00C\x01\x14\x15\x15\x1d\x19\x1d8\x1f\x1f8vOCOvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\xff\xc0\x00\x11\x08\x00\x18\x00d\x03\x01"\x00\x02\x11\x01\x03\x11\x01\xff\xc4\x00\x1b\x00\x00\x03\x01\x00\x03\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x06\x04\x01\x02\x03\x07\xff\xc4\x002\x10\x00\x01\x03\x03\x03\x02\x05\x02\x03\t\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x00\x05\x11\x06\x12!\x131\x14\x15Qaq"A\x07\x81\xa1\x165BRs\x91\xb2\xc1\xf1\xff\xc4\x00\x15\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xff\xc4\x00\x1a\x11\x01\x01\x01\x00\x03\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01A\x11!1a\xff\xda\x00\x0c\x03\x01\x00\x02\x11\x03\x11\x00?\x00\xa5\xbb\xde"\xda#)\xc7\xd6\x92\xbc}\r\x03\xf5,\xfb\x0f\xf7^z~\xf3\xe7p\x97#\xa1\xd0\xda\xe1F\xdd\xfb\xb3\xc09\xce\x07\xad+\xd4z~2\xdb\xb8\xdd\x1dR\xd6\xefK(Od\xa4\x80\x06}\xfbQ\xf8\x7f\xfb\x95\xff\x00\xeb\x9f\xf1M!]\xe6j\xf0\x89\xceD\xb7\xdb\xde\x9c\xb6\x89\n(8\xed\xdf\x18\x07\x8fz\xddb\xd4\x11\xefM\xb9\xb1\ne\xd6\xb9Z\x14s\x81\xea\rI[\x932u\xfek\xbau\xc1\x14\x10J\x8b\xa4\x10A>\x98=\xff\x00OZ\xf5\xd3KKL\xdec-\x0b\xf1\xfd\x15\x92\xbd\xd9\x1cd\x11\xf3\x93L/\xa6\xafkT\x97]\x10m\xcfJe\xaeV\xe8V\x00\x1e\xbc\x03\xc7\xce)\xdd\x9e\xef\x1e\xf1\x0f\xc4G\xdc\x9d\xa7j\xd2\xae\xe957\xa1\xba~Op\xdd\x8e\xff\x00W\xc6\xdf\xfb^\x1a\x19\x85J\x83u\x8eTR\x87P\x94n\xc6pHP\xcd\x03{\xce\xb0\x8bm},\xc7m3\x17\xfc{\\\xc0O\xb6pri\xc5\xc6\xe0\xc5\xb6\n\xe5I$!#\xb0\xe4\x93\xf6\x02\xa0uU\x9e5\x99p\xd9\x8d\xb8\x95%EkQ\xc9Q\xc8\xaf\xa1>\xa8\xe9\x8e<Yh6x=\\c\xf5\xa6\x1a\x99\xfd\xb7)\x08u\xdbK\xe8\x8a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O\xc6\xbd\xa1\x05\xc5)\xa7\x91\xc2\\O<z\x11\xf7\x15\x86&\x8fJf\xb7&\xe3=\xe9\xeao\x1bR\xb1\x81\xc7`rNG\xb5\x14R\nZ(\xa2\x83\xff\xd9',
25+
"driving_privileges": [
26+
{
27+
"vehicle_category_code": "A",
28+
"issue_date": cbor2.CBORTag(
29+
1004,
30+
value=cbor2.dumps(
31+
"2020-09-17"
32+
)
33+
),
34+
"expiry_date": cbor2.CBORTag(
35+
1004,
36+
value=cbor2.dumps(
37+
"2031-06-10"
38+
)
39+
)
40+
}
41+
],
42+
"un_distinguishing_sign": "I"
43+
},
44+
"org.iso.18013.5.1.it": {
45+
"verification.evidence": {
46+
"organization_name": "Motorizzazione Civile",
47+
"organization_id": "m_inf",
48+
"country_code": "it",
49+
},
50+
"verification.trust_framework": "eidas",
51+
"verification.assurance_level": "high"
52+
}
53+
}
54+
55+
mdoci = MdocCborIssuer(
56+
private_key=PKEY,
57+
alg="ES256",
58+
)
59+
60+
mdoc = mdoci.new(
61+
doctype="org.iso.18013.5.1.mDL",
62+
data=PID_DATA,
63+
validity={
64+
"issuance_date": "2024-12-31",
65+
"expiry_date": "2050-12-31"
66+
},
67+
)
68+
69+
mdoc
70+
mdoci.dump()
71+
mdoci.dumps()

0 commit comments

Comments
 (0)