Skip to content

Commit 12017df

Browse files
Check validate condition of parameters
1 parent 47b0997 commit 12017df

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pydatastructs/graphs/graph.py

+10
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ def pedersen_commitment(graph, g, h, p, q, include_weights=True):
5858
5959
include_weights : bool, optional
6060
Whether to include edge weights in the graph serialization. Default is True.
61+
"""
62+
if p.bit_length() < 1024:
63+
raise ValueError("p must be a 1024-bit prime or larger.")
64+
if q.bit_length() < 160:
65+
raise ValueError("q must be a 160-bit prime or larger.")
66+
if (p - 1) % q != 0:
67+
raise ValueError("q must divide (p - 1).")
68+
if pow(g, q, p) != 1 or pow(h, q, p) != 1:
69+
raise ValueError("g and h must be generators of a subgroup of order q.")
70+
6171

6272

6373
__all__ = [

0 commit comments

Comments
 (0)