1
0
mirror of https://github.com/henrydcase/nobs.git synced 2024-11-26 09:01:20 +00:00
nobs/Makefile
Kris Kwiatkowski 1e91fe8a91 cSIDH-511:
Implementation of Commutative Supersingular Isogeny Diffie Hellman,
based on "A faster way to CSIDH" paper (2018/782).

* For fast isogeny calculation, implementation converts a curve from
  Montgomery to Edwards. All calculations are done on Edwards curve
  and then converted back to Montgomery.
* As multiplication in a field Fp511 is most expensive operation
  the implementation contains multiple multiplications. It has
  most performant, assembly implementation which uses BMI2 and
  ADOX/ADCX instructions for modern CPUs. It also contains
  slower implementation which will run on older CPUs

Benchmarks (Intel SkyLake):
----------
BenchmarkGeneratePrivate   	    6459	    172213 ns/op	       0 B/op	       0 allocs/op
BenchmarkGenerateKeyPair   	      25	  45800356 ns/op	       0 B/op	       0 allocs/op
BenchmarkValidate          	     297	   3915983 ns/op	       0 B/op	       0 allocs/op
BenchmarkValidateRandom    	  184683	      6231 ns/op	       0 B/op	       0 allocs/op
BenchmarkValidateGenerated 	      25	  48481306 ns/op	       0 B/op	       0 allocs/op
BenchmarkDerive            	      19	  60928763 ns/op	       0 B/op	       0 allocs/op
BenchmarkDeriveGenerated   	       8	 137342421 ns/op	       0 B/op	       0 allocs/op
BenchmarkXMul              	    2311	    494267 ns/op	       1 B/op	       0 allocs/op
BenchmarkXAdd              	 2396754	       501 ns/op	       0 B/op	       0 allocs/op
BenchmarkXDbl              	 2072690	       571 ns/op	       0 B/op	       0 allocs/op
BenchmarkIsom              	   78004	     15171 ns/op	       0 B/op	       0 allocs/op
BenchmarkFp512Sub          	224635152	         5.33 ns/op	       0 B/op	       0 allocs/op
BenchmarkFp512Mul          	246633255	         4.90 ns/op	       0 B/op	       0 allocs/op
BenchmarkCSwap             	233228547	         5.10 ns/op	       0 B/op	       0 allocs/op
BenchmarkAddRdc            	87348240	        12.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSubRdc            	95112787	        11.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkModExpRdc         	   25436	     46878 ns/op	       0 B/op	       0 allocs/op
BenchmarkMulBmiAsm         	19527573	        60.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkMulGeneric        	 7117650	       164 ns/op	       0 B/op	       0 allocs/op
2019-11-24 03:24:30 +00:00

86 lines
2.5 KiB
Makefile

# I'm sure there is better way. But I would need to find it first
MK_FILE_PATH = $(lastword $(MAKEFILE_LIST))
PRJ_DIR = $(abspath $(dir $(MK_FILE_PATH)))
GO ?= go
GOPATH_LOCAL = $(PRJ_DIR)/build/
GOPATH_DIR = src/github.com/henrydcase/nobs
VENDOR_DIR = tls_vendor
OPTS ?= -v
NOASM ?=
TEST_PATH ?= ./...
GOCACHE ?= off
BENCH_OPTS ?= -v -bench=. -run="^_" -benchmem
TEST_PATH ?= ./...
DBG = 1
OPTS_ENV =
ifeq ($(NOASM),1)
OPTS+=$(OPTS_TAGS)
endif
ifeq ($(PPROF),1)
BENCH_OPTS+= -cpuprofile=cpu.out -memprofile=mem0.out
endif
ifeq ($(DBG),1)
DBG_FLAGS+= #-m # escape analysis
DBG_FLAGS+= -l # no inline
DBG_FLAGS+= -N # debug symbols
#OPTS+=-gcflags=all="$(DBG_FLAGS)"
OPTS+=-gcflags "$(DBG_FLAGS)"
OPTS_ENV+= GOTRACEBACK=crash # enable core dumps
endif
TARGETS ?= \
dh \
drbg \
ec \
hash \
kem \
utils
prep-%:
mkdir -p $(GOPATH_LOCAL)/$(GOPATH_DIR)
cp -rf $* $(GOPATH_LOCAL)/$(GOPATH_DIR)/$*
make_dirs:
mkdir -p $(GOPATH_LOCAL)/$(GOPATH_DIR)
cp -rf etc $(GOPATH_LOCAL)/$(GOPATH_DIR)
test: clean make_dirs $(addprefix prep-,$(TARGETS))
cd $(GOPATH_LOCAL); $(OPTS_ENV) GOPATH=$(GOPATH_LOCAL) go test $(OPTS) $(TEST_PATH)
test_csidh: clean make_dirs $(addprefix prep-,$(TARGETS))
cd $(GOPATH_LOCAL); $(OPTS_ENV) GOPATH=$(GOPATH_LOCAL) go test $(OPTS) github.com/henrydcase/nobs/dh/csidh
test_csidh_bin: clean make_dirs $(addprefix prep-,$(TARGETS))
cd $(GOPATH_LOCAL); $(OPTS_ENV) GOPATH=$(GOPATH_LOCAL) go test -c $(OPTS) github.com/henrydcase/nobs/dh/csidh
cover:
cd $(GOPATH_LOCAL); $(OPTS_ENV) GOPATH=$(GOPATH_LOCAL) go test \
-race -coverprofile=coverage_$(NOASM).txt -covermode=atomic $(OPTS) $(TEST_PATH)
cat $(GOPATH_LOCAL)/coverage_$(NOASM).txt >> coverage.txt
bench: clean $(addprefix prep-,$(TARGETS))
cd $(GOPATH_LOCAL); GOCACHE=$(GOCACHE) GOPATH=$(GOPATH_LOCAL) $(GO) test \
$(BENCH_OPTS) $(TEST_PATH)
bench_csidh: clean $(addprefix prep-,$(TARGETS))
cd $(GOPATH_LOCAL); GOCACHE=$(GOCACHE) GOPATH=$(GOPATH_LOCAL) $(GO) test \
$(BENCH_OPTS) github.com/henrydcase/nobs/dh/csidh
clean:
rm -rf $(GOPATH_LOCAL)
rm -rf $(VENDOR_DIR)
vendor-sidh-for-tls: clean
mkdir -p $(VENDOR_DIR)/github_com/henrydcase/nobs/
rsync -a . $(VENDOR_DIR)/github_com/henrydcase/nobs/ --exclude=$(VENDOR_DIR) --exclude=.git --exclude=.travis.yml --exclude=README.md
find $(VENDOR_DIR) -type f -print0 -name "*.go" | xargs -0 sed -i 's/github\.com/github_com/g'
pprof-cpu:
$(GO) tool pprof $(GOPATH_LOCAL)/cpu.out
pprof-mem:
$(GO) tool pprof $(GOPATH_LOCAL)/mem0.out