Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ECAI Elliptic Compiler Core

This is the core deterministic elliptic compiler skeleton for Erlang.

It separates the system into two layers:

  1. Erlang compiler/retrieval layer (src/ecai.erl)

    • normalizes source text or terms
    • segments source into deterministic atoms
    • derives per-atom scalar material
    • builds an exact retrieval index
    • aggregates curve states into a root commitment
  2. C NIF curve layer (c_src/ecai_nif.c)

    • secp256k1 hash-to-curve by deterministic try-and-increment
    • compressed SEC1 point import/export
    • point addition
    • point negation
    • point aggregation
    • scalar multiplication
    • base point multiplication

The compiler does not guess. It turns source material into deterministic curve-state commitments and retrieves exact compiled states from its index.

Dependencies

  • Erlang/OTP with erl_nif.h
  • OpenSSL development headers/libraries
  • C compiler
  • make

On Arch Linux:

sudo pacman -S erlang openssl base-devel rebar3

On Ubuntu/Debian:

sudo apt install erlang-dev erlang rebar3 build-essential libssl-dev

Build

rebar3 compile

or directly:

make priv/ecai_nif.so
mkdir -p ebin
ERL_LIBS=. erlc -I include -o ebin src/ecai.erl

Smoke test

erl -pa _build/default/lib/ecai/ebin -noshell -eval '
  {ok, P} = ecai:compile(#{mode => token}, <<"Given escrowed sats\nWhen behaviour passes\nThen Damage is released">>),
  io:format("root=~s~n", [maps:get(root_hex, P)]),
  {ok, R} = ecai:retrieve(<<"behaviour passes">>, P),
  io:format("retrieval=~p~n", [maps:with([matched_count, matched_segments, recovered_root_hex], R)]),
  halt().'

API shape

{ok, Program} = ecai:compile(#{mode => token}, <<"DamageBDD verifies behaviour">>),
RootHex = maps:get(root_hex, Program),
{ok, Retrieval} = ecai:retrieve(<<"behaviour">>, Program).

NIF primitives:

{ok, P, Counter} = ecai:hash_to_curve(<<"domain">>, <<"payload">>),
Scalar = crypto:hash(sha256, <<"scalar material">>),
{ok, Q} = ecai:scalar_mult(P, Scalar),
{ok, R} = ecai:point_add(P, Q),
{ok, Root} = ecai:aggregate([P, Q, R]).

Security notes

  • The NIF uses secp256k1 because it aligns with Bitcoin-native infrastructure.
  • hash_to_curve/2 uses deterministic try-and-increment, which is useful for indexing and commitments. For adversarial cryptographic protocols, replace it with a standards-track hash-to-curve suite and run a full audit.
  • NIFs can crash the VM if written incorrectly. Keep this layer small, test it hard, and fuzz binary inputs before production use.

About

ECAI elliptical compiler core in Erlang with C NIF acceleration for secp256k1 point operations, deterministic knowledge encoding, aggregation, retrieval-state recovery, and Bitcoin-native cryptographic indexing.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages