Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion circuit-std-rs/tests/logup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ use circuit_std_rs::{
use expander_compiler::{
field::{BN254Fr, Goldilocks},
frontend::*,
zkcuda::{context::*, kernel::*, proving_system::*, shape::Reshape},
zkcuda::{
context::*,
kernel::*,
proving_system::{expander::config::ZKCudaBN254Hyrax, *},
shape::Reshape,
},
};
use serdes::ExpSerde;

#[test]
fn logup_test() {
Expand Down Expand Up @@ -196,3 +202,31 @@ fn rangeproof_zkcuda_test_fail() {
);
assert!(P::verify(&verifier_setup, &computation_graph, &proof));
}

#[test]
fn rangeproof_zkcuda_no_oversubscribe_test() {
let mut hint_registry = HintRegistry::<BN254Fr>::new();
hint_registry.register("myhint.querycounthint", query_count_hint);
hint_registry.register("myhint.rangeproofhint", rangeproof_hint);
//compile and test
let kernel: KernelPrimitive<BN254Config> = compile_rangeproof_test_kernel().unwrap();
let mut ctx: Context<BN254Config, _> = Context::new(hint_registry);

let a = BN254Fr::from((1 << 9) as u32);
let a = ctx.copy_to_device(&a);
let a = a.reshape(&[1]);
call_kernel!(ctx, kernel, 1, a).unwrap();

let computation_graph = ctx.compile_computation_graph().unwrap();
ctx.solve_witness().unwrap();
let (prover_setup, _) = ExpanderNoOverSubscribe::<ZKCudaBN254Hyrax>::setup(&computation_graph);
let proof = ExpanderNoOverSubscribe::<ZKCudaBN254Hyrax>::prove(
&prover_setup,
&computation_graph,
ctx.export_device_memories(),
);
let file = std::fs::File::create("proof.txt").unwrap();
let writer = std::io::BufWriter::new(file);
proof.serialize_into(writer).expect("serialize failed");
<ExpanderNoOverSubscribe<ZKCudaBN254Hyrax> as ProvingSystem<BN254Config>>::post_process();
}
14 changes: 6 additions & 8 deletions expander_compiler/src/zkcuda/mpi_mem_share.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,16 @@ impl<C: Config> MPISharedMemory for ComputationGraph<C> {

impl<C: Config> MPISharedMemory for Kernel<C> {
fn bytes_size(&self) -> usize {
assert!(
self.hint_solver.is_none(),
"Hint solver is not supported in MPISharedMemory for Kernel"
);
if self.hint_solver.is_some() {
eprintln!("Warning: Shared Memory will ignore the hint solver in Kernel");
}
self.layered_circuit.bytes_size() + self.layered_circuit_input.bytes_size()
}

fn to_memory(&self, ptr: &mut *mut u8) {
assert!(
self.hint_solver.is_none(),
"Hint solver is not supported in MPISharedMemory for Kernel"
);
if self.hint_solver.is_some() {
eprintln!("Warning: Shared Memory will ignore the hint solver in Kernel");
}
self.layered_circuit.to_memory(ptr);
self.layered_circuit_input.to_memory(ptr);
}
Expand Down
Loading