#![cfg(test)]
use super::*;
use crate::attestation;
use crate::error::TrustError;
use crate::merkle::tree::{AppendOnlyTree, RawLeaf};
#[path = "sign_tests/families.rs"]
mod families;
#[path = "sign_tests/issuance.rs"]
mod issuance;
#[path = "sign_tests/uniform_failure.rs"]
mod uniform_failure;
#[path = "sign_tests/verification.rs"]
mod verification;
fn leaf_bytes(index: u64) -> Vec<u8> {
format!("checkpoint-{index}").into_bytes()
}
fn tree_of(size: u64) -> AppendOnlyTree<RawLeaf> {
let mut tree = AppendOnlyTree::<RawLeaf>::new();
for index in 0..size {
tree.append_raw(&leaf_bytes(index));
}
tree
}
fn path_of(size: u64, index: u64) -> Vec<[u8; 32]> {
let tree = tree_of(size);
let proof = tree.prove_inclusion(index).unwrap();
proof
.as_bytes()
.chunks_exact(32)
.map(|c| <[u8; 32]>::try_from(c).unwrap())
.collect()
}
fn anchor(seed: &[u8; 32]) -> crate::Ed25519Identity {
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("anchor.key");
std::fs::write(&path, seed).unwrap();
crate::Ed25519Identity::load(&path).unwrap()
}
fn primary() -> crate::Ed25519Identity {
anchor(b"lys-anchor-receipt-test-seed-01a")
}
fn other() -> crate::Ed25519Identity {
anchor(b"lys-anchor-receipt-test-seed-02b")
}