hop-core 0.1.1

HOP core — finite-field companion-matrix stream primitives (prototype)
Documentation
use hop_core::modules::field::Field;
use hop_core::modules::companion::CompanionMatrix;
use hop_core::modules::stream::StreamGenerator;
use hop_core::modules::poly_eval::poly_matrix_eval;
use hop_core::modules::vss::ShamirVSS;

#[test]
fn integration_smoke() {
    // small smoke test of pipeline
    // Recurrence: F_n = 2*F_{n-1} + 3*F_{n-2}  (k=2)
    let coeffs = vec![2u64, 3u64];
    let c = CompanionMatrix::from_coeffs(&coeffs);
    let _k = c.k;
    let init_state = vec![Field::new(7u128), Field::new(11u128)];

    // choose g(x) = 5 + 6*x
    let g = vec![5u64, 6u64];
    let t = poly_matrix_eval(&g, &c.mat);

    // FIX: Use lowercase `c` and `t`
    let mut sg = StreamGenerator::new(c, t, init_state);

    let out = sg.generate(8);

    // we expect some outputs; check length and they are Field elements
    assert_eq!(out.len(), 8);

    // VSS quick check
    let secret = Field::new(123u128);
    let shares = ShamirVSS::share(secret, 5, 3);
    assert_eq!(shares.len(), 5);

    // Recover using first 3 shares
    let recovered = hop_core::modules::vss::interpolate_at_zero(&shares[0..3]);
    assert_eq!(recovered, secret);
}