Steganography with floating-point numbers

Hello everyone,

I have built a small tool to hide a message in tensors of floats. This is the repository: GitHub - gn0/steganotorchy: Hiding messages inside neural network weights and biases (How it embeds the message is explained in some detail in an accompanying blog post.)

What could I improve in the code base? Are there things that are obviously non-idiomatic, or that could be expressed with better abstractions?

Thanks very much in advance!

I've only skimmed the code, but it looks tidy and readable to me. cargo clippy agrees, no warnings or lint. There are tests that all pass, and the assertions are self-evident.

But docs are really slim. There are only a few public doc comments. cargo doc doesn't have a lot to go off of for anyone interested in learning the API without reading code. This is the best one I could find, and it looks quite nice in the rendered docs: steganotorchy/src/tensor.rs at main · gn0/steganotorchy (More of this, please!)

I kind of dislike even suggesting this, but for cases where you want rustfmt to leave your formatting alone, it is probably better to put #[rustfmt::skip] on each individual item instead of the whole function.

For instance, put it on this assert_eq!() and the following one. You will end up with more attributes overall, but it also allows formatting other unrelated code in the function. The assert!() just above will be reformatted to 3 lines instead of 5, which is a net positive!

Nitpick: You can use PathBuf in your cli args, and accept &Path in your command functions that need to access the file system. Functionally equivalent to OsString/&OsStr, but semantically different.

It looks really nice. Good job.

2 Likes