From 46dd907e0dd49c2227cd6efe4ddd06e731bef69c Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Tue, 15 Nov 2022 04:00:30 +0530 Subject: [PATCH 1/9] working build --- .gitignore | 1 + bindings/rust/Cargo.lock | 243 +++++++++++++++++++++++++++++++++++++++ bindings/rust/Cargo.toml | 14 +++ bindings/rust/build.rs | 65 +++++++++++ bindings/rust/wrapper.h | 1 + src/Makefile | 2 +- 6 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 bindings/rust/Cargo.lock create mode 100644 bindings/rust/Cargo.toml create mode 100644 bindings/rust/build.rs create mode 100644 bindings/rust/wrapper.h diff --git a/.gitignore b/.gitignore index 370b496..6d15fee 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ inc/blst_aux.h* .vscode/ .clang-format *bindings/*/*.so +*bindings/rust/target *bindings/csharp/*.exe *bindings/csharp/*.dll __pycache__ diff --git a/bindings/rust/Cargo.lock b/bindings/rust/Cargo.lock new file mode 100644 index 0000000..9753fe7 --- /dev/null +++ b/bindings/rust/Cargo.lock @@ -0,0 +1,243 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bindgen" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a022e58a142a46fea340d68012b9201c094e93ec3d033a944a24f8fd4a4f09a" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn", + "which", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "c-kzg" +version = "0.1.0" +dependencies = [ + "bindgen", + "libc", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clang-sys" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" + +[[package]] +name = "libloading" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "once_cell" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "proc-macro2" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "shlex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" + +[[package]] +name = "syn" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[package]] +name = "which" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" +dependencies = [ + "either", + "libc", + "once_cell", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/bindings/rust/Cargo.toml b/bindings/rust/Cargo.toml new file mode 100644 index 0000000..02d1d6a --- /dev/null +++ b/bindings/rust/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "c-kzg" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + + +[build-dependencies] +bindgen = "0.61.0" + +[dependencies] +libc = "0.2" + diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs new file mode 100644 index 0000000..41b9b37 --- /dev/null +++ b/bindings/rust/build.rs @@ -0,0 +1,65 @@ +use std::env; +use std::path::PathBuf; +use std::process::Command; + +fn main() { + println!("cargo:rerun-if-changed=wrapper.h"); + + // The bindgen::Builder is the main entry point + // to bindgen, and lets you build up options for + // the resulting bindings. + let bindings = bindgen::Builder::default() + // The input header we would like to generate + // bindings for. + .header("wrapper.h") + // Tell cargo to invalidate the built crate whenever any of the + // included header files changed. + .parse_callbacks(Box::new(bindgen::CargoCallbacks)) + // Finish the builder and generate the bindings. + .derive_partialeq(true) + .derive_eq(true) + .derive_copy(false) + .opaque_type("blst_uniq") + .default_enum_style(bindgen::EnumVariation::Rust { + non_exhaustive: false, + }) + .generate() + // Unwrap the Result and panic on failure. + .expect("Unable to generate bindings"); + + let mut root_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("../../"); + + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + + let mut cmd = Command::new("make"); + let res = cmd + .current_dir(root_dir.join("src")) + .arg("all") + .status() + .unwrap(); + + let obj_file_path = root_dir.join("c_kzg_4844.o"); + + let status = Command::new("ar") + .args(&["crus", "libckzg.a", "c_kzg_4844.o"]) + .current_dir(&root_dir.join("src")) + .status() + .unwrap(); + + std::fs::copy(root_dir.join("src/libckzg.a"), &out_dir.join("libckzg.a")).unwrap(); + std::fs::copy(root_dir.join("lib/libblst.a"), &out_dir.join("libblst.a")).unwrap(); + + println!("cargo:rustc-link-search={}", out_dir.display()); + println!("cargo:rustc-link-search={}", out_dir.display()); + println!("cargo:rustc-link-lib=static=ckzg"); + println!("cargo:rustc-link-lib=static=blst"); + println!( + "cargo:rerun-if-changed={}", + root_dir.join("src/c_kzg_4844.c").display() + ); + + // Write the bindings to the $OUT_DIR/bindings.rs file. + bindings + .write_to_file(out_dir.join("bindings.rs")) + .expect("Couldn't write bindings!"); +} diff --git a/bindings/rust/wrapper.h b/bindings/rust/wrapper.h new file mode 100644 index 0000000..a0c7a84 --- /dev/null +++ b/bindings/rust/wrapper.h @@ -0,0 +1 @@ +#include "c_kzg_4844.h" \ No newline at end of file diff --git a/src/Makefile b/src/Makefile index 3eb3a79..51acff2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,5 +1,5 @@ INCLUDE_DIRS = ../inc -CFLAGS += -O2 +CFLAGS += -O2 -fPIE all: c_kzg_4844.o lib From 86a8ef8193ced3eea7c8f3ddec3ab5a7e999b8da Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Tue, 15 Nov 2022 17:22:46 +0530 Subject: [PATCH 2/9] Move bindings.rs to root directory --- bindings/rust/bindings.rs | 2830 +++++++++++++++++++++++++++++++++++++ 1 file changed, 2830 insertions(+) create mode 100644 bindings/rust/bindings.rs diff --git a/bindings/rust/bindings.rs b/bindings/rust/bindings.rs new file mode 100644 index 0000000..3dab758 --- /dev/null +++ b/bindings/rust/bindings.rs @@ -0,0 +1,2830 @@ +/* automatically generated by rust-bindgen 0.61.0 */ + +pub const _STDIO_H: u32 = 1; +pub const _FEATURES_H: u32 = 1; +pub const _DEFAULT_SOURCE: u32 = 1; +pub const __GLIBC_USE_ISOC2X: u32 = 0; +pub const __USE_ISOC11: u32 = 1; +pub const __USE_ISOC99: u32 = 1; +pub const __USE_ISOC95: u32 = 1; +pub const __USE_POSIX_IMPLICITLY: u32 = 1; +pub const _POSIX_SOURCE: u32 = 1; +pub const _POSIX_C_SOURCE: u32 = 200809; +pub const __USE_POSIX: u32 = 1; +pub const __USE_POSIX2: u32 = 1; +pub const __USE_POSIX199309: u32 = 1; +pub const __USE_POSIX199506: u32 = 1; +pub const __USE_XOPEN2K: u32 = 1; +pub const __USE_XOPEN2K8: u32 = 1; +pub const _ATFILE_SOURCE: u32 = 1; +pub const __USE_MISC: u32 = 1; +pub const __USE_ATFILE: u32 = 1; +pub const __USE_FORTIFY_LEVEL: u32 = 0; +pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0; +pub const __GLIBC_USE_DEPRECATED_SCANF: u32 = 0; +pub const _STDC_PREDEF_H: u32 = 1; +pub const __STDC_IEC_559__: u32 = 1; +pub const __STDC_IEC_559_COMPLEX__: u32 = 1; +pub const __STDC_ISO_10646__: u32 = 201706; +pub const __GNU_LIBRARY__: u32 = 6; +pub const __GLIBC__: u32 = 2; +pub const __GLIBC_MINOR__: u32 = 31; +pub const _SYS_CDEFS_H: u32 = 1; +pub const __glibc_c99_flexarr_available: u32 = 1; +pub const __WORDSIZE: u32 = 64; +pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1; +pub const __SYSCALL_WORDSIZE: u32 = 64; +pub const __LONG_DOUBLE_USES_FLOAT128: u32 = 0; +pub const __HAVE_GENERIC_SELECTION: u32 = 1; +pub const __GLIBC_USE_LIB_EXT2: u32 = 0; +pub const __GLIBC_USE_IEC_60559_BFP_EXT: u32 = 0; +pub const __GLIBC_USE_IEC_60559_BFP_EXT_C2X: u32 = 0; +pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: u32 = 0; +pub const __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X: u32 = 0; +pub const __GLIBC_USE_IEC_60559_TYPES_EXT: u32 = 0; +pub const __GNUC_VA_LIST: u32 = 1; +pub const _BITS_TYPES_H: u32 = 1; +pub const __TIMESIZE: u32 = 64; +pub const _BITS_TYPESIZES_H: u32 = 1; +pub const __OFF_T_MATCHES_OFF64_T: u32 = 1; +pub const __INO_T_MATCHES_INO64_T: u32 = 1; +pub const __RLIM_T_MATCHES_RLIM64_T: u32 = 1; +pub const __STATFS_MATCHES_STATFS64: u32 = 1; +pub const __FD_SETSIZE: u32 = 1024; +pub const _BITS_TIME64_H: u32 = 1; +pub const _____fpos_t_defined: u32 = 1; +pub const ____mbstate_t_defined: u32 = 1; +pub const _____fpos64_t_defined: u32 = 1; +pub const ____FILE_defined: u32 = 1; +pub const __FILE_defined: u32 = 1; +pub const __struct_FILE_defined: u32 = 1; +pub const _IO_EOF_SEEN: u32 = 16; +pub const _IO_ERR_SEEN: u32 = 32; +pub const _IO_USER_LOCK: u32 = 32768; +pub const _IOFBF: u32 = 0; +pub const _IOLBF: u32 = 1; +pub const _IONBF: u32 = 2; +pub const BUFSIZ: u32 = 8192; +pub const EOF: i32 = -1; +pub const SEEK_SET: u32 = 0; +pub const SEEK_CUR: u32 = 1; +pub const SEEK_END: u32 = 2; +pub const P_tmpdir: &[u8; 5usize] = b"/tmp\0"; +pub const _BITS_STDIO_LIM_H: u32 = 1; +pub const L_tmpnam: u32 = 20; +pub const TMP_MAX: u32 = 238328; +pub const FILENAME_MAX: u32 = 4096; +pub const L_ctermid: u32 = 9; +pub const FOPEN_MAX: u32 = 16; +pub const _STDINT_H: u32 = 1; +pub const _BITS_WCHAR_H: u32 = 1; +pub const _BITS_STDINT_INTN_H: u32 = 1; +pub const _BITS_STDINT_UINTN_H: u32 = 1; +pub const INT8_MIN: i32 = -128; +pub const INT16_MIN: i32 = -32768; +pub const INT32_MIN: i32 = -2147483648; +pub const INT8_MAX: u32 = 127; +pub const INT16_MAX: u32 = 32767; +pub const INT32_MAX: u32 = 2147483647; +pub const UINT8_MAX: u32 = 255; +pub const UINT16_MAX: u32 = 65535; +pub const UINT32_MAX: u32 = 4294967295; +pub const INT_LEAST8_MIN: i32 = -128; +pub const INT_LEAST16_MIN: i32 = -32768; +pub const INT_LEAST32_MIN: i32 = -2147483648; +pub const INT_LEAST8_MAX: u32 = 127; +pub const INT_LEAST16_MAX: u32 = 32767; +pub const INT_LEAST32_MAX: u32 = 2147483647; +pub const UINT_LEAST8_MAX: u32 = 255; +pub const UINT_LEAST16_MAX: u32 = 65535; +pub const UINT_LEAST32_MAX: u32 = 4294967295; +pub const INT_FAST8_MIN: i32 = -128; +pub const INT_FAST16_MIN: i64 = -9223372036854775808; +pub const INT_FAST32_MIN: i64 = -9223372036854775808; +pub const INT_FAST8_MAX: u32 = 127; +pub const INT_FAST16_MAX: u64 = 9223372036854775807; +pub const INT_FAST32_MAX: u64 = 9223372036854775807; +pub const UINT_FAST8_MAX: u32 = 255; +pub const UINT_FAST16_MAX: i32 = -1; +pub const UINT_FAST32_MAX: i32 = -1; +pub const INTPTR_MIN: i64 = -9223372036854775808; +pub const INTPTR_MAX: u64 = 9223372036854775807; +pub const UINTPTR_MAX: i32 = -1; +pub const PTRDIFF_MIN: i64 = -9223372036854775808; +pub const PTRDIFF_MAX: u64 = 9223372036854775807; +pub const SIG_ATOMIC_MIN: i32 = -2147483648; +pub const SIG_ATOMIC_MAX: u32 = 2147483647; +pub const SIZE_MAX: i32 = -1; +pub const WINT_MIN: u32 = 0; +pub const WINT_MAX: u32 = 4294967295; +pub const true_: u32 = 1; +pub const false_: u32 = 0; +pub const __bool_true_false_are_defined: u32 = 1; +pub const BYTES_PER_COMMITMENT: u32 = 48; +pub const BYTES_PER_PROOF: u32 = 48; +pub const FIELD_ELEMENTS_PER_BLOB: u32 = 4096; +pub const BYTES_PER_FIELD_ELEMENT: u32 = 32; +pub const BYTES_PER_BLOB: u32 = 131072; +pub type va_list = __builtin_va_list; +pub type __gnuc_va_list = __builtin_va_list; +pub type __u_char = ::std::os::raw::c_uchar; +pub type __u_short = ::std::os::raw::c_ushort; +pub type __u_int = ::std::os::raw::c_uint; +pub type __u_long = ::std::os::raw::c_ulong; +pub type __int8_t = ::std::os::raw::c_schar; +pub type __uint8_t = ::std::os::raw::c_uchar; +pub type __int16_t = ::std::os::raw::c_short; +pub type __uint16_t = ::std::os::raw::c_ushort; +pub type __int32_t = ::std::os::raw::c_int; +pub type __uint32_t = ::std::os::raw::c_uint; +pub type __int64_t = ::std::os::raw::c_long; +pub type __uint64_t = ::std::os::raw::c_ulong; +pub type __int_least8_t = __int8_t; +pub type __uint_least8_t = __uint8_t; +pub type __int_least16_t = __int16_t; +pub type __uint_least16_t = __uint16_t; +pub type __int_least32_t = __int32_t; +pub type __uint_least32_t = __uint32_t; +pub type __int_least64_t = __int64_t; +pub type __uint_least64_t = __uint64_t; +pub type __quad_t = ::std::os::raw::c_long; +pub type __u_quad_t = ::std::os::raw::c_ulong; +pub type __intmax_t = ::std::os::raw::c_long; +pub type __uintmax_t = ::std::os::raw::c_ulong; +pub type __dev_t = ::std::os::raw::c_ulong; +pub type __uid_t = ::std::os::raw::c_uint; +pub type __gid_t = ::std::os::raw::c_uint; +pub type __ino_t = ::std::os::raw::c_ulong; +pub type __ino64_t = ::std::os::raw::c_ulong; +pub type __mode_t = ::std::os::raw::c_uint; +pub type __nlink_t = ::std::os::raw::c_ulong; +pub type __off_t = ::std::os::raw::c_long; +pub type __off64_t = ::std::os::raw::c_long; +pub type __pid_t = ::std::os::raw::c_int; +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct __fsid_t { + pub __val: [::std::os::raw::c_int; 2usize], +} +#[test] +fn bindgen_test_layout___fsid_t() { + const UNINIT: ::std::mem::MaybeUninit<__fsid_t> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__fsid_t>(), + 8usize, + concat!("Size of: ", stringify!(__fsid_t)) + ); + assert_eq!( + ::std::mem::align_of::<__fsid_t>(), + 4usize, + concat!("Alignment of ", stringify!(__fsid_t)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__val) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__fsid_t), + "::", + stringify!(__val) + ) + ); +} +pub type __clock_t = ::std::os::raw::c_long; +pub type __rlim_t = ::std::os::raw::c_ulong; +pub type __rlim64_t = ::std::os::raw::c_ulong; +pub type __id_t = ::std::os::raw::c_uint; +pub type __time_t = ::std::os::raw::c_long; +pub type __useconds_t = ::std::os::raw::c_uint; +pub type __suseconds_t = ::std::os::raw::c_long; +pub type __daddr_t = ::std::os::raw::c_int; +pub type __key_t = ::std::os::raw::c_int; +pub type __clockid_t = ::std::os::raw::c_int; +pub type __timer_t = *mut ::std::os::raw::c_void; +pub type __blksize_t = ::std::os::raw::c_long; +pub type __blkcnt_t = ::std::os::raw::c_long; +pub type __blkcnt64_t = ::std::os::raw::c_long; +pub type __fsblkcnt_t = ::std::os::raw::c_ulong; +pub type __fsblkcnt64_t = ::std::os::raw::c_ulong; +pub type __fsfilcnt_t = ::std::os::raw::c_ulong; +pub type __fsfilcnt64_t = ::std::os::raw::c_ulong; +pub type __fsword_t = ::std::os::raw::c_long; +pub type __ssize_t = ::std::os::raw::c_long; +pub type __syscall_slong_t = ::std::os::raw::c_long; +pub type __syscall_ulong_t = ::std::os::raw::c_ulong; +pub type __loff_t = __off64_t; +pub type __caddr_t = *mut ::std::os::raw::c_char; +pub type __intptr_t = ::std::os::raw::c_long; +pub type __socklen_t = ::std::os::raw::c_uint; +pub type __sig_atomic_t = ::std::os::raw::c_int; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct __mbstate_t { + pub __count: ::std::os::raw::c_int, + pub __value: __mbstate_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union __mbstate_t__bindgen_ty_1 { + pub __wch: ::std::os::raw::c_uint, + pub __wchb: [::std::os::raw::c_char; 4usize], +} +#[test] +fn bindgen_test_layout___mbstate_t__bindgen_ty_1() { + const UNINIT: ::std::mem::MaybeUninit<__mbstate_t__bindgen_ty_1> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__mbstate_t__bindgen_ty_1>(), + 4usize, + concat!("Size of: ", stringify!(__mbstate_t__bindgen_ty_1)) + ); + assert_eq!( + ::std::mem::align_of::<__mbstate_t__bindgen_ty_1>(), + 4usize, + concat!("Alignment of ", stringify!(__mbstate_t__bindgen_ty_1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__wch) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__mbstate_t__bindgen_ty_1), + "::", + stringify!(__wch) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__wchb) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__mbstate_t__bindgen_ty_1), + "::", + stringify!(__wchb) + ) + ); +} +#[test] +fn bindgen_test_layout___mbstate_t() { + const UNINIT: ::std::mem::MaybeUninit<__mbstate_t> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__mbstate_t>(), + 8usize, + concat!("Size of: ", stringify!(__mbstate_t)) + ); + assert_eq!( + ::std::mem::align_of::<__mbstate_t>(), + 4usize, + concat!("Alignment of ", stringify!(__mbstate_t)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__count) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__mbstate_t), + "::", + stringify!(__count) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__value) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(__mbstate_t), + "::", + stringify!(__value) + ) + ); +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _G_fpos_t { + pub __pos: __off_t, + pub __state: __mbstate_t, +} +#[test] +fn bindgen_test_layout__G_fpos_t() { + const UNINIT: ::std::mem::MaybeUninit<_G_fpos_t> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<_G_fpos_t>(), + 16usize, + concat!("Size of: ", stringify!(_G_fpos_t)) + ); + assert_eq!( + ::std::mem::align_of::<_G_fpos_t>(), + 8usize, + concat!("Alignment of ", stringify!(_G_fpos_t)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__pos) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_G_fpos_t), + "::", + stringify!(__pos) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__state) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_G_fpos_t), + "::", + stringify!(__state) + ) + ); +} +pub type __fpos_t = _G_fpos_t; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _G_fpos64_t { + pub __pos: __off64_t, + pub __state: __mbstate_t, +} +#[test] +fn bindgen_test_layout__G_fpos64_t() { + const UNINIT: ::std::mem::MaybeUninit<_G_fpos64_t> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<_G_fpos64_t>(), + 16usize, + concat!("Size of: ", stringify!(_G_fpos64_t)) + ); + assert_eq!( + ::std::mem::align_of::<_G_fpos64_t>(), + 8usize, + concat!("Alignment of ", stringify!(_G_fpos64_t)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__pos) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_G_fpos64_t), + "::", + stringify!(__pos) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__state) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_G_fpos64_t), + "::", + stringify!(__state) + ) + ); +} +pub type __fpos64_t = _G_fpos64_t; +pub type __FILE = _IO_FILE; +pub type FILE = _IO_FILE; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _IO_marker { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _IO_codecvt { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _IO_wide_data { + _unused: [u8; 0], +} +pub type _IO_lock_t = ::std::os::raw::c_void; +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct _IO_FILE { + pub _flags: ::std::os::raw::c_int, + pub _IO_read_ptr: *mut ::std::os::raw::c_char, + pub _IO_read_end: *mut ::std::os::raw::c_char, + pub _IO_read_base: *mut ::std::os::raw::c_char, + pub _IO_write_base: *mut ::std::os::raw::c_char, + pub _IO_write_ptr: *mut ::std::os::raw::c_char, + pub _IO_write_end: *mut ::std::os::raw::c_char, + pub _IO_buf_base: *mut ::std::os::raw::c_char, + pub _IO_buf_end: *mut ::std::os::raw::c_char, + pub _IO_save_base: *mut ::std::os::raw::c_char, + pub _IO_backup_base: *mut ::std::os::raw::c_char, + pub _IO_save_end: *mut ::std::os::raw::c_char, + pub _markers: *mut _IO_marker, + pub _chain: *mut _IO_FILE, + pub _fileno: ::std::os::raw::c_int, + pub _flags2: ::std::os::raw::c_int, + pub _old_offset: __off_t, + pub _cur_column: ::std::os::raw::c_ushort, + pub _vtable_offset: ::std::os::raw::c_schar, + pub _shortbuf: [::std::os::raw::c_char; 1usize], + pub _lock: *mut _IO_lock_t, + pub _offset: __off64_t, + pub _codecvt: *mut _IO_codecvt, + pub _wide_data: *mut _IO_wide_data, + pub _freeres_list: *mut _IO_FILE, + pub _freeres_buf: *mut ::std::os::raw::c_void, + pub __pad5: usize, + pub _mode: ::std::os::raw::c_int, + pub _unused2: [::std::os::raw::c_char; 20usize], +} +#[test] +fn bindgen_test_layout__IO_FILE() { + const UNINIT: ::std::mem::MaybeUninit<_IO_FILE> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<_IO_FILE>(), + 216usize, + concat!("Size of: ", stringify!(_IO_FILE)) + ); + assert_eq!( + ::std::mem::align_of::<_IO_FILE>(), + 8usize, + concat!("Alignment of ", stringify!(_IO_FILE)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._flags) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_flags) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._IO_read_ptr) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_read_ptr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._IO_read_end) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_read_end) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._IO_read_base) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_read_base) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._IO_write_base) as usize - ptr as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_write_base) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._IO_write_ptr) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_write_ptr) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._IO_write_end) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_write_end) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._IO_buf_base) as usize - ptr as usize }, + 56usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_buf_base) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._IO_buf_end) as usize - ptr as usize }, + 64usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_buf_end) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._IO_save_base) as usize - ptr as usize }, + 72usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_save_base) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._IO_backup_base) as usize - ptr as usize }, + 80usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_backup_base) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._IO_save_end) as usize - ptr as usize }, + 88usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_IO_save_end) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._markers) as usize - ptr as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_markers) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._chain) as usize - ptr as usize }, + 104usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_chain) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._fileno) as usize - ptr as usize }, + 112usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_fileno) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._flags2) as usize - ptr as usize }, + 116usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_flags2) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._old_offset) as usize - ptr as usize }, + 120usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_old_offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._cur_column) as usize - ptr as usize }, + 128usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_cur_column) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._vtable_offset) as usize - ptr as usize }, + 130usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_vtable_offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._shortbuf) as usize - ptr as usize }, + 131usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_shortbuf) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._lock) as usize - ptr as usize }, + 136usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_lock) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._offset) as usize - ptr as usize }, + 144usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._codecvt) as usize - ptr as usize }, + 152usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_codecvt) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._wide_data) as usize - ptr as usize }, + 160usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_wide_data) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._freeres_list) as usize - ptr as usize }, + 168usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_freeres_list) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._freeres_buf) as usize - ptr as usize }, + 176usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_freeres_buf) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).__pad5) as usize - ptr as usize }, + 184usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(__pad5) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._mode) as usize - ptr as usize }, + 192usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_mode) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr)._unused2) as usize - ptr as usize }, + 196usize, + concat!( + "Offset of field: ", + stringify!(_IO_FILE), + "::", + stringify!(_unused2) + ) + ); +} +pub type off_t = __off_t; +pub type fpos_t = __fpos_t; +extern "C" { + pub static mut stdin: *mut FILE; +} +extern "C" { + pub static mut stdout: *mut FILE; +} +extern "C" { + pub static mut stderr: *mut FILE; +} +extern "C" { + pub fn remove(__filename: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn rename( + __old: *const ::std::os::raw::c_char, + __new: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn renameat( + __oldfd: ::std::os::raw::c_int, + __old: *const ::std::os::raw::c_char, + __newfd: ::std::os::raw::c_int, + __new: *const ::std::os::raw::c_char, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn tmpfile() -> *mut FILE; +} +extern "C" { + pub fn tmpnam(__s: *mut ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn tmpnam_r(__s: *mut ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn tempnam( + __dir: *const ::std::os::raw::c_char, + __pfx: *const ::std::os::raw::c_char, + ) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn fclose(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn fflush(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn fflush_unlocked(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn fopen( + __filename: *const ::std::os::raw::c_char, + __modes: *const ::std::os::raw::c_char, + ) -> *mut FILE; +} +extern "C" { + pub fn freopen( + __filename: *const ::std::os::raw::c_char, + __modes: *const ::std::os::raw::c_char, + __stream: *mut FILE, + ) -> *mut FILE; +} +extern "C" { + pub fn fdopen(__fd: ::std::os::raw::c_int, __modes: *const ::std::os::raw::c_char) + -> *mut FILE; +} +extern "C" { + pub fn fmemopen( + __s: *mut ::std::os::raw::c_void, + __len: usize, + __modes: *const ::std::os::raw::c_char, + ) -> *mut FILE; +} +extern "C" { + pub fn open_memstream( + __bufloc: *mut *mut ::std::os::raw::c_char, + __sizeloc: *mut usize, + ) -> *mut FILE; +} +extern "C" { + pub fn setbuf(__stream: *mut FILE, __buf: *mut ::std::os::raw::c_char); +} +extern "C" { + pub fn setvbuf( + __stream: *mut FILE, + __buf: *mut ::std::os::raw::c_char, + __modes: ::std::os::raw::c_int, + __n: usize, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn setbuffer(__stream: *mut FILE, __buf: *mut ::std::os::raw::c_char, __size: usize); +} +extern "C" { + pub fn setlinebuf(__stream: *mut FILE); +} +extern "C" { + pub fn fprintf( + __stream: *mut FILE, + __format: *const ::std::os::raw::c_char, + ... + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn printf(__format: *const ::std::os::raw::c_char, ...) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn sprintf( + __s: *mut ::std::os::raw::c_char, + __format: *const ::std::os::raw::c_char, + ... + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn vfprintf( + __s: *mut FILE, + __format: *const ::std::os::raw::c_char, + __arg: *mut __va_list_tag, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn vprintf( + __format: *const ::std::os::raw::c_char, + __arg: *mut __va_list_tag, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn vsprintf( + __s: *mut ::std::os::raw::c_char, + __format: *const ::std::os::raw::c_char, + __arg: *mut __va_list_tag, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn snprintf( + __s: *mut ::std::os::raw::c_char, + __maxlen: ::std::os::raw::c_ulong, + __format: *const ::std::os::raw::c_char, + ... + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn vsnprintf( + __s: *mut ::std::os::raw::c_char, + __maxlen: ::std::os::raw::c_ulong, + __format: *const ::std::os::raw::c_char, + __arg: *mut __va_list_tag, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn vdprintf( + __fd: ::std::os::raw::c_int, + __fmt: *const ::std::os::raw::c_char, + __arg: *mut __va_list_tag, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn dprintf( + __fd: ::std::os::raw::c_int, + __fmt: *const ::std::os::raw::c_char, + ... + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn fscanf( + __stream: *mut FILE, + __format: *const ::std::os::raw::c_char, + ... + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn scanf(__format: *const ::std::os::raw::c_char, ...) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn sscanf( + __s: *const ::std::os::raw::c_char, + __format: *const ::std::os::raw::c_char, + ... + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "\u{1}__isoc99_fscanf"] + pub fn fscanf1( + __stream: *mut FILE, + __format: *const ::std::os::raw::c_char, + ... + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "\u{1}__isoc99_scanf"] + pub fn scanf1(__format: *const ::std::os::raw::c_char, ...) -> ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "\u{1}__isoc99_sscanf"] + pub fn sscanf1( + __s: *const ::std::os::raw::c_char, + __format: *const ::std::os::raw::c_char, + ... + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn vfscanf( + __s: *mut FILE, + __format: *const ::std::os::raw::c_char, + __arg: *mut __va_list_tag, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn vscanf( + __format: *const ::std::os::raw::c_char, + __arg: *mut __va_list_tag, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn vsscanf( + __s: *const ::std::os::raw::c_char, + __format: *const ::std::os::raw::c_char, + __arg: *mut __va_list_tag, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "\u{1}__isoc99_vfscanf"] + pub fn vfscanf1( + __s: *mut FILE, + __format: *const ::std::os::raw::c_char, + __arg: *mut __va_list_tag, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "\u{1}__isoc99_vscanf"] + pub fn vscanf1( + __format: *const ::std::os::raw::c_char, + __arg: *mut __va_list_tag, + ) -> ::std::os::raw::c_int; +} +extern "C" { + #[link_name = "\u{1}__isoc99_vsscanf"] + pub fn vsscanf1( + __s: *const ::std::os::raw::c_char, + __format: *const ::std::os::raw::c_char, + __arg: *mut __va_list_tag, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn fgetc(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn getc(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn getchar() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn getc_unlocked(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn getchar_unlocked() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn fgetc_unlocked(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn fputc(__c: ::std::os::raw::c_int, __stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn putc(__c: ::std::os::raw::c_int, __stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn putchar(__c: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn fputc_unlocked(__c: ::std::os::raw::c_int, __stream: *mut FILE) + -> ::std::os::raw::c_int; +} +extern "C" { + pub fn putc_unlocked(__c: ::std::os::raw::c_int, __stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn putchar_unlocked(__c: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn getw(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn putw(__w: ::std::os::raw::c_int, __stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn fgets( + __s: *mut ::std::os::raw::c_char, + __n: ::std::os::raw::c_int, + __stream: *mut FILE, + ) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn __getdelim( + __lineptr: *mut *mut ::std::os::raw::c_char, + __n: *mut usize, + __delimiter: ::std::os::raw::c_int, + __stream: *mut FILE, + ) -> __ssize_t; +} +extern "C" { + pub fn getdelim( + __lineptr: *mut *mut ::std::os::raw::c_char, + __n: *mut usize, + __delimiter: ::std::os::raw::c_int, + __stream: *mut FILE, + ) -> __ssize_t; +} +extern "C" { + pub fn getline( + __lineptr: *mut *mut ::std::os::raw::c_char, + __n: *mut usize, + __stream: *mut FILE, + ) -> __ssize_t; +} +extern "C" { + pub fn fputs(__s: *const ::std::os::raw::c_char, __stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn puts(__s: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn ungetc(__c: ::std::os::raw::c_int, __stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn fread( + __ptr: *mut ::std::os::raw::c_void, + __size: ::std::os::raw::c_ulong, + __n: ::std::os::raw::c_ulong, + __stream: *mut FILE, + ) -> ::std::os::raw::c_ulong; +} +extern "C" { + pub fn fwrite( + __ptr: *const ::std::os::raw::c_void, + __size: ::std::os::raw::c_ulong, + __n: ::std::os::raw::c_ulong, + __s: *mut FILE, + ) -> ::std::os::raw::c_ulong; +} +extern "C" { + pub fn fread_unlocked( + __ptr: *mut ::std::os::raw::c_void, + __size: usize, + __n: usize, + __stream: *mut FILE, + ) -> usize; +} +extern "C" { + pub fn fwrite_unlocked( + __ptr: *const ::std::os::raw::c_void, + __size: usize, + __n: usize, + __stream: *mut FILE, + ) -> usize; +} +extern "C" { + pub fn fseek( + __stream: *mut FILE, + __off: ::std::os::raw::c_long, + __whence: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn ftell(__stream: *mut FILE) -> ::std::os::raw::c_long; +} +extern "C" { + pub fn rewind(__stream: *mut FILE); +} +extern "C" { + pub fn fseeko( + __stream: *mut FILE, + __off: __off_t, + __whence: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn ftello(__stream: *mut FILE) -> __off_t; +} +extern "C" { + pub fn fgetpos(__stream: *mut FILE, __pos: *mut fpos_t) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn fsetpos(__stream: *mut FILE, __pos: *const fpos_t) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn clearerr(__stream: *mut FILE); +} +extern "C" { + pub fn feof(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn ferror(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn clearerr_unlocked(__stream: *mut FILE); +} +extern "C" { + pub fn feof_unlocked(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn ferror_unlocked(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn perror(__s: *const ::std::os::raw::c_char); +} +extern "C" { + pub static mut sys_nerr: ::std::os::raw::c_int; +} +extern "C" { + pub static sys_errlist: [*const ::std::os::raw::c_char; 0usize]; +} +extern "C" { + pub fn fileno(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn fileno_unlocked(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn popen( + __command: *const ::std::os::raw::c_char, + __modes: *const ::std::os::raw::c_char, + ) -> *mut FILE; +} +extern "C" { + pub fn pclose(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn ctermid(__s: *mut ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn flockfile(__stream: *mut FILE); +} +extern "C" { + pub fn ftrylockfile(__stream: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn funlockfile(__stream: *mut FILE); +} +extern "C" { + pub fn __uflow(arg1: *mut FILE) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn __overflow(arg1: *mut FILE, arg2: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +pub type int_least8_t = __int_least8_t; +pub type int_least16_t = __int_least16_t; +pub type int_least32_t = __int_least32_t; +pub type int_least64_t = __int_least64_t; +pub type uint_least8_t = __uint_least8_t; +pub type uint_least16_t = __uint_least16_t; +pub type uint_least32_t = __uint_least32_t; +pub type uint_least64_t = __uint_least64_t; +pub type int_fast8_t = ::std::os::raw::c_schar; +pub type int_fast16_t = ::std::os::raw::c_long; +pub type int_fast32_t = ::std::os::raw::c_long; +pub type int_fast64_t = ::std::os::raw::c_long; +pub type uint_fast8_t = ::std::os::raw::c_uchar; +pub type uint_fast16_t = ::std::os::raw::c_ulong; +pub type uint_fast32_t = ::std::os::raw::c_ulong; +pub type uint_fast64_t = ::std::os::raw::c_ulong; +pub type intmax_t = __intmax_t; +pub type uintmax_t = __uintmax_t; +#[repr(u32)] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum BLST_ERROR { + BLST_SUCCESS = 0, + BLST_BAD_ENCODING = 1, + BLST_POINT_NOT_ON_CURVE = 2, + BLST_POINT_NOT_IN_GROUP = 3, + BLST_AGGR_TYPE_MISMATCH = 4, + BLST_VERIFY_FAIL = 5, + BLST_PK_IS_INFINITY = 6, + BLST_BAD_SCALAR = 7, +} +pub type byte = u8; +pub type limb_t = u64; +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct blst_scalar { + pub b: [byte; 32usize], +} +#[test] +fn bindgen_test_layout_blst_scalar() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(blst_scalar)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(blst_scalar)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(blst_scalar), + "::", + stringify!(b) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct blst_fr { + pub l: [limb_t; 4usize], +} +#[test] +fn bindgen_test_layout_blst_fr() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(blst_fr)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(blst_fr)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).l) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(blst_fr), + "::", + stringify!(l) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct blst_fp { + pub l: [limb_t; 6usize], +} +#[test] +fn bindgen_test_layout_blst_fp() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 48usize, + concat!("Size of: ", stringify!(blst_fp)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(blst_fp)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).l) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(blst_fp), + "::", + stringify!(l) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct blst_fp2 { + pub fp: [blst_fp; 2usize], +} +#[test] +fn bindgen_test_layout_blst_fp2() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 96usize, + concat!("Size of: ", stringify!(blst_fp2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(blst_fp2)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(blst_fp2), + "::", + stringify!(fp) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct blst_fp6 { + pub fp2: [blst_fp2; 3usize], +} +#[test] +fn bindgen_test_layout_blst_fp6() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 288usize, + concat!("Size of: ", stringify!(blst_fp6)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(blst_fp6)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp2) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(blst_fp6), + "::", + stringify!(fp2) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct blst_fp12 { + pub fp6: [blst_fp6; 2usize], +} +#[test] +fn bindgen_test_layout_blst_fp12() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 576usize, + concat!("Size of: ", stringify!(blst_fp12)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(blst_fp12)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp6) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(blst_fp12), + "::", + stringify!(fp6) + ) + ); +} +extern "C" { + pub fn blst_scalar_from_uint32(out: *mut blst_scalar, a: *const u32); +} +extern "C" { + pub fn blst_uint32_from_scalar(out: *mut u32, a: *const blst_scalar); +} +extern "C" { + pub fn blst_scalar_from_uint64(out: *mut blst_scalar, a: *const u64); +} +extern "C" { + pub fn blst_uint64_from_scalar(out: *mut u64, a: *const blst_scalar); +} +extern "C" { + pub fn blst_scalar_from_bendian(out: *mut blst_scalar, a: *const byte); +} +extern "C" { + pub fn blst_bendian_from_scalar(out: *mut byte, a: *const blst_scalar); +} +extern "C" { + pub fn blst_scalar_from_lendian(out: *mut blst_scalar, a: *const byte); +} +extern "C" { + pub fn blst_lendian_from_scalar(out: *mut byte, a: *const blst_scalar); +} +extern "C" { + pub fn blst_scalar_fr_check(a: *const blst_scalar) -> bool; +} +extern "C" { + pub fn blst_sk_check(a: *const blst_scalar) -> bool; +} +extern "C" { + pub fn blst_sk_add_n_check( + out: *mut blst_scalar, + a: *const blst_scalar, + b: *const blst_scalar, + ) -> bool; +} +extern "C" { + pub fn blst_sk_sub_n_check( + out: *mut blst_scalar, + a: *const blst_scalar, + b: *const blst_scalar, + ) -> bool; +} +extern "C" { + pub fn blst_sk_mul_n_check( + out: *mut blst_scalar, + a: *const blst_scalar, + b: *const blst_scalar, + ) -> bool; +} +extern "C" { + pub fn blst_sk_inverse(out: *mut blst_scalar, a: *const blst_scalar); +} +extern "C" { + pub fn blst_scalar_from_le_bytes(out: *mut blst_scalar, in_: *const byte, len: usize) -> bool; +} +extern "C" { + pub fn blst_scalar_from_be_bytes(out: *mut blst_scalar, in_: *const byte, len: usize) -> bool; +} +extern "C" { + pub fn blst_fr_add(ret: *mut blst_fr, a: *const blst_fr, b: *const blst_fr); +} +extern "C" { + pub fn blst_fr_sub(ret: *mut blst_fr, a: *const blst_fr, b: *const blst_fr); +} +extern "C" { + pub fn blst_fr_mul_by_3(ret: *mut blst_fr, a: *const blst_fr); +} +extern "C" { + pub fn blst_fr_lshift(ret: *mut blst_fr, a: *const blst_fr, count: usize); +} +extern "C" { + pub fn blst_fr_rshift(ret: *mut blst_fr, a: *const blst_fr, count: usize); +} +extern "C" { + pub fn blst_fr_mul(ret: *mut blst_fr, a: *const blst_fr, b: *const blst_fr); +} +extern "C" { + pub fn blst_fr_sqr(ret: *mut blst_fr, a: *const blst_fr); +} +extern "C" { + pub fn blst_fr_cneg(ret: *mut blst_fr, a: *const blst_fr, flag: bool); +} +extern "C" { + pub fn blst_fr_eucl_inverse(ret: *mut blst_fr, a: *const blst_fr); +} +extern "C" { + pub fn blst_fr_inverse(ret: *mut blst_fr, a: *const blst_fr); +} +extern "C" { + pub fn blst_fr_from_uint64(ret: *mut blst_fr, a: *const u64); +} +extern "C" { + pub fn blst_uint64_from_fr(ret: *mut u64, a: *const blst_fr); +} +extern "C" { + pub fn blst_fr_from_scalar(ret: *mut blst_fr, a: *const blst_scalar); +} +extern "C" { + pub fn blst_scalar_from_fr(ret: *mut blst_scalar, a: *const blst_fr); +} +extern "C" { + pub fn blst_fp_add(ret: *mut blst_fp, a: *const blst_fp, b: *const blst_fp); +} +extern "C" { + pub fn blst_fp_sub(ret: *mut blst_fp, a: *const blst_fp, b: *const blst_fp); +} +extern "C" { + pub fn blst_fp_mul_by_3(ret: *mut blst_fp, a: *const blst_fp); +} +extern "C" { + pub fn blst_fp_mul_by_8(ret: *mut blst_fp, a: *const blst_fp); +} +extern "C" { + pub fn blst_fp_lshift(ret: *mut blst_fp, a: *const blst_fp, count: usize); +} +extern "C" { + pub fn blst_fp_mul(ret: *mut blst_fp, a: *const blst_fp, b: *const blst_fp); +} +extern "C" { + pub fn blst_fp_sqr(ret: *mut blst_fp, a: *const blst_fp); +} +extern "C" { + pub fn blst_fp_cneg(ret: *mut blst_fp, a: *const blst_fp, flag: bool); +} +extern "C" { + pub fn blst_fp_eucl_inverse(ret: *mut blst_fp, a: *const blst_fp); +} +extern "C" { + pub fn blst_fp_inverse(ret: *mut blst_fp, a: *const blst_fp); +} +extern "C" { + pub fn blst_fp_sqrt(ret: *mut blst_fp, a: *const blst_fp) -> bool; +} +extern "C" { + pub fn blst_fp_from_uint32(ret: *mut blst_fp, a: *const u32); +} +extern "C" { + pub fn blst_uint32_from_fp(ret: *mut u32, a: *const blst_fp); +} +extern "C" { + pub fn blst_fp_from_uint64(ret: *mut blst_fp, a: *const u64); +} +extern "C" { + pub fn blst_uint64_from_fp(ret: *mut u64, a: *const blst_fp); +} +extern "C" { + pub fn blst_fp_from_bendian(ret: *mut blst_fp, a: *const byte); +} +extern "C" { + pub fn blst_bendian_from_fp(ret: *mut byte, a: *const blst_fp); +} +extern "C" { + pub fn blst_fp_from_lendian(ret: *mut blst_fp, a: *const byte); +} +extern "C" { + pub fn blst_lendian_from_fp(ret: *mut byte, a: *const blst_fp); +} +extern "C" { + pub fn blst_fp2_add(ret: *mut blst_fp2, a: *const blst_fp2, b: *const blst_fp2); +} +extern "C" { + pub fn blst_fp2_sub(ret: *mut blst_fp2, a: *const blst_fp2, b: *const blst_fp2); +} +extern "C" { + pub fn blst_fp2_mul_by_3(ret: *mut blst_fp2, a: *const blst_fp2); +} +extern "C" { + pub fn blst_fp2_mul_by_8(ret: *mut blst_fp2, a: *const blst_fp2); +} +extern "C" { + pub fn blst_fp2_lshift(ret: *mut blst_fp2, a: *const blst_fp2, count: usize); +} +extern "C" { + pub fn blst_fp2_mul(ret: *mut blst_fp2, a: *const blst_fp2, b: *const blst_fp2); +} +extern "C" { + pub fn blst_fp2_sqr(ret: *mut blst_fp2, a: *const blst_fp2); +} +extern "C" { + pub fn blst_fp2_cneg(ret: *mut blst_fp2, a: *const blst_fp2, flag: bool); +} +extern "C" { + pub fn blst_fp2_eucl_inverse(ret: *mut blst_fp2, a: *const blst_fp2); +} +extern "C" { + pub fn blst_fp2_inverse(ret: *mut blst_fp2, a: *const blst_fp2); +} +extern "C" { + pub fn blst_fp2_sqrt(ret: *mut blst_fp2, a: *const blst_fp2) -> bool; +} +extern "C" { + pub fn blst_fp12_sqr(ret: *mut blst_fp12, a: *const blst_fp12); +} +extern "C" { + pub fn blst_fp12_cyclotomic_sqr(ret: *mut blst_fp12, a: *const blst_fp12); +} +extern "C" { + pub fn blst_fp12_mul(ret: *mut blst_fp12, a: *const blst_fp12, b: *const blst_fp12); +} +extern "C" { + pub fn blst_fp12_mul_by_xy00z0( + ret: *mut blst_fp12, + a: *const blst_fp12, + xy00z0: *const blst_fp6, + ); +} +extern "C" { + pub fn blst_fp12_conjugate(a: *mut blst_fp12); +} +extern "C" { + pub fn blst_fp12_inverse(ret: *mut blst_fp12, a: *const blst_fp12); +} +extern "C" { + pub fn blst_fp12_frobenius_map(ret: *mut blst_fp12, a: *const blst_fp12, n: usize); +} +extern "C" { + pub fn blst_fp12_is_equal(a: *const blst_fp12, b: *const blst_fp12) -> bool; +} +extern "C" { + pub fn blst_fp12_is_one(a: *const blst_fp12) -> bool; +} +extern "C" { + pub fn blst_fp12_in_group(a: *const blst_fp12) -> bool; +} +extern "C" { + pub fn blst_fp12_one() -> *const blst_fp12; +} +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct blst_p1 { + pub x: blst_fp, + pub y: blst_fp, + pub z: blst_fp, +} +#[test] +fn bindgen_test_layout_blst_p1() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 144usize, + concat!("Size of: ", stringify!(blst_p1)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(blst_p1)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(blst_p1), + "::", + stringify!(x) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).y) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(blst_p1), + "::", + stringify!(y) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).z) as usize - ptr as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(blst_p1), + "::", + stringify!(z) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct blst_p1_affine { + pub x: blst_fp, + pub y: blst_fp, +} +#[test] +fn bindgen_test_layout_blst_p1_affine() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 96usize, + concat!("Size of: ", stringify!(blst_p1_affine)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(blst_p1_affine)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(blst_p1_affine), + "::", + stringify!(x) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).y) as usize - ptr as usize }, + 48usize, + concat!( + "Offset of field: ", + stringify!(blst_p1_affine), + "::", + stringify!(y) + ) + ); +} +extern "C" { + pub fn blst_p1_add(out: *mut blst_p1, a: *const blst_p1, b: *const blst_p1); +} +extern "C" { + pub fn blst_p1_add_or_double(out: *mut blst_p1, a: *const blst_p1, b: *const blst_p1); +} +extern "C" { + pub fn blst_p1_add_affine(out: *mut blst_p1, a: *const blst_p1, b: *const blst_p1_affine); +} +extern "C" { + pub fn blst_p1_add_or_double_affine( + out: *mut blst_p1, + a: *const blst_p1, + b: *const blst_p1_affine, + ); +} +extern "C" { + pub fn blst_p1_double(out: *mut blst_p1, a: *const blst_p1); +} +extern "C" { + pub fn blst_p1_mult(out: *mut blst_p1, p: *const blst_p1, scalar: *const byte, nbits: usize); +} +extern "C" { + pub fn blst_p1_cneg(p: *mut blst_p1, cbit: bool); +} +extern "C" { + pub fn blst_p1_to_affine(out: *mut blst_p1_affine, in_: *const blst_p1); +} +extern "C" { + pub fn blst_p1_from_affine(out: *mut blst_p1, in_: *const blst_p1_affine); +} +extern "C" { + pub fn blst_p1_on_curve(p: *const blst_p1) -> bool; +} +extern "C" { + pub fn blst_p1_in_g1(p: *const blst_p1) -> bool; +} +extern "C" { + pub fn blst_p1_is_equal(a: *const blst_p1, b: *const blst_p1) -> bool; +} +extern "C" { + pub fn blst_p1_is_inf(a: *const blst_p1) -> bool; +} +extern "C" { + pub fn blst_p1_generator() -> *const blst_p1; +} +extern "C" { + pub fn blst_p1_affine_on_curve(p: *const blst_p1_affine) -> bool; +} +extern "C" { + pub fn blst_p1_affine_in_g1(p: *const blst_p1_affine) -> bool; +} +extern "C" { + pub fn blst_p1_affine_is_equal(a: *const blst_p1_affine, b: *const blst_p1_affine) -> bool; +} +extern "C" { + pub fn blst_p1_affine_is_inf(a: *const blst_p1_affine) -> bool; +} +extern "C" { + pub fn blst_p1_affine_generator() -> *const blst_p1_affine; +} +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct blst_p2 { + pub x: blst_fp2, + pub y: blst_fp2, + pub z: blst_fp2, +} +#[test] +fn bindgen_test_layout_blst_p2() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 288usize, + concat!("Size of: ", stringify!(blst_p2)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(blst_p2)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(blst_p2), + "::", + stringify!(x) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).y) as usize - ptr as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(blst_p2), + "::", + stringify!(y) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).z) as usize - ptr as usize }, + 192usize, + concat!( + "Offset of field: ", + stringify!(blst_p2), + "::", + stringify!(z) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct blst_p2_affine { + pub x: blst_fp2, + pub y: blst_fp2, +} +#[test] +fn bindgen_test_layout_blst_p2_affine() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 192usize, + concat!("Size of: ", stringify!(blst_p2_affine)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(blst_p2_affine)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(blst_p2_affine), + "::", + stringify!(x) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).y) as usize - ptr as usize }, + 96usize, + concat!( + "Offset of field: ", + stringify!(blst_p2_affine), + "::", + stringify!(y) + ) + ); +} +extern "C" { + pub fn blst_p2_add(out: *mut blst_p2, a: *const blst_p2, b: *const blst_p2); +} +extern "C" { + pub fn blst_p2_add_or_double(out: *mut blst_p2, a: *const blst_p2, b: *const blst_p2); +} +extern "C" { + pub fn blst_p2_add_affine(out: *mut blst_p2, a: *const blst_p2, b: *const blst_p2_affine); +} +extern "C" { + pub fn blst_p2_add_or_double_affine( + out: *mut blst_p2, + a: *const blst_p2, + b: *const blst_p2_affine, + ); +} +extern "C" { + pub fn blst_p2_double(out: *mut blst_p2, a: *const blst_p2); +} +extern "C" { + pub fn blst_p2_mult(out: *mut blst_p2, p: *const blst_p2, scalar: *const byte, nbits: usize); +} +extern "C" { + pub fn blst_p2_cneg(p: *mut blst_p2, cbit: bool); +} +extern "C" { + pub fn blst_p2_to_affine(out: *mut blst_p2_affine, in_: *const blst_p2); +} +extern "C" { + pub fn blst_p2_from_affine(out: *mut blst_p2, in_: *const blst_p2_affine); +} +extern "C" { + pub fn blst_p2_on_curve(p: *const blst_p2) -> bool; +} +extern "C" { + pub fn blst_p2_in_g2(p: *const blst_p2) -> bool; +} +extern "C" { + pub fn blst_p2_is_equal(a: *const blst_p2, b: *const blst_p2) -> bool; +} +extern "C" { + pub fn blst_p2_is_inf(a: *const blst_p2) -> bool; +} +extern "C" { + pub fn blst_p2_generator() -> *const blst_p2; +} +extern "C" { + pub fn blst_p2_affine_on_curve(p: *const blst_p2_affine) -> bool; +} +extern "C" { + pub fn blst_p2_affine_in_g2(p: *const blst_p2_affine) -> bool; +} +extern "C" { + pub fn blst_p2_affine_is_equal(a: *const blst_p2_affine, b: *const blst_p2_affine) -> bool; +} +extern "C" { + pub fn blst_p2_affine_is_inf(a: *const blst_p2_affine) -> bool; +} +extern "C" { + pub fn blst_p2_affine_generator() -> *const blst_p2_affine; +} +extern "C" { + pub fn blst_p1s_to_affine( + dst: *mut blst_p1_affine, + points: *const *const blst_p1, + npoints: usize, + ); +} +extern "C" { + pub fn blst_p1s_add(ret: *mut blst_p1, points: *const *const blst_p1_affine, npoints: usize); +} +extern "C" { + pub fn blst_p1s_mult_wbits_precompute_sizeof(wbits: usize, npoints: usize) -> usize; +} +extern "C" { + pub fn blst_p1s_mult_wbits_precompute( + table: *mut blst_p1_affine, + wbits: usize, + points: *const *const blst_p1_affine, + npoints: usize, + ); +} +extern "C" { + pub fn blst_p1s_mult_wbits_scratch_sizeof(npoints: usize) -> usize; +} +extern "C" { + pub fn blst_p1s_mult_wbits( + ret: *mut blst_p1, + table: *const blst_p1_affine, + wbits: usize, + npoints: usize, + scalars: *const *const byte, + nbits: usize, + scratch: *mut limb_t, + ); +} +extern "C" { + pub fn blst_p1s_mult_pippenger_scratch_sizeof(npoints: usize) -> usize; +} +extern "C" { + pub fn blst_p1s_mult_pippenger( + ret: *mut blst_p1, + points: *const *const blst_p1_affine, + npoints: usize, + scalars: *const *const byte, + nbits: usize, + scratch: *mut limb_t, + ); +} +extern "C" { + pub fn blst_p1s_tile_pippenger( + ret: *mut blst_p1, + points: *const *const blst_p1_affine, + npoints: usize, + scalars: *const *const byte, + nbits: usize, + scratch: *mut limb_t, + bit0: usize, + window: usize, + ); +} +extern "C" { + pub fn blst_p2s_to_affine( + dst: *mut blst_p2_affine, + points: *const *const blst_p2, + npoints: usize, + ); +} +extern "C" { + pub fn blst_p2s_add(ret: *mut blst_p2, points: *const *const blst_p2_affine, npoints: usize); +} +extern "C" { + pub fn blst_p2s_mult_wbits_precompute_sizeof(wbits: usize, npoints: usize) -> usize; +} +extern "C" { + pub fn blst_p2s_mult_wbits_precompute( + table: *mut blst_p2_affine, + wbits: usize, + points: *const *const blst_p2_affine, + npoints: usize, + ); +} +extern "C" { + pub fn blst_p2s_mult_wbits_scratch_sizeof(npoints: usize) -> usize; +} +extern "C" { + pub fn blst_p2s_mult_wbits( + ret: *mut blst_p2, + table: *const blst_p2_affine, + wbits: usize, + npoints: usize, + scalars: *const *const byte, + nbits: usize, + scratch: *mut limb_t, + ); +} +extern "C" { + pub fn blst_p2s_mult_pippenger_scratch_sizeof(npoints: usize) -> usize; +} +extern "C" { + pub fn blst_p2s_mult_pippenger( + ret: *mut blst_p2, + points: *const *const blst_p2_affine, + npoints: usize, + scalars: *const *const byte, + nbits: usize, + scratch: *mut limb_t, + ); +} +extern "C" { + pub fn blst_p2s_tile_pippenger( + ret: *mut blst_p2, + points: *const *const blst_p2_affine, + npoints: usize, + scalars: *const *const byte, + nbits: usize, + scratch: *mut limb_t, + bit0: usize, + window: usize, + ); +} +extern "C" { + pub fn blst_map_to_g1(out: *mut blst_p1, u: *const blst_fp, v: *const blst_fp); +} +extern "C" { + pub fn blst_map_to_g2(out: *mut blst_p2, u: *const blst_fp2, v: *const blst_fp2); +} +extern "C" { + pub fn blst_encode_to_g1( + out: *mut blst_p1, + msg: *const byte, + msg_len: usize, + DST: *const byte, + DST_len: usize, + aug: *const byte, + aug_len: usize, + ); +} +extern "C" { + pub fn blst_hash_to_g1( + out: *mut blst_p1, + msg: *const byte, + msg_len: usize, + DST: *const byte, + DST_len: usize, + aug: *const byte, + aug_len: usize, + ); +} +extern "C" { + pub fn blst_encode_to_g2( + out: *mut blst_p2, + msg: *const byte, + msg_len: usize, + DST: *const byte, + DST_len: usize, + aug: *const byte, + aug_len: usize, + ); +} +extern "C" { + pub fn blst_hash_to_g2( + out: *mut blst_p2, + msg: *const byte, + msg_len: usize, + DST: *const byte, + DST_len: usize, + aug: *const byte, + aug_len: usize, + ); +} +extern "C" { + pub fn blst_p1_serialize(out: *mut byte, in_: *const blst_p1); +} +extern "C" { + pub fn blst_p1_compress(out: *mut byte, in_: *const blst_p1); +} +extern "C" { + pub fn blst_p1_affine_serialize(out: *mut byte, in_: *const blst_p1_affine); +} +extern "C" { + pub fn blst_p1_affine_compress(out: *mut byte, in_: *const blst_p1_affine); +} +extern "C" { + pub fn blst_p1_uncompress(out: *mut blst_p1_affine, in_: *const byte) -> BLST_ERROR; +} +extern "C" { + pub fn blst_p1_deserialize(out: *mut blst_p1_affine, in_: *const byte) -> BLST_ERROR; +} +extern "C" { + pub fn blst_p2_serialize(out: *mut byte, in_: *const blst_p2); +} +extern "C" { + pub fn blst_p2_compress(out: *mut byte, in_: *const blst_p2); +} +extern "C" { + pub fn blst_p2_affine_serialize(out: *mut byte, in_: *const blst_p2_affine); +} +extern "C" { + pub fn blst_p2_affine_compress(out: *mut byte, in_: *const blst_p2_affine); +} +extern "C" { + pub fn blst_p2_uncompress(out: *mut blst_p2_affine, in_: *const byte) -> BLST_ERROR; +} +extern "C" { + pub fn blst_p2_deserialize(out: *mut blst_p2_affine, in_: *const byte) -> BLST_ERROR; +} +extern "C" { + pub fn blst_keygen( + out_SK: *mut blst_scalar, + IKM: *const byte, + IKM_len: usize, + info: *const byte, + info_len: usize, + ); +} +extern "C" { + pub fn blst_sk_to_pk_in_g1(out_pk: *mut blst_p1, SK: *const blst_scalar); +} +extern "C" { + pub fn blst_sign_pk_in_g1(out_sig: *mut blst_p2, hash: *const blst_p2, SK: *const blst_scalar); +} +extern "C" { + pub fn blst_sk_to_pk_in_g2(out_pk: *mut blst_p2, SK: *const blst_scalar); +} +extern "C" { + pub fn blst_sign_pk_in_g2(out_sig: *mut blst_p1, hash: *const blst_p1, SK: *const blst_scalar); +} +extern "C" { + pub fn blst_miller_loop( + ret: *mut blst_fp12, + Q: *const blst_p2_affine, + P: *const blst_p1_affine, + ); +} +extern "C" { + pub fn blst_final_exp(ret: *mut blst_fp12, f: *const blst_fp12); +} +extern "C" { + pub fn blst_precompute_lines(Qlines: *mut blst_fp6, Q: *const blst_p2_affine); +} +extern "C" { + pub fn blst_miller_loop_lines( + ret: *mut blst_fp12, + Qlines: *const blst_fp6, + P: *const blst_p1_affine, + ); +} +extern "C" { + pub fn blst_fp12_finalverify(gt1: *const blst_fp12, gt2: *const blst_fp12) -> bool; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct blst_opaque { + _unused: [u8; 0], +} +pub type blst_pairing = blst_opaque; +extern "C" { + pub fn blst_pairing_sizeof() -> usize; +} +extern "C" { + pub fn blst_pairing_init( + new_ctx: *mut blst_pairing, + hash_or_encode: bool, + DST: *const byte, + DST_len: usize, + ); +} +extern "C" { + pub fn blst_pairing_get_dst(ctx: *const blst_pairing) -> *const byte; +} +extern "C" { + pub fn blst_pairing_commit(ctx: *mut blst_pairing); +} +extern "C" { + pub fn blst_pairing_aggregate_pk_in_g2( + ctx: *mut blst_pairing, + PK: *const blst_p2_affine, + signature: *const blst_p1_affine, + msg: *const byte, + msg_len: usize, + aug: *const byte, + aug_len: usize, + ) -> BLST_ERROR; +} +extern "C" { + pub fn blst_pairing_chk_n_aggr_pk_in_g2( + ctx: *mut blst_pairing, + PK: *const blst_p2_affine, + pk_grpchk: bool, + signature: *const blst_p1_affine, + sig_grpchk: bool, + msg: *const byte, + msg_len: usize, + aug: *const byte, + aug_len: usize, + ) -> BLST_ERROR; +} +extern "C" { + pub fn blst_pairing_mul_n_aggregate_pk_in_g2( + ctx: *mut blst_pairing, + PK: *const blst_p2_affine, + sig: *const blst_p1_affine, + scalar: *const byte, + nbits: usize, + msg: *const byte, + msg_len: usize, + aug: *const byte, + aug_len: usize, + ) -> BLST_ERROR; +} +extern "C" { + pub fn blst_pairing_chk_n_mul_n_aggr_pk_in_g2( + ctx: *mut blst_pairing, + PK: *const blst_p2_affine, + pk_grpchk: bool, + sig: *const blst_p1_affine, + sig_grpchk: bool, + scalar: *const byte, + nbits: usize, + msg: *const byte, + msg_len: usize, + aug: *const byte, + aug_len: usize, + ) -> BLST_ERROR; +} +extern "C" { + pub fn blst_pairing_aggregate_pk_in_g1( + ctx: *mut blst_pairing, + PK: *const blst_p1_affine, + signature: *const blst_p2_affine, + msg: *const byte, + msg_len: usize, + aug: *const byte, + aug_len: usize, + ) -> BLST_ERROR; +} +extern "C" { + pub fn blst_pairing_chk_n_aggr_pk_in_g1( + ctx: *mut blst_pairing, + PK: *const blst_p1_affine, + pk_grpchk: bool, + signature: *const blst_p2_affine, + sig_grpchk: bool, + msg: *const byte, + msg_len: usize, + aug: *const byte, + aug_len: usize, + ) -> BLST_ERROR; +} +extern "C" { + pub fn blst_pairing_mul_n_aggregate_pk_in_g1( + ctx: *mut blst_pairing, + PK: *const blst_p1_affine, + sig: *const blst_p2_affine, + scalar: *const byte, + nbits: usize, + msg: *const byte, + msg_len: usize, + aug: *const byte, + aug_len: usize, + ) -> BLST_ERROR; +} +extern "C" { + pub fn blst_pairing_chk_n_mul_n_aggr_pk_in_g1( + ctx: *mut blst_pairing, + PK: *const blst_p1_affine, + pk_grpchk: bool, + sig: *const blst_p2_affine, + sig_grpchk: bool, + scalar: *const byte, + nbits: usize, + msg: *const byte, + msg_len: usize, + aug: *const byte, + aug_len: usize, + ) -> BLST_ERROR; +} +extern "C" { + pub fn blst_pairing_merge(ctx: *mut blst_pairing, ctx1: *const blst_pairing) -> BLST_ERROR; +} +extern "C" { + pub fn blst_pairing_finalverify(ctx: *const blst_pairing, gtsig: *const blst_fp12) -> bool; +} +extern "C" { + pub fn blst_aggregate_in_g1( + out: *mut blst_p1, + in_: *const blst_p1, + zwire: *const byte, + ) -> BLST_ERROR; +} +extern "C" { + pub fn blst_aggregate_in_g2( + out: *mut blst_p2, + in_: *const blst_p2, + zwire: *const byte, + ) -> BLST_ERROR; +} +extern "C" { + pub fn blst_aggregated_in_g1(out: *mut blst_fp12, signature: *const blst_p1_affine); +} +extern "C" { + pub fn blst_aggregated_in_g2(out: *mut blst_fp12, signature: *const blst_p2_affine); +} +extern "C" { + pub fn blst_core_verify_pk_in_g1( + pk: *const blst_p1_affine, + signature: *const blst_p2_affine, + hash_or_encode: bool, + msg: *const byte, + msg_len: usize, + DST: *const byte, + DST_len: usize, + aug: *const byte, + aug_len: usize, + ) -> BLST_ERROR; +} +extern "C" { + pub fn blst_core_verify_pk_in_g2( + pk: *const blst_p2_affine, + signature: *const blst_p1_affine, + hash_or_encode: bool, + msg: *const byte, + msg_len: usize, + DST: *const byte, + DST_len: usize, + aug: *const byte, + aug_len: usize, + ) -> BLST_ERROR; +} +extern "C" { + pub static BLS12_381_G1: blst_p1_affine; +} +extern "C" { + pub static BLS12_381_NEG_G1: blst_p1_affine; +} +extern "C" { + pub static BLS12_381_G2: blst_p2_affine; +} +extern "C" { + pub static BLS12_381_NEG_G2: blst_p2_affine; +} +extern "C" { + pub fn blst_fr_to(ret: *mut blst_fr, a: *const blst_fr); +} +extern "C" { + pub fn blst_fr_from(ret: *mut blst_fr, a: *const blst_fr); +} +extern "C" { + pub fn blst_fp_to(ret: *mut blst_fp, a: *const blst_fp); +} +extern "C" { + pub fn blst_fp_from(ret: *mut blst_fp, a: *const blst_fp); +} +extern "C" { + pub fn blst_fp_is_square(a: *const blst_fp) -> bool; +} +extern "C" { + pub fn blst_fp2_is_square(a: *const blst_fp2) -> bool; +} +extern "C" { + pub fn blst_p1_from_jacobian(out: *mut blst_p1, in_: *const blst_p1); +} +extern "C" { + pub fn blst_p2_from_jacobian(out: *mut blst_p2, in_: *const blst_p2); +} +extern "C" { + pub fn blst_sk_to_pk2_in_g1( + out: *mut byte, + out_pk: *mut blst_p1_affine, + SK: *const blst_scalar, + ); +} +extern "C" { + pub fn blst_sign_pk2_in_g1( + out: *mut byte, + out_sig: *mut blst_p2_affine, + hash: *const blst_p2, + SK: *const blst_scalar, + ); +} +extern "C" { + pub fn blst_sk_to_pk2_in_g2( + out: *mut byte, + out_pk: *mut blst_p2_affine, + SK: *const blst_scalar, + ); +} +extern "C" { + pub fn blst_sign_pk2_in_g2( + out: *mut byte, + out_sig: *mut blst_p1_affine, + hash: *const blst_p1, + SK: *const blst_scalar, + ); +} +#[repr(C)] +#[repr(align(1))] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct blst_uniq { + pub _bindgen_opaque_blob: [u8; 0usize], +} +#[test] +fn bindgen_test_layout_blst_uniq() { + assert_eq!( + ::std::mem::size_of::(), + 0usize, + concat!("Size of: ", stringify!(blst_uniq)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(blst_uniq)) + ); +} +extern "C" { + pub fn blst_uniq_sizeof(n_nodes: usize) -> usize; +} +extern "C" { + pub fn blst_uniq_init(tree: *mut blst_uniq); +} +extern "C" { + pub fn blst_uniq_test(tree: *mut blst_uniq, msg: *const byte, len: usize) -> bool; +} +extern "C" { + pub fn blst_expand_message_xmd( + out: *mut byte, + out_len: usize, + msg: *const byte, + msg_len: usize, + DST: *const byte, + DST_len: usize, + ); +} +extern "C" { + pub fn blst_p1_unchecked_mult( + out: *mut blst_p1, + p: *const blst_p1, + scalar: *const byte, + nbits: usize, + ); +} +extern "C" { + pub fn blst_p2_unchecked_mult( + out: *mut blst_p2, + p: *const blst_p2, + scalar: *const byte, + nbits: usize, + ); +} +extern "C" { + pub fn blst_pairing_raw_aggregate( + ctx: *mut blst_pairing, + q: *const blst_p2_affine, + p: *const blst_p1_affine, + ); +} +extern "C" { + pub fn blst_pairing_as_fp12(ctx: *mut blst_pairing) -> *mut blst_fp12; +} +extern "C" { + pub fn blst_bendian_from_fp12(out: *mut byte, a: *const blst_fp12); +} +extern "C" { + pub fn blst_keygen_v3( + out_SK: *mut blst_scalar, + IKM: *const byte, + IKM_len: usize, + info: *const byte, + info_len: usize, + ); +} +extern "C" { + pub fn blst_keygen_v4_5( + out_SK: *mut blst_scalar, + IKM: *const byte, + IKM_len: usize, + salt: *const byte, + salt_len: usize, + info: *const byte, + info_len: usize, + ); +} +extern "C" { + pub fn blst_keygen_v5( + out_SK: *mut blst_scalar, + IKM: *const byte, + IKM_len: usize, + salt: *const byte, + salt_len: usize, + info: *const byte, + info_len: usize, + ); +} +extern "C" { + pub fn blst_derive_master_eip2333(out_SK: *mut blst_scalar, IKM: *const byte, IKM_len: usize); +} +extern "C" { + pub fn blst_derive_child_eip2333( + out_SK: *mut blst_scalar, + SK: *const blst_scalar, + child_index: u32, + ); +} +extern "C" { + pub fn blst_scalar_from_hexascii(out: *mut blst_scalar, hex: *const byte); +} +extern "C" { + pub fn blst_fr_from_hexascii(ret: *mut blst_fr, hex: *const byte); +} +extern "C" { + pub fn blst_fp_from_hexascii(ret: *mut blst_fp, hex: *const byte); +} +extern "C" { + pub fn blst_p1_sizeof() -> usize; +} +extern "C" { + pub fn blst_p1_affine_sizeof() -> usize; +} +extern "C" { + pub fn blst_p2_sizeof() -> usize; +} +extern "C" { + pub fn blst_p2_affine_sizeof() -> usize; +} +extern "C" { + pub fn blst_fp12_sizeof() -> usize; +} +extern "C" { + pub static FIAT_SHAMIR_PROTOCOL_DOMAIN: [u8; 16usize]; +} +pub type g1_t = blst_p1; +pub type g2_t = blst_p2; +pub type fr_t = blst_fr; +pub type KZGCommitment = g1_t; +pub type KZGProof = g1_t; +pub type BLSFieldElement = fr_t; +pub type Blob = [u8; 131072usize]; +#[repr(u32)] +#[doc = " The common return type for all routines in which something can go wrong."] +#[doc = ""] +#[doc = " @warning In the case of @p C_KZG_OK or @p C_KZG_BADARGS, the caller can assume that all memory allocated by the"] +#[doc = " called routines has been deallocated. However, in the case of @p C_KZG_ERROR or @p C_KZG_MALLOC being returned, these"] +#[doc = " are unrecoverable and memory may have been leaked."] +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum C_KZG_RET { + #[doc = "< Success!"] + C_KZG_OK = 0, + #[doc = "< The supplied data is invalid in some way"] + C_KZG_BADARGS = 1, + #[doc = "< Internal error - this should never occur and may indicate a bug in the library"] + C_KZG_ERROR = 2, + #[doc = "< Could not allocate memory"] + C_KZG_MALLOC = 3, +} +#[doc = " Stores the setup and parameters needed for performing FFTs."] +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct FFTSettings { + #[doc = "< The maximum size of FFT these settings support, a power of 2."] + pub max_width: u64, + #[doc = "< Ascending powers of the root of unity, size `width + 1`."] + pub expanded_roots_of_unity: *mut fr_t, + #[doc = "< Descending powers of the root of unity, size `width + 1`."] + pub reverse_roots_of_unity: *mut fr_t, + #[doc = "< Powers of the root of unity in bit-reversal permutation, size `width`."] + pub roots_of_unity: *mut fr_t, +} +#[test] +fn bindgen_test_layout_FFTSettings() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 32usize, + concat!("Size of: ", stringify!(FFTSettings)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(FFTSettings)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).max_width) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(FFTSettings), + "::", + stringify!(max_width) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).expanded_roots_of_unity) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(FFTSettings), + "::", + stringify!(expanded_roots_of_unity) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reverse_roots_of_unity) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(FFTSettings), + "::", + stringify!(reverse_roots_of_unity) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).roots_of_unity) as usize - ptr as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(FFTSettings), + "::", + stringify!(roots_of_unity) + ) + ); +} +#[doc = " Stores the setup and parameters needed for computing KZG proofs."] +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct KZGSettings { + #[doc = "< The corresponding settings for performing FFTs"] + pub fs: *const FFTSettings, + #[doc = "< G1 group elements from the trusted setup, in Lagrange form bit-reversal permutation"] + pub g1_values: *mut g1_t, + #[doc = "< G2 group elements from the trusted setup; both arrays have FIELD_ELEMENTS_PER_BLOB elements"] + pub g2_values: *mut g2_t, +} +#[test] +fn bindgen_test_layout_KZGSettings() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(KZGSettings)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(KZGSettings)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fs) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(KZGSettings), + "::", + stringify!(fs) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).g1_values) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(KZGSettings), + "::", + stringify!(g1_values) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).g2_values) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(KZGSettings), + "::", + stringify!(g2_values) + ) + ); +} +extern "C" { + #[doc = " Interface functions"] + pub fn bytes_to_g1(out: *mut g1_t, in_: *const u8) -> C_KZG_RET; +} +extern "C" { + pub fn bytes_from_g1(out: *mut u8, in_: *const g1_t); +} +extern "C" { + pub fn bytes_to_bls_field(out: *mut BLSFieldElement, in_: *const u8); +} +extern "C" { + pub fn load_trusted_setup(out: *mut KZGSettings, in_: *mut FILE) -> C_KZG_RET; +} +extern "C" { + pub fn free_trusted_setup(s: *mut KZGSettings); +} +extern "C" { + pub fn compute_aggregate_kzg_proof( + out: *mut KZGProof, + blobs: *const Blob, + n: usize, + s: *const KZGSettings, + ) -> C_KZG_RET; +} +extern "C" { + pub fn verify_aggregate_kzg_proof( + out: *mut bool, + blobs: *const Blob, + expected_kzg_commitments: *const KZGCommitment, + n: usize, + kzg_aggregated_proof: *const KZGProof, + s: *const KZGSettings, + ) -> C_KZG_RET; +} +extern "C" { + pub fn blob_to_kzg_commitment(out: *mut KZGCommitment, blob: *mut u8, s: *const KZGSettings); +} +extern "C" { + pub fn verify_kzg_proof( + out: *mut bool, + polynomial_kzg: *const KZGCommitment, + z: *const BLSFieldElement, + y: *const BLSFieldElement, + kzg_proof: *const KZGProof, + s: *const KZGSettings, + ) -> C_KZG_RET; +} +pub type __builtin_va_list = [__va_list_tag; 1usize]; +#[repr(C)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct __va_list_tag { + pub gp_offset: ::std::os::raw::c_uint, + pub fp_offset: ::std::os::raw::c_uint, + pub overflow_arg_area: *mut ::std::os::raw::c_void, + pub reg_save_area: *mut ::std::os::raw::c_void, +} +#[test] +fn bindgen_test_layout___va_list_tag() { + const UNINIT: ::std::mem::MaybeUninit<__va_list_tag> = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<__va_list_tag>(), + 24usize, + concat!("Size of: ", stringify!(__va_list_tag)) + ); + assert_eq!( + ::std::mem::align_of::<__va_list_tag>(), + 8usize, + concat!("Alignment of ", stringify!(__va_list_tag)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).gp_offset) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(__va_list_tag), + "::", + stringify!(gp_offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).fp_offset) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(__va_list_tag), + "::", + stringify!(fp_offset) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).overflow_arg_area) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(__va_list_tag), + "::", + stringify!(overflow_arg_area) + ) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).reg_save_area) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(__va_list_tag), + "::", + stringify!(reg_save_area) + ) + ); +} From 72f1c01ba70ff7b67eb691632aa21ed3301ab125 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Tue, 15 Nov 2022 17:40:31 +0530 Subject: [PATCH 3/9] tidy build script --- bindings/rust/bindings.rs | 2 +- bindings/rust/build.rs | 53 +++++++++++---------------------------- bindings/rust/wrapper.h | 1 - 3 files changed, 15 insertions(+), 41 deletions(-) delete mode 100644 bindings/rust/wrapper.h diff --git a/bindings/rust/bindings.rs b/bindings/rust/bindings.rs index 3dab758..f2eb419 100644 --- a/bindings/rust/bindings.rs +++ b/bindings/rust/bindings.rs @@ -2663,7 +2663,7 @@ fn bindgen_test_layout_FFTSettings() { } #[doc = " Stores the setup and parameters needed for computing KZG proofs."] #[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct KZGSettings { #[doc = "< The corresponding settings for performing FFTs"] pub fs: *const FFTSettings, diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs index 41b9b37..912803b 100644 --- a/bindings/rust/build.rs +++ b/bindings/rust/build.rs @@ -3,51 +3,31 @@ use std::path::PathBuf; use std::process::Command; fn main() { - println!("cargo:rerun-if-changed=wrapper.h"); - - // The bindgen::Builder is the main entry point - // to bindgen, and lets you build up options for - // the resulting bindings. - let bindings = bindgen::Builder::default() - // The input header we would like to generate - // bindings for. - .header("wrapper.h") - // Tell cargo to invalidate the built crate whenever any of the - // included header files changed. - .parse_callbacks(Box::new(bindgen::CargoCallbacks)) - // Finish the builder and generate the bindings. - .derive_partialeq(true) - .derive_eq(true) - .derive_copy(false) - .opaque_type("blst_uniq") - .default_enum_style(bindgen::EnumVariation::Rust { - non_exhaustive: false, - }) - .generate() - // Unwrap the Result and panic on failure. - .expect("Unable to generate bindings"); - - let mut root_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("../../"); - + let root_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("../../"); let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - let mut cmd = Command::new("make"); - let res = cmd + // Ensure libblst exists in `OUT_DIR` + // Assuming blst submodule exists + Command::new("make") .current_dir(root_dir.join("src")) - .arg("all") + .arg("blst") .status() .unwrap(); + std::fs::copy(root_dir.join("lib/libblst.a"), &out_dir.join("libblst.a")).unwrap(); - let obj_file_path = root_dir.join("c_kzg_4844.o"); + // Ensure libckzg exists in `OUT_DIR` + Command::new("make") + .current_dir(root_dir.join("src")) + .arg("all") + .status() + .unwrap(); - let status = Command::new("ar") - .args(&["crus", "libckzg.a", "c_kzg_4844.o"]) + Command::new("ar") .current_dir(&root_dir.join("src")) + .args(&["crus", "libckzg.a", "c_kzg_4844.o"]) .status() .unwrap(); - std::fs::copy(root_dir.join("src/libckzg.a"), &out_dir.join("libckzg.a")).unwrap(); - std::fs::copy(root_dir.join("lib/libblst.a"), &out_dir.join("libblst.a")).unwrap(); println!("cargo:rustc-link-search={}", out_dir.display()); println!("cargo:rustc-link-search={}", out_dir.display()); @@ -57,9 +37,4 @@ fn main() { "cargo:rerun-if-changed={}", root_dir.join("src/c_kzg_4844.c").display() ); - - // Write the bindings to the $OUT_DIR/bindings.rs file. - bindings - .write_to_file(out_dir.join("bindings.rs")) - .expect("Couldn't write bindings!"); } diff --git a/bindings/rust/wrapper.h b/bindings/rust/wrapper.h deleted file mode 100644 index a0c7a84..0000000 --- a/bindings/rust/wrapper.h +++ /dev/null @@ -1 +0,0 @@ -#include "c_kzg_4844.h" \ No newline at end of file From e0a556dd8ec3c93491b8bbba89f4d5b1cb18e726 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Tue, 15 Nov 2022 17:40:44 +0530 Subject: [PATCH 4/9] Add initial rust safe bindings --- bindings/rust/src/lib.rs | 158 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 bindings/rust/src/lib.rs diff --git a/bindings/rust/src/lib.rs b/bindings/rust/src/lib.rs new file mode 100644 index 0000000..34587a0 --- /dev/null +++ b/bindings/rust/src/lib.rs @@ -0,0 +1,158 @@ +#![allow(non_upper_case_globals)] +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +include!("../bindings.rs"); + +use std::ffi::CString; +use std::mem::MaybeUninit; +use std::os::unix::prelude::OsStrExt; +use std::path::PathBuf; + +impl g1_t { + pub fn bytes_to_g1(bytes: &[u8]) -> Result { + let mut g1_point = MaybeUninit::::uninit(); + unsafe { + let res = bytes_to_g1(g1_point.as_mut_ptr(), bytes.as_ptr()); + if let C_KZG_RET::C_KZG_OK = res { + Ok(g1_point.assume_init()) + } else { + Err(res) + } + } + } + + pub fn bytes_from_g1(&self) -> [u8; 48] { + let mut bytes = [0; 48]; + unsafe { bytes_from_g1(bytes.as_mut_ptr(), self) } + bytes + } +} + +impl BLSFieldElement { + pub fn bytes_to_bls_field(bytes: [u8; BYTES_PER_FIELD_ELEMENT as usize]) -> Self { + let mut bls_field_element = MaybeUninit::::uninit(); + unsafe { + bytes_to_bls_field(bls_field_element.as_mut_ptr(), bytes.as_ptr()); + bls_field_element.assume_init() + } + } +} + +impl KZGSettings { + pub fn load_trusted_setup(file_path: PathBuf) -> Result { + let file_path = CString::new(file_path.as_os_str().as_bytes()).unwrap(); + let mut kzg_settings = MaybeUninit::::uninit(); + unsafe { + let file_ptr = fopen(file_path.as_ptr(), &('r' as libc::c_char)); + let res = load_trusted_setup(kzg_settings.as_mut_ptr(), file_ptr); + if let C_KZG_RET::C_KZG_OK = res { + Ok(kzg_settings.assume_init()) + } else { + Err(res) + } + } + } +} + +impl Drop for KZGSettings { + fn drop(&mut self) { + unsafe { free_trusted_setup(self) } + } +} + +impl KZGProof { + pub fn compute_aggregate_kzg_proof( + blobs: &[Blob], + kzg_settings: &KZGSettings, + ) -> Result { + let mut kzg_proof = MaybeUninit::::uninit(); + unsafe { + let res = compute_aggregate_kzg_proof( + kzg_proof.as_mut_ptr(), + blobs.as_ptr(), + blobs.len(), + kzg_settings, + ); + if let C_KZG_RET::C_KZG_OK = res { + Ok(kzg_proof.assume_init()) + } else { + Err(res) + } + } + } + + pub fn verify_aggregate_kzg_proof( + &self, + blobs: &[Blob], + expected_kzg_commitments: &[KZGCommitment], + kzg_settings: &KZGSettings, + ) -> Result { + let mut verified: MaybeUninit = MaybeUninit::uninit(); + unsafe { + let res = verify_aggregate_kzg_proof( + verified.as_mut_ptr(), + blobs.as_ptr(), + expected_kzg_commitments.as_ptr(), + blobs.len(), + self, + kzg_settings, + ); + if let C_KZG_RET::C_KZG_OK = res { + Ok(verified.assume_init()) + } else { + Err(res) + } + } + } + + pub fn verify_kzg_proof( + &self, + kzg_commitment: KZGCommitment, + z: BLSFieldElement, + y: BLSFieldElement, + kzg_settings: &KZGSettings, + ) -> Result { + let mut verified: MaybeUninit = MaybeUninit::uninit(); + unsafe { + let res = verify_kzg_proof( + verified.as_mut_ptr(), + &kzg_commitment, + &z, + &y, + self, + kzg_settings, + ); + if let C_KZG_RET::C_KZG_OK = res { + Ok(verified.assume_init()) + } else { + Err(res) + } + } + } +} + +impl KZGCommitment { + pub fn blob_to_kzg_commitment(mut blob: Blob, kzg_settings: &KZGSettings) -> Self { + let mut kzg_commitment: MaybeUninit = MaybeUninit::uninit(); + unsafe { + blob_to_kzg_commitment(kzg_commitment.as_mut_ptr(), blob.as_mut_ptr(), kzg_settings); + kzg_commitment.assume_init() + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_load() { + { + let a = KZGSettings::load_trusted_setup(PathBuf::from( + "/home/pawan/eth2/c-kzg/src/trusted_setup.txt", + )); + assert!(a.is_ok()); + } + } +} From a1ba482d29b92925f88c2b48a5a4ba2e29a355d3 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Tue, 15 Nov 2022 17:50:43 +0530 Subject: [PATCH 5/9] import fewer c stuff in bindings --- bindings/rust/bindings.rs | 1206 +------------------------------------ 1 file changed, 3 insertions(+), 1203 deletions(-) diff --git a/bindings/rust/bindings.rs b/bindings/rust/bindings.rs index f2eb419..3aaddfd 100644 --- a/bindings/rust/bindings.rs +++ b/bindings/rust/bindings.rs @@ -1,1213 +1,13 @@ /* automatically generated by rust-bindgen 0.61.0 */ -pub const _STDIO_H: u32 = 1; -pub const _FEATURES_H: u32 = 1; -pub const _DEFAULT_SOURCE: u32 = 1; -pub const __GLIBC_USE_ISOC2X: u32 = 0; -pub const __USE_ISOC11: u32 = 1; -pub const __USE_ISOC99: u32 = 1; -pub const __USE_ISOC95: u32 = 1; -pub const __USE_POSIX_IMPLICITLY: u32 = 1; -pub const _POSIX_SOURCE: u32 = 1; -pub const _POSIX_C_SOURCE: u32 = 200809; -pub const __USE_POSIX: u32 = 1; -pub const __USE_POSIX2: u32 = 1; -pub const __USE_POSIX199309: u32 = 1; -pub const __USE_POSIX199506: u32 = 1; -pub const __USE_XOPEN2K: u32 = 1; -pub const __USE_XOPEN2K8: u32 = 1; -pub const _ATFILE_SOURCE: u32 = 1; -pub const __USE_MISC: u32 = 1; -pub const __USE_ATFILE: u32 = 1; -pub const __USE_FORTIFY_LEVEL: u32 = 0; -pub const __GLIBC_USE_DEPRECATED_GETS: u32 = 0; -pub const __GLIBC_USE_DEPRECATED_SCANF: u32 = 0; -pub const _STDC_PREDEF_H: u32 = 1; -pub const __STDC_IEC_559__: u32 = 1; -pub const __STDC_IEC_559_COMPLEX__: u32 = 1; -pub const __STDC_ISO_10646__: u32 = 201706; -pub const __GNU_LIBRARY__: u32 = 6; -pub const __GLIBC__: u32 = 2; -pub const __GLIBC_MINOR__: u32 = 31; -pub const _SYS_CDEFS_H: u32 = 1; -pub const __glibc_c99_flexarr_available: u32 = 1; -pub const __WORDSIZE: u32 = 64; -pub const __WORDSIZE_TIME64_COMPAT32: u32 = 1; -pub const __SYSCALL_WORDSIZE: u32 = 64; -pub const __LONG_DOUBLE_USES_FLOAT128: u32 = 0; -pub const __HAVE_GENERIC_SELECTION: u32 = 1; -pub const __GLIBC_USE_LIB_EXT2: u32 = 0; -pub const __GLIBC_USE_IEC_60559_BFP_EXT: u32 = 0; -pub const __GLIBC_USE_IEC_60559_BFP_EXT_C2X: u32 = 0; -pub const __GLIBC_USE_IEC_60559_FUNCS_EXT: u32 = 0; -pub const __GLIBC_USE_IEC_60559_FUNCS_EXT_C2X: u32 = 0; -pub const __GLIBC_USE_IEC_60559_TYPES_EXT: u32 = 0; -pub const __GNUC_VA_LIST: u32 = 1; -pub const _BITS_TYPES_H: u32 = 1; -pub const __TIMESIZE: u32 = 64; -pub const _BITS_TYPESIZES_H: u32 = 1; -pub const __OFF_T_MATCHES_OFF64_T: u32 = 1; -pub const __INO_T_MATCHES_INO64_T: u32 = 1; -pub const __RLIM_T_MATCHES_RLIM64_T: u32 = 1; -pub const __STATFS_MATCHES_STATFS64: u32 = 1; -pub const __FD_SETSIZE: u32 = 1024; -pub const _BITS_TIME64_H: u32 = 1; -pub const _____fpos_t_defined: u32 = 1; -pub const ____mbstate_t_defined: u32 = 1; -pub const _____fpos64_t_defined: u32 = 1; -pub const ____FILE_defined: u32 = 1; -pub const __FILE_defined: u32 = 1; -pub const __struct_FILE_defined: u32 = 1; -pub const _IO_EOF_SEEN: u32 = 16; -pub const _IO_ERR_SEEN: u32 = 32; -pub const _IO_USER_LOCK: u32 = 32768; -pub const _IOFBF: u32 = 0; -pub const _IOLBF: u32 = 1; -pub const _IONBF: u32 = 2; -pub const BUFSIZ: u32 = 8192; -pub const EOF: i32 = -1; -pub const SEEK_SET: u32 = 0; -pub const SEEK_CUR: u32 = 1; -pub const SEEK_END: u32 = 2; -pub const P_tmpdir: &[u8; 5usize] = b"/tmp\0"; -pub const _BITS_STDIO_LIM_H: u32 = 1; -pub const L_tmpnam: u32 = 20; -pub const TMP_MAX: u32 = 238328; -pub const FILENAME_MAX: u32 = 4096; -pub const L_ctermid: u32 = 9; -pub const FOPEN_MAX: u32 = 16; -pub const _STDINT_H: u32 = 1; -pub const _BITS_WCHAR_H: u32 = 1; -pub const _BITS_STDINT_INTN_H: u32 = 1; -pub const _BITS_STDINT_UINTN_H: u32 = 1; -pub const INT8_MIN: i32 = -128; -pub const INT16_MIN: i32 = -32768; -pub const INT32_MIN: i32 = -2147483648; -pub const INT8_MAX: u32 = 127; -pub const INT16_MAX: u32 = 32767; -pub const INT32_MAX: u32 = 2147483647; -pub const UINT8_MAX: u32 = 255; -pub const UINT16_MAX: u32 = 65535; -pub const UINT32_MAX: u32 = 4294967295; -pub const INT_LEAST8_MIN: i32 = -128; -pub const INT_LEAST16_MIN: i32 = -32768; -pub const INT_LEAST32_MIN: i32 = -2147483648; -pub const INT_LEAST8_MAX: u32 = 127; -pub const INT_LEAST16_MAX: u32 = 32767; -pub const INT_LEAST32_MAX: u32 = 2147483647; -pub const UINT_LEAST8_MAX: u32 = 255; -pub const UINT_LEAST16_MAX: u32 = 65535; -pub const UINT_LEAST32_MAX: u32 = 4294967295; -pub const INT_FAST8_MIN: i32 = -128; -pub const INT_FAST16_MIN: i64 = -9223372036854775808; -pub const INT_FAST32_MIN: i64 = -9223372036854775808; -pub const INT_FAST8_MAX: u32 = 127; -pub const INT_FAST16_MAX: u64 = 9223372036854775807; -pub const INT_FAST32_MAX: u64 = 9223372036854775807; -pub const UINT_FAST8_MAX: u32 = 255; -pub const UINT_FAST16_MAX: i32 = -1; -pub const UINT_FAST32_MAX: i32 = -1; -pub const INTPTR_MIN: i64 = -9223372036854775808; -pub const INTPTR_MAX: u64 = 9223372036854775807; -pub const UINTPTR_MAX: i32 = -1; -pub const PTRDIFF_MIN: i64 = -9223372036854775808; -pub const PTRDIFF_MAX: u64 = 9223372036854775807; -pub const SIG_ATOMIC_MIN: i32 = -2147483648; -pub const SIG_ATOMIC_MAX: u32 = 2147483647; -pub const SIZE_MAX: i32 = -1; -pub const WINT_MIN: u32 = 0; -pub const WINT_MAX: u32 = 4294967295; -pub const true_: u32 = 1; -pub const false_: u32 = 0; -pub const __bool_true_false_are_defined: u32 = 1; +use libc::{fopen, FILE}; + pub const BYTES_PER_COMMITMENT: u32 = 48; pub const BYTES_PER_PROOF: u32 = 48; pub const FIELD_ELEMENTS_PER_BLOB: u32 = 4096; pub const BYTES_PER_FIELD_ELEMENT: u32 = 32; pub const BYTES_PER_BLOB: u32 = 131072; -pub type va_list = __builtin_va_list; -pub type __gnuc_va_list = __builtin_va_list; -pub type __u_char = ::std::os::raw::c_uchar; -pub type __u_short = ::std::os::raw::c_ushort; -pub type __u_int = ::std::os::raw::c_uint; -pub type __u_long = ::std::os::raw::c_ulong; -pub type __int8_t = ::std::os::raw::c_schar; -pub type __uint8_t = ::std::os::raw::c_uchar; -pub type __int16_t = ::std::os::raw::c_short; -pub type __uint16_t = ::std::os::raw::c_ushort; -pub type __int32_t = ::std::os::raw::c_int; -pub type __uint32_t = ::std::os::raw::c_uint; -pub type __int64_t = ::std::os::raw::c_long; -pub type __uint64_t = ::std::os::raw::c_ulong; -pub type __int_least8_t = __int8_t; -pub type __uint_least8_t = __uint8_t; -pub type __int_least16_t = __int16_t; -pub type __uint_least16_t = __uint16_t; -pub type __int_least32_t = __int32_t; -pub type __uint_least32_t = __uint32_t; -pub type __int_least64_t = __int64_t; -pub type __uint_least64_t = __uint64_t; -pub type __quad_t = ::std::os::raw::c_long; -pub type __u_quad_t = ::std::os::raw::c_ulong; -pub type __intmax_t = ::std::os::raw::c_long; -pub type __uintmax_t = ::std::os::raw::c_ulong; -pub type __dev_t = ::std::os::raw::c_ulong; -pub type __uid_t = ::std::os::raw::c_uint; -pub type __gid_t = ::std::os::raw::c_uint; -pub type __ino_t = ::std::os::raw::c_ulong; -pub type __ino64_t = ::std::os::raw::c_ulong; -pub type __mode_t = ::std::os::raw::c_uint; -pub type __nlink_t = ::std::os::raw::c_ulong; -pub type __off_t = ::std::os::raw::c_long; -pub type __off64_t = ::std::os::raw::c_long; -pub type __pid_t = ::std::os::raw::c_int; -#[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub struct __fsid_t { - pub __val: [::std::os::raw::c_int; 2usize], -} -#[test] -fn bindgen_test_layout___fsid_t() { - const UNINIT: ::std::mem::MaybeUninit<__fsid_t> = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::<__fsid_t>(), - 8usize, - concat!("Size of: ", stringify!(__fsid_t)) - ); - assert_eq!( - ::std::mem::align_of::<__fsid_t>(), - 4usize, - concat!("Alignment of ", stringify!(__fsid_t)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).__val) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__fsid_t), - "::", - stringify!(__val) - ) - ); -} -pub type __clock_t = ::std::os::raw::c_long; -pub type __rlim_t = ::std::os::raw::c_ulong; -pub type __rlim64_t = ::std::os::raw::c_ulong; -pub type __id_t = ::std::os::raw::c_uint; -pub type __time_t = ::std::os::raw::c_long; -pub type __useconds_t = ::std::os::raw::c_uint; -pub type __suseconds_t = ::std::os::raw::c_long; -pub type __daddr_t = ::std::os::raw::c_int; -pub type __key_t = ::std::os::raw::c_int; -pub type __clockid_t = ::std::os::raw::c_int; -pub type __timer_t = *mut ::std::os::raw::c_void; -pub type __blksize_t = ::std::os::raw::c_long; -pub type __blkcnt_t = ::std::os::raw::c_long; -pub type __blkcnt64_t = ::std::os::raw::c_long; -pub type __fsblkcnt_t = ::std::os::raw::c_ulong; -pub type __fsblkcnt64_t = ::std::os::raw::c_ulong; -pub type __fsfilcnt_t = ::std::os::raw::c_ulong; -pub type __fsfilcnt64_t = ::std::os::raw::c_ulong; -pub type __fsword_t = ::std::os::raw::c_long; -pub type __ssize_t = ::std::os::raw::c_long; -pub type __syscall_slong_t = ::std::os::raw::c_long; -pub type __syscall_ulong_t = ::std::os::raw::c_ulong; -pub type __loff_t = __off64_t; -pub type __caddr_t = *mut ::std::os::raw::c_char; -pub type __intptr_t = ::std::os::raw::c_long; -pub type __socklen_t = ::std::os::raw::c_uint; -pub type __sig_atomic_t = ::std::os::raw::c_int; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct __mbstate_t { - pub __count: ::std::os::raw::c_int, - pub __value: __mbstate_t__bindgen_ty_1, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub union __mbstate_t__bindgen_ty_1 { - pub __wch: ::std::os::raw::c_uint, - pub __wchb: [::std::os::raw::c_char; 4usize], -} -#[test] -fn bindgen_test_layout___mbstate_t__bindgen_ty_1() { - const UNINIT: ::std::mem::MaybeUninit<__mbstate_t__bindgen_ty_1> = - ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::<__mbstate_t__bindgen_ty_1>(), - 4usize, - concat!("Size of: ", stringify!(__mbstate_t__bindgen_ty_1)) - ); - assert_eq!( - ::std::mem::align_of::<__mbstate_t__bindgen_ty_1>(), - 4usize, - concat!("Alignment of ", stringify!(__mbstate_t__bindgen_ty_1)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).__wch) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__mbstate_t__bindgen_ty_1), - "::", - stringify!(__wch) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).__wchb) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__mbstate_t__bindgen_ty_1), - "::", - stringify!(__wchb) - ) - ); -} -#[test] -fn bindgen_test_layout___mbstate_t() { - const UNINIT: ::std::mem::MaybeUninit<__mbstate_t> = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::<__mbstate_t>(), - 8usize, - concat!("Size of: ", stringify!(__mbstate_t)) - ); - assert_eq!( - ::std::mem::align_of::<__mbstate_t>(), - 4usize, - concat!("Alignment of ", stringify!(__mbstate_t)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).__count) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__mbstate_t), - "::", - stringify!(__count) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).__value) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(__mbstate_t), - "::", - stringify!(__value) - ) - ); -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _G_fpos_t { - pub __pos: __off_t, - pub __state: __mbstate_t, -} -#[test] -fn bindgen_test_layout__G_fpos_t() { - const UNINIT: ::std::mem::MaybeUninit<_G_fpos_t> = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::<_G_fpos_t>(), - 16usize, - concat!("Size of: ", stringify!(_G_fpos_t)) - ); - assert_eq!( - ::std::mem::align_of::<_G_fpos_t>(), - 8usize, - concat!("Alignment of ", stringify!(_G_fpos_t)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).__pos) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_G_fpos_t), - "::", - stringify!(__pos) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).__state) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_G_fpos_t), - "::", - stringify!(__state) - ) - ); -} -pub type __fpos_t = _G_fpos_t; -#[repr(C)] -#[derive(Copy, Clone)] -pub struct _G_fpos64_t { - pub __pos: __off64_t, - pub __state: __mbstate_t, -} -#[test] -fn bindgen_test_layout__G_fpos64_t() { - const UNINIT: ::std::mem::MaybeUninit<_G_fpos64_t> = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::<_G_fpos64_t>(), - 16usize, - concat!("Size of: ", stringify!(_G_fpos64_t)) - ); - assert_eq!( - ::std::mem::align_of::<_G_fpos64_t>(), - 8usize, - concat!("Alignment of ", stringify!(_G_fpos64_t)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).__pos) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_G_fpos64_t), - "::", - stringify!(__pos) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).__state) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_G_fpos64_t), - "::", - stringify!(__state) - ) - ); -} -pub type __fpos64_t = _G_fpos64_t; -pub type __FILE = _IO_FILE; -pub type FILE = _IO_FILE; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _IO_marker { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _IO_codecvt { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct _IO_wide_data { - _unused: [u8; 0], -} -pub type _IO_lock_t = ::std::os::raw::c_void; -#[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub struct _IO_FILE { - pub _flags: ::std::os::raw::c_int, - pub _IO_read_ptr: *mut ::std::os::raw::c_char, - pub _IO_read_end: *mut ::std::os::raw::c_char, - pub _IO_read_base: *mut ::std::os::raw::c_char, - pub _IO_write_base: *mut ::std::os::raw::c_char, - pub _IO_write_ptr: *mut ::std::os::raw::c_char, - pub _IO_write_end: *mut ::std::os::raw::c_char, - pub _IO_buf_base: *mut ::std::os::raw::c_char, - pub _IO_buf_end: *mut ::std::os::raw::c_char, - pub _IO_save_base: *mut ::std::os::raw::c_char, - pub _IO_backup_base: *mut ::std::os::raw::c_char, - pub _IO_save_end: *mut ::std::os::raw::c_char, - pub _markers: *mut _IO_marker, - pub _chain: *mut _IO_FILE, - pub _fileno: ::std::os::raw::c_int, - pub _flags2: ::std::os::raw::c_int, - pub _old_offset: __off_t, - pub _cur_column: ::std::os::raw::c_ushort, - pub _vtable_offset: ::std::os::raw::c_schar, - pub _shortbuf: [::std::os::raw::c_char; 1usize], - pub _lock: *mut _IO_lock_t, - pub _offset: __off64_t, - pub _codecvt: *mut _IO_codecvt, - pub _wide_data: *mut _IO_wide_data, - pub _freeres_list: *mut _IO_FILE, - pub _freeres_buf: *mut ::std::os::raw::c_void, - pub __pad5: usize, - pub _mode: ::std::os::raw::c_int, - pub _unused2: [::std::os::raw::c_char; 20usize], -} -#[test] -fn bindgen_test_layout__IO_FILE() { - const UNINIT: ::std::mem::MaybeUninit<_IO_FILE> = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::<_IO_FILE>(), - 216usize, - concat!("Size of: ", stringify!(_IO_FILE)) - ); - assert_eq!( - ::std::mem::align_of::<_IO_FILE>(), - 8usize, - concat!("Alignment of ", stringify!(_IO_FILE)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._flags) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_flags) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._IO_read_ptr) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_read_ptr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._IO_read_end) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_read_end) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._IO_read_base) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_read_base) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._IO_write_base) as usize - ptr as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_write_base) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._IO_write_ptr) as usize - ptr as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_write_ptr) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._IO_write_end) as usize - ptr as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_write_end) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._IO_buf_base) as usize - ptr as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_buf_base) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._IO_buf_end) as usize - ptr as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_buf_end) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._IO_save_base) as usize - ptr as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_save_base) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._IO_backup_base) as usize - ptr as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_backup_base) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._IO_save_end) as usize - ptr as usize }, - 88usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_IO_save_end) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._markers) as usize - ptr as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_markers) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._chain) as usize - ptr as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_chain) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._fileno) as usize - ptr as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_fileno) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._flags2) as usize - ptr as usize }, - 116usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_flags2) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._old_offset) as usize - ptr as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_old_offset) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._cur_column) as usize - ptr as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_cur_column) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._vtable_offset) as usize - ptr as usize }, - 130usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_vtable_offset) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._shortbuf) as usize - ptr as usize }, - 131usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_shortbuf) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._lock) as usize - ptr as usize }, - 136usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_lock) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._offset) as usize - ptr as usize }, - 144usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_offset) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._codecvt) as usize - ptr as usize }, - 152usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_codecvt) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._wide_data) as usize - ptr as usize }, - 160usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_wide_data) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._freeres_list) as usize - ptr as usize }, - 168usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_freeres_list) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._freeres_buf) as usize - ptr as usize }, - 176usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_freeres_buf) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).__pad5) as usize - ptr as usize }, - 184usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(__pad5) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._mode) as usize - ptr as usize }, - 192usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_mode) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr)._unused2) as usize - ptr as usize }, - 196usize, - concat!( - "Offset of field: ", - stringify!(_IO_FILE), - "::", - stringify!(_unused2) - ) - ); -} -pub type off_t = __off_t; -pub type fpos_t = __fpos_t; -extern "C" { - pub static mut stdin: *mut FILE; -} -extern "C" { - pub static mut stdout: *mut FILE; -} -extern "C" { - pub static mut stderr: *mut FILE; -} -extern "C" { - pub fn remove(__filename: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn rename( - __old: *const ::std::os::raw::c_char, - __new: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn renameat( - __oldfd: ::std::os::raw::c_int, - __old: *const ::std::os::raw::c_char, - __newfd: ::std::os::raw::c_int, - __new: *const ::std::os::raw::c_char, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn tmpfile() -> *mut FILE; -} -extern "C" { - pub fn tmpnam(__s: *mut ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn tmpnam_r(__s: *mut ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn tempnam( - __dir: *const ::std::os::raw::c_char, - __pfx: *const ::std::os::raw::c_char, - ) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn fclose(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn fflush(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn fflush_unlocked(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn fopen( - __filename: *const ::std::os::raw::c_char, - __modes: *const ::std::os::raw::c_char, - ) -> *mut FILE; -} -extern "C" { - pub fn freopen( - __filename: *const ::std::os::raw::c_char, - __modes: *const ::std::os::raw::c_char, - __stream: *mut FILE, - ) -> *mut FILE; -} -extern "C" { - pub fn fdopen(__fd: ::std::os::raw::c_int, __modes: *const ::std::os::raw::c_char) - -> *mut FILE; -} -extern "C" { - pub fn fmemopen( - __s: *mut ::std::os::raw::c_void, - __len: usize, - __modes: *const ::std::os::raw::c_char, - ) -> *mut FILE; -} -extern "C" { - pub fn open_memstream( - __bufloc: *mut *mut ::std::os::raw::c_char, - __sizeloc: *mut usize, - ) -> *mut FILE; -} -extern "C" { - pub fn setbuf(__stream: *mut FILE, __buf: *mut ::std::os::raw::c_char); -} -extern "C" { - pub fn setvbuf( - __stream: *mut FILE, - __buf: *mut ::std::os::raw::c_char, - __modes: ::std::os::raw::c_int, - __n: usize, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn setbuffer(__stream: *mut FILE, __buf: *mut ::std::os::raw::c_char, __size: usize); -} -extern "C" { - pub fn setlinebuf(__stream: *mut FILE); -} -extern "C" { - pub fn fprintf( - __stream: *mut FILE, - __format: *const ::std::os::raw::c_char, - ... - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn printf(__format: *const ::std::os::raw::c_char, ...) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn sprintf( - __s: *mut ::std::os::raw::c_char, - __format: *const ::std::os::raw::c_char, - ... - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn vfprintf( - __s: *mut FILE, - __format: *const ::std::os::raw::c_char, - __arg: *mut __va_list_tag, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn vprintf( - __format: *const ::std::os::raw::c_char, - __arg: *mut __va_list_tag, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn vsprintf( - __s: *mut ::std::os::raw::c_char, - __format: *const ::std::os::raw::c_char, - __arg: *mut __va_list_tag, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn snprintf( - __s: *mut ::std::os::raw::c_char, - __maxlen: ::std::os::raw::c_ulong, - __format: *const ::std::os::raw::c_char, - ... - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn vsnprintf( - __s: *mut ::std::os::raw::c_char, - __maxlen: ::std::os::raw::c_ulong, - __format: *const ::std::os::raw::c_char, - __arg: *mut __va_list_tag, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn vdprintf( - __fd: ::std::os::raw::c_int, - __fmt: *const ::std::os::raw::c_char, - __arg: *mut __va_list_tag, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn dprintf( - __fd: ::std::os::raw::c_int, - __fmt: *const ::std::os::raw::c_char, - ... - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn fscanf( - __stream: *mut FILE, - __format: *const ::std::os::raw::c_char, - ... - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn scanf(__format: *const ::std::os::raw::c_char, ...) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn sscanf( - __s: *const ::std::os::raw::c_char, - __format: *const ::std::os::raw::c_char, - ... - ) -> ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "\u{1}__isoc99_fscanf"] - pub fn fscanf1( - __stream: *mut FILE, - __format: *const ::std::os::raw::c_char, - ... - ) -> ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "\u{1}__isoc99_scanf"] - pub fn scanf1(__format: *const ::std::os::raw::c_char, ...) -> ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "\u{1}__isoc99_sscanf"] - pub fn sscanf1( - __s: *const ::std::os::raw::c_char, - __format: *const ::std::os::raw::c_char, - ... - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn vfscanf( - __s: *mut FILE, - __format: *const ::std::os::raw::c_char, - __arg: *mut __va_list_tag, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn vscanf( - __format: *const ::std::os::raw::c_char, - __arg: *mut __va_list_tag, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn vsscanf( - __s: *const ::std::os::raw::c_char, - __format: *const ::std::os::raw::c_char, - __arg: *mut __va_list_tag, - ) -> ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "\u{1}__isoc99_vfscanf"] - pub fn vfscanf1( - __s: *mut FILE, - __format: *const ::std::os::raw::c_char, - __arg: *mut __va_list_tag, - ) -> ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "\u{1}__isoc99_vscanf"] - pub fn vscanf1( - __format: *const ::std::os::raw::c_char, - __arg: *mut __va_list_tag, - ) -> ::std::os::raw::c_int; -} -extern "C" { - #[link_name = "\u{1}__isoc99_vsscanf"] - pub fn vsscanf1( - __s: *const ::std::os::raw::c_char, - __format: *const ::std::os::raw::c_char, - __arg: *mut __va_list_tag, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn fgetc(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn getc(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn getchar() -> ::std::os::raw::c_int; -} -extern "C" { - pub fn getc_unlocked(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn getchar_unlocked() -> ::std::os::raw::c_int; -} -extern "C" { - pub fn fgetc_unlocked(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn fputc(__c: ::std::os::raw::c_int, __stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn putc(__c: ::std::os::raw::c_int, __stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn putchar(__c: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn fputc_unlocked(__c: ::std::os::raw::c_int, __stream: *mut FILE) - -> ::std::os::raw::c_int; -} -extern "C" { - pub fn putc_unlocked(__c: ::std::os::raw::c_int, __stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn putchar_unlocked(__c: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn getw(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn putw(__w: ::std::os::raw::c_int, __stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn fgets( - __s: *mut ::std::os::raw::c_char, - __n: ::std::os::raw::c_int, - __stream: *mut FILE, - ) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn __getdelim( - __lineptr: *mut *mut ::std::os::raw::c_char, - __n: *mut usize, - __delimiter: ::std::os::raw::c_int, - __stream: *mut FILE, - ) -> __ssize_t; -} -extern "C" { - pub fn getdelim( - __lineptr: *mut *mut ::std::os::raw::c_char, - __n: *mut usize, - __delimiter: ::std::os::raw::c_int, - __stream: *mut FILE, - ) -> __ssize_t; -} -extern "C" { - pub fn getline( - __lineptr: *mut *mut ::std::os::raw::c_char, - __n: *mut usize, - __stream: *mut FILE, - ) -> __ssize_t; -} -extern "C" { - pub fn fputs(__s: *const ::std::os::raw::c_char, __stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn puts(__s: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn ungetc(__c: ::std::os::raw::c_int, __stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn fread( - __ptr: *mut ::std::os::raw::c_void, - __size: ::std::os::raw::c_ulong, - __n: ::std::os::raw::c_ulong, - __stream: *mut FILE, - ) -> ::std::os::raw::c_ulong; -} -extern "C" { - pub fn fwrite( - __ptr: *const ::std::os::raw::c_void, - __size: ::std::os::raw::c_ulong, - __n: ::std::os::raw::c_ulong, - __s: *mut FILE, - ) -> ::std::os::raw::c_ulong; -} -extern "C" { - pub fn fread_unlocked( - __ptr: *mut ::std::os::raw::c_void, - __size: usize, - __n: usize, - __stream: *mut FILE, - ) -> usize; -} -extern "C" { - pub fn fwrite_unlocked( - __ptr: *const ::std::os::raw::c_void, - __size: usize, - __n: usize, - __stream: *mut FILE, - ) -> usize; -} -extern "C" { - pub fn fseek( - __stream: *mut FILE, - __off: ::std::os::raw::c_long, - __whence: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn ftell(__stream: *mut FILE) -> ::std::os::raw::c_long; -} -extern "C" { - pub fn rewind(__stream: *mut FILE); -} -extern "C" { - pub fn fseeko( - __stream: *mut FILE, - __off: __off_t, - __whence: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn ftello(__stream: *mut FILE) -> __off_t; -} -extern "C" { - pub fn fgetpos(__stream: *mut FILE, __pos: *mut fpos_t) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn fsetpos(__stream: *mut FILE, __pos: *const fpos_t) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn clearerr(__stream: *mut FILE); -} -extern "C" { - pub fn feof(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn ferror(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn clearerr_unlocked(__stream: *mut FILE); -} -extern "C" { - pub fn feof_unlocked(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn ferror_unlocked(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn perror(__s: *const ::std::os::raw::c_char); -} -extern "C" { - pub static mut sys_nerr: ::std::os::raw::c_int; -} -extern "C" { - pub static sys_errlist: [*const ::std::os::raw::c_char; 0usize]; -} -extern "C" { - pub fn fileno(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn fileno_unlocked(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn popen( - __command: *const ::std::os::raw::c_char, - __modes: *const ::std::os::raw::c_char, - ) -> *mut FILE; -} -extern "C" { - pub fn pclose(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn ctermid(__s: *mut ::std::os::raw::c_char) -> *mut ::std::os::raw::c_char; -} -extern "C" { - pub fn flockfile(__stream: *mut FILE); -} -extern "C" { - pub fn ftrylockfile(__stream: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn funlockfile(__stream: *mut FILE); -} -extern "C" { - pub fn __uflow(arg1: *mut FILE) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn __overflow(arg1: *mut FILE, arg2: ::std::os::raw::c_int) -> ::std::os::raw::c_int; -} -pub type int_least8_t = __int_least8_t; -pub type int_least16_t = __int_least16_t; -pub type int_least32_t = __int_least32_t; -pub type int_least64_t = __int_least64_t; -pub type uint_least8_t = __uint_least8_t; -pub type uint_least16_t = __uint_least16_t; -pub type uint_least32_t = __uint_least32_t; -pub type uint_least64_t = __uint_least64_t; -pub type int_fast8_t = ::std::os::raw::c_schar; -pub type int_fast16_t = ::std::os::raw::c_long; -pub type int_fast32_t = ::std::os::raw::c_long; -pub type int_fast64_t = ::std::os::raw::c_long; -pub type uint_fast8_t = ::std::os::raw::c_uchar; -pub type uint_fast16_t = ::std::os::raw::c_ulong; -pub type uint_fast32_t = ::std::os::raw::c_ulong; -pub type uint_fast64_t = ::std::os::raw::c_ulong; -pub type intmax_t = __intmax_t; -pub type uintmax_t = __uintmax_t; + #[repr(u32)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum BLST_ERROR { From 99e142f6980eb3115365a0da9d8e3d328608405b Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Tue, 15 Nov 2022 18:13:21 +0530 Subject: [PATCH 6/9] remove unnecessary blst definitions in bindings --- bindings/rust/bindings.rs | 739 +------------------------------------- 1 file changed, 5 insertions(+), 734 deletions(-) diff --git a/bindings/rust/bindings.rs b/bindings/rust/bindings.rs index 3aaddfd..517e54e 100644 --- a/bindings/rust/bindings.rs +++ b/bindings/rust/bindings.rs @@ -8,18 +8,6 @@ pub const FIELD_ELEMENTS_PER_BLOB: u32 = 4096; pub const BYTES_PER_FIELD_ELEMENT: u32 = 32; pub const BYTES_PER_BLOB: u32 = 131072; -#[repr(u32)] -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub enum BLST_ERROR { - BLST_SUCCESS = 0, - BLST_BAD_ENCODING = 1, - BLST_POINT_NOT_ON_CURVE = 2, - BLST_POINT_NOT_IN_GROUP = 3, - BLST_AGGR_TYPE_MISMATCH = 4, - BLST_VERIFY_FAIL = 5, - BLST_PK_IS_INFINITY = 6, - BLST_BAD_SCALAR = 7, -} pub type byte = u8; pub type limb_t = u64; #[repr(C)] @@ -202,235 +190,7 @@ fn bindgen_test_layout_blst_fp12() { ) ); } -extern "C" { - pub fn blst_scalar_from_uint32(out: *mut blst_scalar, a: *const u32); -} -extern "C" { - pub fn blst_uint32_from_scalar(out: *mut u32, a: *const blst_scalar); -} -extern "C" { - pub fn blst_scalar_from_uint64(out: *mut blst_scalar, a: *const u64); -} -extern "C" { - pub fn blst_uint64_from_scalar(out: *mut u64, a: *const blst_scalar); -} -extern "C" { - pub fn blst_scalar_from_bendian(out: *mut blst_scalar, a: *const byte); -} -extern "C" { - pub fn blst_bendian_from_scalar(out: *mut byte, a: *const blst_scalar); -} -extern "C" { - pub fn blst_scalar_from_lendian(out: *mut blst_scalar, a: *const byte); -} -extern "C" { - pub fn blst_lendian_from_scalar(out: *mut byte, a: *const blst_scalar); -} -extern "C" { - pub fn blst_scalar_fr_check(a: *const blst_scalar) -> bool; -} -extern "C" { - pub fn blst_sk_check(a: *const blst_scalar) -> bool; -} -extern "C" { - pub fn blst_sk_add_n_check( - out: *mut blst_scalar, - a: *const blst_scalar, - b: *const blst_scalar, - ) -> bool; -} -extern "C" { - pub fn blst_sk_sub_n_check( - out: *mut blst_scalar, - a: *const blst_scalar, - b: *const blst_scalar, - ) -> bool; -} -extern "C" { - pub fn blst_sk_mul_n_check( - out: *mut blst_scalar, - a: *const blst_scalar, - b: *const blst_scalar, - ) -> bool; -} -extern "C" { - pub fn blst_sk_inverse(out: *mut blst_scalar, a: *const blst_scalar); -} -extern "C" { - pub fn blst_scalar_from_le_bytes(out: *mut blst_scalar, in_: *const byte, len: usize) -> bool; -} -extern "C" { - pub fn blst_scalar_from_be_bytes(out: *mut blst_scalar, in_: *const byte, len: usize) -> bool; -} -extern "C" { - pub fn blst_fr_add(ret: *mut blst_fr, a: *const blst_fr, b: *const blst_fr); -} -extern "C" { - pub fn blst_fr_sub(ret: *mut blst_fr, a: *const blst_fr, b: *const blst_fr); -} -extern "C" { - pub fn blst_fr_mul_by_3(ret: *mut blst_fr, a: *const blst_fr); -} -extern "C" { - pub fn blst_fr_lshift(ret: *mut blst_fr, a: *const blst_fr, count: usize); -} -extern "C" { - pub fn blst_fr_rshift(ret: *mut blst_fr, a: *const blst_fr, count: usize); -} -extern "C" { - pub fn blst_fr_mul(ret: *mut blst_fr, a: *const blst_fr, b: *const blst_fr); -} -extern "C" { - pub fn blst_fr_sqr(ret: *mut blst_fr, a: *const blst_fr); -} -extern "C" { - pub fn blst_fr_cneg(ret: *mut blst_fr, a: *const blst_fr, flag: bool); -} -extern "C" { - pub fn blst_fr_eucl_inverse(ret: *mut blst_fr, a: *const blst_fr); -} -extern "C" { - pub fn blst_fr_inverse(ret: *mut blst_fr, a: *const blst_fr); -} -extern "C" { - pub fn blst_fr_from_uint64(ret: *mut blst_fr, a: *const u64); -} -extern "C" { - pub fn blst_uint64_from_fr(ret: *mut u64, a: *const blst_fr); -} -extern "C" { - pub fn blst_fr_from_scalar(ret: *mut blst_fr, a: *const blst_scalar); -} -extern "C" { - pub fn blst_scalar_from_fr(ret: *mut blst_scalar, a: *const blst_fr); -} -extern "C" { - pub fn blst_fp_add(ret: *mut blst_fp, a: *const blst_fp, b: *const blst_fp); -} -extern "C" { - pub fn blst_fp_sub(ret: *mut blst_fp, a: *const blst_fp, b: *const blst_fp); -} -extern "C" { - pub fn blst_fp_mul_by_3(ret: *mut blst_fp, a: *const blst_fp); -} -extern "C" { - pub fn blst_fp_mul_by_8(ret: *mut blst_fp, a: *const blst_fp); -} -extern "C" { - pub fn blst_fp_lshift(ret: *mut blst_fp, a: *const blst_fp, count: usize); -} -extern "C" { - pub fn blst_fp_mul(ret: *mut blst_fp, a: *const blst_fp, b: *const blst_fp); -} -extern "C" { - pub fn blst_fp_sqr(ret: *mut blst_fp, a: *const blst_fp); -} -extern "C" { - pub fn blst_fp_cneg(ret: *mut blst_fp, a: *const blst_fp, flag: bool); -} -extern "C" { - pub fn blst_fp_eucl_inverse(ret: *mut blst_fp, a: *const blst_fp); -} -extern "C" { - pub fn blst_fp_inverse(ret: *mut blst_fp, a: *const blst_fp); -} -extern "C" { - pub fn blst_fp_sqrt(ret: *mut blst_fp, a: *const blst_fp) -> bool; -} -extern "C" { - pub fn blst_fp_from_uint32(ret: *mut blst_fp, a: *const u32); -} -extern "C" { - pub fn blst_uint32_from_fp(ret: *mut u32, a: *const blst_fp); -} -extern "C" { - pub fn blst_fp_from_uint64(ret: *mut blst_fp, a: *const u64); -} -extern "C" { - pub fn blst_uint64_from_fp(ret: *mut u64, a: *const blst_fp); -} -extern "C" { - pub fn blst_fp_from_bendian(ret: *mut blst_fp, a: *const byte); -} -extern "C" { - pub fn blst_bendian_from_fp(ret: *mut byte, a: *const blst_fp); -} -extern "C" { - pub fn blst_fp_from_lendian(ret: *mut blst_fp, a: *const byte); -} -extern "C" { - pub fn blst_lendian_from_fp(ret: *mut byte, a: *const blst_fp); -} -extern "C" { - pub fn blst_fp2_add(ret: *mut blst_fp2, a: *const blst_fp2, b: *const blst_fp2); -} -extern "C" { - pub fn blst_fp2_sub(ret: *mut blst_fp2, a: *const blst_fp2, b: *const blst_fp2); -} -extern "C" { - pub fn blst_fp2_mul_by_3(ret: *mut blst_fp2, a: *const blst_fp2); -} -extern "C" { - pub fn blst_fp2_mul_by_8(ret: *mut blst_fp2, a: *const blst_fp2); -} -extern "C" { - pub fn blst_fp2_lshift(ret: *mut blst_fp2, a: *const blst_fp2, count: usize); -} -extern "C" { - pub fn blst_fp2_mul(ret: *mut blst_fp2, a: *const blst_fp2, b: *const blst_fp2); -} -extern "C" { - pub fn blst_fp2_sqr(ret: *mut blst_fp2, a: *const blst_fp2); -} -extern "C" { - pub fn blst_fp2_cneg(ret: *mut blst_fp2, a: *const blst_fp2, flag: bool); -} -extern "C" { - pub fn blst_fp2_eucl_inverse(ret: *mut blst_fp2, a: *const blst_fp2); -} -extern "C" { - pub fn blst_fp2_inverse(ret: *mut blst_fp2, a: *const blst_fp2); -} -extern "C" { - pub fn blst_fp2_sqrt(ret: *mut blst_fp2, a: *const blst_fp2) -> bool; -} -extern "C" { - pub fn blst_fp12_sqr(ret: *mut blst_fp12, a: *const blst_fp12); -} -extern "C" { - pub fn blst_fp12_cyclotomic_sqr(ret: *mut blst_fp12, a: *const blst_fp12); -} -extern "C" { - pub fn blst_fp12_mul(ret: *mut blst_fp12, a: *const blst_fp12, b: *const blst_fp12); -} -extern "C" { - pub fn blst_fp12_mul_by_xy00z0( - ret: *mut blst_fp12, - a: *const blst_fp12, - xy00z0: *const blst_fp6, - ); -} -extern "C" { - pub fn blst_fp12_conjugate(a: *mut blst_fp12); -} -extern "C" { - pub fn blst_fp12_inverse(ret: *mut blst_fp12, a: *const blst_fp12); -} -extern "C" { - pub fn blst_fp12_frobenius_map(ret: *mut blst_fp12, a: *const blst_fp12, n: usize); -} -extern "C" { - pub fn blst_fp12_is_equal(a: *const blst_fp12, b: *const blst_fp12) -> bool; -} -extern "C" { - pub fn blst_fp12_is_one(a: *const blst_fp12) -> bool; -} -extern "C" { - pub fn blst_fp12_in_group(a: *const blst_fp12) -> bool; -} -extern "C" { - pub fn blst_fp12_one() -> *const blst_fp12; -} + #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct blst_p1 { @@ -524,67 +284,7 @@ fn bindgen_test_layout_blst_p1_affine() { ) ); } -extern "C" { - pub fn blst_p1_add(out: *mut blst_p1, a: *const blst_p1, b: *const blst_p1); -} -extern "C" { - pub fn blst_p1_add_or_double(out: *mut blst_p1, a: *const blst_p1, b: *const blst_p1); -} -extern "C" { - pub fn blst_p1_add_affine(out: *mut blst_p1, a: *const blst_p1, b: *const blst_p1_affine); -} -extern "C" { - pub fn blst_p1_add_or_double_affine( - out: *mut blst_p1, - a: *const blst_p1, - b: *const blst_p1_affine, - ); -} -extern "C" { - pub fn blst_p1_double(out: *mut blst_p1, a: *const blst_p1); -} -extern "C" { - pub fn blst_p1_mult(out: *mut blst_p1, p: *const blst_p1, scalar: *const byte, nbits: usize); -} -extern "C" { - pub fn blst_p1_cneg(p: *mut blst_p1, cbit: bool); -} -extern "C" { - pub fn blst_p1_to_affine(out: *mut blst_p1_affine, in_: *const blst_p1); -} -extern "C" { - pub fn blst_p1_from_affine(out: *mut blst_p1, in_: *const blst_p1_affine); -} -extern "C" { - pub fn blst_p1_on_curve(p: *const blst_p1) -> bool; -} -extern "C" { - pub fn blst_p1_in_g1(p: *const blst_p1) -> bool; -} -extern "C" { - pub fn blst_p1_is_equal(a: *const blst_p1, b: *const blst_p1) -> bool; -} -extern "C" { - pub fn blst_p1_is_inf(a: *const blst_p1) -> bool; -} -extern "C" { - pub fn blst_p1_generator() -> *const blst_p1; -} -extern "C" { - pub fn blst_p1_affine_on_curve(p: *const blst_p1_affine) -> bool; -} -extern "C" { - pub fn blst_p1_affine_in_g1(p: *const blst_p1_affine) -> bool; -} -extern "C" { - pub fn blst_p1_affine_is_equal(a: *const blst_p1_affine, b: *const blst_p1_affine) -> bool; -} -extern "C" { - pub fn blst_p1_affine_is_inf(a: *const blst_p1_affine) -> bool; -} -extern "C" { - pub fn blst_p1_affine_generator() -> *const blst_p1_affine; -} + #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct blst_p2 { @@ -909,331 +609,14 @@ extern "C" { aug_len: usize, ); } -extern "C" { - pub fn blst_p1_serialize(out: *mut byte, in_: *const blst_p1); -} -extern "C" { - pub fn blst_p1_compress(out: *mut byte, in_: *const blst_p1); -} -extern "C" { - pub fn blst_p1_affine_serialize(out: *mut byte, in_: *const blst_p1_affine); -} -extern "C" { - pub fn blst_p1_affine_compress(out: *mut byte, in_: *const blst_p1_affine); -} -extern "C" { - pub fn blst_p1_uncompress(out: *mut blst_p1_affine, in_: *const byte) -> BLST_ERROR; -} -extern "C" { - pub fn blst_p1_deserialize(out: *mut blst_p1_affine, in_: *const byte) -> BLST_ERROR; -} -extern "C" { - pub fn blst_p2_serialize(out: *mut byte, in_: *const blst_p2); -} -extern "C" { - pub fn blst_p2_compress(out: *mut byte, in_: *const blst_p2); -} -extern "C" { - pub fn blst_p2_affine_serialize(out: *mut byte, in_: *const blst_p2_affine); -} -extern "C" { - pub fn blst_p2_affine_compress(out: *mut byte, in_: *const blst_p2_affine); -} -extern "C" { - pub fn blst_p2_uncompress(out: *mut blst_p2_affine, in_: *const byte) -> BLST_ERROR; -} -extern "C" { - pub fn blst_p2_deserialize(out: *mut blst_p2_affine, in_: *const byte) -> BLST_ERROR; -} -extern "C" { - pub fn blst_keygen( - out_SK: *mut blst_scalar, - IKM: *const byte, - IKM_len: usize, - info: *const byte, - info_len: usize, - ); -} -extern "C" { - pub fn blst_sk_to_pk_in_g1(out_pk: *mut blst_p1, SK: *const blst_scalar); -} -extern "C" { - pub fn blst_sign_pk_in_g1(out_sig: *mut blst_p2, hash: *const blst_p2, SK: *const blst_scalar); -} -extern "C" { - pub fn blst_sk_to_pk_in_g2(out_pk: *mut blst_p2, SK: *const blst_scalar); -} -extern "C" { - pub fn blst_sign_pk_in_g2(out_sig: *mut blst_p1, hash: *const blst_p1, SK: *const blst_scalar); -} -extern "C" { - pub fn blst_miller_loop( - ret: *mut blst_fp12, - Q: *const blst_p2_affine, - P: *const blst_p1_affine, - ); -} -extern "C" { - pub fn blst_final_exp(ret: *mut blst_fp12, f: *const blst_fp12); -} -extern "C" { - pub fn blst_precompute_lines(Qlines: *mut blst_fp6, Q: *const blst_p2_affine); -} -extern "C" { - pub fn blst_miller_loop_lines( - ret: *mut blst_fp12, - Qlines: *const blst_fp6, - P: *const blst_p1_affine, - ); -} -extern "C" { - pub fn blst_fp12_finalverify(gt1: *const blst_fp12, gt2: *const blst_fp12) -> bool; -} + #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct blst_opaque { _unused: [u8; 0], } pub type blst_pairing = blst_opaque; -extern "C" { - pub fn blst_pairing_sizeof() -> usize; -} -extern "C" { - pub fn blst_pairing_init( - new_ctx: *mut blst_pairing, - hash_or_encode: bool, - DST: *const byte, - DST_len: usize, - ); -} -extern "C" { - pub fn blst_pairing_get_dst(ctx: *const blst_pairing) -> *const byte; -} -extern "C" { - pub fn blst_pairing_commit(ctx: *mut blst_pairing); -} -extern "C" { - pub fn blst_pairing_aggregate_pk_in_g2( - ctx: *mut blst_pairing, - PK: *const blst_p2_affine, - signature: *const blst_p1_affine, - msg: *const byte, - msg_len: usize, - aug: *const byte, - aug_len: usize, - ) -> BLST_ERROR; -} -extern "C" { - pub fn blst_pairing_chk_n_aggr_pk_in_g2( - ctx: *mut blst_pairing, - PK: *const blst_p2_affine, - pk_grpchk: bool, - signature: *const blst_p1_affine, - sig_grpchk: bool, - msg: *const byte, - msg_len: usize, - aug: *const byte, - aug_len: usize, - ) -> BLST_ERROR; -} -extern "C" { - pub fn blst_pairing_mul_n_aggregate_pk_in_g2( - ctx: *mut blst_pairing, - PK: *const blst_p2_affine, - sig: *const blst_p1_affine, - scalar: *const byte, - nbits: usize, - msg: *const byte, - msg_len: usize, - aug: *const byte, - aug_len: usize, - ) -> BLST_ERROR; -} -extern "C" { - pub fn blst_pairing_chk_n_mul_n_aggr_pk_in_g2( - ctx: *mut blst_pairing, - PK: *const blst_p2_affine, - pk_grpchk: bool, - sig: *const blst_p1_affine, - sig_grpchk: bool, - scalar: *const byte, - nbits: usize, - msg: *const byte, - msg_len: usize, - aug: *const byte, - aug_len: usize, - ) -> BLST_ERROR; -} -extern "C" { - pub fn blst_pairing_aggregate_pk_in_g1( - ctx: *mut blst_pairing, - PK: *const blst_p1_affine, - signature: *const blst_p2_affine, - msg: *const byte, - msg_len: usize, - aug: *const byte, - aug_len: usize, - ) -> BLST_ERROR; -} -extern "C" { - pub fn blst_pairing_chk_n_aggr_pk_in_g1( - ctx: *mut blst_pairing, - PK: *const blst_p1_affine, - pk_grpchk: bool, - signature: *const blst_p2_affine, - sig_grpchk: bool, - msg: *const byte, - msg_len: usize, - aug: *const byte, - aug_len: usize, - ) -> BLST_ERROR; -} -extern "C" { - pub fn blst_pairing_mul_n_aggregate_pk_in_g1( - ctx: *mut blst_pairing, - PK: *const blst_p1_affine, - sig: *const blst_p2_affine, - scalar: *const byte, - nbits: usize, - msg: *const byte, - msg_len: usize, - aug: *const byte, - aug_len: usize, - ) -> BLST_ERROR; -} -extern "C" { - pub fn blst_pairing_chk_n_mul_n_aggr_pk_in_g1( - ctx: *mut blst_pairing, - PK: *const blst_p1_affine, - pk_grpchk: bool, - sig: *const blst_p2_affine, - sig_grpchk: bool, - scalar: *const byte, - nbits: usize, - msg: *const byte, - msg_len: usize, - aug: *const byte, - aug_len: usize, - ) -> BLST_ERROR; -} -extern "C" { - pub fn blst_pairing_merge(ctx: *mut blst_pairing, ctx1: *const blst_pairing) -> BLST_ERROR; -} -extern "C" { - pub fn blst_pairing_finalverify(ctx: *const blst_pairing, gtsig: *const blst_fp12) -> bool; -} -extern "C" { - pub fn blst_aggregate_in_g1( - out: *mut blst_p1, - in_: *const blst_p1, - zwire: *const byte, - ) -> BLST_ERROR; -} -extern "C" { - pub fn blst_aggregate_in_g2( - out: *mut blst_p2, - in_: *const blst_p2, - zwire: *const byte, - ) -> BLST_ERROR; -} -extern "C" { - pub fn blst_aggregated_in_g1(out: *mut blst_fp12, signature: *const blst_p1_affine); -} -extern "C" { - pub fn blst_aggregated_in_g2(out: *mut blst_fp12, signature: *const blst_p2_affine); -} -extern "C" { - pub fn blst_core_verify_pk_in_g1( - pk: *const blst_p1_affine, - signature: *const blst_p2_affine, - hash_or_encode: bool, - msg: *const byte, - msg_len: usize, - DST: *const byte, - DST_len: usize, - aug: *const byte, - aug_len: usize, - ) -> BLST_ERROR; -} -extern "C" { - pub fn blst_core_verify_pk_in_g2( - pk: *const blst_p2_affine, - signature: *const blst_p1_affine, - hash_or_encode: bool, - msg: *const byte, - msg_len: usize, - DST: *const byte, - DST_len: usize, - aug: *const byte, - aug_len: usize, - ) -> BLST_ERROR; -} -extern "C" { - pub static BLS12_381_G1: blst_p1_affine; -} -extern "C" { - pub static BLS12_381_NEG_G1: blst_p1_affine; -} -extern "C" { - pub static BLS12_381_G2: blst_p2_affine; -} -extern "C" { - pub static BLS12_381_NEG_G2: blst_p2_affine; -} -extern "C" { - pub fn blst_fr_to(ret: *mut blst_fr, a: *const blst_fr); -} -extern "C" { - pub fn blst_fr_from(ret: *mut blst_fr, a: *const blst_fr); -} -extern "C" { - pub fn blst_fp_to(ret: *mut blst_fp, a: *const blst_fp); -} -extern "C" { - pub fn blst_fp_from(ret: *mut blst_fp, a: *const blst_fp); -} -extern "C" { - pub fn blst_fp_is_square(a: *const blst_fp) -> bool; -} -extern "C" { - pub fn blst_fp2_is_square(a: *const blst_fp2) -> bool; -} -extern "C" { - pub fn blst_p1_from_jacobian(out: *mut blst_p1, in_: *const blst_p1); -} -extern "C" { - pub fn blst_p2_from_jacobian(out: *mut blst_p2, in_: *const blst_p2); -} -extern "C" { - pub fn blst_sk_to_pk2_in_g1( - out: *mut byte, - out_pk: *mut blst_p1_affine, - SK: *const blst_scalar, - ); -} -extern "C" { - pub fn blst_sign_pk2_in_g1( - out: *mut byte, - out_sig: *mut blst_p2_affine, - hash: *const blst_p2, - SK: *const blst_scalar, - ); -} -extern "C" { - pub fn blst_sk_to_pk2_in_g2( - out: *mut byte, - out_pk: *mut blst_p2_affine, - SK: *const blst_scalar, - ); -} -extern "C" { - pub fn blst_sign_pk2_in_g2( - out: *mut byte, - out_sig: *mut blst_p1_affine, - hash: *const blst_p1, - SK: *const blst_scalar, - ); -} + #[repr(C)] #[repr(align(1))] #[derive(Debug, Copy, Clone, PartialEq, Eq)] @@ -1253,119 +636,7 @@ fn bindgen_test_layout_blst_uniq() { concat!("Alignment of ", stringify!(blst_uniq)) ); } -extern "C" { - pub fn blst_uniq_sizeof(n_nodes: usize) -> usize; -} -extern "C" { - pub fn blst_uniq_init(tree: *mut blst_uniq); -} -extern "C" { - pub fn blst_uniq_test(tree: *mut blst_uniq, msg: *const byte, len: usize) -> bool; -} -extern "C" { - pub fn blst_expand_message_xmd( - out: *mut byte, - out_len: usize, - msg: *const byte, - msg_len: usize, - DST: *const byte, - DST_len: usize, - ); -} -extern "C" { - pub fn blst_p1_unchecked_mult( - out: *mut blst_p1, - p: *const blst_p1, - scalar: *const byte, - nbits: usize, - ); -} -extern "C" { - pub fn blst_p2_unchecked_mult( - out: *mut blst_p2, - p: *const blst_p2, - scalar: *const byte, - nbits: usize, - ); -} -extern "C" { - pub fn blst_pairing_raw_aggregate( - ctx: *mut blst_pairing, - q: *const blst_p2_affine, - p: *const blst_p1_affine, - ); -} -extern "C" { - pub fn blst_pairing_as_fp12(ctx: *mut blst_pairing) -> *mut blst_fp12; -} -extern "C" { - pub fn blst_bendian_from_fp12(out: *mut byte, a: *const blst_fp12); -} -extern "C" { - pub fn blst_keygen_v3( - out_SK: *mut blst_scalar, - IKM: *const byte, - IKM_len: usize, - info: *const byte, - info_len: usize, - ); -} -extern "C" { - pub fn blst_keygen_v4_5( - out_SK: *mut blst_scalar, - IKM: *const byte, - IKM_len: usize, - salt: *const byte, - salt_len: usize, - info: *const byte, - info_len: usize, - ); -} -extern "C" { - pub fn blst_keygen_v5( - out_SK: *mut blst_scalar, - IKM: *const byte, - IKM_len: usize, - salt: *const byte, - salt_len: usize, - info: *const byte, - info_len: usize, - ); -} -extern "C" { - pub fn blst_derive_master_eip2333(out_SK: *mut blst_scalar, IKM: *const byte, IKM_len: usize); -} -extern "C" { - pub fn blst_derive_child_eip2333( - out_SK: *mut blst_scalar, - SK: *const blst_scalar, - child_index: u32, - ); -} -extern "C" { - pub fn blst_scalar_from_hexascii(out: *mut blst_scalar, hex: *const byte); -} -extern "C" { - pub fn blst_fr_from_hexascii(ret: *mut blst_fr, hex: *const byte); -} -extern "C" { - pub fn blst_fp_from_hexascii(ret: *mut blst_fp, hex: *const byte); -} -extern "C" { - pub fn blst_p1_sizeof() -> usize; -} -extern "C" { - pub fn blst_p1_affine_sizeof() -> usize; -} -extern "C" { - pub fn blst_p2_sizeof() -> usize; -} -extern "C" { - pub fn blst_p2_affine_sizeof() -> usize; -} -extern "C" { - pub fn blst_fp12_sizeof() -> usize; -} + extern "C" { pub static FIAT_SHAMIR_PROTOCOL_DOMAIN: [u8; 16usize]; } From c1d6b321ce3e4e37174e7af93dd3e05ed23d4948 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Tue, 15 Nov 2022 18:53:02 +0530 Subject: [PATCH 7/9] remove bindgen build dependency --- bindings/rust/Cargo.lock | 227 --------------------------------------- bindings/rust/Cargo.toml | 4 - 2 files changed, 231 deletions(-) diff --git a/bindings/rust/Cargo.lock b/bindings/rust/Cargo.lock index 9753fe7..59994af 100644 --- a/bindings/rust/Cargo.lock +++ b/bindings/rust/Cargo.lock @@ -2,242 +2,15 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "bindgen" -version = "0.61.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a022e58a142a46fea340d68012b9201c094e93ec3d033a944a24f8fd4a4f09a" -dependencies = [ - "bitflags", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "log", - "peeking_take_while", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn", - "which", -] - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "c-kzg" version = "0.1.0" dependencies = [ - "bindgen", - "libc", -] - -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "clang-sys" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" -dependencies = [ - "glob", "libc", - "libloading", ] -[[package]] -name = "either" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" - -[[package]] -name = "glob" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "libc" version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" - -[[package]] -name = "libloading" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" -dependencies = [ - "cfg-if", - "winapi", -] - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - -[[package]] -name = "nom" -version = "7.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "once_cell" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" - -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - -[[package]] -name = "proc-macro2" -version = "1.0.47" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "regex" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" -dependencies = [ - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "shlex" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" - -[[package]] -name = "syn" -version = "1.0.103" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" - -[[package]] -name = "which" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" -dependencies = [ - "either", - "libc", - "once_cell", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/bindings/rust/Cargo.toml b/bindings/rust/Cargo.toml index 02d1d6a..5b8de57 100644 --- a/bindings/rust/Cargo.toml +++ b/bindings/rust/Cargo.toml @@ -5,10 +5,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[build-dependencies] -bindgen = "0.61.0" - [dependencies] libc = "0.2" From bd56f0d2154cc40bdc00acac0ac15a21265eb988 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Wed, 16 Nov 2022 20:08:20 +0530 Subject: [PATCH 8/9] improve interface --- bindings/rust/Cargo.lock | 7 + bindings/rust/Cargo.toml | 1 + bindings/rust/build.rs | 2 +- bindings/rust/{ => src}/bindings.rs | 314 +--------------------------- bindings/rust/src/lib.rs | 169 ++++++++++----- 5 files changed, 140 insertions(+), 353 deletions(-) rename bindings/rust/{ => src}/bindings.rs (67%) diff --git a/bindings/rust/Cargo.lock b/bindings/rust/Cargo.lock index 59994af..a417c39 100644 --- a/bindings/rust/Cargo.lock +++ b/bindings/rust/Cargo.lock @@ -6,9 +6,16 @@ version = 3 name = "c-kzg" version = "0.1.0" dependencies = [ + "hex", "libc", ] +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "libc" version = "0.2.137" diff --git a/bindings/rust/Cargo.toml b/bindings/rust/Cargo.toml index 5b8de57..ccf5151 100644 --- a/bindings/rust/Cargo.toml +++ b/bindings/rust/Cargo.toml @@ -7,4 +7,5 @@ edition = "2021" [dependencies] libc = "0.2" +hex = "0.4.2" diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs index 912803b..4648ed2 100644 --- a/bindings/rust/build.rs +++ b/bindings/rust/build.rs @@ -24,7 +24,7 @@ fn main() { Command::new("ar") .current_dir(&root_dir.join("src")) - .args(&["crus", "libckzg.a", "c_kzg_4844.o"]) + .args(["crus", "libckzg.a", "c_kzg_4844.o"]) .status() .unwrap(); std::fs::copy(root_dir.join("src/libckzg.a"), &out_dir.join("libckzg.a")).unwrap(); diff --git a/bindings/rust/bindings.rs b/bindings/rust/src/bindings.rs similarity index 67% rename from bindings/rust/bindings.rs rename to bindings/rust/src/bindings.rs index 517e54e..cce30c3 100644 --- a/bindings/rust/bindings.rs +++ b/bindings/rust/src/bindings.rs @@ -1,12 +1,12 @@ /* automatically generated by rust-bindgen 0.61.0 */ -use libc::{fopen, FILE}; +use libc::FILE; -pub const BYTES_PER_COMMITMENT: u32 = 48; -pub const BYTES_PER_PROOF: u32 = 48; -pub const FIELD_ELEMENTS_PER_BLOB: u32 = 4096; -pub const BYTES_PER_FIELD_ELEMENT: u32 = 32; -pub const BYTES_PER_BLOB: u32 = 131072; +pub const BYTES_PER_COMMITMENT: usize = 48; +pub const BYTES_PER_PROOF: usize = 48; +pub const FIELD_ELEMENTS_PER_BLOB: usize = 4096; +pub const BYTES_PER_FIELD_ELEMENT: usize = 32; +pub const BYTES_PER_BLOB: usize = 131072; pub type byte = u8; pub type limb_t = u64; @@ -378,244 +378,12 @@ fn bindgen_test_layout_blst_p2_affine() { ) ); } -extern "C" { - pub fn blst_p2_add(out: *mut blst_p2, a: *const blst_p2, b: *const blst_p2); -} -extern "C" { - pub fn blst_p2_add_or_double(out: *mut blst_p2, a: *const blst_p2, b: *const blst_p2); -} -extern "C" { - pub fn blst_p2_add_affine(out: *mut blst_p2, a: *const blst_p2, b: *const blst_p2_affine); -} -extern "C" { - pub fn blst_p2_add_or_double_affine( - out: *mut blst_p2, - a: *const blst_p2, - b: *const blst_p2_affine, - ); -} -extern "C" { - pub fn blst_p2_double(out: *mut blst_p2, a: *const blst_p2); -} -extern "C" { - pub fn blst_p2_mult(out: *mut blst_p2, p: *const blst_p2, scalar: *const byte, nbits: usize); -} -extern "C" { - pub fn blst_p2_cneg(p: *mut blst_p2, cbit: bool); -} -extern "C" { - pub fn blst_p2_to_affine(out: *mut blst_p2_affine, in_: *const blst_p2); -} -extern "C" { - pub fn blst_p2_from_affine(out: *mut blst_p2, in_: *const blst_p2_affine); -} -extern "C" { - pub fn blst_p2_on_curve(p: *const blst_p2) -> bool; -} -extern "C" { - pub fn blst_p2_in_g2(p: *const blst_p2) -> bool; -} -extern "C" { - pub fn blst_p2_is_equal(a: *const blst_p2, b: *const blst_p2) -> bool; -} -extern "C" { - pub fn blst_p2_is_inf(a: *const blst_p2) -> bool; -} -extern "C" { - pub fn blst_p2_generator() -> *const blst_p2; -} -extern "C" { - pub fn blst_p2_affine_on_curve(p: *const blst_p2_affine) -> bool; -} -extern "C" { - pub fn blst_p2_affine_in_g2(p: *const blst_p2_affine) -> bool; -} -extern "C" { - pub fn blst_p2_affine_is_equal(a: *const blst_p2_affine, b: *const blst_p2_affine) -> bool; -} -extern "C" { - pub fn blst_p2_affine_is_inf(a: *const blst_p2_affine) -> bool; -} -extern "C" { - pub fn blst_p2_affine_generator() -> *const blst_p2_affine; -} -extern "C" { - pub fn blst_p1s_to_affine( - dst: *mut blst_p1_affine, - points: *const *const blst_p1, - npoints: usize, - ); -} -extern "C" { - pub fn blst_p1s_add(ret: *mut blst_p1, points: *const *const blst_p1_affine, npoints: usize); -} -extern "C" { - pub fn blst_p1s_mult_wbits_precompute_sizeof(wbits: usize, npoints: usize) -> usize; -} -extern "C" { - pub fn blst_p1s_mult_wbits_precompute( - table: *mut blst_p1_affine, - wbits: usize, - points: *const *const blst_p1_affine, - npoints: usize, - ); -} -extern "C" { - pub fn blst_p1s_mult_wbits_scratch_sizeof(npoints: usize) -> usize; -} -extern "C" { - pub fn blst_p1s_mult_wbits( - ret: *mut blst_p1, - table: *const blst_p1_affine, - wbits: usize, - npoints: usize, - scalars: *const *const byte, - nbits: usize, - scratch: *mut limb_t, - ); -} -extern "C" { - pub fn blst_p1s_mult_pippenger_scratch_sizeof(npoints: usize) -> usize; -} -extern "C" { - pub fn blst_p1s_mult_pippenger( - ret: *mut blst_p1, - points: *const *const blst_p1_affine, - npoints: usize, - scalars: *const *const byte, - nbits: usize, - scratch: *mut limb_t, - ); -} -extern "C" { - pub fn blst_p1s_tile_pippenger( - ret: *mut blst_p1, - points: *const *const blst_p1_affine, - npoints: usize, - scalars: *const *const byte, - nbits: usize, - scratch: *mut limb_t, - bit0: usize, - window: usize, - ); -} -extern "C" { - pub fn blst_p2s_to_affine( - dst: *mut blst_p2_affine, - points: *const *const blst_p2, - npoints: usize, - ); -} -extern "C" { - pub fn blst_p2s_add(ret: *mut blst_p2, points: *const *const blst_p2_affine, npoints: usize); -} -extern "C" { - pub fn blst_p2s_mult_wbits_precompute_sizeof(wbits: usize, npoints: usize) -> usize; -} -extern "C" { - pub fn blst_p2s_mult_wbits_precompute( - table: *mut blst_p2_affine, - wbits: usize, - points: *const *const blst_p2_affine, - npoints: usize, - ); -} -extern "C" { - pub fn blst_p2s_mult_wbits_scratch_sizeof(npoints: usize) -> usize; -} -extern "C" { - pub fn blst_p2s_mult_wbits( - ret: *mut blst_p2, - table: *const blst_p2_affine, - wbits: usize, - npoints: usize, - scalars: *const *const byte, - nbits: usize, - scratch: *mut limb_t, - ); -} -extern "C" { - pub fn blst_p2s_mult_pippenger_scratch_sizeof(npoints: usize) -> usize; -} -extern "C" { - pub fn blst_p2s_mult_pippenger( - ret: *mut blst_p2, - points: *const *const blst_p2_affine, - npoints: usize, - scalars: *const *const byte, - nbits: usize, - scratch: *mut limb_t, - ); -} -extern "C" { - pub fn blst_p2s_tile_pippenger( - ret: *mut blst_p2, - points: *const *const blst_p2_affine, - npoints: usize, - scalars: *const *const byte, - nbits: usize, - scratch: *mut limb_t, - bit0: usize, - window: usize, - ); -} -extern "C" { - pub fn blst_map_to_g1(out: *mut blst_p1, u: *const blst_fp, v: *const blst_fp); -} -extern "C" { - pub fn blst_map_to_g2(out: *mut blst_p2, u: *const blst_fp2, v: *const blst_fp2); -} -extern "C" { - pub fn blst_encode_to_g1( - out: *mut blst_p1, - msg: *const byte, - msg_len: usize, - DST: *const byte, - DST_len: usize, - aug: *const byte, - aug_len: usize, - ); -} -extern "C" { - pub fn blst_hash_to_g1( - out: *mut blst_p1, - msg: *const byte, - msg_len: usize, - DST: *const byte, - DST_len: usize, - aug: *const byte, - aug_len: usize, - ); -} -extern "C" { - pub fn blst_encode_to_g2( - out: *mut blst_p2, - msg: *const byte, - msg_len: usize, - DST: *const byte, - DST_len: usize, - aug: *const byte, - aug_len: usize, - ); -} -extern "C" { - pub fn blst_hash_to_g2( - out: *mut blst_p2, - msg: *const byte, - msg_len: usize, - DST: *const byte, - DST_len: usize, - aug: *const byte, - aug_len: usize, - ); -} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct blst_opaque { _unused: [u8; 0], } -pub type blst_pairing = blst_opaque; #[repr(C)] #[repr(align(1))] @@ -637,9 +405,9 @@ fn bindgen_test_layout_blst_uniq() { ); } -extern "C" { - pub static FIAT_SHAMIR_PROTOCOL_DOMAIN: [u8; 16usize]; -} +pub const FIAT_SHAMIR_PROTOCOL_DOMAIN: [u8; 16usize] = [ + 70, 83, 66, 76, 79, 66, 86, 69, 82, 73, 70, 89, 95, 86, 49, 95, +]; pub type g1_t = blst_p1; pub type g2_t = blst_p2; pub type fr_t = blst_fr; @@ -835,67 +603,3 @@ extern "C" { s: *const KZGSettings, ) -> C_KZG_RET; } -pub type __builtin_va_list = [__va_list_tag; 1usize]; -#[repr(C)] -#[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub struct __va_list_tag { - pub gp_offset: ::std::os::raw::c_uint, - pub fp_offset: ::std::os::raw::c_uint, - pub overflow_arg_area: *mut ::std::os::raw::c_void, - pub reg_save_area: *mut ::std::os::raw::c_void, -} -#[test] -fn bindgen_test_layout___va_list_tag() { - const UNINIT: ::std::mem::MaybeUninit<__va_list_tag> = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::<__va_list_tag>(), - 24usize, - concat!("Size of: ", stringify!(__va_list_tag)) - ); - assert_eq!( - ::std::mem::align_of::<__va_list_tag>(), - 8usize, - concat!("Alignment of ", stringify!(__va_list_tag)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).gp_offset) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(__va_list_tag), - "::", - stringify!(gp_offset) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).fp_offset) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(__va_list_tag), - "::", - stringify!(fp_offset) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).overflow_arg_area) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(__va_list_tag), - "::", - stringify!(overflow_arg_area) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).reg_save_area) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(__va_list_tag), - "::", - stringify!(reg_save_area) - ) - ); -} diff --git a/bindings/rust/src/lib.rs b/bindings/rust/src/lib.rs index 34587a0..914b9f5 100644 --- a/bindings/rust/src/lib.rs +++ b/bindings/rust/src/lib.rs @@ -2,52 +2,73 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] -include!("../bindings.rs"); - +mod bindings; +use bindings::{g1_t, Blob, C_KZG_RET}; +use libc::fopen; use std::ffi::CString; use std::mem::MaybeUninit; use std::os::unix::prelude::OsStrExt; use std::path::PathBuf; -impl g1_t { - pub fn bytes_to_g1(bytes: &[u8]) -> Result { - let mut g1_point = MaybeUninit::::uninit(); - unsafe { - let res = bytes_to_g1(g1_point.as_mut_ptr(), bytes.as_ptr()); - if let C_KZG_RET::C_KZG_OK = res { - Ok(g1_point.assume_init()) - } else { - Err(res) - } +pub use bindings::{ + BYTES_PER_BLOB, BYTES_PER_COMMITMENT, BYTES_PER_FIELD_ELEMENT, BYTES_PER_PROOF, + FIAT_SHAMIR_PROTOCOL_DOMAIN, FIELD_ELEMENTS_PER_BLOB, +}; + +const BYTES_PER_G1_POINT: usize = 48; + +#[derive(Debug)] +// TODO(add separate error type for commitments and proof) +pub enum Error { + /// The KZG proof is invalid. + InvalidKZGProof(String), + /// The KZG commitment is invalid. + InvalidKZGCommitment(String), + /// The underlying c-kzg library returned an error. + CError(C_KZG_RET), +} + +pub fn bytes_to_g1(bytes: &[u8]) -> Result { + let mut g1_point = MaybeUninit::::uninit(); + unsafe { + let res = bindings::bytes_to_g1(g1_point.as_mut_ptr(), bytes.as_ptr()); + if let C_KZG_RET::C_KZG_OK = res { + Ok(g1_point.assume_init()) + } else { + Err(Error::CError(res)) } } +} - pub fn bytes_from_g1(&self) -> [u8; 48] { - let mut bytes = [0; 48]; - unsafe { bytes_from_g1(bytes.as_mut_ptr(), self) } - bytes - } +pub fn bytes_from_g1(g1_point: g1_t) -> [u8; BYTES_PER_G1_POINT] { + let mut bytes = [0; 48]; + unsafe { bindings::bytes_from_g1(bytes.as_mut_ptr(), &g1_point) } + bytes } +#[derive(Debug, Clone, Copy)] +pub struct BLSFieldElement(bindings::BLSFieldElement); + impl BLSFieldElement { pub fn bytes_to_bls_field(bytes: [u8; BYTES_PER_FIELD_ELEMENT as usize]) -> Self { - let mut bls_field_element = MaybeUninit::::uninit(); + let mut bls_field_element = MaybeUninit::::uninit(); unsafe { - bytes_to_bls_field(bls_field_element.as_mut_ptr(), bytes.as_ptr()); - bls_field_element.assume_init() + bindings::bytes_to_bls_field(bls_field_element.as_mut_ptr(), bytes.as_ptr()); + Self(bls_field_element.assume_init()) } } } +pub struct KZGSettings(bindings::KZGSettings); impl KZGSettings { pub fn load_trusted_setup(file_path: PathBuf) -> Result { let file_path = CString::new(file_path.as_os_str().as_bytes()).unwrap(); - let mut kzg_settings = MaybeUninit::::uninit(); + let mut kzg_settings = MaybeUninit::::uninit(); unsafe { let file_ptr = fopen(file_path.as_ptr(), &('r' as libc::c_char)); - let res = load_trusted_setup(kzg_settings.as_mut_ptr(), file_ptr); + let res = bindings::load_trusted_setup(kzg_settings.as_mut_ptr(), file_ptr); if let C_KZG_RET::C_KZG_OK = res { - Ok(kzg_settings.assume_init()) + Ok(Self(kzg_settings.assume_init())) } else { Err(res) } @@ -57,27 +78,50 @@ impl KZGSettings { impl Drop for KZGSettings { fn drop(&mut self) { - unsafe { free_trusted_setup(self) } + unsafe { bindings::free_trusted_setup(&mut self.0) } } } +pub struct KZGProof(bindings::KZGProof); + impl KZGProof { + pub fn from_bytes(bytes: &[u8]) -> Result { + if bytes.len() != BYTES_PER_PROOF { + return Err(Error::InvalidKZGProof(format!( + "Invalid byte length. Expected {} got {}", + BYTES_PER_PROOF, + bytes.len(), + ))); + } + let mut proof_bytes = [0; BYTES_PER_PROOF]; + proof_bytes.copy_from_slice(bytes); + Ok(Self(bytes_to_g1(bytes)?)) + } + + pub fn to_bytes(&self) -> Vec { + bytes_from_g1(self.0).to_vec() + } + + pub fn as_hex_string(&self) -> String { + hex::encode(self.to_bytes()) + } + pub fn compute_aggregate_kzg_proof( blobs: &[Blob], kzg_settings: &KZGSettings, - ) -> Result { - let mut kzg_proof = MaybeUninit::::uninit(); + ) -> Result { + let mut kzg_proof = MaybeUninit::::uninit(); unsafe { - let res = compute_aggregate_kzg_proof( + let res = bindings::compute_aggregate_kzg_proof( kzg_proof.as_mut_ptr(), blobs.as_ptr(), blobs.len(), - kzg_settings, + &kzg_settings.0, ); if let C_KZG_RET::C_KZG_OK = res { - Ok(kzg_proof.assume_init()) + Ok(Self(kzg_proof.assume_init())) } else { - Err(res) + Err(Error::CError(res)) } } } @@ -87,21 +131,25 @@ impl KZGProof { blobs: &[Blob], expected_kzg_commitments: &[KZGCommitment], kzg_settings: &KZGSettings, - ) -> Result { + ) -> Result { let mut verified: MaybeUninit = MaybeUninit::uninit(); unsafe { - let res = verify_aggregate_kzg_proof( + let res = bindings::verify_aggregate_kzg_proof( verified.as_mut_ptr(), blobs.as_ptr(), - expected_kzg_commitments.as_ptr(), + expected_kzg_commitments + .iter() + .map(|c| c.0) + .collect::>() + .as_ptr(), blobs.len(), - self, - kzg_settings, + &self.0, + &kzg_settings.0, ); if let C_KZG_RET::C_KZG_OK = res { Ok(verified.assume_init()) } else { - Err(res) + Err(Error::CError(res)) } } } @@ -112,32 +160,59 @@ impl KZGProof { z: BLSFieldElement, y: BLSFieldElement, kzg_settings: &KZGSettings, - ) -> Result { + ) -> Result { let mut verified: MaybeUninit = MaybeUninit::uninit(); unsafe { - let res = verify_kzg_proof( + let res = bindings::verify_kzg_proof( verified.as_mut_ptr(), - &kzg_commitment, - &z, - &y, - self, - kzg_settings, + &kzg_commitment.0, + &z.0, + &y.0, + &self.0, + &kzg_settings.0, ); if let C_KZG_RET::C_KZG_OK = res { Ok(verified.assume_init()) } else { - Err(res) + Err(Error::CError(res)) } } } } +pub struct KZGCommitment(bindings::KZGCommitment); + impl KZGCommitment { + pub fn from_bytes(bytes: &[u8]) -> Result { + if bytes.len() != BYTES_PER_COMMITMENT { + return Err(Error::InvalidKZGCommitment(format!( + "Invalid byte length. Expected {} got {}", + BYTES_PER_PROOF, + bytes.len(), + ))); + } + let mut proof_bytes = [0; BYTES_PER_COMMITMENT]; + proof_bytes.copy_from_slice(bytes); + Ok(Self(bytes_to_g1(bytes)?)) + } + + pub fn to_bytes(&self) -> Vec { + bytes_from_g1(self.0).to_vec() + } + + pub fn as_hex_string(&self) -> String { + hex::encode(self.to_bytes()) + } + pub fn blob_to_kzg_commitment(mut blob: Blob, kzg_settings: &KZGSettings) -> Self { - let mut kzg_commitment: MaybeUninit = MaybeUninit::uninit(); + let mut kzg_commitment: MaybeUninit = MaybeUninit::uninit(); unsafe { - blob_to_kzg_commitment(kzg_commitment.as_mut_ptr(), blob.as_mut_ptr(), kzg_settings); - kzg_commitment.assume_init() + bindings::blob_to_kzg_commitment( + kzg_commitment.as_mut_ptr(), + blob.as_mut_ptr(), + &kzg_settings.0, + ); + Self(kzg_commitment.assume_init()) } } } From a7633f2b17f86aba664f3e6c99d530862148cfd3 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Wed, 16 Nov 2022 20:12:46 +0530 Subject: [PATCH 9/9] Remove more stuff from bindings --- bindings/rust/src/bindings.rs | 341 +--------------------------------- 1 file changed, 5 insertions(+), 336 deletions(-) diff --git a/bindings/rust/src/bindings.rs b/bindings/rust/src/bindings.rs index cce30c3..8aaf402 100644 --- a/bindings/rust/src/bindings.rs +++ b/bindings/rust/src/bindings.rs @@ -15,181 +15,34 @@ pub type limb_t = u64; pub struct blst_scalar { pub b: [byte; 32usize], } -#[test] -fn bindgen_test_layout_blst_scalar() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(blst_scalar)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(blst_scalar)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).b) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(blst_scalar), - "::", - stringify!(b) - ) - ); -} + #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct blst_fr { pub l: [limb_t; 4usize], } -#[test] -fn bindgen_test_layout_blst_fr() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(blst_fr)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(blst_fr)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).l) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(blst_fr), - "::", - stringify!(l) - ) - ); -} + #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct blst_fp { pub l: [limb_t; 6usize], } -#[test] -fn bindgen_test_layout_blst_fp() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 48usize, - concat!("Size of: ", stringify!(blst_fp)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(blst_fp)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).l) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(blst_fp), - "::", - stringify!(l) - ) - ); -} #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct blst_fp2 { pub fp: [blst_fp; 2usize], } -#[test] -fn bindgen_test_layout_blst_fp2() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 96usize, - concat!("Size of: ", stringify!(blst_fp2)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(blst_fp2)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).fp) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(blst_fp2), - "::", - stringify!(fp) - ) - ); -} #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct blst_fp6 { pub fp2: [blst_fp2; 3usize], } -#[test] -fn bindgen_test_layout_blst_fp6() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 288usize, - concat!("Size of: ", stringify!(blst_fp6)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(blst_fp6)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).fp2) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(blst_fp6), - "::", - stringify!(fp2) - ) - ); -} + #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct blst_fp12 { pub fp6: [blst_fp6; 2usize], } -#[test] -fn bindgen_test_layout_blst_fp12() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 576usize, - concat!("Size of: ", stringify!(blst_fp12)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(blst_fp12)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).fp6) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(blst_fp12), - "::", - stringify!(fp6) - ) - ); -} #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] @@ -198,92 +51,13 @@ pub struct blst_p1 { pub y: blst_fp, pub z: blst_fp, } -#[test] -fn bindgen_test_layout_blst_p1() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 144usize, - concat!("Size of: ", stringify!(blst_p1)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(blst_p1)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(blst_p1), - "::", - stringify!(x) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).y) as usize - ptr as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(blst_p1), - "::", - stringify!(y) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).z) as usize - ptr as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(blst_p1), - "::", - stringify!(z) - ) - ); -} + #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct blst_p1_affine { pub x: blst_fp, pub y: blst_fp, } -#[test] -fn bindgen_test_layout_blst_p1_affine() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 96usize, - concat!("Size of: ", stringify!(blst_p1_affine)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(blst_p1_affine)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(blst_p1_affine), - "::", - stringify!(x) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).y) as usize - ptr as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(blst_p1_affine), - "::", - stringify!(y) - ) - ); -} #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] @@ -292,118 +66,13 @@ pub struct blst_p2 { pub y: blst_fp2, pub z: blst_fp2, } -#[test] -fn bindgen_test_layout_blst_p2() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 288usize, - concat!("Size of: ", stringify!(blst_p2)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(blst_p2)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(blst_p2), - "::", - stringify!(x) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).y) as usize - ptr as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(blst_p2), - "::", - stringify!(y) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).z) as usize - ptr as usize }, - 192usize, - concat!( - "Offset of field: ", - stringify!(blst_p2), - "::", - stringify!(z) - ) - ); -} + #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct blst_p2_affine { pub x: blst_fp2, pub y: blst_fp2, } -#[test] -fn bindgen_test_layout_blst_p2_affine() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 192usize, - concat!("Size of: ", stringify!(blst_p2_affine)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(blst_p2_affine)) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).x) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(blst_p2_affine), - "::", - stringify!(x) - ) - ); - assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).y) as usize - ptr as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(blst_p2_affine), - "::", - stringify!(y) - ) - ); -} - -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct blst_opaque { - _unused: [u8; 0], -} - -#[repr(C)] -#[repr(align(1))] -#[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub struct blst_uniq { - pub _bindgen_opaque_blob: [u8; 0usize], -} -#[test] -fn bindgen_test_layout_blst_uniq() { - assert_eq!( - ::std::mem::size_of::(), - 0usize, - concat!("Size of: ", stringify!(blst_uniq)) - ); - assert_eq!( - ::std::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(blst_uniq)) - ); -} pub const FIAT_SHAMIR_PROTOCOL_DOMAIN: [u8; 16usize] = [ 70, 83, 66, 76, 79, 66, 86, 69, 82, 73, 70, 89, 95, 86, 49, 95,