fix(ci/crypto/lfs): update ceremony rustfmt, differential test, LFS attributes, and workflow pins
Browse files
crates/zymatica-zk-mesh/groth16/src/ceremony.rs
CHANGED
|
@@ -356,12 +356,21 @@ pub fn initialize(output_path: &str) -> Result<(), String> {
|
|
| 356 |
}
|
| 357 |
|
| 358 |
/// Phase 2: Contribute entropy to the ceremony parameters.
|
| 359 |
-
pub fn contribute(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 360 |
eprintln!("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
|
| 361 |
eprintln!("β ZK-LoRaWAN MPC Ceremony β Phase 2: Contribute β");
|
| 362 |
eprintln!("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
|
| 363 |
eprintln!();
|
| 364 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
eprintln!(" Loaded ceremony params from: {}", input_path);
|
| 366 |
eprintln!(" Previous contribution: #{}", params.contribution_index);
|
| 367 |
eprintln!(
|
|
@@ -792,13 +801,42 @@ mod tests {
|
|
| 792 |
|
| 793 |
#[test]
|
| 794 |
fn test_keccak256_sponge_boundary_differential() {
|
| 795 |
-
|
| 796 |
-
let test_lengths = [
|
|
|
|
|
|
|
| 797 |
for &len in &test_lengths {
|
| 798 |
-
let data = vec![0x61u8; len];
|
| 799 |
-
let
|
| 800 |
-
|
| 801 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 802 |
}
|
| 803 |
}
|
| 804 |
}
|
|
|
|
| 356 |
}
|
| 357 |
|
| 358 |
/// Phase 2: Contribute entropy to the ceremony parameters.
|
| 359 |
+
pub fn contribute(
|
| 360 |
+
input_path: &str,
|
| 361 |
+
output_path: &str,
|
| 362 |
+
contributor_name: &str,
|
| 363 |
+
) -> Result<(), String> {
|
| 364 |
eprintln!("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
|
| 365 |
eprintln!("β ZK-LoRaWAN MPC Ceremony β Phase 2: Contribute β");
|
| 366 |
eprintln!("ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ");
|
| 367 |
eprintln!();
|
| 368 |
|
| 369 |
+
// Load previous parameters
|
| 370 |
+
let data =
|
| 371 |
+
std::fs::read(input_path).map_err(|e| format!("Failed to read {}: {}", input_path, e))?;
|
| 372 |
+
let mut params = CeremonyParams::from_bytes(&data)?;
|
| 373 |
+
|
| 374 |
eprintln!(" Loaded ceremony params from: {}", input_path);
|
| 375 |
eprintln!(" Previous contribution: #{}", params.contribution_index);
|
| 376 |
eprintln!(
|
|
|
|
| 801 |
|
| 802 |
#[test]
|
| 803 |
fn test_keccak256_sponge_boundary_differential() {
|
| 804 |
+
use sha3::{Digest, Keccak256};
|
| 805 |
+
let test_lengths = [
|
| 806 |
+
0, 1, 2, 7, 31, 32, 63, 100, 134, 135, 136, 137, 138, 270, 271, 272, 273, 274, 4096,
|
| 807 |
+
];
|
| 808 |
for &len in &test_lengths {
|
| 809 |
+
let data = vec![0x61u8; len];
|
| 810 |
+
let ours = keccak256(&data);
|
| 811 |
+
let mut reference = Keccak256::new();
|
| 812 |
+
reference.update(&data);
|
| 813 |
+
let expected = reference.finalize();
|
| 814 |
+
assert_eq!(
|
| 815 |
+
ours.as_slice(),
|
| 816 |
+
expected.as_slice(),
|
| 817 |
+
"Keccak mismatch at boundary length {len}"
|
| 818 |
+
);
|
| 819 |
+
}
|
| 820 |
+
|
| 821 |
+
// 1,000 deterministic seeded randomized test vectors
|
| 822 |
+
let mut seed = 0x12345678u64;
|
| 823 |
+
for _ in 0..1000 {
|
| 824 |
+
seed = seed
|
| 825 |
+
.wrapping_mul(6364136223846793005)
|
| 826 |
+
.wrapping_add(1442695040888963407);
|
| 827 |
+
let len = (seed % 4096) as usize;
|
| 828 |
+
let data: Vec<u8> = (0..len)
|
| 829 |
+
.map(|i| ((seed.wrapping_add(i as u64)) & 0xFF) as u8)
|
| 830 |
+
.collect();
|
| 831 |
+
let ours = keccak256(&data);
|
| 832 |
+
let mut reference = Keccak256::new();
|
| 833 |
+
reference.update(&data);
|
| 834 |
+
let expected = reference.finalize();
|
| 835 |
+
assert_eq!(
|
| 836 |
+
ours.as_slice(),
|
| 837 |
+
expected.as_slice(),
|
| 838 |
+
"Keccak randomized differential mismatch at length {len}"
|
| 839 |
+
);
|
| 840 |
}
|
| 841 |
}
|
| 842 |
}
|