FourQ ECDH research port

Research only. Microsoft says upstream FourQlib is no longer maintained and is provided for research. This portable64 C subset has no production audit or compiled-Wasm constant-time qualification. Public decoding/encoding remains variable-time. It imports no SchnorrQ signing code, OS, RNG or allocation calls.

use cdk_rsx_crypto_fourq::{Error, PublicKey, SecretKey, SharedSecret};

fn exchange(secret: [u8; 32], peer: [u8; 32]) -> Result<SharedSecret, Error> {
    let secret = SecretKey::from_bytes(secret)?;
    let peer = PublicKey::from_bytes(peer)?;
    secret.agree(&peer)
}

Secret material must come from caller-owned cryptographic entropy; an all-zero input rejects. public_key derives a compressed 32-byte public key. Public-key imports require canonical field/point encodings and reject neutral points. Agreement validates the point, clears the cofactor and rejects a neutral result. Inputs copy to aligned bounded scratch before native word access. Explicit secret scratch and Rust key/shared-secret owners erase; this does not cover every compiler temporary or prior copy.

The 32-byte result is raw shared y-coordinate material. Apply a transcript-bound KDF and authenticate the peer before use; this primitive is not a complete key exchange or forward-secrecy protocol. The crate targets little-endian native tools and IC Wasm64 with the same generic arithmetic and no native assembly/SIMD.

Provenance pins upstream commit 1031567f23278e1135b35cc04e5d74c2ac88c029, archive/source hashes and local adaptations. The MIT license and upstream README are retained. Tests include the frozen upstream 1000-doubling point, 64 symmetric ECDH exchanges and malformed/canonical/weak-point cases. This does not replace independent adversarial ECDH review. The research note records portability, validation and timing limits; benchmark invalid inputs intentionally reject early.