Skip to content

Commit

Permalink
fix: usage examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dr committed Jun 28, 2024
1 parent ba0d2ad commit 98bfd59
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 32 deletions.
2 changes: 1 addition & 1 deletion benches/benchmark_aes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use capycrypt::aes::encryptable::AesEncryptable;
use capycrypt::aes::aes_functions::{apply_pcks7_padding, remove_pcks7_padding};
use capycrypt::aes::encryptable::AesEncryptable;
use capycrypt::sha3::aux_functions::byte_utils::get_random_bytes;
use capycrypt::Message;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
Expand Down
1 change: 0 additions & 1 deletion src/ecc/encryptable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub trait KeyEncryptable {
}

impl KeyEncryptable for Message {

/// # Asymmetric Encryption
/// Encrypts a [`Message`] in place under the (Schnorr/ECDHIES) public key 𝑉.
/// Operates under Schnorr/ECDHIES principle in that shared symmetric key is
Expand Down
25 changes: 0 additions & 25 deletions src/ecc/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,6 @@ impl KeyPair {
/// # KeyPair Saving
///
/// Saves the key pair to a JSON file.
///
/// ## Usage:
///
/// ```rust
/// use capycrypt::ecc::ecc_keypair::KeyPair;
/// use capycrypt::SecParam;
///
/// let key_pair = KeyPair::new("password".as_bytes(), "owner".to_string(), &SecParam::D512)
/// .expect("Failed to create key pair");
///
/// // key_pair.write_to_file("keypai1r.json").expect("Failed to save key pair");
pub fn write_to_file(&self, filename: &str) -> std::io::Result<()> {
let json_key_pair = serde_json::to_string_pretty(self).unwrap();
std::fs::write(filename, json_key_pair)
Expand All @@ -80,20 +69,6 @@ impl KeyPair {
/// Returns an error if:
/// - The file cannot be opened or read.
/// - The JSON content cannot be parsed into a `KeyPair`.
///
/// ## Usage:
///
/// ```rust
/// use capycrypt::ecc::ecc_keypair::KeyPair;
///
/// // Assuming "keypair.json" contains a serialized KeyPair
/// match KeyPair::read_from_file("keypair.json") {
/// Ok(key_pair) => {
/// println!("Loaded KeyPair: {:?}", key_pair);
/// },
/// Err(err) => eprintln!("Error loading KeyPair: {}", err),
/// }
/// ```
pub fn read_from_file(filename: &str) -> Result<KeyPair, Box<dyn std::error::Error>> {
let mut file = File::open(filename)?;
let mut contents = String::new();
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ pub mod sha3 {
/// Submodule that implements NIST 800-185 compliant functions
pub mod aux_functions;
pub mod constants;
pub mod encryptable;
pub mod hashable;
/// Submodule that implements the Keccak-f[1600] permutation
pub mod keccakf;
pub mod hashable;
pub mod shake_functions;
/// Submodule that implements the sponge construction
pub mod sponge;
pub mod encryptable;
}

pub mod aes {
Expand Down
4 changes: 1 addition & 3 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ pub mod ops_tests {
use capycrypt::{
ecc::{encryptable::KeyEncryptable, keypair::KeyPair, signable::Signable},
kem::{encryptable::KEMEncryptable, keypair::kem_keygen},
sha3::{
aux_functions::byte_utils::get_random_bytes, encryptable::SpongeEncryptable,
},
sha3::{aux_functions::byte_utils::get_random_bytes, encryptable::SpongeEncryptable},
Message, SecParam,
};

Expand Down

0 comments on commit 98bfd59

Please sign in to comment.