Skip to main content

TequelHash

Struct TequelHash 

Source
pub struct TequelHash {
    pub states: [u32; 12],
    pub salt: String,
    pub iterations: u32,
}
Expand description

TequelHash provides hash functions, custom iterations and salt.

Fields§

§states: [u32; 12]§salt: String§iterations: u32

Implementations§

Source§

impl TequelHash

Source

pub fn new() -> Self

Source

pub fn with_salt(self, salt: &str) -> Self

Source

pub fn with_iteration(self, value: u32) -> Self

Source

pub fn tqlhash(&mut self, input: &[u8]) -> String

Generates a unique 384-bit hexadecimal hash from the input data.

This function is the core of the Tequel engine, utilizing SIMD/AVX2 /// instructions to process data in 256-bit blocks. It is designed for high-speed performance and maximum bit diffusion.

§Performance

By leveraging hardware acceleration, tqlhash achieves significantly lower latency compared to scalar implementations, making it ideal for large-scale data integrity checks and real-time obfuscation.

§Determinism

The algorithm is strictly deterministic. Providing the same input bytes will always yield the exact same hexadecimal string.

§Arguments
  • input - The raw data bytes (&[u8]) to be hashed.
§Returns

A 96-character hexadecimal String (12 x 32-bit internal states).

§Example
use tequel::hash::TequelHash;
 
let mut tequel = TequelHash::new();
let data = b"secret_data";
 
let hash_a = tequel.tqlhash(data);
let hash_b = tequel.tqlhash(data);
 
assert_eq!(hash_a, hash_b);
println!("Hash: {}", hash_a);
Source

pub fn tqlhash_raw(&mut self, input: &[u8]) -> [u8; 48]

Generates a unique 384-bit hexadecimal hash from the input data.

This function is the core of the Tequel engine, utilizing SIMD/AVX2 /// instructions to process data in 256-bit blocks. It is designed for high-speed performance and maximum bit diffusion.

§Performance

By leveraging hardware acceleration, tqlhash_raw achieves significantly lower latency compared to scalar implementations, making it ideal for large-scale data integrity checks and real-time obfuscation.

§Determinism

The algorithm is strictly deterministic. Providing the same input bytes will always yield the exact same hexadecimal string.

§Arguments
  • input - The raw data bytes (&[u8]).
§Returns

A 32-bit list [u8; 32]

§Example
use tequel::hash::TequelHash;
 
let mut tequel = TequelHash::new();
let data = b"secret_data";
 
let bytes_a = tequel.tqlhash_raw(data);
let bytes_b = tequel.tqlhash_raw(data);
 
assert_eq!(bytes_a, bytes_b);
println!("bytes: {:?}", bytes_a);
Source

pub fn isv_tqlhash(&mut self, hash: &String, input: &[u8]) -> bool

Verifies if a given hash matches the original input data.

This is a convenience function that re-hashes the provided input and performs a comparison against the existing hash string.

§Security

The verification process leverages the TQL-11 SIMD engine to ensure high-speed integrity checks. It is ideal for verifying file integrity or checking stored credentials.

§Arguments
  • hash - The pre-computed hexadecimal hash string to be verified.
  • input - The raw bytes (&[u8]) of the data to check.
§Returns

Returns true if the re-computed hash matches the provided one, false otherwise.

§Example
use tequel::hash::TequelHash;
 
let mut tequel = TequelHash::new();
let data = b"secret_message";
let hash = tequel.tqlhash(data);

if tequel.isv_tqlhash(&hash, data) {
    println!("Integrity verified: VALID!");
} else {
    println!("Integrity compromised: NOT VALID!");
}
Source

pub fn isv_tqlhash_raw(&mut self, hash: &[u8; 48], input: &[u8]) -> bool

Source

pub fn derive_key(&mut self, password: &str, iterations: u32) -> [u8; 32]

Derives a high-entropy cryptographic key from a password and a salt.

This function implements a Key Derivation Function (KDF) powered by the TQL-11 engine. It utilizes a “Key Stretching” mechanism to make brute-force and dictionary attacks computationally expensive.

§Architecture

The process is SIMD-accelerated (AVX2), ensuring that the computational cost remains high for attackers (who must replicate the intensive TQL-11 rounds) while staying efficient for legitimate local use. Every iteration triggers a non-linear mutation with a validated 51% avalanche diffusion.

§Arguments
  • password - The raw bytes of the master password (e.g., from user input).
  • salt - A unique, random value used to prevent Rainbow Table attacks.
  • iterations - The number of hashing rounds. Higher values increase resistance against GPU-accelerated cracking (Recommended: >1000).
§Returns

A 384-bit hexadecimal String representing the derived cryptographic key.

§Example
use tequel::hash::TequelHash;
 
fn main() {
    let mut teq = TequelHash::new();
    let key = teq.derive_key("master_password_123", 2048);
    println!("Derived Key: {:?}", key);
}

Trait Implementations§

Source§

impl Clone for TequelHash

Source§

fn clone(&self) -> TequelHash

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TequelHash

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for TequelHash

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl PartialEq for TequelHash

Source§

fn eq(&self, other: &TequelHash) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Zeroize for TequelHash

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl Eq for TequelHash

Source§

impl StructuralPartialEq for TequelHash

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.