Skip to content

Commit bee31ad

Browse files
committed
Fix transmute: use raw pointer cast for gate coef serialization
1 parent fa97e44 commit bee31ad

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • expander_compiler/src/zkcuda/proving_system/expander_local_deferred

expander_compiler/src/zkcuda/proving_system/expander_local_deferred/api.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,10 @@ fn dump_circuits_for_gpu<F: gkr_engine::FieldEngine>(
261261
gf.write_all(&(gate.o_id as u32).to_le_bytes()).unwrap();
262262
gf.write_all(&(gate.i_ids[0] as u32).to_le_bytes()).unwrap();
263263
gf.write_all(&(gate.i_ids[1] as u32).to_le_bytes()).unwrap();
264-
// coef is M31, extract .v field via unsafe transmute
265-
let coef_bytes: [u8; 4] = unsafe { std::mem::transmute(gate.coef) };
264+
// coef is CircuitField (M31 = 4 bytes)
265+
let coef_bytes: &[u8] = unsafe {
266+
std::slice::from_raw_parts(&gate.coef as *const _ as *const u8, 4)
267+
};
266268
gf.write_all(&coef_bytes).unwrap();
267269
}
268270

0 commit comments

Comments
 (0)