Skip to content

Codebase Tour

Claudio Lucisano edited this page Sep 22, 2026 · 1 revision

Codebase Tour

A map of the repository for new contributors. Everything lives in the oabe namespace (symmetric crypto in oabe::crypto).

Top level

Path What it is
env Shell script to source before anything else. It sets ZROOT, library paths, OS detection and Android cross-compilation.
Makefile, Makefile.common Top-level build. Makefile.common holds shared flags: C++17, include paths, RELIC and OpenSSL libraries, per-OS tweaks.
deps/ Bundled third-party code, downloaded and built into deps/root/: RELIC 0.7.0, OpenSSL 4.0.1, GoogleTest
src/ The library itself: builds libopenabe (static and shared) and the unit tests
cli/ The oabe_setup, oabe_keygen, oabe_enc and oabe_dec tools, plus their test scripts
examples/ Small programs using the crypto box API: test_cp, test_kp, test_pk, test_km
bindings/python/ Cython bindings (pyopenabe)
platforms/android.sh Cross-compiles dependencies for Android
docs/ Reference docs (Markdown) and the original v1.0 PDF guides
root/ Build output: installed headers and libraries (git-ignored)

Layers of src/

From the top (what users call) to the bottom (math):

 crypto box        zcrypto_box.cpp           OpenABECryptoContext, OpenPKEContext, OpenPKSIGContext
      │
 CCA / contexts    zcontext.cpp, abe/zcontextcca.cpp, abe/zcontextabe.cpp
      │
 schemes           abe/zcontextcpwaters.cpp  (CP-ABE, Waters)
                   abe/zcontextkpgpsw.cpp    (KP-ABE, GPSW)
                   pke/zcontextpke.cpp       (PK-ENC, one-pass DH)
                   pksig/zcontextpksig.cpp   (ECDSA)
                   ske/zcontextske.cpp       (symmetric, authenticated)
      │
 building blocks   tools/zlsss.cpp           linear secret sharing (policies → shares)
                   tools/zprng.cpp           CTR_DRBG (NIST SP 800-90A)
                   keys/                     key objects, KDF, keystore
                   utils/                    policies, attribute lists, ciphertexts, containers, errors, X.509
      │
 math (zml)        zml/zgroup.cpp, zelement_bp.cpp, zelement_ec.cpp, zpairing.cpp, zelliptic.cpp
                   zml/zelement.c            C wrappers over RELIC, BN-254 build
                   zml/zelement_ec_relic.c   C wrappers over RELIC, P-256 build (isolated)

Directory by directory

src/zml/: Zeutro Math Library

An abstraction over elliptic curves and pairings, so the schemes never call RELIC directly.

  • zgroup, zelement_bp, zpairing: pairing groups G1, G2, GT and the pairing (BN-254), used by ABE
  • zelement_ec, zelliptic: plain elliptic-curve groups (NIST P-256), used by PKE and ECDSA
  • zelement.c / zelement_ec_relic.c: the only files that touch RELIC. They talk to two different RELIC builds and must never be mixed; see RELIC Dual Build.

src/abe/, pke/, pksig/, ske/: schemes

Each scheme implements a context class declared under src/include/openabe/low/…. zcontextcca.cpp turns the CPA-secure ABE schemes into CCA-secure ones, which is what the crypto box and CLI always use.

src/keys/

zkey (base key object with header), zpkey (public-key keys), zsymkey (symmetric keys), zkdf (key derivation), and zkeystore (the in-memory store behind the key manager; see Key Management).

src/utils/

  • zpolicy, zattributelist, zfunctioninput: parsed policies and attribute lists
  • zdriver: the glue between bison/flex and the policy tree. Numeric comparisons, ranges and dates are expanded here.
  • zciphertext, zcontainer, zbytestring (header only): serialization
  • zkeymgr: key manager, zx509: certificates, zerror: error strings, zbenchmark: timing

Parser

File Role
src/zparser.yy Bison grammar for policies and attribute lists
src/zscanner.ll Flex scanner: what counts as an attribute, the keywords
zparser.tab.*, location.hh, position.hh, stack.hh, zscanner.cpp, zparser.output Generated. Committed for convenience, regenerated by the build, never edited or formatted by hand

Headers: src/include/openabe/

openabe.h is the umbrella header: applications include it and get everything. Most internal headers are not self-contained and rely on the include order inside openabe.h, which is why include sorting is disabled. The low/ subfolder holds the scheme-level (non crypto box) APIs.

Programs inside src/

Program Purpose
test_libopenabe, test_zml, test_abe, test_pke, test_ske, test_keystore, test_zsym Unit tests (GoogleTest)
test_policy, test_zml1, test_zml2 Extra tests, not run by make test
bench_libopenabe, profile_libopenabe Benchmarking and profiling
fuzz_policy, fuzz_attrlist Fuzz targets for the parser

Where to start for common changes

I want to… Look at
extend the policy language zparser.yy, zscanner.ll, utils/zdriver.cpp, then test_policy.cpp
change the high-level API zcrypto_box.h/.cpp, bindings/python/pyopenabe.pyx, examples/
touch curve or pairing code RELIC Dual Build first, then zml/
add a CLI option cli/common.* and the relevant tool

Clone this wiki locally