Skip to content

Commit ef7e291

Browse files
Fix add_snapshot: include HMAC for secure graph state storage
1 parent 6e54936 commit ef7e291

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pydatastructs/graphs/graph.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ def add_snapshot(self):
126126
}
127127
for key, edge in snapshot_copy.edge_weights.items():
128128
snapshot_copy.__getattribute__(edge.source.name).add_adjacent_node(edge.target.name)
129-
self.snapshots[timestamp] = snapshot_copy
129+
snapshot_data = serialize_graph(snapshot_copy)
130+
snapshot_signature = generate_hmac(snapshot_data)
131+
self.snapshots[timestamp] = {"graph": snapshot_copy, "signature": snapshot_signature}
130132
def get_snapshot(self, timestamp: int):
131133
"""Retrieves a past version of the graph if the timestamp exists."""
132134
if timestamp not in self.snapshots:

0 commit comments

Comments
 (0)