Skip to content

Commit d7d2aac

Browse files
committed
Rename JC_map to jc_map to maintain consistency
Signed-off-by: HarshvMahawar <[email protected]>
1 parent 31de3a1 commit d7d2aac

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

src/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# Abstract class to define structure to subclasses
77
class BaseJCSerializable(ABC):
8-
JC_map: Dict[str, int]
8+
jc_map: Dict[str, int]
99

1010
@abstractmethod
1111
def to_dict(self) -> Dict[str, Any]:

src/claims.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class AttestationResult(BaseJCSerializable):
1717
submods: Dict[str, Dict[str, Any]] = field(default_factory=dict)
1818

1919
# https://www.ietf.org/archive/id/draft-ietf-rats-eat-31.html#section-7.2.4
20-
JC_map = {
20+
jc_map = {
2121
"profile": 265,
2222
"issued_at": 6,
2323
"verifier_id": 1004,
@@ -42,13 +42,13 @@ def to_dict(self) -> Dict[str, Any]:
4242

4343
def to_cbor(self) -> Dict[int, Any]:
4444
return {
45-
self.JC_map["profile"]: self.profile,
46-
self.JC_map["issued_at"]: self.issued_at,
47-
self.JC_map["verifier_id"]: self.verifier_id.to_cbor(),
48-
self.JC_map["submods"]: {
45+
self.jc_map["profile"]: self.profile,
46+
self.jc_map["issued_at"]: self.issued_at,
47+
self.jc_map["verifier_id"]: self.verifier_id.to_cbor(),
48+
self.jc_map["submods"]: {
4949
key: {
50-
self.JC_map["submod.trust_vector"]: value["trust_vector"].to_cbor(),
51-
self.JC_map["submod.status"]: value["status"].value,
50+
self.jc_map["submod.trust_vector"]: value["trust_vector"].to_cbor(),
51+
self.jc_map["submod.status"]: value["status"].value,
5252
}
5353
for key, value in self.submods.items()
5454
},
@@ -76,16 +76,16 @@ def from_json(cls, json_str: str):
7676
@classmethod
7777
def from_cbor(cls, data: Dict[int, Any]):
7878
return cls(
79-
profile=data.get(cls.JC_map["profile"], ""),
80-
issued_at=data.get(cls.JC_map["issued_at"], 0),
81-
verifier_id=VerifierID.from_cbor(data.get(cls.JC_map["verifier_id"], {})),
79+
profile=data.get(cls.jc_map["profile"], ""),
80+
issued_at=data.get(cls.jc_map["issued_at"], 0),
81+
verifier_id=VerifierID.from_cbor(data.get(cls.jc_map["verifier_id"], {})),
8282
submods={
8383
key: {
8484
"trust_vector": TrustVector.from_cbor(
85-
value.get(cls.JC_map["submod.trust_vector"], {})
85+
value.get(cls.jc_map["submod.trust_vector"], {})
8686
),
87-
"status": to_trust_tier(value.get(cls.JC_map["submod.status"], 0)),
87+
"status": to_trust_tier(value.get(cls.jc_map["submod.status"], 0)),
8888
}
89-
for key, value in data.get(cls.JC_map["submods"], {}).items()
89+
for key, value in data.get(cls.jc_map["submods"], {}).items()
9090
},
9191
)

src/trust_vector.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TrustVector(BaseJCSerializable):
1818
storage_opaque: Optional[TrustClaim] = None
1919
sourced_data: Optional[TrustClaim] = None
2020

21-
JC_map = {
21+
jc_map = {
2222
"instance_identity": 0,
2323
"configuration": 1,
2424
"executables": 2,
@@ -35,21 +35,21 @@ def to_dict(self) -> Dict[str, Any]:
3535
def to_cbor(self) -> Dict[int, Dict[str, Any]]:
3636
return {
3737
index: getattr(self, field).to_dict()
38-
for field, index in self.JC_map.items()
38+
for field, index in self.jc_map.items()
3939
if getattr(self, field)
4040
}
4141

4242
@classmethod
4343
def from_dict(cls, data: Dict[str, Any]):
4444
kwargs = {
4545
field: TrustClaim(**data[field]) if data.get(field) else None
46-
for field in cls.JC_map
46+
for field in cls.jc_map
4747
}
4848
return cls(**kwargs)
4949

5050
@classmethod
5151
def from_cbor(cls, data: Dict[int, Dict[str, Any]]):
52-
reverse_map = {v: k for k, v in cls.JC_map.items()}
52+
reverse_map = {v: k for k, v in cls.jc_map.items()}
5353
kwargs = {
5454
reverse_map[index]: TrustClaim(**value)
5555
for index, value in data.items()

src/verifier_id.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class VerifierID(BaseJCSerializable):
1010
developer: str
1111
build: str
12-
JC_map = {
12+
jc_map = {
1313
"developer": 0, # JC<"developer", 0>
1414
"build": 1, # JC<"build", 1>
1515
}
@@ -20,7 +20,7 @@ def to_dict(self) -> Dict[str, Any]:
2020
# Convert to a dict with integer keys (for CBOR)
2121
def to_cbor(self) -> Dict[int, str]:
2222
return {
23-
index: getattr(self, field) for field, index in self.JC_map.items()
23+
index: getattr(self, field) for field, index in self.jc_map.items()
2424
} # noqa: E501
2525

2626
# Create an instance from a dict with string keys
@@ -31,6 +31,6 @@ def from_dict(cls, data: Dict[str, str]):
3131
# Create an instance from a CBOR-like dict (integer keys)
3232
@classmethod
3333
def from_cbor(cls, data: Dict[int, str]):
34-
reverse_map = {v: k for k, v in cls.JC_map.items()}
34+
reverse_map = {v: k for k, v in cls.jc_map.items()}
3535
kwargs = {reverse_map[index]: value for index, value in data.items()}
3636
return cls(**kwargs)

0 commit comments

Comments
 (0)