Skip to content

Commit 1135d79

Browse files
Add a toy example in the docstring of pederson algorithm
1 parent 6de940d commit 1135d79

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Diff for: pydatastructs/graphs/graph.py

+15
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,21 @@ 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+
Toy Example
62+
-----------
63+
>>> g = Graph(implementation='adjacency_list')
64+
>>> g.add_edge('A', 'B', 5)
65+
>>> p = 208351617316091241234326746312124448251235562226470491514186331217050270460481
66+
>>> q = 233970423115425145524320034830162017933
67+
>>> commitment, r = pedersen_commitment(g, g=5, h=7, p=p, q=q)
68+
>>> print(commitment)
69+
98392819481230984098123
70+
71+
Notes
72+
-----
73+
- The blinding factor `r` must be kept private.
74+
- Changing even a single edge or vertex will yield a different commitment.
75+
6176
"""
6277
if p.bit_length() < 1024:
6378
raise ValueError("p must be a 1024-bit prime or larger.")

0 commit comments

Comments
 (0)