Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Signed-off-by: Vlad Gheorghiu <[email protected]>
  • Loading branch information
vsoftco committed Jan 15, 2025
1 parent 6a164a6 commit 622f6dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- `Signature.sign_with_ctx_str(self, message, context)`
- `Signature.verify_with_ctx_str(self, message, signature, context,
public_key)`
- When operations fail (i.e., `OQS_SUCCESS != 0`) in functions returning
non-boolean objects, a `RuntimeError` is now raised, instead of returning 0

# Version 0.10.0 - April 1, 2024

Expand Down
10 changes: 7 additions & 3 deletions examples/sig.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
message = "This is the message to sign".encode()

# Create signer and verifier with sample signature mechanisms
sigalg = "Dilithium2"
sigalg = "ML-DSA-44"
with oqs.Signature(sigalg) as signer:
with oqs.Signature(sigalg) as verifier:
print("\nSignature details:")
Expand All @@ -27,10 +27,14 @@
# Store key pair, wait... (session resumption):
# signer = oqs.Signature(sigalg, secret_key)

context = bytes([0, 1, 2])

# Signer signs the message
signature = signer.sign(message)
signature = signer.sign_with_ctx_str(message, context)

# Verifier verifies the signature
is_valid = verifier.verify(message, signature, signer_public_key)
is_valid = verifier.verify_with_ctx_str(
message, signature, context, signer_public_key
)

print("\nValid signature?", is_valid)
2 changes: 1 addition & 1 deletion tests/test_sig.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def check_correctness(alg_name):
def check_correctness_with_ctx_str(alg_name):
with oqs.Signature(alg_name) as sig:
message = bytes(random.getrandbits(8) for _ in range(100))
context = bytes("some context", "utf-8")
context = "some context".encode()
public_key = sig.generate_keypair()
signature = sig.sign_with_ctx_str(message, context)
assert sig.verify_with_ctx_str(message, signature, context, public_key)
Expand Down

0 comments on commit 622f6dd

Please sign in to comment.