Skip to content

Commit

Permalink
Merge pull request #12 from nadav-fireblocks/organize-dependencies
Browse files Browse the repository at this point in the history
Organize dependencies
  • Loading branch information
cblokh authored Dec 12, 2023
2 parents 8eec54c + cba8a97 commit ebff055
Show file tree
Hide file tree
Showing 13 changed files with 481 additions and 237 deletions.
32 changes: 32 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

name: Run tests
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-20.04
strategy:
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update && sudo apt install -y build-essential uuid-dev libssl-dev libsecp256k1-dev
- name: Build
run: |
make -C src
- name: Build tests
run: |
make -C test
- name: Run Tests
run: |
make run-tests
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@
# Executables
*.exe
*.out
*.app

*.app
25 changes: 25 additions & 0 deletions docker/Dockerfile.bookworm
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM debian:bookworm-slim

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt install -y \
build-essential \
uuid-dev \
libsecp256k1-dev \
wget \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/cache/apt/archives/*

WORKDIR /usr/src/

RUN wget -O openssl-1.1.1t.tar.gz https://www.openssl.org/source/openssl-1.1.1t.tar.gz \
&& tar zxf openssl-1.1.1t.tar.gz \
&& cd openssl-1.1.1t \
&& ./config && make && make install_sw \
&& cd ../ && rm -rf openssl-1.1.1t\
&& find /usr/local/share -type f -delete


ENV LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
COPY . /usr/src/mpc-lib/
WORKDIR /usr/src/mpc-lib
15 changes: 15 additions & 0 deletions docker/Dockerfile.focal
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

FROM ubuntu:focal

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt install -y \
build-essential \
uuid-dev \
libssl-dev \
libsecp256k1-dev \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/cache/apt/archives/*

COPY . /usr/src/mpc-lib/
WORKDIR /usr/src/mpc-lib
25 changes: 25 additions & 0 deletions docker/Dockerfile.jammy
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

FROM ubuntu:jammy

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt install -y \
build-essential \
uuid-dev \
libsecp256k1-dev \
wget \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/cache/apt/archives/*

WORKDIR /usr/src/

RUN wget -O openssl-1.1.1t.tar.gz https://www.openssl.org/source/openssl-1.1.1t.tar.gz \
&& tar zxf openssl-1.1.1t.tar.gz \
&& cd openssl-1.1.1t \
&& ./config && make && make install_sw \
&& cd ../ && rm -rf openssl-1.1.1t\
&& find /usr/local/share -type f -delete

ENV LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
COPY . /usr/src/mpc-lib/
WORKDIR /usr/src/mpc-lib
38 changes: 38 additions & 0 deletions docker/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
set -e

if [ x${1} != "x" ]; then
Dockerfile=${1}
else
echo "Must Select a Dockerfile"
exit 1
fi

if [ ! -f ${Dockerfile} ]; then
echo "${Dockerfile} not found"
exit 1
fi

input_base_name=$(basename ${Dockerfile})
prefix=$(echo ${input_base_name}| awk '{split($0,a,"."); print a[1]}')
tag=$(echo ${input_base_name}| awk '{split($0,a,"."); print a[2]}')

if [ x${prefix} != "xDockerfile" ]; then
echo "Must Select a valid Dockerfile"
exit 1
fi

if [ x${tag} == "x" ]; then
echo "Dockerfile has no tag"
exit 1
fi

IMAGE_NAME=mpc-lib-tester-$tag

docker build -f ${Dockerfile} . -t $IMAGE_NAME

docker run \
--rm \
${IMAGE_NAME} bash -c "make -j && make run-tests"

echo "Done"
534 changes: 309 additions & 225 deletions include/tests/catch.hpp

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ Lib_Name := libcosigner.so
all: $(Lib_Name)

$(C_Objects): %.o: %.c
@$(CC) $(C_Flags) -c $< -o $@
@echo "CC <= $<"
@$(CC) $(C_Flags) -c $< -o $@

$(Cpp_Objects): %.o: %.cpp
@$(CXX) $(Cpp_Flags) -c $< -o $@
@echo "CXX <= $<"
@$(CXX) $(Cpp_Flags) -c $< -o $@

$(Lib_Name): $(Cpp_Objects) $(C_Objects) lib.lds
@$(CXX) $(Cpp_Objects) $(C_Objects) -o $@ $(Link_Flags)
@echo "LINK => $@"
@$(CXX) $(Cpp_Objects) $(C_Objects) -o $@ $(Link_Flags)

clean:
@rm -fR $(Lib_Name) $(Cpp_Objects) $(C_Objects)
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ verifiable_secret_sharing_status verifiable_secret_sharing_get_share(const verif
return VERIFIABLE_SECRET_SHARING_INVALID_PARAMETER;
if (index >= shares->num_shares)
return VERIFIABLE_SECRET_SHARING_INVALID_INDEX;
if (!shares->shares[index])
if (!shares->shares)
return VERIFIABLE_SECRET_SHARING_UNKNOWN_ERROR;
share->id = shares->ids[index];
memcpy(share->data, shares->shares[index], sizeof(shamir_secret_sharing_scalar_t));
Expand Down
4 changes: 2 additions & 2 deletions test/cosigner/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ cosigner:
@$(MAKE) -C ../../src/

$(App_Cpp_Objects): %.o: %.cpp
@$(CXX) $(App_Cpp_Flags) -c $< -o $@
@echo "CXX <= $<"
@$(CXX) $(App_Cpp_Flags) -c $< -o $@

$(App_Name): $(App_Cpp_Objects) cosigner
@$(CXX) $(App_Cpp_Objects) -o $@ $(App_Link_Flags)
@echo "LINK => $@"
@$(CXX) $(App_Cpp_Objects) -o $@ $(App_Link_Flags)

clean:
@rm -rf $(App_Name) *.o
Expand Down
1 change: 1 addition & 0 deletions test/cosigner/setup_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ void create_secret(players_setup_info& players, cosigner_sign_algorithm type, co
{
std::unique_ptr<elliptic_curve256_algebra_ctx_t, void(*)(elliptic_curve256_algebra_ctx_t*)> algebra(create_algebra(type), elliptic_curve256_algebra_ctx_free);
const size_t PUBKEY_SIZE = algebra->point_size(algebra.get());
memset(pubkey, 0, sizeof(elliptic_curve256_point_t));

std::cout << "keyid = " << keyid << std::endl;
std::vector<uint64_t> players_ids;
Expand Down
8 changes: 4 additions & 4 deletions test/crypto/ed25519_algebra/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ App_Link_Flags := -Wl,-Bstatic -lcrypto -Wl,-Bdynamic -pthread -ldl
all: $(App_Name)

main.o: main.cpp
@$(CXX) $(App_Cpp_Flags) -c $< -o $@
@echo "CXX <= $<"
@$(CXX) $(App_Cpp_Flags) -c $< -o $@

ed25519_algebra.o: ../../../src/common/crypto/ed25519_algebra/ed25519_algebra.c
@$(CC) $(App_C_Flags) -c $< -o $@
@echo "CC <= $<"
@$(CC) $(App_C_Flags) -c $< -o $@

keccak1600.o: ../../../src/common/crypto/keccak1600/keccak1600.c
@$(CC) $(App_C_Flags) -c $< -o $@
@echo "CC <= $<"
@$(CC) $(App_C_Flags) -c $< -o $@

$(App_Name): main.o ed25519_algebra.o keccak1600.o
@$(CXX) $^ -o $@ $(App_Link_Flags)
@echo "LINK => $@"
@$(CXX) $^ -o $@ $(App_Link_Flags)

clean:
@rm -rf $(App_Name) *.o
Expand Down

0 comments on commit ebff055

Please sign in to comment.