use crypto::ntt
use crypto::fieldq

fn main() {
    let z = ntt_zetas()
    println("=== Zeta pairing check ===")
    println("For inverse to work: fqmul(z[64+i], z[127-i]) should = -1 mod q = 3328")
    println("")

    // Forward len=2 uses z[64..127], inverse len=2 uses z[127..64]
    // Forward group i uses z[64+i], inverse group i uses z[127-i]
    let mut i = 0
    while i < 8 {
        let fwd_idx = 64 + i
        let inv_idx = 127 - i
        let fwd_z = t_index_get(z, fwd_idx)
        let inv_z = t_index_get(z, inv_idx)
        let prod = fqmul(fwd_z, inv_z)
        let prod_norm = fq_normalize(prod)
        println("z[" + int_to_str(fwd_idx) + "]=" + float_to_str(fwd_z) + " * z[" + int_to_str(inv_idx) + "]=" + float_to_str(inv_z) + " = " + int_to_str(prod_norm))
        i = i + 1
    }

    // Also check: what IS the correct inverse zeta for z[64]?
    // If forward uses z[64] = -1103, inverse needs z_inv such that fqmul(z[64], z_inv) = q-1 = 3328
    println("")
    println("z[64] = " + float_to_str(t_index_get(z, 64)))
    println("z[127] = " + float_to_str(t_index_get(z, 127)))

    // Check if my tensor has the right length
    println("zetas tensor length: " + int_to_str(tensor_len(z)))

    // Print first and last few zetas
    println("")
    println("First 4 zetas: " + float_to_str(t_index_get(z, 0)) + " " + float_to_str(t_index_get(z, 1)) + " " + float_to_str(t_index_get(z, 2)) + " " + float_to_str(t_index_get(z, 3)))
    println("Last 4 zetas: " + float_to_str(t_index_get(z, 124)) + " " + float_to_str(t_index_get(z, 125)) + " " + float_to_str(t_index_get(z, 126)) + " " + float_to_str(t_index_get(z, 127)))
}
