aigis-enc-binding 0.1.0

Rust bindings for the AIGIS-ENC KEM/TKEM implementation from PQMagic
Documentation
  • Coverage
  • 41.38%
    12 out of 29 items documented0 out of 12 items with examples
  • Size
  • Source code size: 152.04 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 630.73 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 17s Average build duration of successful builds.
  • all releases: 17s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • OxAndHorse

aigis-enc-binding

Rust bindings for the PQMagic AIGIS-ENC implementation (KEM + tagged KEM/TKEM).

This crate compiles the upstream C implementation with cc and exposes:

  • Low-level FFI-style wrappers (aigis_enc_*, aigis_tkem_*)
  • A safe high-level API (AigisEnc)

Features

Choose one parameter set at compile time:

  • params-1
  • params-2 (default)
  • params-3
  • params-4

Example:

cargo run --example demo --features params-2

Quick Start

use aigis_enc_binding::{AigisEnc, CRYPTO_TKEM_TAGBYTES};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let (pk, sk) = AigisEnc::keypair()?;

    // KEM
    let (ct, ss1) = AigisEnc::encapsulate(&pk)?;
    let ss2 = AigisEnc::decapsulate(&ct, &sk)?;
    assert_eq!(ss1, ss2);

    // TKEM
    let tag = vec![0x42u8; CRYPTO_TKEM_TAGBYTES];
    let (tct, tss1) = AigisEnc::encapsulate_with_tag(&pk, &tag)?;
    let tss2 = AigisEnc::decapsulate_with_tag(&tct, &sk, &tag)?;
    assert_eq!(tss1, tss2);

    Ok(())
}

Public API

  • AigisEnc::keypair()
  • AigisEnc::encapsulate(pk)
  • AigisEnc::decapsulate(ct, sk)
  • AigisEnc::encapsulate_with_tag(pk, tag)
  • AigisEnc::decapsulate_with_tag(ct, sk, tag)

Constants:

  • CRYPTO_PUBLICKEYBYTES
  • CRYPTO_SECRETKEYBYTES
  • CRYPTO_CIPHERTEXTBYTES
  • CRYPTO_BYTES
  • CRYPTO_TKEM_TAGBYTES
  • PARAMS

Build Notes

  • The crate contains vendored C sources under vendor/pqmagic so it can be packaged and published.
  • On Windows, the build links advapi32 for system randomness.

License

Apache-2.0