Skip to content

Commit 56620ea

Browse files
authored
Refactor session handling in demo.py
1 parent 9ad4e61 commit 56620ea

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

demo.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
from cyphersyntax.identity import Identity
2-
from cyphersyntax.session import SessionFactory, AeadSuite
2+
from cyphersyntax.session import AeadSuite, SessionFactory
33

44

55
def main() -> None:
66
alice = Identity.generate("alice")
77
bob = Identity.generate("bob")
8-
alice_session, bob_session = SessionFactory.pair_for_tests(
9-
alice=alice,
10-
bob=bob,
8+
9+
pending_alice = SessionFactory.initiator(
10+
local_identity=alice,
11+
remote_name=bob.name,
1112
suite=AeadSuite.AES_GCM_SIV,
1213
supplemental_secret=b"future-pq-kem-secret",
1314
)
15+
response, bob_session = SessionFactory.responder(
16+
local_identity=bob,
17+
offer=pending_alice.offer,
18+
supplemental_secret=b"future-pq-kem-secret",
19+
)
20+
alice_session = pending_alice.complete(response)
21+
1422
packet = alice_session.encrypt(b"CypherSyntax demo message")
1523
plaintext = bob_session.decrypt(packet)
1624
print(plaintext.decode("utf-8"))

0 commit comments

Comments
 (0)