Skip to content

Commit

Permalink
Remove chacha implementation
Browse files Browse the repository at this point in the history
Archivers are on hold for now.
  • Loading branch information
sakridge committed Aug 4, 2020
1 parent 6011e8a commit cda1f2a
Show file tree
Hide file tree
Showing 15 changed files with 8 additions and 3,059 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ $ make -j$(nproc)
```

This should generate the libraries:
* libcuda-crypt.so - ed25519 verify (used by leaders) and chacha (used by validators) cuda implementations
* libcuda-crypt.so - ed25519 verify and poh verify cuda implementations
* libcl-crypt.so - ed25519 verify and poh verify OpenCL implementations

Copy libraries to the main Solana repo:
```bash
Expand Down
38 changes: 6 additions & 32 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@
# so more than one .so cannot be linked into a single program.
# Shared objects with device kernels also did not seem to work--
# it can build, but the kernel launch is not successful. (with cuda 9.2)
# Hence, build ed25519 ecdsa verify and chacha encryption device
# Hence, build ed25519 ecdsa verify and poh verify device
# code into a single binary.

V=debug
include gpu-common.mk

CHACHA_TEST_BIN=cuda_chacha_test
ECC_TEST_BIN=cuda_ed25519_verify
LIB=cuda-crypt

CL_ECC_TEST_BIN=cl_ed25519_verify
CL_LIB=cl-crypt

CHACHA_IF_DIR:=crypt-if

CL_HEADER_DIR:=opencl-platform

CUDA_HEADER_DIR:=cuda-headers
Expand All @@ -30,7 +27,7 @@ CUDA_DIR ?= /usr/local/cuda

CXX ?= g++

CFLAGS_COMMON:=-DENDIAN_NEUTRAL -DLTC_NO_ASM -I$(CHACHA_IF_DIR)
CFLAGS_COMMON:=-DENDIAN_NEUTRAL -DLTC_NO_ASM
CFLAGS+=$(CFLAGS_COMMON) -I$(CUDA_HEADER_DIR) -I$(CUDA_SHA256_DIR)

#use -DUSE_RDTSC for Windows compilation
Expand All @@ -41,8 +38,7 @@ CL_CFLAGS_release:=$(CL_CFLAGS_common) -O3
CL_CFLAGS_debug:=$(CL_CFLAGS_common) -O0 -g
CL_CFLAGS:=$(CL_CFLAGS_$V)

all: $(V)/$(CHACHA_TEST_BIN) \
$(V)/$(ECC_TEST_BIN) \
all: $(V)/$(ECC_TEST_BIN) \
$(V)/$(CL_ECC_TEST_BIN) \
$(V)/lib$(LIB).so \
$(V)/lib$(CL_LIB).so
Expand Down Expand Up @@ -82,11 +78,6 @@ $V/cl_poh_verify.o: $(CL_POH_VERIFY_SRCS)
@mkdir -p $(@D)
$(CXX) $(CL_CFLAGS) -I$(ECC_DIR) -c $< -o $@

CL_CHACHA_SRCS:=$(CL_CRYPT_DIR)/cl_chacha.cpp
$V/cl_chacha.o: $(CL_CHACHA_SRCS)
@mkdir -p $(@D)
$(CXX) $(CL_CFLAGS) -I$(ECC_DIR) -c $< -o $@

CL_SIGN_SRCS:=$(CL_ECC_DIR)/sign.cpp $(ECC_DIR)/fe.cu $(ECC_DIR)/ed25519.h
$V/cl_sign.o: $(CL_SIGN_SRCS)
@mkdir -p $(@D)
Expand All @@ -101,31 +92,18 @@ $V/cl_gpu_ctx.o: $(addprefix $(CL_ECC_DIR)/,gpu_ctx.cpp gpu_ctx.h)
@mkdir -p $(@D)
$(CXX) $(CL_CFLAGS) -I$(ECC_DIR) -c $< -o $@

CHACHA_DIR:=cuda-crypt
CHACHA_SRCS:=$(addprefix $(CHACHA_DIR)/,chacha_cbc.cu common.cu) $(CHACHA_IF_DIR)/chacha.h

