def to_json(self) -> str: """ :return: Return the JSON string representation of the Signature object. :rtype: str """ return json.dumps({'ID_C': str(self.ID_C), 'i': self.i, 'z_i': bytes_to_base64_str(self.z_i), 'c_i': bytes_to_base64_str(pickle.dumps(self.c_i)), 'msg': bytes_to_base64_str(self.message), 'S_t': self.S_t.to_json()})
def publish_signed_request(self, msg: bytes, resp: TimestampResponse) -> bool: """ In json it looks like: { "org.ksi.client1": { "2016-02-18T21:24:56.082991": { base64(b'AAAA'): "<sig in base64>", base64(b'BBBB'): "<sig in base64>", ... }, "2016-03-21T23:54:50.181911": { base64(b'AAAA'): "<sig in base64>" }, ... }, "org.ksi.client2": { /* no signatures yet */ }, ... } """ s_id_c = str(resp.ID_C).replace('.', '#') doc = { s_id_c: { resp.t.isoformat(): { bytes_to_base64_str(msg): resp.signature } } } return self.signed.insert_one(doc).acknowledged
def publish_signed_request(self, msg: bytes, resp: TimestampResponse) -> bool: """ In json it looks like: { "org.ksi.client1": { "2016-02-18T21:24:56.082991": { base64(b'AAAA'): "<sig in base64>", base64(b'BBBB'): "<sig in base64>", ... }, "2016-03-21T23:54:50.181911": { base64(b'AAAA'): "<sig in base64>" }, ... }, "org.ksi.client2": { /* no signatures yet */ }, ... } """ s_id_c = str(resp.ID_C).replace('.', '#') doc = {s_id_c: {resp.t.isoformat(): {bytes_to_base64_str(msg): resp.signature}}} return self.signed.insert_one(doc).acknowledged