1#![no_std]
2
3pub mod core;
4pub mod host;
5pub mod sfield;
6pub mod types;
7
8#[cfg(target_arch = "wasm32")]
11#[panic_handler]
12fn panic(_info: &::core::panic::PanicInfo) -> ! {
13 ::core::arch::wasm32::unreachable();
16}
17
18fn hex_char_to_nibble(c: u8) -> Option<u8> {
19 match c {
20 b'0'..=b'9' => Some(c - b'0'),
21 b'a'..=b'f' => Some(c - b'a' + 10),
22 b'A'..=b'F' => Some(c - b'A' + 10),
23 _ => None,
24 }
25}
26
27pub fn decode_hex_32(hex: &[u8; 64]) -> Option<[u8; 32]> {
28 let mut out = [0u8; 32];
29 let mut i = 0;
30 while i < 32 {
31 let high = hex_char_to_nibble(hex[i * 2])?;
32 let low = hex_char_to_nibble(hex[i * 2 + 1])?;
33 out[i] = (high << 4) | low;
34 i += 1;
35 }
36 Some(out)
37}