Skip to content

Commit 4ec64df

Browse files
committed
Add a 32-bit platform to CI
Add some test vectors for `Uint::from_xof_reader()` Fix yaml error rustfmt Fix CI More platform independence tests Fix an error in test
1 parent 329341a commit 4ec64df

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ jobs:
7979
strategy:
8080
matrix:
8181
include:
82+
- target: i686-unknown-linux-gnu
83+
rust: 1.83.0 # MSRV
84+
deps: sudo apt update && sudo apt install gcc-multilib
8285
- target: x86_64-unknown-linux-gnu
8386
rust: 1.83.0 # MSRV
8487
steps:

src/paillier/keys.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,18 @@ mod tests {
430430
let sk = SecretKeyPaillierWire::<PaillierTest>::random(&mut OsRng);
431431

432432
let debug_output = format!("Sikrit {:?}", sk);
433+
434+
#[cfg(target_pointer_width = "32")]
435+
assert_eq!(
436+
debug_output,
437+
concat![
438+
"Sikrit SecretKeyPaillierWire ",
439+
"{ primes: SecretPrimesWire { p: Secret<crypto_bigint::uint::Uint<4>>(...), ",
440+
"q: Secret<crypto_bigint::uint::Uint<4>>(...) } }",
441+
]
442+
);
443+
444+
#[cfg(target_pointer_width = "64")]
433445
assert_eq!(
434446
debug_output,
435447
concat![

src/paillier/rsa.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,21 @@ impl<P: PaillierParams> PublicModulus<P> {
322322
.square()
323323
}
324324
}
325+
326+
#[cfg(test)]
327+
mod tests {
328+
use crypto_bigint::U128;
329+
use rand::SeedableRng;
330+
use rand_chacha::ChaChaRng;
331+
332+
use super::random_paillier_blum_prime;
333+
use crate::dev::PaillierTest;
334+
335+
#[test]
336+
fn platform_independence() {
337+
let mut rng = ChaChaRng::from_seed([7u8; 32]);
338+
339+
let x = random_paillier_blum_prime::<PaillierTest>(&mut rng);
340+
assert_eq!(x, U128::from_be_hex("EB855D60925A997645C143DBB9609D33"));
341+
}
342+
}

src/uint/traits.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,31 @@ impl<const L: usize> BoxedEncoding for Uint<L> {
220220
Ok(Self::from_be_slice(bytes))
221221
}
222222
}
223+
224+
#[cfg(test)]
225+
mod tests {
226+
use crypto_bigint::U256;
227+
use sha3::Shake256;
228+
229+
use super::FromXofReader;
230+
use crate::tools::hashing::{Chain, Hasher};
231+
232+
#[test]
233+
fn platform_independence() {
234+
let mut reader = Hasher::<Shake256>::new_with_dst(b"")
235+
.chain_bytes(b"abcde")
236+
.finalize_to_reader();
237+
238+
let x = U256::from_xof_reader(&mut reader, 256);
239+
assert_eq!(
240+
x,
241+
U256::from_be_hex("4E88D21E0CC82AD5C70B5140BCED37A5CC7EACC669D7BE9F87F467A4E798410F")
242+
);
243+
244+
let x = U256::from_xof_reader(&mut reader, 200);
245+
assert_eq!(
246+
x,
247+
U256::from_be_hex("000000000000007E7D58E090BE4D0C3DF61E93E7A733F410C243A648E93F0578")
248+
);
249+
}
250+
}

0 commit comments

Comments
 (0)