use curves::{EdCurvePoint, EdCurves};
use num_bigint::BigInt as Integer;
pub mod curves;
pub mod sha3 {
pub mod aux_functions;
pub mod keccakf;
pub mod sponge;
}
pub mod ops;
#[derive(Debug)]
pub struct Signature {
pub h: Vec<u8>,
pub z: Integer,
}
impl Clone for Signature {
fn clone(&self) -> Signature {
Signature {
h: self.h.clone(),
z: self.z.clone(),
}
}
}
#[derive(Debug)]
pub struct KeyPair {
pub owner: String,
pub pub_key: EdCurvePoint,
pub priv_key: Vec<u8>,
pub date_created: String,
pub curve: EdCurves,
}
impl Message {
pub fn new(data: Vec<u8>) -> Message {
Message {
msg: Box::new(data),
d: None,
sym_nonce: None,
asym_nonce: None,
digest: None,
op_result: None,
sig: None,
}
}
}
#[derive(Debug)]
pub struct Message {
pub msg: Box<Vec<u8>>,
pub d: Option<u64>,
pub sym_nonce: Option<Vec<u8>>,
pub asym_nonce: Option<EdCurvePoint>,
pub digest: Option<Vec<u8>>,
pub op_result: Option<bool>,
pub sig: Option<Signature>,
}
pub trait Hashable {
fn compute_sha3_hash(&mut self, d: u64);
fn compute_tagged_hash(&mut self, pw: &mut Vec<u8>, s: &str, d: u64);
}
pub trait PwEncryptable {
fn pw_encrypt(&mut self, pw: &[u8], d: u64);
fn pw_decrypt(&mut self, pw: &[u8]);
}
pub trait KeyEncryptable {
fn key_encrypt(&mut self, pub_key: &EdCurvePoint, d: u64);
fn key_decrypt(&mut self, pw: &[u8]);
}
pub trait Signable {
fn sign(&mut self, key: &KeyPair, d: u64);
fn verify(&mut self, pub_key: &EdCurvePoint);
}