Skip to content

Commit 6de940d

Browse files
Generates a secure random blinding factor r ∈ Z_q and computes commitment: C = g^m * h^r mod p
1 parent abe87b0 commit 6de940d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: pydatastructs/graphs/graph.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ def pedersen_commitment(graph, g, h, p, q, include_weights=True):
6969
raise ValueError("g and h must be generators of a subgroup of order q.")
7070
data = serialize_graph(graph, include_weights)
7171
m = int(hashlib.sha256(data.encode()).hexdigest(), 16) % q
72-
73-
72+
r = secrets.randbelow(q)
73+
commitment = (pow(g, m, p) * pow(h, r, p)) % p
74+
return commitment, r
7475
__all__ = [
7576
'Graph', 'pedersen_commitment'
7677
]

0 commit comments

Comments
 (0)