Skip to content

Commit

Permalink
Add hash module with twox128 and keccak256
Browse files Browse the repository at this point in the history
  • Loading branch information
vklachkov committed Nov 23, 2024
1 parent 995ef10 commit 6f949e3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ mod chainql {
}
}

#[pymodule]
mod hash {
use super::*;
use chainql_core::hex::Hex;

/// Conduct a 128-bit XX hash
#[pyfunction]
fn twox128(data: Vec<u8>) -> Vec<u8> {
chainql_core::builtin_twox128(Hex(data)).0
}

/// Conduct a 256-bit Keccak hash
#[pyfunction]
fn keccak256(data: Vec<u8>) -> Vec<u8> {
chainql_core::builtin_keccak256(Hex(data)).0
}
}

#[pymodule]
mod hex {
use super::*;
Expand Down

0 comments on commit 6f949e3

Please sign in to comment.