KEY1 = "$(shell cat ../sensitive/KEY1.hex)"
KEY2 = "$(shell cat ../sensitive/KEY2.hex)"

KEY3 = "f5 f5 81 00 0d 76 e2 d0 \
	d8 0b 91 37 cf 0b 1e d2 \
	ce 16 56 80 2b 7b 15 30 \
	4f af f1 3d df 7b cd e3"
KEY4 = "ae 70 08 1c a4 00 fe de \
	32 c0 5a 8a ca 2f 42 fe \
	0a e8 5a d0 6a 54 03 c5 \
	17 ff ba 48 a5 04 79 68"
SEED3 = 1940712257
SEED4 = 1830820818

EXAMPLE = "../data/Example/Example"
EXERCISE = "../data/Exercise/Exercise"

all:
	scalac -explaintypes -d classes *.scala

test:
	time python TestResults.py $(EXERCISE).res $(EXERCISE).msg
	time scala -cp classes TestResults $(EXERCISE).res $(EXERCISE).msg

anonymize:
	python ParseFBdata.py ../sensitive/Example.txt $(EXAMPLE).net $(KEY1)
	python ParseFBdata.py ../sensitive/Exercise.txt $(EXERCISE).net $(KEY2)

traces:
	## Use a fixed seed so that results are repeatable
	## Results generated using Python 2.6.2 with scipy 0.7.0 on Ubuntu Jaunty
	python makeTraces.py $(EXAMPLE).net $(EXAMPLE).soc $(EXAMPLE).dot \
	  $(EXAMPLE).msg $(EXAMPLE).trc $(KEY3) $(SEED3) | tee $(EXAMPLE).log
	python makeTraces.py $(EXERCISE).net $(EXERCISE).soc $(EXERCISE).dot \
	  $(EXERCISE).msg $(EXERCISE).trc $(KEY4) $(SEED4) | tee $(EXERCISE).log
	neato -Tpng -o$(EXAMPLE).dot.png $(EXAMPLE).dot
	neato -Tpng -o$(EXERCISE).dot.png $(EXERCISE).dot

sda:
	## Perform an SDA attack
	python SDA.py $(EXAMPLE).trc $(EXAMPLE).res 0809ef07
	python SDA.py $(EXERCISE).trc $(EXERCISE).res e29b9154
	python TestResults.py $(EXAMPLE).res $(EXAMPLE).msg
	python TestResults.py $(EXERCISE).res $(EXERCISE).msg

.PHONY: anonymize test traces sda
