# The golden-vector generator. Not part of the CONTRA binary and not on the
# Go build path — it exists so the vectors come from an implementation nobody
# here wrote (OpenSSL) rather than from the Go code they are meant to test.
#
#   make            build both tools
#   make vectors    regenerate ../contra-v1.json
#   make search     find a fresh rejecting seed (minutes; only needed if the
#                   EC derivation label ever changes)
#
# REJECT_K is the witness from seedsearch. It is pinned rather than searched
# on every run because the search costs a few billion HKDF evaluations.

CC      ?= cc
CFLAGS  ?= -O2 -Wall -Wextra -std=c99
LDLIBS  := -lcrypto
REJECT_K ?= 10962785172

all: gen seedsearch

gen: gen.c
	$(CC) $(CFLAGS) -o $@ $< $(LDLIBS)

seedsearch: seedsearch.c
	$(CC) $(CFLAGS) -O3 -o $@ $< $(LDLIBS) -lpthread

vectors: gen
	./gen $(REJECT_K) > ../contra-v1.json

search: seedsearch
	./seedsearch $$(nproc)

clean:
	rm -f gen seedsearch

.PHONY: all vectors search clean
