lav-vrf 0.0.1

Pure Rust implementation of LaV, an experimental lattice-based verifiable random function (VRF)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
#[cfg(target_arch = "aarch64")]
pub use ::core::arch::aarch64::int64x2_t as __m128i;
#[cfg(target_arch = "x86")]
pub use ::core::arch::x86::__m128i;
#[cfg(target_arch = "x86_64")]
pub use ::core::arch::x86_64::__m128i;
unsafe extern "C" {
    fn lanes_plus_rq_crt_sub(
        out: *mut LANES_PLUS_Rq_CRT,
        a: *const LANES_PLUS_Rq_CRT,
        b: *const LANES_PLUS_Rq_CRT,
    );
    fn lanes_plus_rq_crt_inner_product_nomodq(
        out: *mut LANES_PLUS_Rq_CRT,
        a: *const LANES_PLUS_Rq_CRT,
        b: *const LANES_PLUS_Rq_CRT,
        len: size_t,
    );
    fn lanes_plus_rq_to_crt(out: *mut LANES_PLUS_Rq_CRT, in_0: *const LANES_PLUS_Rq);
    fn lanes_plus_crt_to_rq(out: *mut LANES_PLUS_Rq, in_0: *const LANES_PLUS_Rq_CRT);
    fn lanes_plus_crt_to_rounding(
        out: *mut LANES_PLUS_Rq,
        in_0: *const LANES_PLUS_Rq_CRT,
    );
    fn lanes_plus_rounding_mulq0_to_crt(
        out: *mut LANES_PLUS_Rq_CRT,
        in_0: *const LANES_PLUS_Rq,
    );
    fn rp_ntt(a: *mut int64_t);
    fn rp_intt(a: *mut int64_t);
    fn lanes_plus_rq_crt_mul_ntt(
        out: *mut LANES_PLUS_Rq_CRT,
        a: *const LANES_PLUS_Rq_CRT,
        b: *const LANES_PLUS_Rq_CRT,
    );
    fn lanes_plus_rq_crt_inner_product_nomodq_ntt(
        out: *mut LANES_PLUS_Rq_CRT,
        a: *const LANES_PLUS_Rq_CRT,
        b: *const LANES_PLUS_Rq_CRT,
        len: size_t,
    );
    fn lanes_plus_rq_crt_inner_product_ntt(
        out: *mut LANES_PLUS_Rq_CRT,
        a: *const LANES_PLUS_Rq_CRT,
        b: *const LANES_PLUS_Rq_CRT,
        len: size_t,
    );
    fn r_gen(pp: *mut R_PP, ctx: *mut aes256ctr_ctx);
    fn r_prove(
        out: *mut R_PROOF,
        pp: *const R_PP,
        ulp: *const R_ULP,
        s: *const LANES_PLUS_Rq,
        ctx: *mut aes256ctr_ctx,
        rho: *mut LANES_PLUS_RHO,
    );
    fn r_ver(
        pp: *const R_PP,
        ulp: *const R_ULP,
        in_0: *const R_PROOF,
        rho: *mut LANES_PLUS_RHO,
    ) -> ::core::ffi::c_int;
    fn lav_sampler_rq_crt_1d(
        out_crt: *mut LANES_PLUS_Rq_CRT,
        len: size_t,
        ctx: *mut aes256ctr_ctx,
    );
    fn lav_sampler_ternary_1d(
        out: *mut LANES_PLUS_Rq,
        len: size_t,
        ctx: *mut aes256ctr_ctx,
    );
    fn lav_sampler_g_crt(
        out_crt: *mut LANES_PLUS_Rq_CRT,
        m: *const ::core::ffi::c_uchar,
        mlen: size_t,
    );
}
pub type size_t = usize;
pub type int16_t = i16;
pub type uint16_t = u16;
pub type int32_t = i32;
pub type int64_t = i64;
pub type uint64_t = u64;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct aes256ctr_ctx {
    pub rkeys: [__m128i; 16],
    pub n: __m128i,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LANES_Rqhat {
    pub poly: [int64_t; 128],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LANES_Rqhat_16 {
    pub poly: [int16_t; 128],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LANES_PP {
    pub B0: [[LANES_Rqhat; 22]; 7],
    pub b: [[LANES_Rqhat; 22]; 9],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LANES_COM_PUB {
    pub t0: [LANES_Rqhat; 7],
    pub t: [LANES_Rqhat; 6],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LANES_PROOF {
    pub tN: [LANES_Rqhat; 3],
    pub w: [LANES_Rqhat; 7],
    pub alpha: [LANES_Rqhat; 6],
    pub gamma: *mut int64_t,
    pub h: LANES_Rqhat,
    pub v: LANES_Rqhat,
    pub v_prime: LANES_Rqhat,
    pub c: LANES_Rqhat_16,
    pub z: [LANES_Rqhat_16; 22],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LANES_PLUS_Rq {
    pub poly: [int64_t; 32],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LANES_PLUS_Rq_CRT {
    pub poly_q0: [int32_t; 32],
    pub poly_p: [int64_t; 32],
}
pub type LANES_PLUS_PP = LANES_PP;
pub type LANES_PLUS_COM_PUB = LANES_COM_PUB;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LANES_PLUS_PROOF {
    pub lanes_proof: LANES_PROOF,
    pub c: LANES_PLUS_Rq,
    pub z: *mut LANES_PLUS_Rq,
    pub f: LANES_PLUS_Rq,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LANES_PLUS_RHO {
    pub rho: *mut ::core::ffi::c_uchar,
    pub rho_len: size_t,
    pub extra: *const ::core::ffi::c_void,
    pub callback: Option<
        unsafe extern "C" fn(*mut ::core::ffi::c_void, *const ::core::ffi::c_void) -> (),
    >,
}
pub type R_PP = LANES_PLUS_PP;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct R_ULP {
    pub B_crt: *const LANES_PLUS_Rq_CRT,
    pub v: *const LANES_PLUS_Rq,
    pub dim: size_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct R_PROOF {
    pub t: LANES_PLUS_COM_PUB,
    pub pi: LANES_PLUS_PROOF,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LAV_PP {
    pub pp_prime: R_PP,
    pub A_crt: [[LANES_PLUS_Rq_CRT; 40]; 48],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LAV_SK {
    pub s: [LANES_PLUS_Rq; 40],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LAV_PK {
    pub t: [LANES_PLUS_Rq; 48],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LAV_VRF {
    pub v: LANES_PLUS_Rq,
    pub sigma: R_PROOF,
}
#[inline]
unsafe extern "C" fn ct_lt(x: uint64_t, y: uint64_t) -> uint64_t {
    return x.wrapping_sub(y);
}
#[inline]
unsafe extern "C" fn store_16(mut x: *mut ::core::ffi::c_uchar, c: uint16_t) {
    *x = c as ::core::ffi::c_uchar;
    *x.offset(1 as ::core::ffi::c_int as isize) = (c as ::core::ffi::c_int
        >> 8 as ::core::ffi::c_int) as ::core::ffi::c_uchar;
}
#[inline]
unsafe extern "C" fn norm_check(
    mut z: *const LANES_PLUS_Rq,
    len: size_t,
    bound: uint64_t,
) -> uint64_t {
    let mut i: size_t = 0;
    let mut j: size_t = 0;
    let mut ret: uint64_t = 0 as uint64_t;
    i = 0 as size_t;
    while i < len {
        j = 0 as size_t;
        while j < 32 as size_t {
            ret
                |= ct_lt(bound, (*z.offset(i as isize)).poly[j as usize] as uint64_t)
                    | ct_lt(
                        (*z.offset(i as isize)).poly[j as usize] as uint64_t,
                        bound.wrapping_neg(),
                    );
            j = j.wrapping_add(1);
        }
        i = i.wrapping_add(1);
    }
    return ret;
}
static mut lav_k: size_t = 26 as size_t;
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lav_paramgen(mut pp: *mut LAV_PP, mut ctx: *mut aes256ctr_ctx) {
    let mut i: size_t = 0;
    r_gen(&raw mut (*pp).pp_prime, ctx);
    i = 0 as size_t;
    while i < 48 as size_t {
        lav_sampler_rq_crt_1d(
            &raw mut *(&raw mut (*pp).A_crt as *mut [LANES_PLUS_Rq_CRT; 40])
                .offset(i as isize) as *mut LANES_PLUS_Rq_CRT,
            40 as size_t,
            ctx,
        );
        i = i.wrapping_add(1);
    }
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lav_keygen(
    mut pk: *mut LAV_PK,
    mut sk: *mut LAV_SK,
    mut pp: *const LAV_PP,
    mut ctx: *mut aes256ctr_ctx,
) {
    let mut s_crt_ntt: [LANES_PLUS_Rq_CRT; 40] = [LANES_PLUS_Rq_CRT {
        poly_q0: [0; 32],
        poly_p: [0; 32],
    }; 40];
    let mut As_crt_ntt: LANES_PLUS_Rq_CRT = LANES_PLUS_Rq_CRT {
        poly_q0: [0; 32],
        poly_p: [0; 32],
    };
    let mut i: size_t = 0;
    let mut j: size_t = 0;
    lav_sampler_ternary_1d(&raw mut (*sk).s as *mut LANES_PLUS_Rq, 40 as size_t, ctx);
    i = 0 as size_t;
    while i < 40 as size_t {
        lanes_plus_rq_to_crt(
            (&raw mut s_crt_ntt as *mut LANES_PLUS_Rq_CRT).offset(i as isize),
            (&raw mut (*sk).s as *mut LANES_PLUS_Rq).offset(i as isize),
        );
        rp_ntt(
            &raw mut (*(&raw mut s_crt_ntt as *mut LANES_PLUS_Rq_CRT).offset(i as isize))
                .poly_p as *mut int64_t,
        );
        i = i.wrapping_add(1);
    }
    i = 0 as size_t;
    while i < 48 as size_t {
        lanes_plus_rq_crt_inner_product_ntt(
            &raw mut As_crt_ntt,
            &raw const *(&raw const (*pp).A_crt as *const [LANES_PLUS_Rq_CRT; 40])
                .offset(i as isize) as *const LANES_PLUS_Rq_CRT,
            &raw mut s_crt_ntt as *mut LANES_PLUS_Rq_CRT,
            40 as size_t,
        );
        rp_intt(&raw mut As_crt_ntt.poly_p as *mut int64_t);
        lanes_plus_crt_to_rounding(
            (&raw mut (*pk).t as *mut LANES_PLUS_Rq).offset(i as isize),
            &raw mut As_crt_ntt,
        );
        i = i.wrapping_add(1);
    }
}
#[inline]
unsafe extern "C" fn power2round(
    mut a0: *mut int64_t,
    a: int64_t,
    D: size_t,
) -> int64_t {
    let mut a1: int64_t = 0;
    a1 = a + ((1 as ::core::ffi::c_int) << D.wrapping_sub(1 as size_t)) as int64_t
        - 1 as int64_t >> D;
    *a0 = a - (a1 << D);
    return a1;
}
unsafe extern "C" fn eval_callback(
    mut out: *mut ::core::ffi::c_void,
    mut in_0: *const ::core::ffi::c_void,
) {
    let mut rho: *mut LANES_PLUS_RHO = out as *mut LANES_PLUS_RHO;
    let mut A_crt: *mut [LANES_PLUS_Rq_CRT; 40] = (*rho).extra
        as *mut [LANES_PLUS_Rq_CRT; 40];
    let mut y_crt: *mut LANES_PLUS_Rq_CRT = in_0 as *mut LANES_PLUS_Rq_CRT;
    let mut Ay_crt_ntt: LANES_PLUS_Rq_CRT = LANES_PLUS_Rq_CRT {
        poly_q0: [0; 32],
        poly_p: [0; 32],
    };
    let mut w: LANES_PLUS_Rq = LANES_PLUS_Rq { poly: [0; 32] };
    let mut i: size_t = 0;
    let mut j: size_t = 0;
    let mut tmp: int64_t = 0;
    let mut buf: *mut ::core::ffi::c_uchar = (*rho).rho;
    let mut y_crt_ntt: [LANES_PLUS_Rq_CRT; 40] = [LANES_PLUS_Rq_CRT {
        poly_q0: [0; 32],
        poly_p: [0; 32],
    }; 40];
    i = 0 as size_t;
    while i < 40 as size_t {
        j = 0 as size_t;
        while j < 32 as size_t {
            y_crt_ntt[i as usize].poly_q0[j as usize] = (*y_crt.offset(i as isize))
                .poly_q0[j as usize];
            y_crt_ntt[i as usize].poly_p[j as usize] = (*y_crt.offset(i as isize))
                .poly_p[j as usize];
            j = j.wrapping_add(1);
        }
        rp_ntt(
            &raw mut (*(&raw mut y_crt_ntt as *mut LANES_PLUS_Rq_CRT).offset(i as isize))
                .poly_p as *mut int64_t,
        );
        i = i.wrapping_add(1);
    }
    i = 0 as size_t;
    while i < 48 as size_t {
        lanes_plus_rq_crt_inner_product_ntt(
            &raw mut Ay_crt_ntt,
            &raw mut *A_crt.offset(i as isize) as *mut LANES_PLUS_Rq_CRT,
            &raw mut y_crt_ntt as *mut LANES_PLUS_Rq_CRT,
            40 as size_t,
        );
        rp_intt(&raw mut Ay_crt_ntt.poly_p as *mut int64_t);
        lanes_plus_crt_to_rq(&raw mut w, &raw mut Ay_crt_ntt);
        j = 0 as size_t;
        while j < 32 as size_t {
            store_16(
                buf,
                power2round(&raw mut tmp, w.poly[j as usize], lav_k) as uint16_t,
            );
            buf = buf.offset(2 as ::core::ffi::c_int as isize);
            j = j.wrapping_add(1);
        }
        i = i.wrapping_add(1);
    }
}
#[inline]
unsafe extern "C" fn compute_w2(
    mut w2: *mut LANES_PLUS_Rq,
    mut A_crt: *const [LANES_PLUS_Rq_CRT; 40],
    mut z: *const LANES_PLUS_Rq,
    mut c: *const LANES_PLUS_Rq,
    mut q0t_crt_ntt: *const LANES_PLUS_Rq_CRT,
) {
    let mut z_crt_ntt: [LANES_PLUS_Rq_CRT; 40] = [LANES_PLUS_Rq_CRT {
        poly_q0: [0; 32],
        poly_p: [0; 32],
    }; 40];
    let mut c_crt_ntt: LANES_PLUS_Rq_CRT = LANES_PLUS_Rq_CRT {
        poly_q0: [0; 32],
        poly_p: [0; 32],
    };
    let mut c_q0t_crt_ntt: LANES_PLUS_Rq_CRT = LANES_PLUS_Rq_CRT {
        poly_q0: [0; 32],
        poly_p: [0; 32],
    };
    let mut w2_crt_ntt: LANES_PLUS_Rq_CRT = LANES_PLUS_Rq_CRT {
        poly_q0: [0; 32],
        poly_p: [0; 32],
    };
    let mut i: size_t = 0;
    let mut j: size_t = 0;
    i = 0 as size_t;
    while i < 40 as size_t {
        lanes_plus_rq_to_crt(
            (&raw mut z_crt_ntt as *mut LANES_PLUS_Rq_CRT).offset(i as isize),
            z.offset(i as isize),
        );
        rp_ntt(
            &raw mut (*(&raw mut z_crt_ntt as *mut LANES_PLUS_Rq_CRT).offset(i as isize))
                .poly_p as *mut int64_t,
        );
        i = i.wrapping_add(1);
    }
    lanes_plus_rq_to_crt(&raw mut c_crt_ntt, c);
    rp_ntt(&raw mut c_crt_ntt.poly_p as *mut int64_t);
    i = 0 as size_t;
    while i < 48 as size_t {
        lanes_plus_rq_crt_inner_product_nomodq_ntt(
            &raw mut w2_crt_ntt,
            &raw const *A_crt.offset(i as isize) as *const LANES_PLUS_Rq_CRT,
            &raw mut z_crt_ntt as *mut LANES_PLUS_Rq_CRT,
            40 as size_t,
        );
        lanes_plus_rq_crt_mul_ntt(
            &raw mut c_q0t_crt_ntt,
            &raw mut c_crt_ntt,
            q0t_crt_ntt.offset(i as isize),
        );
        lanes_plus_rq_crt_sub(
            &raw mut w2_crt_ntt,
            &raw mut w2_crt_ntt,
            &raw mut c_q0t_crt_ntt,
        );
        rp_intt(&raw mut w2_crt_ntt.poly_p as *mut int64_t);
        lanes_plus_crt_to_rq(w2.offset(i as isize), &raw mut w2_crt_ntt);
        i = i.wrapping_add(1);
    }
}
static mut w2_hat_bound: uint64_t = 33523200 as uint64_t;
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lav_eval(
    mut out: *mut LAV_VRF,
    mut pp: *const LAV_PP,
    mut pk: *const LAV_PK,
    mut sk: *const LAV_SK,
    mut m: *const ::core::ffi::c_uchar,
    mlen: size_t,
    mut ctx: *mut aes256ctr_ctx,
) {
    let mut b_crt: [LANES_PLUS_Rq_CRT; 40] = [LANES_PLUS_Rq_CRT {
        poly_q0: [0; 32],
        poly_p: [0; 32],
    }; 40];
    let mut s_crt: [LANES_PLUS_Rq_CRT; 40] = [LANES_PLUS_Rq_CRT {
        poly_q0: [0; 32],
        poly_p: [0; 32],
    }; 40];
    let mut bs_crt: LANES_PLUS_Rq_CRT = LANES_PLUS_Rq_CRT {
        poly_q0: [0; 32],
        poly_p: [0; 32],
    };
    let mut q0t_crt_ntt: [LANES_PLUS_Rq_CRT; 48] = [LANES_PLUS_Rq_CRT {
        poly_q0: [0; 32],
        poly_p: [0; 32],
    }; 48];
    let mut w2_hat_2k: [LANES_PLUS_Rq; 48] = [LANES_PLUS_Rq { poly: [0; 32] }; 48];
    let mut i: size_t = 0;
    let mut j: size_t = 0;
    lav_sampler_g_crt(&raw mut b_crt as *mut LANES_PLUS_Rq_CRT, m, mlen);
    i = 0 as size_t;
    while i < 40 as size_t {
        lanes_plus_rq_to_crt(
            (&raw mut s_crt as *mut LANES_PLUS_Rq_CRT).offset(i as isize),
            (&raw const (*sk).s as *const LANES_PLUS_Rq).offset(i as isize),
        );
        i = i.wrapping_add(1);
    }
    lanes_plus_rq_crt_inner_product_nomodq(
        &raw mut bs_crt,
        &raw mut b_crt as *mut LANES_PLUS_Rq_CRT,
        &raw mut s_crt as *mut LANES_PLUS_Rq_CRT,
        40 as size_t,
    );
    lanes_plus_crt_to_rounding(&raw mut (*out).v, &raw mut bs_crt);
    let mut ulp: R_ULP = R_ULP {
        B_crt: &raw mut b_crt as *mut LANES_PLUS_Rq_CRT,
        v: &raw mut (*out).v,
        dim: 40 as size_t,
    };
    let mut rho: LANES_PLUS_RHO = LANES_PLUS_RHO {
        rho: ::core::ptr::null_mut::<::core::ffi::c_uchar>(),
        rho_len: (2 as ::core::ffi::c_int * 48 as ::core::ffi::c_int
            * 32 as ::core::ffi::c_int) as size_t,
        extra: &raw const (*pp).A_crt as *const [LANES_PLUS_Rq_CRT; 40]
            as *const ::core::ffi::c_void,
        callback: Some(
            eval_callback
                as unsafe extern "C" fn(
                    *mut ::core::ffi::c_void,
                    *const ::core::ffi::c_void,
                ) -> (),
        ),
    };
    i = 0 as size_t;
    while i < 48 as size_t {
        lanes_plus_rounding_mulq0_to_crt(
            (&raw mut q0t_crt_ntt as *mut LANES_PLUS_Rq_CRT).offset(i as isize),
            (&raw const (*pk).t as *const LANES_PLUS_Rq).offset(i as isize),
        );
        rp_ntt(
            &raw mut (*(&raw mut q0t_crt_ntt as *mut LANES_PLUS_Rq_CRT)
                .offset(i as isize))
                .poly_p as *mut int64_t,
        );
        i = i.wrapping_add(1);
    }
    loop {
        r_prove(
            &raw mut (*out).sigma,
            &raw const (*pp).pp_prime,
            &raw mut ulp,
            &raw const (*sk).s as *const LANES_PLUS_Rq,
            ctx,
            &raw mut rho,
        );
        compute_w2(
            &raw mut w2_hat_2k as *mut LANES_PLUS_Rq,
            &raw const (*pp).A_crt as *const [LANES_PLUS_Rq_CRT; 40],
            (*out).sigma.pi.z,
            &raw mut (*out).sigma.pi.c,
            &raw mut q0t_crt_ntt as *mut LANES_PLUS_Rq_CRT,
        );
        i = 0 as size_t;
        while i < 48 as size_t {
            j = 0 as size_t;
            while j < 32 as size_t {
                power2round(
                    (&raw mut (*(&raw mut w2_hat_2k as *mut LANES_PLUS_Rq)
                        .offset(i as isize))
                        .poly as *mut int64_t)
                        .offset(j as isize),
                    w2_hat_2k[i as usize].poly[j as usize],
                    lav_k,
                );
                j = j.wrapping_add(1);
            }
            i = i.wrapping_add(1);
        }
        if !(norm_check(
            &raw mut w2_hat_2k as *mut LANES_PLUS_Rq,
            48 as size_t,
            w2_hat_bound,
        ) >> 63 as ::core::ffi::c_int != 0)
        {
            break;
        }
    };
}
unsafe extern "C" fn ver_callback(
    mut out: *mut ::core::ffi::c_void,
    mut in_0: *const ::core::ffi::c_void,
) {
    let mut rho: *mut LANES_PLUS_RHO = out as *mut LANES_PLUS_RHO;
    let mut w2_prime: *mut LANES_PLUS_Rq = (*rho).extra as *mut LANES_PLUS_Rq;
    let mut i: size_t = 0;
    let mut j: size_t = 0;
    let mut tmp: int64_t = 0;
    let mut buf: *mut ::core::ffi::c_uchar = (*rho).rho;
    i = 0 as size_t;
    while i < 48 as size_t {
        j = 0 as size_t;
        while j < 32 as size_t {
            store_16(
                buf,
                power2round(
                    &raw mut tmp,
                    (*w2_prime.offset(i as isize)).poly[j as usize],
                    lav_k,
                ) as uint16_t,
            );
            buf = buf.offset(2 as ::core::ffi::c_int as isize);
            j = j.wrapping_add(1);
        }
        i = i.wrapping_add(1);
    }
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lav_verify(
    mut pp: *const LAV_PP,
    mut pk: *const LAV_PK,
    mut m: *const ::core::ffi::c_uchar,
    mlen: size_t,
    mut in_0: *const LAV_VRF,
) -> ::core::ffi::c_int {
    let mut b_crt: [LANES_PLUS_Rq_CRT; 40] = [LANES_PLUS_Rq_CRT {
        poly_q0: [0; 32],
        poly_p: [0; 32],
    }; 40];
    let mut q0t_crt_ntt: [LANES_PLUS_Rq_CRT; 48] = [LANES_PLUS_Rq_CRT {
        poly_q0: [0; 32],
        poly_p: [0; 32],
    }; 48];
    let mut w2_prime: [LANES_PLUS_Rq; 48] = [LANES_PLUS_Rq { poly: [0; 32] }; 48];
    let mut i: size_t = 0;
    lav_sampler_g_crt(&raw mut b_crt as *mut LANES_PLUS_Rq_CRT, m, mlen);
    i = 0 as size_t;
    while i < 48 as size_t {
        lanes_plus_rounding_mulq0_to_crt(
            (&raw mut q0t_crt_ntt as *mut LANES_PLUS_Rq_CRT).offset(i as isize),
            (&raw const (*pk).t as *const LANES_PLUS_Rq).offset(i as isize),
        );
        rp_ntt(
            &raw mut (*(&raw mut q0t_crt_ntt as *mut LANES_PLUS_Rq_CRT)
                .offset(i as isize))
                .poly_p as *mut int64_t,
        );
        i = i.wrapping_add(1);
    }
    compute_w2(
        &raw mut w2_prime as *mut LANES_PLUS_Rq,
        &raw const (*pp).A_crt as *const [LANES_PLUS_Rq_CRT; 40],
        (*in_0).sigma.pi.z,
        &raw const (*in_0).sigma.pi.c,
        &raw mut q0t_crt_ntt as *mut LANES_PLUS_Rq_CRT,
    );
    let mut ulp: R_ULP = R_ULP {
        B_crt: &raw mut b_crt as *mut LANES_PLUS_Rq_CRT,
        v: &raw const (*in_0).v,
        dim: 40 as size_t,
    };
    let mut rho: LANES_PLUS_RHO = LANES_PLUS_RHO {
        rho: ::core::ptr::null_mut::<::core::ffi::c_uchar>(),
        rho_len: (2 as ::core::ffi::c_int * 48 as ::core::ffi::c_int
            * 32 as ::core::ffi::c_int) as size_t,
        extra: &raw mut w2_prime as *mut LANES_PLUS_Rq as *const ::core::ffi::c_void,
        callback: Some(
            ver_callback
                as unsafe extern "C" fn(
                    *mut ::core::ffi::c_void,
                    *const ::core::ffi::c_void,
                ) -> (),
        ),
    };
    return r_ver(
        &raw const (*pp).pp_prime,
        &raw mut ulp,
        &raw const (*in_0).sigma,
        &raw mut rho,
    );
}