Skip to content

Commit

Permalink
fix clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishqjasoria committed Aug 13, 2024
1 parent 4960905 commit ee3121b
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions bindings/c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ use ipa_multipoint::committer::Committer;
use ipa_multipoint::multiproof::{MultiPoint, MultiPointProof, ProverQuery, VerifierQuery};
use ipa_multipoint::transcript::Transcript;

#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[no_mangle]
pub extern "C" fn context_new() -> *mut Context {
let ctx = Box::new(Context::default());
Box::into_raw(ctx)
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[no_mangle]
pub extern "C" fn context_free(ctx: *mut Context) {
if ctx.is_null() {
Expand All @@ -22,6 +24,7 @@ pub extern "C" fn context_free(ctx: *mut Context) {
}
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[no_mangle]
pub extern "C" fn pedersen_hash(
ctx: *mut Context,
Expand Down Expand Up @@ -55,6 +58,7 @@ pub extern "C" fn pedersen_hash(
}
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[no_mangle]
pub extern "C" fn multi_scalar_mul(
ctx: *mut Context,
Expand Down Expand Up @@ -83,6 +87,7 @@ pub extern "C" fn multi_scalar_mul(
}
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[no_mangle]
pub extern "C" fn create_proof(ctx: *mut Context, input: *const u8, len: usize, out: *mut u8) {
const CHUNK_SIZE: usize = 8257; // TODO: get this from ipa-multipoint
Expand Down Expand Up @@ -132,6 +137,7 @@ pub extern "C" fn create_proof(ctx: *mut Context, input: *const u8, len: usize,
}
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[no_mangle]
pub extern "C" fn create_proof_uncompressed(
ctx: *mut Context,
Expand Down Expand Up @@ -189,6 +195,7 @@ pub extern "C" fn create_proof_uncompressed(
}
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[no_mangle]
pub extern "C" fn verify_proof(ctx: *mut Context, input: *const u8, len: usize) -> bool {
const CHUNK_SIZE: usize = 65; // TODO: get this from ipa-multipoint
Expand Down Expand Up @@ -230,17 +237,17 @@ pub extern "C" fn verify_proof(ctx: *mut Context, input: *const u8, len: usize)
let mut transcript = Transcript::new(b"verkle");

// TODO: This should not need to clone the CRS, but instead take a reference
let is_valid = MultiPointProof::check(

MultiPointProof::check(
&proof,
&context.crs.clone(),
&context.precomputed_weights,
&verifier_queries,
&mut transcript,
);

return is_valid;
)
}

#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[no_mangle]
pub extern "C" fn verify_proof_uncompressed(
ctx: *mut Context,
Expand Down Expand Up @@ -287,13 +294,12 @@ pub extern "C" fn verify_proof_uncompressed(
let mut transcript = Transcript::new(b"verkle");

// TODO: This should not need to clone the CRS, but instead take a reference
let is_valid = MultiPointProof::check(

MultiPointProof::check(
&proof,
&context.crs.clone(),
&context.precomputed_weights,
&verifier_queries,
&mut transcript,
);

return is_valid;
)
}

0 comments on commit ee3121b

Please sign in to comment.