pub const SXT_CPU_BACKEND: u32 = 1;
pub const SXT_GPU_BACKEND: u32 = 2;
pub const SXT_CURVE_RISTRETTO255: u32 = 0;
pub const SXT_CURVE_BLS_381: u32 = 1;
pub const SXT_CURVE_BN_254: u32 = 2;
pub const SXT_CURVE_GRUMPKIN: u32 = 2;
#[doc = " config struct to hold the chosen backend"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sxt_config {
pub backend: ::std::os::raw::c_int,
pub num_precomputed_generators: u64,
}
#[test]
fn bindgen_test_layout_sxt_config() {
const UNINIT: ::std::mem::MaybeUninit<sxt_config> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<sxt_config>(),
16usize,
concat!("Size of: ", stringify!(sxt_config))
);
assert_eq!(
::std::mem::align_of::<sxt_config>(),
8usize,
concat!("Alignment of ", stringify!(sxt_config))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).backend) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(sxt_config),
"::",
stringify!(backend)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).num_precomputed_generators) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(sxt_config),
"::",
stringify!(num_precomputed_generators)
)
);
}
#[doc = " encodes an element of the `ristretto255` group"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sxt_ristretto255_compressed {
pub ristretto_bytes: [u8; 32usize],
}
#[test]
fn bindgen_test_layout_sxt_ristretto255_compressed() {
const UNINIT: ::std::mem::MaybeUninit<sxt_ristretto255_compressed> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<sxt_ristretto255_compressed>(),
32usize,
concat!("Size of: ", stringify!(sxt_ristretto255_compressed))
);
assert_eq!(
::std::mem::align_of::<sxt_ristretto255_compressed>(),
1usize,
concat!("Alignment of ", stringify!(sxt_ristretto255_compressed))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).ristretto_bytes) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(sxt_ristretto255_compressed),
"::",
stringify!(ristretto_bytes)
)
);
}
#[doc = " encodes an element of the `bls12-381` `G1` group in compressed form"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sxt_bls12_381_g1_compressed {
pub g1_bytes: [u8; 48usize],
}
#[test]
fn bindgen_test_layout_sxt_bls12_381_g1_compressed() {
const UNINIT: ::std::mem::MaybeUninit<sxt_bls12_381_g1_compressed> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<sxt_bls12_381_g1_compressed>(),
48usize,
concat!("Size of: ", stringify!(sxt_bls12_381_g1_compressed))
);
assert_eq!(
::std::mem::align_of::<sxt_bls12_381_g1_compressed>(),
1usize,
concat!("Alignment of ", stringify!(sxt_bls12_381_g1_compressed))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).g1_bytes) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(sxt_bls12_381_g1_compressed),
"::",
stringify!(g1_bytes)
)
);
}
#[doc = " encodes an element of the finite field for `curve25519`\n\n modulo `(2^252 + 27742317777372353535851937790883648493)`"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sxt_curve25519_scalar {
pub bytes: [u8; 32usize],
}
#[test]
fn bindgen_test_layout_sxt_curve25519_scalar() {
const UNINIT: ::std::mem::MaybeUninit<sxt_curve25519_scalar> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<sxt_curve25519_scalar>(),
32usize,
concat!("Size of: ", stringify!(sxt_curve25519_scalar))
);
assert_eq!(
::std::mem::align_of::<sxt_curve25519_scalar>(),
1usize,
concat!("Alignment of ", stringify!(sxt_curve25519_scalar))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).bytes) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(sxt_curve25519_scalar),
"::",
stringify!(bytes)
)
);
}
#[doc = " encodes a strobe-based transcript"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sxt_transcript {
pub bytes: [u8; 203usize],
}
#[test]
fn bindgen_test_layout_sxt_transcript() {
const UNINIT: ::std::mem::MaybeUninit<sxt_transcript> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<sxt_transcript>(),
203usize,
concat!("Size of: ", stringify!(sxt_transcript))
);
assert_eq!(
::std::mem::align_of::<sxt_transcript>(),
1usize,
concat!("Alignment of ", stringify!(sxt_transcript))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).bytes) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(sxt_transcript),
"::",
stringify!(bytes)
)
);
}
#[doc = " encodes an element of the `curve25519` group"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sxt_ristretto255 {
pub X: [u64; 5usize],
pub Y: [u64; 5usize],
pub Z: [u64; 5usize],
pub T: [u64; 5usize],
}
#[test]
fn bindgen_test_layout_sxt_ristretto255() {
const UNINIT: ::std::mem::MaybeUninit<sxt_ristretto255> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<sxt_ristretto255>(),
160usize,
concat!("Size of: ", stringify!(sxt_ristretto255))
);
assert_eq!(
::std::mem::align_of::<sxt_ristretto255>(),
8usize,
concat!("Alignment of ", stringify!(sxt_ristretto255))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).X) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(sxt_ristretto255),
"::",
stringify!(X)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).Y) as usize - ptr as usize },
40usize,
concat!(
"Offset of field: ",
stringify!(sxt_ristretto255),
"::",
stringify!(Y)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).Z) as usize - ptr as usize },
80usize,
concat!(
"Offset of field: ",
stringify!(sxt_ristretto255),
"::",
stringify!(Z)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).T) as usize - ptr as usize },
120usize,
concat!(
"Offset of field: ",
stringify!(sxt_ristretto255),
"::",
stringify!(T)
)
);
}
#[doc = " encodes an affine element of the `bls12-381` `G1` group"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sxt_bls12_381_g1 {
pub X: [u64; 6usize],
pub Y: [u64; 6usize],
}
#[test]
fn bindgen_test_layout_sxt_bls12_381_g1() {
const UNINIT: ::std::mem::MaybeUninit<sxt_bls12_381_g1> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<sxt_bls12_381_g1>(),
96usize,
concat!("Size of: ", stringify!(sxt_bls12_381_g1))
);
assert_eq!(
::std::mem::align_of::<sxt_bls12_381_g1>(),
8usize,
concat!("Alignment of ", stringify!(sxt_bls12_381_g1))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).X) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(sxt_bls12_381_g1),
"::",
stringify!(X)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).Y) as usize - ptr as usize },
48usize,
concat!(
"Offset of field: ",
stringify!(sxt_bls12_381_g1),
"::",
stringify!(Y)
)
);
}
#[doc = " encodes an affine element of the `bls12-381` `G1` group in projective form"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sxt_bls12_381_g1_p2 {
pub X: [u64; 6usize],
pub Y: [u64; 6usize],
pub Z: [u64; 6usize],
}
#[test]
fn bindgen_test_layout_sxt_bls12_381_g1_p2() {
const UNINIT: ::std::mem::MaybeUninit<sxt_bls12_381_g1_p2> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<sxt_bls12_381_g1_p2>(),
144usize,
concat!("Size of: ", stringify!(sxt_bls12_381_g1_p2))
);
assert_eq!(
::std::mem::align_of::<sxt_bls12_381_g1_p2>(),
8usize,
concat!("Alignment of ", stringify!(sxt_bls12_381_g1_p2))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).X) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(sxt_bls12_381_g1_p2),
"::",
stringify!(X)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).Y) as usize - ptr as usize },
48usize,
concat!(
"Offset of field: ",
stringify!(sxt_bls12_381_g1_p2),
"::",
stringify!(Y)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).Z) as usize - ptr as usize },
96usize,
concat!(
"Offset of field: ",
stringify!(sxt_bls12_381_g1_p2),
"::",
stringify!(Z)
)
);
}
#[doc = " encodes an affine element of the `bn254` `G1` group"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sxt_bn254_g1 {
pub X: [u64; 4usize],
pub Y: [u64; 4usize],
pub infinity: u8,
}
#[test]
fn bindgen_test_layout_sxt_bn254_g1() {
const UNINIT: ::std::mem::MaybeUninit<sxt_bn254_g1> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<sxt_bn254_g1>(),
72usize,
concat!("Size of: ", stringify!(sxt_bn254_g1))
);
assert_eq!(
::std::mem::align_of::<sxt_bn254_g1>(),
8usize,
concat!("Alignment of ", stringify!(sxt_bn254_g1))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).X) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(sxt_bn254_g1),
"::",
stringify!(X)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).Y) as usize - ptr as usize },
32usize,
concat!(
"Offset of field: ",
stringify!(sxt_bn254_g1),
"::",
stringify!(Y)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).infinity) as usize - ptr as usize },
64usize,
concat!(
"Offset of field: ",
stringify!(sxt_bn254_g1),
"::",
stringify!(infinity)
)
);
}
#[doc = " encodes an affine element of the `bn254` `G1` group in projective form"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sxt_bn254_g1_p2 {
pub X: [u64; 4usize],
pub Y: [u64; 4usize],
pub Z: [u64; 4usize],
}
#[test]
fn bindgen_test_layout_sxt_bn254_g1_p2() {
const UNINIT: ::std::mem::MaybeUninit<sxt_bn254_g1_p2> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<sxt_bn254_g1_p2>(),
96usize,
concat!("Size of: ", stringify!(sxt_bn254_g1_p2))
);
assert_eq!(
::std::mem::align_of::<sxt_bn254_g1_p2>(),
8usize,
concat!("Alignment of ", stringify!(sxt_bn254_g1_p2))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).X) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(sxt_bn254_g1_p2),
"::",
stringify!(X)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).Y) as usize - ptr as usize },
32usize,
concat!(
"Offset of field: ",
stringify!(sxt_bn254_g1_p2),
"::",
stringify!(Y)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).Z) as usize - ptr as usize },
64usize,
concat!(
"Offset of field: ",
stringify!(sxt_bn254_g1_p2),
"::",
stringify!(Z)
)
);
}
#[doc = " encodes an affine element of the `grumpkin` group"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sxt_grumpkin {
pub X: [u64; 4usize],
pub Y: [u64; 4usize],
pub infinity: u8,
}
#[test]
fn bindgen_test_layout_sxt_grumpkin() {
const UNINIT: ::std::mem::MaybeUninit<sxt_grumpkin> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<sxt_grumpkin>(),
72usize,
concat!("Size of: ", stringify!(sxt_grumpkin))
);
assert_eq!(
::std::mem::align_of::<sxt_grumpkin>(),
8usize,
concat!("Alignment of ", stringify!(sxt_grumpkin))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).X) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(sxt_grumpkin),
"::",
stringify!(X)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).Y) as usize - ptr as usize },
32usize,
concat!(
"Offset of field: ",
stringify!(sxt_grumpkin),
"::",
stringify!(Y)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).infinity) as usize - ptr as usize },
64usize,
concat!(
"Offset of field: ",
stringify!(sxt_grumpkin),
"::",
stringify!(infinity)
)
);
}
#[doc = " encodes an affine element of the `grumpkin` group in projective form"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sxt_grumpkin_p2 {
pub X: [u64; 4usize],
pub Y: [u64; 4usize],
pub Z: [u64; 4usize],
}
#[test]
fn bindgen_test_layout_sxt_grumpkin_p2() {
const UNINIT: ::std::mem::MaybeUninit<sxt_grumpkin_p2> = ::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<sxt_grumpkin_p2>(),
96usize,
concat!("Size of: ", stringify!(sxt_grumpkin_p2))
);
assert_eq!(
::std::mem::align_of::<sxt_grumpkin_p2>(),
8usize,
concat!("Alignment of ", stringify!(sxt_grumpkin_p2))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).X) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(sxt_grumpkin_p2),
"::",
stringify!(X)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).Y) as usize - ptr as usize },
32usize,
concat!(
"Offset of field: ",
stringify!(sxt_grumpkin_p2),
"::",
stringify!(Y)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).Z) as usize - ptr as usize },
64usize,
concat!(
"Offset of field: ",
stringify!(sxt_grumpkin_p2),
"::",
stringify!(Z)
)
);
}
#[doc = " describes a sequence of values"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sxt_sequence_descriptor {
pub element_nbytes: u8,
pub n: u64,
pub data: *const u8,
pub is_signed: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_sxt_sequence_descriptor() {
const UNINIT: ::std::mem::MaybeUninit<sxt_sequence_descriptor> =
::std::mem::MaybeUninit::uninit();
let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<sxt_sequence_descriptor>(),
32usize,
concat!("Size of: ", stringify!(sxt_sequence_descriptor))
);
assert_eq!(
::std::mem::align_of::<sxt_sequence_descriptor>(),
8usize,
concat!("Alignment of ", stringify!(sxt_sequence_descriptor))
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).element_nbytes) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(sxt_sequence_descriptor),
"::",
stringify!(element_nbytes)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).n) as usize - ptr as usize },
8usize,
concat!(
"Offset of field: ",
stringify!(sxt_sequence_descriptor),
"::",
stringify!(n)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).data) as usize - ptr as usize },
16usize,
concat!(
"Offset of field: ",
stringify!(sxt_sequence_descriptor),
"::",
stringify!(data)
)
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).is_signed) as usize - ptr as usize },
24usize,
concat!(
"Offset of field: ",
stringify!(sxt_sequence_descriptor),
"::",
stringify!(is_signed)
)
);
}
#[doc = " resources for multiexponentiations with pre-specified generators"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sxt_multiexp_handle {
_unused: [u8; 0],
}
extern "C" {
#[doc = " Initializes the library.\n\n This should only be called once.\n\n # Arguments:\n\n - config (in): specifies which backend should be used in the computations. Those\n available are: `SXT_GPU_BACKEND`, and `SXT_CPU_BACKEND`.\n\n # Return:\n\n - `0` on success; otherwise a nonzero error code"]
pub fn sxt_init(config: *const sxt_config) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " Compute the Pedersen commitments for sequences of values that internally generates `curve25519`\n group elements.\n\n Denote an element of a sequence by `a_ij` where `i` represents the sequence index\n and `j` represents the element index. Let `*` represent the operator for the\n ristretto255 group. Then `res[i]` encodes the ristretto255 group value\n\n ```text\n Prod_{j=1 to n_i} g_{offset_generators + j} ^ a_ij\n ```\n\n where `n_i` represents the number of elements in sequence `i` and `g_{offset_generators + j}`\n is a group element determined by a prespecified function\n\n ```text\n g: uint64_t -> ristretto255\n ```\n\n # Arguments:\n\n - `commitments` (out): an array of length num_sequences where the computed commitments\n of each sequence must be written into\n\n - `num_sequences` (in): specifies the number of sequences\n - `descriptors` (in): an array of length `num_sequences` that specifies each sequence\n - `offset_generators` (in): specifies the offset used to fetch the generators\n\n # Abnormal program termination in case of:\n\n - backend not initialized or incorrectly initialized\n - `descriptors == nullptr`\n - `commitments == nullptr`\n - `descriptor[i].element_nbytes == 0`\n - `descriptor[i].element_nbytes > 32`\n - `descriptor[i].n > 0 && descriptor[i].data == nullptr`\n\n # Considerations:\n\n - `num_sequences == 0` will skip the computation"]
pub fn sxt_curve25519_compute_pedersen_commitments(
commitments: *mut sxt_ristretto255_compressed,
num_sequences: u32,
descriptors: *const sxt_sequence_descriptor,
offset_generators: u64,
);
}
extern "C" {
#[doc = " Compute the Pedersen commitments for sequences of values using `curve25519` group elements.\n\n Denote an element of a sequence by `a_ij` where `i` represents the sequence index\n and `j` represents the element index. Let `*` represent the operator for the\n ristretto255 group. Then `res[i]` encodes the ristretto255 group value.\n\n ```text\n Prod_{j=1 to n_i} g_j ^ a_ij\n ```\n\n where `n_i` represents the number of elements in sequence `i` and `g_j` is a group\n element determined by the `generators[j]` user value given as input.\n\n # Arguments:\n\n - `commitments` (out): an array of length num_sequences where the computed commitments\n of each sequence must be written into\n\n - `num_sequences` (in): specifies the number of sequences\n - `descriptors` (in): an array of length `num_sequences` that specifies each sequence\n - `generators` (in): an array of length `max_num_rows` equals the maximum between all `n_i`\n\n # Abnormal program termination in case of:\n\n - backend not initialized or incorrectly initialized\n - `descriptors == nullptr`\n - `commitments == nullptr`\n - `descriptor[i].element_nbytes == 0`\n - `descriptor[i].element_nbytes > 32`\n - `descriptor[i].n > 0 && descriptor[i].data == nullptr`\n\n # Considerations:\n\n - `num_sequences == 0` will skip the computation"]
pub fn sxt_curve25519_compute_pedersen_commitments_with_generators(
commitments: *mut sxt_ristretto255_compressed,
num_sequences: u32,
descriptors: *const sxt_sequence_descriptor,
generators: *const sxt_ristretto255,
);
}
extern "C" {
#[doc = " Compute the Pedersen commitments for sequences of values using `bls12-381` `G1` group elements.\n\n Denote an element of a sequence by `a_ij` where `i` represents the sequence index\n and `j` represents the element index. Let `*` represent the operator for the\n `bls12-381` `G1` group. Then `res[i]` encodes the `bls12-381` `G1` group value\n\n ```text\n Prod_{j=1 to n_i} g_j ^ a_ij\n ```\n\n where `n_i` represents the number of elements in sequence `i` and `g_j` is a group\n element determined by the `generators[j]` user value given as input\n\n # Arguments:\n\n - `commitments` (out): an array of length num_sequences where the computed commitments\n of each sequence must be written into\n\n - `num_sequences` (in): specifies the number of sequences\n - `descriptors` (in): an array of length `num_sequences` that specifies each sequence\n - `generators` (in): an array of length `max_num_rows` equals the maximum between all `n_i`\n\n # Abnormal program termination in case of:\n\n - backend not initialized or incorrectly initialized\n - `descriptors == nullptr`\n - `commitments == nullptr`\n - `descriptor[i].element_nbytes == 0`\n - `descriptor[i].element_nbytes > 32`\n - `descriptor[i].n > 0 && descriptor[i].data == nullptr`\n\n # Considerations:\n\n - `num_sequences == 0` will skip the computation"]
pub fn sxt_bls12_381_g1_compute_pedersen_commitments_with_generators(
commitments: *mut sxt_bls12_381_g1_compressed,
num_sequences: u32,
descriptors: *const sxt_sequence_descriptor,
generators: *const sxt_bls12_381_g1,
);
}
extern "C" {
#[doc = " Compute the Pedersen commitments for sequences of values using `bn254` `G1` group elements.\n\n Denote an element of a sequence by `a_ij` where `i` represents the sequence index\n and `j` represents the element index. Let `*` represent the operator for the\n `bn254` `G1` group. Then `res[i]` encodes the `bn254` `G1` group value\n\n ```text\n Prod_{j=1 to n_i} g_j ^ a_ij\n ```\n\n where `n_i` represents the number of elements in sequence `i` and `g_j` is a group\n element determined by the `generators[j]` user value given as input\n\n # Arguments:\n\n - `commitments` (out): an array of length num_sequences where the computed commitments\n of each sequence must be written into\n\n - `num_sequences` (in): specifies the number of sequences\n - `descriptors` (in): an array of length `num_sequences` that specifies each sequence\n - `generators` (in): an array of length `max_num_rows` equals the maximum between all `n_i`\n\n # Abnormal program termination in case of:\n\n - backend not initialized or incorrectly initialized\n - `descriptors == nullptr`\n - `commitments == nullptr`\n - `descriptor[i].element_nbytes == 0`\n - `descriptor[i].element_nbytes > 32`\n - `descriptor[i].n > 0 && descriptor[i].data == nullptr`\n\n # Considerations:\n\n - `num_sequences == 0` will skip the computation"]
pub fn sxt_bn254_g1_uncompressed_compute_pedersen_commitments_with_generators(
commitments: *mut sxt_bn254_g1,
num_sequences: u32,
descriptors: *const sxt_sequence_descriptor,
generators: *const sxt_bn254_g1,
);
}
extern "C" {
#[doc = " Compute the Pedersen commitments for sequences of values using `grumpkin` group elements.\n\n Denote an element of a sequence by `a_ij` where `i` represents the sequence index\n and `j` represents the element index. Let `*` represent the operator for the\n `grumpkin` curve. Then `res[i]` encodes the `grumpkin` group value\n\n ```text\n Prod_{j=1 to n_i} g_j ^ a_ij\n ```\n\n where `n_i` represents the number of elements in sequence `i` and `g_j` is a group\n element determined by the `generators[j]` user value given as input\n\n # Arguments:\n\n - `commitments` (out): an array of length num_sequences where the computed commitments\n of each sequence must be written into\n\n - `num_sequences` (in): specifies the number of sequences\n - `descriptors` (in): an array of length `num_sequences` that specifies each sequence\n - `generators` (in): an array of length `max_num_rows` equals the maximum between all `n_i`\n\n # Abnormal program termination in case of:\n\n - backend not initialized or incorrectly initialized\n - `descriptors == nullptr`\n - `commitments == nullptr`\n - `descriptor[i].element_nbytes == 0`\n - `descriptor[i].element_nbytes > 32`\n - `descriptor[i].n > 0 && descriptor[i].data == nullptr`\n\n # Considerations:\n\n - `num_sequences == 0` will skip the computation"]
pub fn sxt_grumpkin_uncompressed_compute_pedersen_commitments_with_generators(
commitments: *mut sxt_grumpkin,
num_sequences: u32,
descriptors: *const sxt_sequence_descriptor,
generators: *const sxt_grumpkin,
);
}
extern "C" {
#[doc = " Gets the pre-specified random generated elements used for the Pedersen commitments in the\n `sxt_curve25519_compute_pedersen_commitments` function.\n\n ```text\n sxt_ristretto255_get_generators(generators, num_generators, offset_generators) →\n generators[0] = generate_random_ristretto(0 + offset_generators)\n generators[1] = generate_random_ristretto(1 + offset_generators)\n generators[2] = generate_random_ristretto(2 + offset_generators)\n ...\n generators[num_generators - 1] = generate_random_ristretto(num_generators - 1 +\n offset_generators)\n ```\n # Arguments:\n\n - `generators` (out): `sxt_ristretto255` pointer where the results must be written into\n - `offset_generators` (in): the offset that shifts the first element computed from `0` to\n `offset_generators`\n - `num_generators` (in): the total number of random generated elements to be computed\n\n # Return:\n\n - `0` on success; otherwise a nonzero error code\n\n # Invalid input parameters, which generate error code:\n\n - `num_generators > 0 && generators == nullptr`\n\n # Considerations:\n\n - `num_generators == 0` will skip the computation"]
pub fn sxt_ristretto255_get_generators(
generators: *mut sxt_ristretto255,
offset_generators: u64,
num_generators: u64,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " Gets the `n`-th Ristretto point.\n\n The `n`-th Ristretto point is defined as:\n\n ```text\n if n == 0:\n one_commit[0] = ristretto_identity;\n else:\n one_commit[0] = g[0] + g[1] + ... + g[n - 1];\n ```\n\n where\n\n ```text\n struct sxt_ristretto255 ristretto_identity = {\n {0, 0, 0, 0, 0},\n {1, 0, 0, 0, 0},\n {1, 0, 0, 0, 0},\n {0, 0, 0, 0, 0},\n };\n ```\n\n and `g[i]` is the `i`-th generator provided by `sxt_ristretto255_get_generators` function at\n offset `0`.\n\n # Return:\n\n - `0` on success; otherwise a nonzero error code\n\n # Invalid input parameters, which generate error code:\n\n - `one_commit == nullptr`"]
pub fn sxt_curve25519_get_one_commit(
one_commit: *mut sxt_ristretto255,
n: u64,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " Creates an inner product proof.\n\n The proof is created with respect to the base `G`, provided by\n `sxt_ristretto255_get_generators(G, generators_offset, 1ull << ceil(log2(n)))`.\n\n The `verifier` transcript is passed in as a parameter so that the\n challenges depend on the *entire* transcript (including parent\n protocols).\n\n Note that we don't have any restriction to the `n` value, other than\n it has to be non-zero.\n\n # Algorithm description\n\n Initially, we compute `G` and `Q = G[np]`, where `np = 1ull << ceil(log2(n))`\n and `G` is zero-indexed.\n\n The protocol consists of `k = ceil(lg_2(n))` rounds, indexed by `j = k - 1 , ... , 0`.\n\n In the `j`-th round, the prover computes:\n\n ```text\n a_lo = {a[0], a[1], ..., a[n / 2 - 1]}\n a_hi = {a[n/2], a[n/2 + 1], ..., a[n - 1]}\n b_lo = {b[0], b[1], ..., b[n / 2 - 1]}\n b_hi = {b[n/2], b[n/2 + 1], ..., b[n - 1]}\n G_lo = {G[0], G[1], ..., G[n / 2 - 1]}\n G_hi = {G[n/2], G[n/2 + 1], ..., G[n-1]}\n\n l_vector[j] = <a_lo, G_hi> + <a_lo, b_hi> * Q\n r_vector[j] = <a_hi, G_lo> + <a_hi, b_lo> * Q\n ```\n\n Note that if the `a` or `b` length is not a power of `2`,\n then `a` or `b` is padded with zeros until it has a power of `2`.\n `G` always has a power of `2` given how it is constructed.\n\n Then the prover sends `l_vector[j]` and `r_vector[j]` to the verifier,\n and the verifier responds with a\n challenge value `u[j] <- Z_p` (finite field of order p),\n which is non-interactively simulated by\n the input strobe-based transcript:\n\n ```text\n transcript.append(\"L\", l_vector[j]);\n transcript.append(\"R\", r_vector[j]);\n\n u[j] = transcript.challenge_value(\"x\");\n ```\n\n Then the prover uses `u[j]` to compute\n\n ```text\n a = a_lo * u[j] + (u[j]^-1) * a_hi;\n b = b_lo * (u[j]^-1) + u[j] * b_hi;\n ```\n\n Then, the prover and verifier both compute\n\n ```text\n G = G_lo * (u[j]^-1) + u[j] * G_hi\n\n n = n / 2;\n ```\n\n and use these vectors (all of length `2^j`) for the next round.\n\n After the last `(j = 0)` round, the prover sends `ap_value = a[0]` to the verifier.\n\n # Arguments:\n\n - `l_vector` (out): transcript point array with length `ceil(log2(n))`\n - `r_vector` (out): transcript point array with length `ceil(log2(n))`\n - `ap_value` (out): a single scalar\n - `transcript` (in/out): a single strobe-based transcript\n - `n` (in): non-zero length for the input arrays\n - `generators_offset` (in): offset used to fetch the bases\n - `a_vector` (in): array with length `n`\n - `b_vector` (in): array with length `n`\n\n # Abnormal program termination in case of:\n\n - `transcript`, `ap_value`, `b_vector`, or `a_vector` is `nullptr`\n - `n` is zero\n - `n` is non-zero, but `l_vector` or `r_vector` is `nullptr`"]
pub fn sxt_curve25519_prove_inner_product(
l_vector: *mut sxt_ristretto255_compressed,
r_vector: *mut sxt_ristretto255_compressed,
ap_value: *mut sxt_curve25519_scalar,
transcript: *mut sxt_transcript,
n: u64,
generators_offset: u64,
a_vector: *const sxt_curve25519_scalar,
b_vector: *const sxt_curve25519_scalar,
);
}
extern "C" {
#[doc = " Verifies an inner product proof.\n\n The proof is verified with respect to the base G, provided by\n `sxt_ristretto255_get_generators(G, generators_offset, 1ull << ceil(log2(n)))`.\n\n Note that we don't have any restriction to the `n` value, other than\n it has to be non-zero.\n\n # Arguments:\n\n - `transcript` (in/out): a single strobe-based transcript\n - `n` (in): non-zero length for the input arrays\n - `generators_offset` (in): offset used to fetch the bases\n - `b_vector` (in): array with length `n`, the same one used by\n `sxt_curve25519_prove_inner_product`\n - `product` (in): a single scalar, represented by `<a, b>`,\n the inner product of the two vectors `a` and `b` used by\n `sxt_curve25519_prove_inner_product`\n - `a_commit` (in): a single ristretto point, represented by `<a, G>` (the inner product of the\n two vectors)\n - `l_vector` (in): transcript point array with length `ceil(log2(n))`, generated by\n `sxt_curve25519_prove_inner_product`\n - `r_vector` (in): transcript point array with length `ceil(log2(n))`, generated by\n `sxt_curve25519_prove_inner_product`\n - `ap_value` (in): a single scalar, generated by `sxt_curve25519_prove_inner_product`\n\n # Return:\n\n - `1` in case the proof can be verified; otherwise, return `0`\n\n # Abnormal program termination in case of:\n\n - `transcript`, `ap_value`, `product`, `a_commit`, or `b_vector` is `nullptr`\n - `n` is zero\n - `n` is non-zero, but `l_vector` or `r_vector` is `nullptr`"]
pub fn sxt_curve25519_verify_inner_product(
transcript: *mut sxt_transcript,
n: u64,
generators_offset: u64,
b_vector: *const sxt_curve25519_scalar,
product: *const sxt_curve25519_scalar,
a_commit: *const sxt_ristretto255,
l_vector: *const sxt_ristretto255_compressed,
r_vector: *const sxt_ristretto255_compressed,
ap_value: *const sxt_curve25519_scalar,
) -> ::std::os::raw::c_int;
}
extern "C" {
#[doc = " Create a handle for computing multiexponentiations using a fixed sequence of generators.\n\n Note: `generators` must match the type indicated by `curve_id`\n\n curve_id generators type\n SXT_CURVE_RISTRETTO255 struct sxt_ristretto255*\n SXT_CURVE_BLS_381 struct sxt_bls12_381_g1_p2*\n SXT_CURVE_BN_254 struct sxt_bn254_g1_p2*\n SXT_CURVE_GRUMPKIN struct sxt_grumpkin_p2*"]
pub fn sxt_multiexp_handle_new(
curve_id: ::std::os::raw::c_uint,
generators: *const ::std::os::raw::c_void,
n: ::std::os::raw::c_uint,
) -> *mut sxt_multiexp_handle;
}
extern "C" {
#[doc = " Use a serialized file to create a handle for computing multiexponentiations using a fixed\n sequence of generators.\n\n Reading the handle from a file can be significantly faster than calling\n sxt_multiexp_handle_new."]
pub fn sxt_multiexp_handle_new_from_file(
curve_id: ::std::os::raw::c_uint,
filename: *const ::std::os::raw::c_char,
) -> *mut sxt_multiexp_handle;
}
extern "C" {
#[doc = " Write a multiexponentiation handle to file.\n\n Use this function in combination with sxt_multiexp_handle_new_from_file."]
pub fn sxt_multiexp_handle_write_to_file(
handle: *const sxt_multiexp_handle,
filename: *const ::std::os::raw::c_char,
);
}
extern "C" {
#[doc = " Free resources for a multiexponentiation handle"]
pub fn sxt_multiexp_handle_free(handle: *mut sxt_multiexp_handle);
}
extern "C" {
#[doc = " Compute a multiexponentiation using a handle to pre-specified generators.\n\n On completion `res` contains an array of size `num_outputs` for the multiexponentiation\n of the given `scalars` array.\n\n `scalars` specifies a contiguous multi-dimension `num_outputs` by `n` array laid out in\n column-major order. An entry in the array specifies the `element_num_bytes` bytes of a\n particular scalar.\n\n For example, if `g_1, g_2, ..., g_n` are the generators associated with `handle` and\n\n ```text\n s_11, s_12, ..., s_1n\n s_21, s_22, ..., s_2n\n ```\n\n is the scalar array (laid out in memory as `s_11, s_21, s_12, s_22, ..., s_1n, s_2n`), then `res`\n will contain the two values\n\n ```text\n res[0] = g1^s11 g2^s12 ... gn^s1n\n res[1] = g1^s21 g2^s22 ... gn^s2n\n ```\n\n Note: `res` must match the generator type of the curve. See `sxt_multiexp_handle_new` for\n the types."]
pub fn sxt_fixed_multiexponentiation(
res: *mut ::std::os::raw::c_void,
handle: *const sxt_multiexp_handle,
element_num_bytes: ::std::os::raw::c_uint,
num_outputs: ::std::os::raw::c_uint,
n: ::std::os::raw::c_uint,
scalars: *const u8,
);
}
extern "C" {
#[doc = " Compute a multiexponentiation of scalars in packed format using a handle to pre-specified\n generators.\n\n On completion `res` contains an array of size `num_outputs` for the multiexponentiation\n of the given `scalars` array.\n\n An entry output_bit_table[output_index] specifies the number of scalar bits used for\n output_index.\n\n Put\n bit_sum = sum_{output_index} output_bit_table[output_index]\n and let num_bytes denote the smallest integer greater than or equal to bit_sum that is a\n multiple of 8.\n\n\n `scalars` specifies a contiguous multi-dimension `num_bytes` by `n` array laid out in\n a packed column-major order as specified by output_bit_table. A given row determines the scalar\n exponents for generator g_i with the output scalars packed contiguously and padded with zeros.\n\n Note: `res` must match the generator type of the curve. See `sxt_multiexp_handle_new` for\n the types."]
pub fn sxt_fixed_packed_multiexponentiation(
res: *mut ::std::os::raw::c_void,
handle: *const sxt_multiexp_handle,
output_bit_table: *const ::std::os::raw::c_uint,
num_outputs: ::std::os::raw::c_uint,
n: ::std::os::raw::c_uint,
scalars: *const u8,
);
}
extern "C" {
#[doc = " Compute a varying lengthing multiexponentiation of scalars in packed format using a handle to\n pre-specified generators.\n\n On completion `res` contains an array of size `num_outputs` for the multiexponentiation\n of the given `scalars` array.\n\n An entry output_bit_table[output_index] specifies the number of scalar bits used for\n output_index and output_lengths[output_index] specifies the length used for output_index.\n\n Note: output_lengths must be sorted in ascending order\n\n Put\n bit_sum = sum_{output_index} output_bit_table[output_index]\n and let num_bytes denote the smallest integer greater than or equal to bit_sum that is a\n multiple of 8.\n\n Let n denote the length of the longest output. Then `scalars` specifies a contiguous\n multi-dimension `num_bytes` by `n` array laid out in a packed column-major order as specified by\n output_bit_table. A given row determines the scalar exponents for generator g_i with the output\n scalars packed contiguously and padded with zeros.\n\n Note: `res` must match the generator type of the curve. See `sxt_multiexp_handle_new` for\n the types."]
pub fn sxt_fixed_vlen_multiexponentiation(
res: *mut ::std::os::raw::c_void,
handle: *const sxt_multiexp_handle,
output_bit_table: *const ::std::os::raw::c_uint,
output_lengths: *const ::std::os::raw::c_uint,
num_outputs: ::std::os::raw::c_uint,
scalars: *const u8,
);
}