Refactors signing/verifiying functionality to be part of the Cryptographer

- All encryption/decryption and signing/verifying calls are performed by the cryptographer now.

- The current signature format is temporal. We should define something not base on json.

- Some Cryptographer tests are still missing.

- The cli tests should be modified to fit this too.
This commit is contained in:
Sergi Delgado Segura
2019-12-07 13:22:39 +01:00
parent ae676e6632
commit d39056a0cc
12 changed files with 144 additions and 177 deletions

View File

@@ -32,7 +32,7 @@ class Appointment:
return appointment
def to_dict(self):
def to_dict(self, include_triggered=True):
# ToDO: #3-improve-appointment-structure
appointment = {
"locator": self.locator,
@@ -40,15 +40,16 @@ class Appointment:
"end_time": self.end_time,
"dispute_delta": self.dispute_delta,
"encrypted_blob": self.encrypted_blob.data,
"triggered": self.triggered,
}
if include_triggered:
appointment["triggered"] = self.triggered
return appointment
def to_json(self):
return json.dumps(self.to_dict(), sort_keys=True, separators=(",", ":"))
def serialize(self):
data = self.to_dict()
data.pop("triggered")
return json.dumps(data, sort_keys=True, separators=(",", ":")).encode("utf-8")
# FIXME: This is temporary serialization. A proper one is required
return self.to_dict(include_triggered=False)