Skip to content

nmoutschen/garble

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data garbling crate

The purpose of this crate is to provide a way to slightly modify data in controlled way for fault injection purposes.

Example

use garble::{Garble, SimpleGarbler};

// Create a garbler with a 50% probability of garbling data
let mut garbler = SimpleGarbler::new(0.5);

// Garble some data
dbg!(true.garble(&mut garbler));
dbg!(128u64.garble(&mut garbler));
dbg!((3.5_f32).garble(&mut garbler));

Derive macro

This crate provides a derive macro for garbling structs.

use garble::{Garble, SimpleGarbler};

#[derive(Debug, Garble)]
struct MyStruct {
    a: u32,
}

// Create a garbler with a 50% probability of garbling data
let mut garbler = SimpleGarbler::new(0.5);

// Garble some data
dbg!(MyStruct { a: 128 }.garble(&mut garbler));

Skip garbling fields

You can use the #[nogarble] attribute to skip garbling specific fields:

use garble::{Garble, SimpleGarbler};

#[derive(Debug, Garble)]
struct MyStruct {
    a: u32,
    #[nogarble]
    b: u32,
}

// Create a garbler with a 50% probability of garbling data
let mut garbler = SimpleGarbler::new(0.5);

// Garble some data
dbg!(MyStruct { a: 128, b: 127 }.garble(&mut garbler));

About

Data garbling crate

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages