some lib changes

This commit is contained in:
Mars Ultor
2025-04-19 23:38:12 -05:00
parent 485e0ecf1d
commit df5ae14758
7 changed files with 223 additions and 12 deletions
+4
View File
@@ -12,3 +12,7 @@ rsa = "0.9.8"
x25519-dalek = "2.0.1"
ed25519-dalek = {version="2.1.1", features=["rand_core", "serde", "pkcs8", "alloc", "pem", "std"]}
rand = "0.9.1"
socket2 = "0.5.9"
serde = { version = "1.0", features = ["derive"] }
serde-big-array = "0.5"
postcard = "1.0.0"
+17 -11
View File
@@ -1,14 +1,20 @@
pub fn add(left: u64, right: u64) -> u64 {
left + right
// always use the following derive flags: #[derive(Deserialize, Serialize, Type, PartialEq, Debug)]
use serde::{Deserialize, Serialize};
use serde_big_array::BigArray;
const CHALLENGE_DIFF: usize = 40;
const SHA_LENGTH: usize = 512;
const BITS_IN_BYTE: usize = 8;
#[derive(Deserialize, Serialize, PartialEq, Debug)]
pub struct PowChallengeQuery{
#[serde(with = "BigArray")]
hash: [u8;SHA_LENGTH/BITS_IN_BYTE],
}
#[derive(Deserialize, Serialize, PartialEq, Debug)]
pub struct PowChallengeResponse{
#[serde(with = "BigArray")]
hash: [u8; SHA_LENGTH/BITS_IN_BYTE],
#[serde(with = "BigArray")]
secret: [u8; CHALLENGE_DIFF/BITS_IN_BYTE],
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}