@@ -89,9 +89,9 @@ <h1 class="modulename">
8989 </ div >
9090 < a class ="headerlink " href ="#RingVerifier "> </ a >
9191
92- < div class ="docstring "> < p > Verifier instance used for verifying signatures against a particular ring</ p >
92+ < div class ="docstring "> < p > Used for verifying signatures against a particular ring</ p >
9393
94- < p > < strong > Args:</ strong > </ p >
94+ < p > < strong > Constructor Args:</ strong > </ p >
9595
9696< ul >
9797< li > commitment: < code > bytes</ code > - ring commitment (in JAM this is called a < strong > ring root</ strong > )</ li >
@@ -101,19 +101,12 @@ <h1 class="modulename">
101101< p > < strong > Raises:</ strong > </ p >
102102
103103< ul >
104- < li > < code > Exception</ code > - if an internal error is encountered </ li >
104+ < li > < code > Exception</ code > - internal error</ li >
105105</ ul >
106106
107107< p > < strong > Example:</ strong > </ p >
108108
109- < pre > < code > from jam_vrf import RingVerifier
110-
111- # arguments
112- commitment = bytes.fromhex("85f9...")
113- ring_size = 6
114-
115- # construct ring verifier
116- try:
109+ < pre > < code > try:
117110 verifier = RingVerifier(commitment, ring_size)
118111except Exception as e:
119112 ...
@@ -144,26 +137,16 @@ <h1 class="modulename">
144137< p > < strong > Raises:</ strong > </ p >
145138
146139< ul >
147- < li > < code > ValueError</ code > - if the signature is invalid </ li >
148- < li > < code > Exception</ code > - if an internal error is encountered </ li >
140+ < li > < code > ValueError</ code > - invalid signature</ li >
141+ < li > < code > Exception</ code > - internal error</ li >
149142</ ul >
150143
151144< p > < strong > Example:</ strong > </ p >
152145
153146< pre > < code > verifier: RingVerifier
154147
155- # arguments
156- entropy = bytes.fromhex("bb30...")
157- attempt = 1
158- signature = bytes.fromhex("1dfb...")
159-
160- # verify signature
161148try:
162- verifier.verify(
163- b"jam_ticket_seal" + entropy + bytes([attempt]),
164- b"",
165- signature
166- )
149+ verifier.verify(data, ad, signature)
167150except ValueError as e:
168151 print("invalid signature!")
169152</ code > </ pre >
@@ -187,23 +170,16 @@ <h1 class="modulename">
187170< p > < strong > Args:</ strong > </ p >
188171
189172< ul >
190- < li > bytes : < code > bytes</ code > - output bytes </ li >
173+ < li > output : < code > bytes</ code > </ li >
191174</ ul >
192175
193176< p > < strong > Raises:</ strong > </ p >
194177
195178< ul >
196- < li > < code > Exception</ code > if an internal error is encountered </ li >
179+ < li > < code > Exception</ code > - internal error</ li >
197180</ ul >
198181
199- < p > < strong > Example:</ strong > </ p >
200-
201- < pre > < code > from jam_vrf import VRFOutput
202-
203- # construct vrf output from a safrole ticket signature
204- signature = bytes.fromhex("1dfb...")
205- vrf_output = VRFOutput(signature[:32])
206- </ code > </ pre >
182+ < p > < strong > Example:</ strong > < code > vrf_output = VRFOutput(output)</ code > </ p >
207183</ div >
208184
209185
@@ -217,13 +193,9 @@ <h1 class="modulename">
217193 </ div >
218194 < a class ="headerlink " href ="#VRFOutput.hash "> </ a >
219195
220- < div class ="docstring "> < p > Return the VRF output hash </ p >
196+ < div class ="docstring "> < p > Hash the VRF output point </ p >
221197
222- < p > < strong > Example:</ strong > </ p >
223-
224- < pre > < code > vrf_output: VRFOutput
225- id = vrf_output.hash()[:32] # ticket IDs in JAM only use the first 32 bytes
226- </ code > </ pre >
198+ < p > < strong > Example:</ strong > < code > id = VRFOutput(...).hash()</ code > </ p >
227199</ div >
228200
229201
@@ -256,22 +228,13 @@ <h1 class="modulename">
256228< p > < strong > Raises:</ strong > </ p >
257229
258230< ul >
259- < li > < code > ValueError</ code > if no public keys are provided </ li >
260- < li > < code > Exception</ code > if an internal error is encountered </ li >
231+ < li > < code > ValueError</ code > - invalid or empty input keys </ li >
232+ < li > < code > Exception</ code > - internal error</ li >
261233</ ul >
262234
263235< p > < strong > Example</ strong > </ p >
264236
265- < pre > < code > from jam_vrf get_ring_commitment
266-
267- # ring public keys
268- public_keys = [
269- bytes.fromhex("7b32..."),
270- ...
271- ]
272-
273- # generate ring commitment
274- try:
237+ < pre > < code > try:
275238 commitment = get_ring_commitment(public_keys)
276239except Exception as e:
277240 ...
@@ -304,22 +267,13 @@ <h1 class="modulename">
304267< p > < strong > Raises:</ strong > </ p >
305268
306269< ul >
307- < li > < code > ValueError</ code > if the signature is invalid </ li >
308- < li > < code > Exception</ code > if an internal error is encountered </ li >
270+ < li > < code > ValueError</ code > - invalid signature</ li >
271+ < li > < code > Exception</ code > - internal error</ li >
309272</ ul >
310273
311274< p > < strong > Example:</ strong > </ p >
312275
313- < pre > < code > from jam_vrf import ietf_verify
314-
315- # arguments
316- public_key = bytes.fromhex("b0e1...")
317- data = bytes.fromhex("4261...")
318- ad = bytes.fromhex("1f42")
319- signature = bytes.fromhex("6d1d...")
320-
321- # verify signature
322- try:
276+ < pre > < code > try:
323277 ietf_verify(public_key, data, ad, signature)
324278except ValueError as e:
325279 print("invalid signature!")
0 commit comments