Created
October 3, 2023 03:12
-
-
Save RajeshRk18/eb10e3506c83c196d69116e86e0910e5 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 curve25519_dalek::Scalar; | |
let (mut a, ptr) = { | |
let b = Scalar::from_bytes_mod_order([ | |
45, 34, 23, 78, 7, 12, 65, 4, 34, 12, 12, 45, 65, 45, 4, 54, 33, 26, 65, 44, 65, 44, | |
67, 86, 43, 66, 8, 56, 42, 67, 78, 94, | |
]); | |
println!("Creation Address: {:?}", b.bytes.as_ptr()); | |
(b, b.bytes.as_ptr()) | |
}; | |
println!("Value before dropping: {:?}", a.bytes); | |
let addr_a = a.bytes.as_ptr(); | |
println!("Returned Address: {:?}", addr_a); | |
a.zeroize(); | |
let val_at_returned_memory = unsafe { core::slice::from_raw_parts(addr_a, 32) }; | |
println!("Value at Returned Address: {:?}", val_at_returned_memory); // Zeroed | |
let val_at_original_memory = unsafe { core::slice::from_raw_parts(ptr, 32) }; | |
println!("Value at Creation Address: {:?}", val_at_original_memory); // value still in original memory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment