#[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_gen(out: *mut LANES_PP, ctx: *mut aes256ctr_ctx);
fn lanes_com(
pub_0: *mut LANES_COM_PUB,
sec: *mut LANES_COM_SEC,
pp: *const LANES_PP,
m: *const int64_t,
ctx: *mut aes256ctr_ctx,
);
fn lanes_prove(
out: *mut LANES_PROOF,
pp: *const LANES_PP,
lanes_mp_prove: Option<
unsafe extern "C" fn(
*mut ::core::ffi::c_void,
*const ::core::ffi::c_void,
) -> (),
>,
ulp: *const LANES_ULP,
com_sec: *const LANES_COM_SEC,
m: *const int64_t,
m_alpha1: size_t,
m_alpha2: size_t,
ctx: *mut aes256ctr_ctx,
);
fn lanes_ver(
pp: *const LANES_PP,
lanes_mp_ver: Option<
unsafe extern "C" fn(*const ::core::ffi::c_void) -> ::core::ffi::c_int,
>,
ulp: *const LANES_ULP,
com_pub: *const LANES_COM_PUB,
pi: *const LANES_PROOF,
m_alpha1: size_t,
m_alpha2: size_t,
) -> ::core::ffi::c_int;
fn lanes_plus_rq_crt_mul(
out: *mut LANES_PLUS_Rq_CRT,
a: *const LANES_PLUS_Rq_CRT,
b: *const LANES_PLUS_Rq_CRT,
);
fn lanes_plus_rq_crt_add_nomodq(
out: *mut LANES_PLUS_Rq_CRT,
a: *const LANES_PLUS_Rq_CRT,
b: *const LANES_PLUS_Rq_CRT,
);
fn lanes_plus_rq_crt_add(
out: *mut LANES_PLUS_Rq_CRT,
a: *const LANES_PLUS_Rq_CRT,
b: *const LANES_PLUS_Rq_CRT,
);
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_r_mul(
out: *mut LANES_PLUS_Rq,
a: *const LANES_PLUS_Rq,
b: *const LANES_PLUS_Rq,
);
fn lanes_plus_r_add(
out: *mut LANES_PLUS_Rq,
a: *const LANES_PLUS_Rq,
b: *const LANES_PLUS_Rq,
);
fn shake256(out: *mut uint8_t, outlen: size_t, in_0: *const uint8_t, inlen: size_t);
fn gaussian_sampler_phieta_m(
sample: *mut int64_t,
slen: uint32_t,
ctx: *mut aes256ctr_ctx,
);
fn gaussian_sampler_phieta(
sample: *mut int64_t,
slen: uint32_t,
ctx: *mut aes256ctr_ctx,
);
fn rej_phieta_m(x: int64_t, ctx: *mut aes256ctr_ctx) -> uint64_t;
fn rej_phieta(x: int64_t, ctx: *mut aes256ctr_ctx) -> uint64_t;
fn malloc(_: size_t) -> *mut ::core::ffi::c_void;
fn free(_: *mut ::core::ffi::c_void);
}
pub type size_t = usize;
pub type int8_t = i8;
pub type uint8_t = u8;
pub type int16_t = i16;
pub type int32_t = i32;
pub type uint32_t = u32;
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_COM_SEC {
pub r: [LANES_Rqhat_16; 22],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LANES_ULP {
pub A: *const [int64_t; 192],
pub Am: size_t,
pub u: *const int64_t,
}
#[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_COM_SEC {
pub lanes_com_sec: LANES_COM_SEC,
pub m: *const LANES_PLUS_Rq,
pub r: *const LANES_PLUS_Rq,
pub v: *const int64_t,
pub u: LANES_PLUS_Rq,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct LANES_PLUS_ULP {
pub A_crt: *const LANES_PLUS_Rq_CRT,
pub B_crt: *const LANES_PLUS_Rq_CRT,
pub t_crt: *const LANES_PLUS_Rq_CRT,
pub G1: *const [int64_t; 32],
pub G2: *const [int64_t; 128],
pub dim_r: size_t,
}
#[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) -> (),
>,
}
#[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_32(mut x: *mut ::core::ffi::c_uchar, c: uint32_t) {
*x = c as ::core::ffi::c_uchar;
*x.offset(1 as ::core::ffi::c_int as isize) = (c >> 8 as ::core::ffi::c_int)
as ::core::ffi::c_uchar;
*x.offset(2 as ::core::ffi::c_int as isize) = (c >> 16 as ::core::ffi::c_int)
as ::core::ffi::c_uchar;
*x.offset(3 as ::core::ffi::c_int as isize) = (c >> 24 as ::core::ffi::c_int)
as ::core::ffi::c_uchar;
}
#[inline]
unsafe extern "C" fn store_40(mut x: *mut ::core::ffi::c_uchar, c: uint64_t) {
*x = c as ::core::ffi::c_uchar;
*x.offset(1 as ::core::ffi::c_int as isize) = (c >> 8 as ::core::ffi::c_int)
as ::core::ffi::c_uchar;
*x.offset(2 as ::core::ffi::c_int as isize) = (c >> 16 as ::core::ffi::c_int)
as ::core::ffi::c_uchar;
*x.offset(3 as ::core::ffi::c_int as isize) = (c >> 24 as ::core::ffi::c_int)
as ::core::ffi::c_uchar;
*x.offset(4 as ::core::ffi::c_int as isize) = (c >> 32 as ::core::ffi::c_int)
as ::core::ffi::c_uchar;
}
static mut lanes_plus_q0: uint64_t = 61 as uint64_t;
#[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;
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lanes_plus_gen(
mut pp: *mut LANES_PLUS_PP,
mut ctx: *mut aes256ctr_ctx,
) {
lanes_gen(pp as *mut LANES_PP, ctx);
}
#[inline]
unsafe extern "C" fn build_lanes_m(
mut s: *mut int64_t,
mut u: *const LANES_PLUS_Rq,
mut m: *const LANES_PLUS_Rq,
mut v: *const int64_t,
) {
let mut i: size_t = 0;
i = 0 as size_t;
while i < 32 as size_t {
*s.offset(i as isize) = (*u).poly[i as usize];
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < 32 as size_t {
*s.offset((32 as size_t).wrapping_add(i) as isize) = (*m).poly[i as usize];
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < (4 as ::core::ffi::c_int * 32 as ::core::ffi::c_int) as size_t {
*s
.offset(
((2 as ::core::ffi::c_int * 32 as ::core::ffi::c_int) as size_t)
.wrapping_add(i) as isize,
) = *v.offset(i as isize);
i = i.wrapping_add(1);
}
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lanes_plus_com(
mut pub_0: *mut LANES_PLUS_COM_PUB,
mut sec: *mut LANES_PLUS_COM_SEC,
mut pp: *const LANES_PLUS_PP,
mut ctx: *mut aes256ctr_ctx,
) {
let mut s: [int64_t; 192] = [0; 192];
let mut i: size_t = 0;
gaussian_sampler_phieta_m(
&raw mut (*sec).u.poly as *mut int64_t,
32 as uint32_t,
ctx,
);
build_lanes_m(&raw mut s as *mut int64_t, &raw mut (*sec).u, (*sec).m, (*sec).v);
lanes_com(
pub_0 as *mut LANES_COM_PUB,
&raw mut (*sec).lanes_com_sec,
pp as *const LANES_PP,
&raw mut s as *mut int64_t,
ctx,
);
}
#[inline]
unsafe extern "C" fn rej(
mut z: *const LANES_PLUS_Rq,
mut c: *const LANES_PLUS_Rq,
len: size_t,
sigma_6: uint64_t,
mut ctx: *mut aes256ctr_ctx,
mut rej_bernoulli: Option<
unsafe extern "C" fn(int64_t, *mut aes256ctr_ctx) -> uint64_t,
>,
) -> uint64_t {
let mut ret: uint64_t = 0 as uint64_t;
let mut x: uint64_t = 0 as uint64_t;
let mut i: uint64_t = 0;
let mut j: uint64_t = 0;
i = 0 as uint64_t;
while i < len as uint64_t {
j = 0 as uint64_t;
while j < 32 as uint64_t {
x = x
.wrapping_add(
((*c.offset(i as isize)).poly[j as usize]
* (*c.offset(i as isize)).poly[j as usize]
- 2 as int64_t * (*z.offset(i as isize)).poly[j as usize]
* (*c.offset(i as isize)).poly[j as usize]) as uint64_t,
);
j = j.wrapping_add(1);
}
i = i.wrapping_add(1);
}
ret = norm_check(z, len, sigma_6)
| rej_bernoulli.expect("non-null function pointer")(x as int64_t, ctx);
return ret >> 63 as ::core::ffi::c_int;
}
#[inline]
unsafe extern "C" fn hash(
mut c: *mut LANES_PLUS_Rq,
mut pp: *const LANES_PLUS_PP,
mut ulp: *const LANES_PLUS_ULP,
mut com_pub: *const LANES_PLUS_COM_PUB,
mut w_crt: *const LANES_PLUS_Rq_CRT,
dim_r: size_t,
mut rho: *mut LANES_PLUS_RHO,
mut rho_in: *const ::core::ffi::c_void,
) {
let mut buf: *mut ::core::ffi::c_uchar = ::core::ptr::null_mut::<
::core::ffi::c_uchar,
>();
let mut buf_head: *mut ::core::ffi::c_uchar = ::core::ptr::null_mut::<
::core::ffi::c_uchar,
>();
let mut hash_out: [::core::ffi::c_uchar; 32] = [0; 32];
let mut i: size_t = 0;
let mut j: size_t = 0;
let mut k: size_t = 0;
let mut buf_size: size_t = ((7 as ::core::ffi::c_int
* (6 as ::core::ffi::c_int + 7 as ::core::ffi::c_int + 6 as ::core::ffi::c_int
+ 3 as ::core::ffi::c_int) * 128 as ::core::ffi::c_int
* 4 as ::core::ffi::c_int
+ (6 as ::core::ffi::c_int + 3 as ::core::ffi::c_int)
* (6 as ::core::ffi::c_int + 7 as ::core::ffi::c_int
+ 6 as ::core::ffi::c_int + 3 as ::core::ffi::c_int)
* 128 as ::core::ffi::c_int * 4 as ::core::ffi::c_int) as size_t)
.wrapping_add(dim_r.wrapping_mul(32 as size_t).wrapping_mul(5 as size_t))
.wrapping_add((32 as ::core::ffi::c_int * 5 as ::core::ffi::c_int) as size_t)
.wrapping_add((32 as ::core::ffi::c_int * 5 as ::core::ffi::c_int) as size_t)
.wrapping_add(
(32 as ::core::ffi::c_int * 32 as ::core::ffi::c_int
* 5 as ::core::ffi::c_int) as size_t,
)
.wrapping_add(
(32 as ::core::ffi::c_int
* (4 as ::core::ffi::c_int * 32 as ::core::ffi::c_int)
* 5 as ::core::ffi::c_int) as size_t,
)
.wrapping_add(
(7 as ::core::ffi::c_int * 128 as ::core::ffi::c_int
* 4 as ::core::ffi::c_int) as size_t,
)
.wrapping_add(
(6 as ::core::ffi::c_int * 128 as ::core::ffi::c_int
* 4 as ::core::ffi::c_int) as size_t,
)
.wrapping_add((32 as ::core::ffi::c_int * 5 as ::core::ffi::c_int) as size_t);
if !rho.is_null() {
buf_size = buf_size.wrapping_add((*rho).rho_len);
}
buf = malloc(buf_size) as *mut ::core::ffi::c_uchar;
buf_head = buf;
i = 0 as size_t;
while i < 7 as size_t {
j = 0 as size_t;
while j
< (6 as ::core::ffi::c_int + 7 as ::core::ffi::c_int
+ 6 as ::core::ffi::c_int + 3 as ::core::ffi::c_int) as size_t
{
k = 0 as size_t;
while k < 128 as size_t {
store_32(
buf_head,
(*pp).B0[i as usize][j as usize].poly[k as usize] as uint32_t,
);
buf_head = buf_head.offset(4 as ::core::ffi::c_int as isize);
k = k.wrapping_add(1);
}
j = j.wrapping_add(1);
}
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < (6 as ::core::ffi::c_int + 3 as ::core::ffi::c_int) as size_t {
j = 0 as size_t;
while j
< (6 as ::core::ffi::c_int + 7 as ::core::ffi::c_int
+ 6 as ::core::ffi::c_int + 3 as ::core::ffi::c_int) as size_t
{
k = 0 as size_t;
while k < 128 as size_t {
store_32(
buf_head,
(*pp).b[i as usize][j as usize].poly[k as usize] as uint32_t,
);
buf_head = buf_head.offset(4 as ::core::ffi::c_int as isize);
k = k.wrapping_add(1);
}
j = j.wrapping_add(1);
}
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < dim_r {
j = 0 as size_t;
while j < 32 as size_t {
let fresh0 = buf_head;
buf_head = buf_head.offset(1);
*fresh0 = (*(*ulp).A_crt.offset(i as isize)).poly_q0[j as usize]
as ::core::ffi::c_uchar;
store_32(
buf_head,
(*(*ulp).A_crt.offset(i as isize)).poly_p[j as usize] as uint32_t,
);
buf_head = buf_head.offset(4 as ::core::ffi::c_int as isize);
j = j.wrapping_add(1);
}
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < 32 as size_t {
let fresh1 = buf_head;
buf_head = buf_head.offset(1);
*fresh1 = (*(*ulp).B_crt).poly_q0[i as usize] as ::core::ffi::c_uchar;
store_32(buf_head, (*(*ulp).B_crt).poly_p[i as usize] as uint32_t);
buf_head = buf_head.offset(4 as ::core::ffi::c_int as isize);
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < 32 as size_t {
let fresh2 = buf_head;
buf_head = buf_head.offset(1);
*fresh2 = (*(*ulp).t_crt).poly_q0[i as usize] as ::core::ffi::c_uchar;
store_32(buf_head, (*(*ulp).t_crt).poly_p[i as usize] as uint32_t);
buf_head = buf_head.offset(4 as ::core::ffi::c_int as isize);
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < 32 as size_t {
j = 0 as size_t;
while j < 32 as size_t {
store_40(buf_head, (*(*ulp).G1.offset(i as isize))[j as usize] as uint64_t);
buf_head = buf_head.offset(5 as ::core::ffi::c_int as isize);
j = j.wrapping_add(1);
}
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < 32 as size_t {
j = 0 as size_t;
while j < (4 as ::core::ffi::c_int * 32 as ::core::ffi::c_int) as size_t {
store_40(buf_head, (*(*ulp).G2.offset(i as isize))[j as usize] as uint64_t);
buf_head = buf_head.offset(5 as ::core::ffi::c_int as isize);
j = j.wrapping_add(1);
}
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < 7 as size_t {
j = 0 as size_t;
while j < 128 as size_t {
store_32(buf_head, (*com_pub).t0[i as usize].poly[j as usize] as uint32_t);
buf_head = buf_head.offset(4 as ::core::ffi::c_int as isize);
j = j.wrapping_add(1);
}
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < 6 as size_t {
j = 0 as size_t;
while j < 128 as size_t {
store_32(buf_head, (*com_pub).t[i as usize].poly[j as usize] as uint32_t);
buf_head = buf_head.offset(4 as ::core::ffi::c_int as isize);
j = j.wrapping_add(1);
}
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < 32 as size_t {
let fresh3 = buf_head;
buf_head = buf_head.offset(1);
*fresh3 = (*w_crt).poly_q0[i as usize] as ::core::ffi::c_uchar;
store_32(buf_head, (*w_crt).poly_p[i as usize] as uint32_t);
buf_head = buf_head.offset(4 as ::core::ffi::c_int as isize);
i = i.wrapping_add(1);
}
if !rho.is_null() {
(*rho).rho = buf_head;
(*rho)
.callback
.expect(
"non-null function pointer",
)(rho as *mut ::core::ffi::c_void, rho_in);
}
shake256(&raw mut hash_out as *mut uint8_t, 32 as size_t, buf, buf_size);
i = 0 as size_t;
while i < 32 as size_t {
let mut x: int8_t = (hash_out[i as usize] as ::core::ffi::c_int
& 15 as ::core::ffi::c_int) as int8_t;
let mut y: int8_t = (hash_out[i as usize] as ::core::ffi::c_int
>> 4 as ::core::ffi::c_int & 1 as ::core::ffi::c_int) as int8_t;
(*c).poly[i as usize] = ((1 as ::core::ffi::c_int
- 2 as ::core::ffi::c_int * y as ::core::ffi::c_int)
* (x as ::core::ffi::c_int + 1 as ::core::ffi::c_int)) as int64_t;
i = i.wrapping_add(1);
}
free(buf as *mut ::core::ffi::c_void);
}
unsafe extern "C" fn set_ulp_prime_fixed(
mut L: *mut [int64_t; 192],
mut u: *mut int64_t,
mut G1: *const [int64_t; 32],
mut G2: *const [int64_t; 128],
) {
let mut i: size_t = 0;
let mut j: size_t = 0;
i = 0 as size_t;
while i < (32 as ::core::ffi::c_int * 2 as ::core::ffi::c_int) as size_t {
j = 0 as size_t;
while j < (6 as ::core::ffi::c_int * 32 as ::core::ffi::c_int) as size_t {
(*L.offset(i as isize))[j as usize] = 0 as int64_t;
j = j.wrapping_add(1);
}
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < 32 as size_t {
(*L.offset(i as isize))[i as usize] = 1 as int64_t;
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < 32 as size_t {
j = 0 as size_t;
while j < 32 as size_t {
(*L
.offset(
i.wrapping_add(32 as size_t) as isize,
))[j.wrapping_add(32 as size_t) as usize] = (*G1
.offset(i as isize))[j as usize];
j = j.wrapping_add(1);
}
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < 32 as size_t {
j = 0 as size_t;
while j < (4 as ::core::ffi::c_int * 32 as ::core::ffi::c_int) as size_t {
(*L
.offset(
i.wrapping_add(32 as size_t) as isize,
))[j
.wrapping_add(
(32 as ::core::ffi::c_int * 2 as ::core::ffi::c_int) as size_t,
) as usize] = -(*G2.offset(i as isize))[j as usize];
j = j.wrapping_add(1);
}
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < 32 as size_t {
*u.offset(i.wrapping_add(32 as size_t) as isize) = 0 as int64_t;
i = i.wrapping_add(1);
}
}
#[inline]
unsafe extern "C" fn set_ulp_prime(
mut L: *mut [int64_t; 192],
mut u: *mut int64_t,
mut c: *const LANES_PLUS_Rq,
mut f: *const LANES_PLUS_Rq,
) {
let mut i: size_t = 0;
let mut j: size_t = 0;
i = 0 as size_t;
while i < 32 as size_t {
j = (32 as size_t).wrapping_sub(i);
while j < 32 as size_t {
(*L
.offset(
j.wrapping_sub((32 as size_t).wrapping_sub(i)) as isize,
))[i.wrapping_add(32 as size_t) as usize] = -(*c).poly[j as usize];
j = j.wrapping_add(1);
}
j = i;
while j < 32 as size_t {
(*L.offset(j as isize))[i.wrapping_add(32 as size_t) as usize] = (*c)
.poly[j.wrapping_sub(i) as usize];
j = j.wrapping_add(1);
}
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < 32 as size_t {
*u.offset(i as isize) = (*f).poly[i as usize];
i = i.wrapping_add(1);
}
}
static mut phieta_m_sigma_6: uint64_t = 6256029 as uint64_t;
static mut phieta_sigma_6: uint64_t = 1318888 as uint64_t;
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lanes_plus_prove(
mut out: *mut LANES_PLUS_PROOF,
mut pp: *const LANES_PLUS_PP,
mut mp_prove: Option<
unsafe extern "C" fn(*mut ::core::ffi::c_void, *const ::core::ffi::c_void) -> (),
>,
mut ulp: *const LANES_PLUS_ULP,
mut com_pub: *const LANES_PLUS_COM_PUB,
mut com_sec: *const LANES_PLUS_COM_SEC,
mut ctx: *mut aes256ctr_ctx,
mut rho: *mut LANES_PLUS_RHO,
) {
let mut y: *mut LANES_PLUS_Rq = ::core::ptr::null_mut::<LANES_PLUS_Rq>();
let mut y_crt: *mut LANES_PLUS_Rq_CRT = ::core::ptr::null_mut::<LANES_PLUS_Rq_CRT>();
let mut u_crt: LANES_PLUS_Rq_CRT = LANES_PLUS_Rq_CRT {
poly_q0: [0; 32],
poly_p: [0; 32],
};
let mut w_crt: LANES_PLUS_Rq_CRT = LANES_PLUS_Rq_CRT {
poly_q0: [0; 32],
poly_p: [0; 32],
};
let mut Bu_crt: LANES_PLUS_Rq_CRT = LANES_PLUS_Rq_CRT {
poly_q0: [0; 32],
poly_p: [0; 32],
};
let mut cr: *mut LANES_PLUS_Rq = ::core::ptr::null_mut::<LANES_PLUS_Rq>();
let mut cm: LANES_PLUS_Rq = LANES_PLUS_Rq { poly: [0; 32] };
let mut L: [[int64_t; 192]; 64] = [[0; 192]; 64];
let mut lanes_u: [int64_t; 64] = [0; 64];
let mut lanes_s: [int64_t; 192] = [0; 192];
let mut i: size_t = 0;
let mut j: size_t = 0;
let mut rej_res: ::core::ffi::c_int = 0 as ::core::ffi::c_int;
(*out).z = malloc(
(*ulp).dim_r.wrapping_mul(::core::mem::size_of::<LANES_PLUS_Rq>() as size_t),
) as *mut LANES_PLUS_Rq;
y = malloc(
(::core::mem::size_of::<LANES_PLUS_Rq>() as size_t).wrapping_mul((*ulp).dim_r),
) as *mut LANES_PLUS_Rq;
y_crt = malloc(
(::core::mem::size_of::<LANES_PLUS_Rq_CRT>() as size_t)
.wrapping_mul((*ulp).dim_r),
) as *mut LANES_PLUS_Rq_CRT;
cr = malloc(
(::core::mem::size_of::<LANES_PLUS_Rq>() as size_t).wrapping_mul((*ulp).dim_r),
) as *mut LANES_PLUS_Rq;
lanes_plus_rq_to_crt(&raw mut u_crt, &raw const (*com_sec).u);
lanes_plus_rq_crt_mul(&raw mut Bu_crt, (*ulp).B_crt, &raw mut u_crt);
set_ulp_prime_fixed(
&raw mut L as *mut [int64_t; 192],
&raw mut lanes_u as *mut int64_t,
(*ulp).G1 as *const [int64_t; 32],
(*ulp).G2 as *const [int64_t; 128],
);
build_lanes_m(
&raw mut lanes_s as *mut int64_t,
&raw const (*com_sec).u,
(*com_sec).m,
(*com_sec).v,
);
loop {
i = 0 as size_t;
while i < (*ulp).dim_r {
gaussian_sampler_phieta(
&raw mut (*y.offset(i as isize)).poly as *mut int64_t,
32 as uint32_t,
ctx,
);
lanes_plus_rq_to_crt(y_crt.offset(i as isize), y.offset(i as isize));
i = i.wrapping_add(1);
}
lanes_plus_rq_crt_inner_product_nomodq(
&raw mut w_crt,
(*ulp).A_crt,
y_crt,
(*ulp).dim_r,
);
lanes_plus_rq_crt_add(&raw mut w_crt, &raw mut w_crt, &raw mut Bu_crt);
hash(
&raw mut (*out).c,
pp,
ulp,
com_pub,
&raw mut w_crt,
(*ulp).dim_r,
rho,
y_crt as *const ::core::ffi::c_void,
);
i = 0 as size_t;
while i < (*ulp).dim_r {
lanes_plus_r_mul(
cr.offset(i as isize),
&raw mut (*out).c,
(*com_sec).r.offset(i as isize),
);
lanes_plus_r_add(
(*out).z.offset(i as isize),
y.offset(i as isize),
cr.offset(i as isize),
);
i = i.wrapping_add(1);
}
lanes_plus_r_mul(&raw mut cm, &raw mut (*out).c, (*com_sec).m);
lanes_plus_r_add(&raw mut (*out).f, &raw const (*com_sec).u, &raw mut cm);
rej_res = rej(
(*out).z,
cr,
(*ulp).dim_r,
phieta_sigma_6,
ctx,
Some(
rej_phieta
as unsafe extern "C" fn(int64_t, *mut aes256ctr_ctx) -> uint64_t,
),
) as ::core::ffi::c_int;
if !(rej_res != 0) {
rej_res = rej(
&raw mut (*out).f,
&raw mut cm,
1 as size_t,
phieta_m_sigma_6,
ctx,
Some(
rej_phieta_m
as unsafe extern "C" fn(int64_t, *mut aes256ctr_ctx) -> uint64_t,
),
) as ::core::ffi::c_int;
if !(rej_res != 0) {
set_ulp_prime(
&raw mut L as *mut [int64_t; 192],
&raw mut lanes_u as *mut int64_t,
&raw mut (*out).c,
&raw mut (*out).f,
);
let mut ulp_prime: LANES_ULP = LANES_ULP {
A: &raw mut L as *mut [int64_t; 192] as *const [int64_t; 192],
Am: (32 as ::core::ffi::c_int * 2 as ::core::ffi::c_int) as size_t,
u: &raw mut lanes_u as *mut int64_t,
};
lanes_prove(
&raw mut (*out).lanes_proof,
pp as *const LANES_PP,
mp_prove,
&raw mut ulp_prime,
&raw const (*com_sec).lanes_com_sec,
&raw mut lanes_s as *mut int64_t,
(6 as ::core::ffi::c_int - 4 as ::core::ffi::c_int) as size_t,
6 as size_t,
ctx,
);
}
}
if !(rej_res != 0) {
break;
}
}
free(y as *mut ::core::ffi::c_void);
free(y_crt as *mut ::core::ffi::c_void);
free(cr as *mut ::core::ffi::c_void);
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lanes_plus_ver(
mut pp: *const LANES_PLUS_PP,
mut mp_ver: Option<
unsafe extern "C" fn(*const ::core::ffi::c_void) -> ::core::ffi::c_int,
>,
mut ulp: *const LANES_PLUS_ULP,
mut com_pub: *const LANES_PLUS_COM_PUB,
mut in_0: *const LANES_PLUS_PROOF,
mut rho: *mut LANES_PLUS_RHO,
) -> ::core::ffi::c_int {
let mut z_crt: *mut LANES_PLUS_Rq_CRT = ::core::ptr::null_mut::<LANES_PLUS_Rq_CRT>();
let mut f_crt: LANES_PLUS_Rq_CRT = LANES_PLUS_Rq_CRT {
poly_q0: [0; 32],
poly_p: [0; 32],
};
let mut c_crt: LANES_PLUS_Rq_CRT = LANES_PLUS_Rq_CRT {
poly_q0: [0; 32],
poly_p: [0; 32],
};
let mut w_prime_crt: LANES_PLUS_Rq_CRT = LANES_PLUS_Rq_CRT {
poly_q0: [0; 32],
poly_p: [0; 32],
};
let mut c_prime: LANES_PLUS_Rq = LANES_PLUS_Rq { poly: [0; 32] };
let mut offset: LANES_PLUS_Rq = LANES_PLUS_Rq { poly: [0; 32] };
let mut f_prime: LANES_PLUS_Rq = LANES_PLUS_Rq { poly: [0; 32] };
let mut L: [[int64_t; 192]; 64] = [[0; 192]; 64];
let mut lanes_u: [int64_t; 64] = [0; 64];
let mut i: size_t = 0;
let mut buf_crt: LANES_PLUS_Rq_CRT = LANES_PLUS_Rq_CRT {
poly_q0: [0; 32],
poly_p: [0; 32],
};
if norm_check((*in_0).z, (*ulp).dim_r, phieta_sigma_6) >> 63 as ::core::ffi::c_int
!= 0
{
return 0 as ::core::ffi::c_int;
}
if norm_check(&raw const (*in_0).f, 1 as size_t, phieta_m_sigma_6)
>> 63 as ::core::ffi::c_int != 0
{
return 0 as ::core::ffi::c_int;
}
z_crt = malloc(
(::core::mem::size_of::<LANES_PLUS_Rq_CRT>() as size_t)
.wrapping_mul((*ulp).dim_r),
) as *mut LANES_PLUS_Rq_CRT;
i = 0 as size_t;
while i < (*ulp).dim_r {
lanes_plus_rq_to_crt(z_crt.offset(i as isize), (*in_0).z.offset(i as isize));
i = i.wrapping_add(1);
}
i = 0 as size_t;
while i < 32 as size_t {
offset.poly[i as usize] = lanes_plus_q0
.wrapping_sub(1 as uint64_t)
.wrapping_div(2 as uint64_t) as int64_t;
i = i.wrapping_add(1);
}
lanes_plus_r_mul(&raw mut offset, &raw mut offset, &raw const (*in_0).c);
lanes_plus_r_add(&raw mut f_prime, &raw const (*in_0).f, &raw mut offset);
lanes_plus_rq_to_crt(&raw mut f_crt, &raw mut f_prime);
lanes_plus_rq_to_crt(&raw mut c_crt, &raw const (*in_0).c);
lanes_plus_rq_crt_inner_product_nomodq(
&raw mut w_prime_crt,
(*ulp).A_crt,
z_crt,
(*ulp).dim_r,
);
free(z_crt as *mut ::core::ffi::c_void);
lanes_plus_rq_crt_mul(&raw mut buf_crt, (*ulp).B_crt, &raw mut f_crt);
lanes_plus_rq_crt_add_nomodq(
&raw mut w_prime_crt,
&raw mut w_prime_crt,
&raw mut buf_crt,
);
lanes_plus_rq_crt_mul(&raw mut buf_crt, &raw mut c_crt, (*ulp).t_crt);
lanes_plus_rq_crt_sub(&raw mut w_prime_crt, &raw mut w_prime_crt, &raw mut buf_crt);
hash(
&raw mut c_prime,
pp,
ulp,
com_pub,
&raw mut w_prime_crt,
(*ulp).dim_r,
rho,
::core::ptr::null::<::core::ffi::c_void>(),
);
i = 0 as size_t;
while i < 32 as size_t {
if (*in_0).c.poly[i as usize] != c_prime.poly[i as usize] {
return 0 as ::core::ffi::c_int;
}
i = i.wrapping_add(1);
}
set_ulp_prime_fixed(
&raw mut L as *mut [int64_t; 192],
&raw mut lanes_u as *mut int64_t,
(*ulp).G1 as *const [int64_t; 32],
(*ulp).G2 as *const [int64_t; 128],
);
set_ulp_prime(
&raw mut L as *mut [int64_t; 192],
&raw mut lanes_u as *mut int64_t,
&raw const (*in_0).c,
&raw const (*in_0).f,
);
let mut ulp_prime: LANES_ULP = LANES_ULP {
A: &raw mut L as *mut [int64_t; 192] as *const [int64_t; 192],
Am: (32 as ::core::ffi::c_int * 2 as ::core::ffi::c_int) as size_t,
u: &raw mut lanes_u as *mut int64_t,
};
return lanes_ver(
pp as *const LANES_PP,
mp_ver,
&raw mut ulp_prime,
com_pub as *const LANES_COM_PUB,
&raw const (*in_0).lanes_proof,
(6 as ::core::ffi::c_int - 4 as ::core::ffi::c_int) as size_t,
6 as size_t,
);
}