Created
October 3, 2023 05:37
-
-
Save RajeshRk18/515828f76f34d115dbfd3c81fd0d4c95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use ark_ff::BigInt; | |
let (mut a, ptr) = { | |
let b = BigInt::<4>::new([12, 34, 56, 78]); | |
println!("Creation Address: {:?}", b.0.as_ptr()); | |
(b, b.0.as_ptr()) | |
}; | |
println!("Value before dropping: {:?}", a); | |
let addr_a = a.0.as_ptr(); | |
println!("Returned Address: {:?}", addr_a); | |
a.zeroize(); | |
println!("{:?}", a); | |
let val_at_returned_memory = unsafe { core::slice::from_raw_parts(addr_a, 4) }; | |
println!("Value at Returned Address: {:?}", val_at_returned_memory); // Zeroed | |
let val_at_dropped_memory = unsafe { core::slice::from_raw_parts(ptr, 4) }; | |
println!("Value at Creation Address: {:?}", val_at_dropped_memory); // value still in original memory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment