CryptoSym

Struct CryptoSym 

Source
pub struct CryptoSym;

Trait Implementations§

Source§

impl BlockCipher for CryptoSym

Source§

fn encrypt_message( signer_sk: &[u8; 32], receiver_pk: &[u8; 32], msg: &[u8], ) -> Result<Vec<u8>>

Encode a message text with AES-GCM algorithm using the signer’s the PrivateKey and receiver’s PublicKey.

§Inputs
  • signer_sk: The signer’s private key.

  • receiver_pk: The receiver’s public key.

  • msg: Message to encrypt.

§Returns

A Result whose okay value is an encrypt message Vec<u8> or whose error value is an failure::Error describing the error that occurred.

Source§

fn decrypt_message( receiver_sk: &[u8; 32], signer_pk: &[u8; 32], enc_msg: &[u8], ) -> Result<Vec<u8>>

Decrypt a message text with AES-GCM algorithm using the receiver’s the PrivateKey and signer’s PublicKey.

§Inputs
  • receiver_sk: The receiver’s private key.

  • signer_pk: The signer’s public key.

  • enc_msg: Message encrypted.

§Example
use std::str::FromStr;
use symbol_crypto_core::{PrivateKey, PublicKey,decrypt_message };

let receiver_sk = PrivateKey::from_str("A22A4BBF126A2D7D7ECE823174DFD184C5DE0FDE4CB2075D30CFA409F7EF8908").unwrap();
let signer_pk = PublicKey::from_str("3FD283D8543C12B81917C154CDF4EFD3D48E553E6D7BC77E29CB168138CED17D").unwrap();

let encrypt_text_vec = [
    125, 59, 126, 248, 124, 129, 157, 100, 111, 84, 49, 163, 111, 68, 22, 137, 75, 132, 135,
    217, 251, 158, 115, 74, 226, 172, 200, 208, 33, 183, 110, 103, 107, 170, 52, 174, 192, 110,
    164, 44, 77, 69, 203, 48, 43, 17, 206, 143, 154, 155, 231, 72, 28, 24, 20, 241, 234, 202,
    184, 66,
];

let decrypted_text = decrypt_message( receiver_sk.as_fixed_bytes(), signer_pk.as_fixed_bytes(), &encrypt_text_vec).unwrap();
§Returns

A Result whose okay value is an decrypted message Vec<u8> or whose error value is an failure::Error describing the error that occurred.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V