This is the core deterministic elliptic compiler skeleton for Erlang.
It separates the system into two layers:
-
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
-
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.
- Erlang/OTP with
erl_nif.h - OpenSSL development headers/libraries
- C compiler
make
On Arch Linux:
sudo pacman -S erlang openssl base-devel rebar3On Ubuntu/Debian:
sudo apt install erlang-dev erlang rebar3 build-essential libssl-devrebar3 compileor directly:
make priv/ecai_nif.so
mkdir -p ebin
ERL_LIBS=. erlc -I include -o ebin src/ecai.erlerl -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().'{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]).- The NIF uses secp256k1 because it aligns with Bitcoin-native infrastructure.
hash_to_curve/2uses 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.