Minor rust bindings cleanup (#75)

* Minor rust bindings cleanup

* Use g2_bytes variable
This commit is contained in:
Justin Traglia 2023-01-18 15:45:44 -06:00 committed by GitHub
parent 9fbe40a5eb
commit ac3c829727
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 19 deletions

View File

@ -122,7 +122,6 @@ impl Deref for KZGProof {
} }
} }
pub const FIAT_SHAMIR_PROTOCOL_DOMAIN: &[u8; 16usize] = b"FSBLOBVERIFY_V1_";
type g1_t = blst_p1; type g1_t = blst_p1;
type g2_t = blst_p2; type g2_t = blst_p2;
type fr_t = blst_fr; type fr_t = blst_fr;
@ -186,7 +185,6 @@ unsafe impl Sync for KZGSettings {}
unsafe impl Send for KZGSettings {} unsafe impl Send for KZGSettings {}
extern "C" { extern "C" {
#[doc = " Interface functions"]
pub fn load_trusted_setup( pub fn load_trusted_setup(
out: *mut KZGSettings, out: *mut KZGSettings,
g1_bytes: *const u8, /* n1 * 48 bytes */ g1_bytes: *const u8, /* n1 * 48 bytes */
@ -194,22 +192,18 @@ extern "C" {
g2_bytes: *const u8, /* n2 * 96 bytes */ g2_bytes: *const u8, /* n2 * 96 bytes */
n2: usize, n2: usize,
) -> C_KZG_RET; ) -> C_KZG_RET;
}
extern "C" {
pub fn load_trusted_setup_file(out: *mut KZGSettings, in_: *mut FILE) -> C_KZG_RET; pub fn load_trusted_setup_file(out: *mut KZGSettings, in_: *mut FILE) -> C_KZG_RET;
}
extern "C" {
pub fn free_trusted_setup(s: *mut KZGSettings); pub fn free_trusted_setup(s: *mut KZGSettings);
}
extern "C" {
pub fn compute_aggregate_kzg_proof( pub fn compute_aggregate_kzg_proof(
out: *mut KZGProof, out: *mut KZGProof,
blobs: *const Blob, blobs: *const Blob,
n: usize, n: usize,
s: *const KZGSettings, s: *const KZGSettings,
) -> C_KZG_RET; ) -> C_KZG_RET;
}
extern "C" {
pub fn verify_aggregate_kzg_proof( pub fn verify_aggregate_kzg_proof(
out: *mut bool, out: *mut bool,
blobs: *const Blob, blobs: *const Blob,
@ -218,15 +212,13 @@ extern "C" {
kzg_aggregated_proof: *const KZGProof, kzg_aggregated_proof: *const KZGProof,
s: *const KZGSettings, s: *const KZGSettings,
) -> C_KZG_RET; ) -> C_KZG_RET;
}
extern "C" {
pub fn blob_to_kzg_commitment( pub fn blob_to_kzg_commitment(
out: *mut KZGCommitment, out: *mut KZGCommitment,
blob: *const Blob, blob: *const Blob,
s: *const KZGSettings, s: *const KZGSettings,
) -> C_KZG_RET; ) -> C_KZG_RET;
}
extern "C" {
pub fn verify_kzg_proof( pub fn verify_kzg_proof(
out: *mut bool, out: *mut bool,
polynomial_kzg: *const KZGCommitment, polynomial_kzg: *const KZGCommitment,

View File

@ -55,15 +55,12 @@ impl KZGSettings {
} }
let mut kzg_settings = MaybeUninit::<KZGSettings>::uninit(); let mut kzg_settings = MaybeUninit::<KZGSettings>::uninit();
unsafe { unsafe {
let n1 = g1_bytes.len();
let n2 = g2_bytes.len();
let res = load_trusted_setup( let res = load_trusted_setup(
kzg_settings.as_mut_ptr(), kzg_settings.as_mut_ptr(),
g1_bytes.as_ptr() as *const u8, g1_bytes.as_ptr() as *const u8,
n1, g1_bytes.len(),
g2_bytes.as_ptr() as *const u8, g2_bytes.as_ptr() as *const u8,
n2, g2_bytes.len(),
); );
if let C_KZG_RET::C_KZG_OK = res { if let C_KZG_RET::C_KZG_OK = res {
Ok(kzg_settings.assume_init()) Ok(kzg_settings.assume_init())