$V/chacha_cbc.o: $(CHACHA_SRCS)
@mkdir -p $(@D)
$(NVCC) -rdc=true $(CFLAGS) -c $< -o $@

$V/cl_init_platform.o: opencl-platform/cl_init_platform.cpp
@mkdir -p $(@D)
$(CXX) $(CL_CFLAGS) -c $< -o $@

AES_SRCS:=$(addprefix $(CHACHA_DIR)/,aes_cbc.cu aes_core.cu modes_lcl.h common.cu)

$V/aes_cbc.o: $(AES_SRCS)
@mkdir -p $(@D)
$(NVCC) -rdc=true $(CFLAGS) -c $< -o $@

POH_DIR:=cuda-poh-verify
POH_SRCS:=$(addprefix $(POH_DIR)/,poh_verify.cu)

$V/poh_verify.o: $(POH_SRCS)
@mkdir -p $(@D)
$(NVCC) -rdc=true $(CFLAGS) -c $< -o $@

CL_CPU_GPU_OBJS=$(addprefix $V/,cl_init_platform.o cl_verify.o cl_gpu_ctx.o cl_sign.o cl_chacha.o cl_poh_verify.o)
CL_CPU_GPU_OBJS=$(addprefix $V/,cl_init_platform.o cl_verify.o cl_gpu_ctx.o cl_sign.o cl_poh_verify.o)

$V/lib$(CL_LIB).so: $(CL_CPU_GPU_OBJS)
$(CXX) -shared $^ -L$(CUDA_DIR)/lib64 -lOpenCL -o $@
Expand All @@ -137,17 +115,14 @@ $V/cl_ecc_main.o: $(CL_ECC_DIR)/main.cpp $(ECC_DIR)/ed25519.h
$V/$(CL_ECC_TEST_BIN): $V/cl_ecc_main.o $V/lib$(CL_LIB).so
$(CXX) $(CL_CFLAGS) -L$(CUDA_DIR)/lib64 -L$V -pthread $< -l$(CL_LIB) -lOpenCL -o $@

CPU_GPU_OBJS=$(addprefix $V/,chacha_cbc.o aes_cbc.o verify.o poh_verify.o gpu_ctx.o sign.o seed.o keypair.o)
CPU_GPU_OBJS=$(addprefix $V/,verify.o poh_verify.o gpu_ctx.o sign.o seed.o keypair.o)

$V/crypt-dlink.o: $(CPU_GPU_OBJS)
$(NVCC) -Xcompiler "-fPIC" $(CFLAGS) --device-link $^ --output-file $@

$V/lib$(LIB).so: $V/crypt-dlink.o $(CPU_GPU_OBJS)
$(NVCC) -Xcompiler "-fPIC" --shared --output-file $@ $^

$V/$(CHACHA_TEST_BIN): $(CHACHA_DIR)/test.cu $V/lib$(LIB).so
$(NVCC) $(CFLAGS) -L$V -l$(LIB) $< -o $@

$V/ecc_main.o: $(addprefix $(ECC_DIR)/,main.cu ed25519.h)
@mkdir -p $(@D)
$(NVCC) -rdc=true $(CFLAGS) -c $< -o $@
Expand All @@ -159,8 +134,7 @@ $V/$(ECC_TEST_BIN): $V/ecc_main.o $V/lib$(LIB).so
clean:
rm -rf $V

test: $V/$(ECC_TEST_BIN) $V/$(CHACHA_TEST_BIN)
cd $(V) && ./$(CHACHA_TEST_BIN) 64 \
test: $V/$(ECC_TEST_BIN)
cd $(V) && ./$(ECC_TEST_BIN) 1 1 1 1 1 1
cd $(V) && ./$(ECC_TEST_BIN) 64 1 1 1 1 0
cd $(V) && ./$(ECC_TEST_BIN) 100201 1 1 4 10 1
44 changes: 0 additions & 44 deletions src/crypt-if/chacha.h

This file was deleted.

98 changes: 0 additions & 98 deletions src/cuda-crypt/aes.h

This file was deleted.

Loading

0 comments on commit cda1f2a

Please sign in to comment.