Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MPC] Phase2 MPC #73

Merged
merged 46 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ce84326
mpc: correctly return errors from utils
dtebbs Sep 18, 2019
e43f9fb
consistent compile flags, fixes intermittent test failure in some con…
dtebbs Sep 13, 2019
a54d51d
mpc: more output from dummy_phase2 command
dtebbs Sep 6, 2019
8f272fc
mpc: move functions and types for phase 2 mpc into their own file
dtebbs Sep 2, 2019
b290ada
powersoftau: determine degree and check vector sizes when validating
dtebbs Sep 9, 2019
182d220
powersoftau: functions to perform fast same_ratio checks in batches
dtebbs Sep 9, 2019
7dfe0f2
powersoftau: faster same_ratio batch tests using wnaf and concurrency
dtebbs Sep 12, 2019
e5b4f1c
use batch versions of same_ratio where possible for faster verification
dtebbs Sep 9, 2019
e582a35
libsodium: add submodule and build target in cmake
dtebbs Oct 17, 2019
68cf513
mpc: implementation of hash interface using blake2b
dtebbs Sep 3, 2019
6c8aa77
ci: find openssl headers on mac
dtebbs Sep 11, 2019
7ebd226
mpc: initial code and tests for phase2 operations
dtebbs Sep 2, 2019
6ed0519
mpc: verification of phase2 publickey in its own function
dtebbs Sep 5, 2019
7fe627d
mpc: phase2 transcript verification
dtebbs Sep 5, 2019
291cf81
mpc: fix some naming
dtebbs Sep 5, 2019
7562fef
mpc: use challenge and response in dummy-phase2 and keygen
dtebbs Sep 5, 2019
5416247
mpc: factor out check of consistency between phase2 accumulators
dtebbs Sep 6, 2019
3f80846
mpc: output final transcript digest from transcript verification
dtebbs Sep 6, 2019
f45c168
mpc: phase2_begin command
dtebbs Sep 6, 2019
960c9e6
mpc: phase2-contribute command
dtebbs Sep 6, 2019
285ccf6
mpc: add phase2 commands to test script
dtebbs Sep 6, 2019
27ae282
mpc: verify-contribution command
dtebbs Sep 6, 2019
828da20
mpc: verify-transcript command implementation
dtebbs Sep 6, 2019
a45b710
mpc: functions to read/write mpc hash as human-readable strings
dtebbs Sep 9, 2019
55cb9bb
mpc: check inclusion of contribution in phase2 transcript
dtebbs Sep 9, 2019
d828a99
mpc: flag to write out contribution digest
dtebbs Sep 9, 2019
d4b7b67
mpc: flag to check inclusion of contribution in transcript
dtebbs Sep 9, 2019
52f658e
mpc: contribution checks in test script
dtebbs Sep 10, 2019
f43408c
powersoftau: tests for point compression
dtebbs Sep 11, 2019
074ef1d
mpc: use compressed points in phase2 MPC responses
dtebbs Sep 11, 2019
3fe45ee
powersoftau: load uncompressed data (as used in challenge and transcr…
dtebbs Sep 16, 2019
bf68715
mpc: rng implementation to match powersoftau and phase2
dtebbs Sep 18, 2019
8447f42
mpc: generate g2 using chacha_rng
dtebbs Sep 18, 2019
1c35465
mpc: improve contribution randomness (including user input)
dtebbs Sep 18, 2019
e299cbd
rearrange source code
dtebbs Sep 18, 2019
1e8648f
mpc: create separate administrator and client tools
dtebbs Sep 18, 2019
06ac174
ci: faster builds for non-PR commits
dtebbs Sep 18, 2019
dcd3427
move type definitions to a single file, shared by all executables
dtebbs Sep 19, 2019
5d6fa25
tests: support for combining tests (combined mimc tests)
dtebbs Oct 22, 2019
4ef50e4
mpc: move hash functions and hash test into separate files
dtebbs Oct 22, 2019
b50425d
mpc: hashing stream wrapper and test
dtebbs Oct 18, 2019
b6daab8
mpc: use linear comb digest as initial transcript digest in phase2, a…
dtebbs Oct 18, 2019
54b91e6
util: better namning of type parameters
dtebbs Oct 22, 2019
634290b
mpc: require explicit output parameters in all mpc subcommands
dtebbs Oct 22, 2019
5b02ad4
mpc: small change to usage text layout
dtebbs Oct 22, 2019
684a86c
mpc: name global options common to all commands
dtebbs Oct 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "depends/googletest"]
path = depends/googletest
url = https://github.com/google/googletest.git
[submodule "depends/libsodium"]
path = depends/libsodium
url = https://github.com/jedisct1/libsodium.git
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ addons:
- boost
- openssl
- cmake
- libtool
- autoconf
- automake
# - llvm

matrix:
Expand Down
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,18 @@ option(
ON
)

option(
MONTGOMERY_OUTPUT
"Serialize Fp elements as their Montgomery representations (faster but not human-readable)"
ON
)

option(
USE_PT_COMPRESSION
"Use point compression"
OFF
)

set(USE_PT_COMPRESSION OFF)

if(APPLE)
# These must be disabled to make dependencies build on macos
set(WITH_PROCPS OFF)
Expand Down Expand Up @@ -154,6 +158,10 @@ if("${BINARY_OUTPUT}")
add_definitions(-DBINARY_OUTPUT)
endif()

if("${MONTGOMERY_OUTPUT}")
add_definitions(-DMONTGOMERY_OUTPUT)
endif()

if(NOT "${USE_PT_COMPRESSION}")
add_definitions(-DNO_PT_COMPRESSION=1)
endif()
Expand Down
19 changes: 19 additions & 0 deletions depends/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# libsnark
OPTION(IS_LIBSNARK_PARENT OFF)
add_subdirectory(libsnark)

Expand All @@ -8,3 +9,21 @@ set_target_properties(snark PROPERTIES COMPILE_FLAGS
set_target_properties(ff PROPERTIES COMPILE_FLAGS
"-Wno-unused-variable -Wno-unused-parameter"
)

# get NUM_CPUS
include(ProcessorCount)
ProcessorCount(NUM_CPUS)
if(NOT NUM_CPUS EQUAL 0)
set(MAKE_BUILD_FLAGS -j${NUM_CPUS})
endif()

# libsodium
set(LIBSODIUM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libsodium)

include(ExternalProject)
ExternalProject_Add(
libsodium
SOURCE_DIR ${LIBSODIUM_SOURCE_DIR}
CONFIGURE_COMMAND cd ${LIBSODIUM_SOURCE_DIR} && ./autogen.sh && ./configure --prefix=<INSTALL_DIR> --enable-minimal --disable-shared --enable-static
BUILD_COMMAND cd ${LIBSODIUM_SOURCE_DIR} && make ${MAKE_BUILD_FLAGS}
INSTALL_COMMAND cd ${LIBSODIUM_SOURCE_DIR} && make install)
1 change: 1 addition & 0 deletions depends/libsodium
Submodule libsodium added at 940ef4
25 changes: 20 additions & 5 deletions scripts/ci
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function command_tests() {

function build() {
build_type=$1
full=$2

# Enable warnings-as-errors
cxx_flags="-Werror"
Expand All @@ -33,13 +34,17 @@ function build() {
export PATH="/usr/local/opt/llvm/bin:/usr/local/bin:${PATH}"
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
export LIBRARY_PATH="/usr/local/opt/openssl/lib"
export LDFLAGS="-L/usr/local/opt/llvm/lib -L-L/usr/local/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include -I/usr/local/include"
export LDFLAGS="-L/usr/local/lib"
export CPPFLAGS="-I/usr/local/include"

cxx_flags="${cxx_flags} -I/usr/local/opt/openssl/include"
cxx_flags="${cxx_flags} -Wno-deprecated-declarations"
fi

cmake_flags="-DCMAKE_BUILD_TYPE=${build_type}"
if ! [ "${full}" == "1" ] ; then
cmake_flags="${cmake_flags} -DFAST_TESTS_ONLY=ON"
fi

. setup_env.sh
mkdir -p build
Expand All @@ -55,10 +60,20 @@ function build() {
}

function ci() {
build $1
build $1 $2
command_tests
}

build_type=$1
full_build=$2
if [ "${full_build}" == "" ] ; then
if [ "${TRAVIS_PULL_REQUEST}" == "false" ] || [ "${TRAVIS_PULL_REQUEST}" == "" ] ; then
full_build=0
else
full_build=1
fi
fi

if [ "${CI_CHECK_FORMAT}" == "1" ] ; then
format_check
fi
Expand All @@ -68,7 +83,7 @@ fi
if [ "${CI_USE_DOCKER}" == "1" ] ; then
docker pull clearmatics/zeth-base:latest
docker build -f Dockerfile-zeth -t zeth-dev .
docker run -t -p 50051:50051 --name zeth zeth-dev:latest $0 $@
docker run -t -p 50051:50051 --name zeth zeth-dev:latest $0 ${build_type} ${full_build}
else
ci $@
ci $build_type ${build_type} ${full_build}
fi
106 changes: 88 additions & 18 deletions scripts/test_mpc
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,112 @@ set -x
set -e

POT="build/src/pot-process"
MPC="build/src/mpc-test"
MPC="build/src/mpc/mpc-test"
QAP_DEGREE=8

pot_file=_test_pot-${QAP_DEGREE}.bin
lagrange_file=_test_lagrange-${QAP_DEGREE}.bin

linear_combination_file=_test_linear_combination-${QAP_DEGREE}.bin
phase2_file=_test_phase2-${QAP_DEGREE}.bin

transcript_file=_test_transcript.bin
challenge_0_file=_test_challenge_0.bin
response_1_file=_test_response_1.bin
response_digest_1_file=_test_response_digest_1.bin
challenge_1_file=_test_challenge_1.bin
response_2_file=_test_response_2.bin
response_digest_2_file=_test_response_digest_2.bin
challenge_2_file=_test_challenge_2.bin
response_3_file=_test_response_3.bin
response_digest_3_file=_test_response_digest_3.bin
challenge_3_file=_test_challenge_3.bin
final_phase2_file=${challenge_3_file}
invalid_response_digest_file=_test_response_digest_invalid.bin

keypair_file=_test_keypair-${QAP_DEGREE}.bin

rm -f ${transcript_file}

# Dummy pot data
${POT} --dummy ${pot_file} ${QAP_DEGREE}

# Compute lagrange points
${POT} --out ${lagrange_file} ${pot_file} ${QAP_DEGREE}

# Generate the linear combination
${MPC} \
linear-combination --out ${linear_combination_file} \
${pot_file} ${lagrange_file}
${MPC} linear-combination \
${pot_file} ${lagrange_file} ${linear_combination_file}

# Begin Phase2 MPC and run some rounds, accumulating transcript.
${MPC} phase2-begin ${linear_combination_file} ${challenge_0_file}

${MPC} phase2-contribute \
--skip-user-input \
--digest ${response_digest_1_file} \
${challenge_0_file} ${response_1_file}
${MPC} phase2-verify-contribution \
--transcript ${transcript_file} \
--new-challenge ${challenge_1_file} \
${challenge_0_file} ${response_1_file}

# Create a dummy phase2 file
${MPC} \
dummy-phase2 --out ${phase2_file} ${linear_combination_file}
${MPC} phase2-contribute \
--skip-user-input \
--digest ${response_digest_2_file} \
${challenge_1_file} ${response_2_file}
${MPC} phase2-verify-contribution \
--transcript ${transcript_file} \
--new-challenge ${challenge_2_file} \
${challenge_1_file} ${response_2_file}

${MPC} phase2-contribute \
--skip-user-input \
--digest ${response_digest_3_file} \
${challenge_2_file} ${response_3_file}
${MPC} phase2-verify-contribution \
--transcript ${transcript_file} \
--new-challenge ${challenge_3_file} \
${challenge_2_file} ${response_3_file}

# Verify the transcript
${MPC} phase2-verify-transcript \
${challenge_0_file} ${transcript_file} ${challenge_3_file}

# Verify the transcript, checking for each contribution
${MPC} phase2-verify-transcript \
--digest ${response_digest_1_file} \
${challenge_0_file} ${transcript_file} ${challenge_3_file}
${MPC} phase2-verify-transcript \
--digest ${response_digest_2_file} \
${challenge_0_file} ${transcript_file} ${challenge_3_file}
${MPC} phase2-verify-transcript \
--digest ${response_digest_3_file} \
${challenge_0_file} ${transcript_file} ${challenge_3_file}

# Invalid contribution check
echo 00000000 >> ${invalid_response_digest_file}
AntoineRondelet marked this conversation as resolved.
Show resolved Hide resolved
cat ${response_digest_3_file} >> ${invalid_response_digest_file}
if (${MPC} phase2-verify-transcript \
--digest ${invalid_response_digest_file} \
${challenge_0_file} ${transcript_file} ${challenge_3_file}) then
echo ERROR: expected failure
exit 1
fi

# Create the keypair
${MPC} \
create-keypair --out ${keypair_file} \
${pot_file} ${linear_combination_file} ${phase2_file}

rm \
${pot_file} \
${lagrange_file} \
${linear_combination_file} \
${phase2_file} \
${keypair_file}
${MPC} create-keypair \
${pot_file} ${linear_combination_file} ${final_phase2_file} \
${keypair_file}

# Clean up files
rm ${pot_file} ${lagrange_file} ${linear_combination_file}
rm ${transcript_file}
rm ${challenge_0_file}
rm ${response_1_file} ${challenge_1_file} ${response_1_digest_file}
rm ${response_2_file} ${challenge_2_file} ${response_2_digest_file}
rm ${response_3_file} ${challenge_3_file} ${response_3_digest_file}
rm -f ${final_phase2_file} # Same as challenge_3_file
rm ${invalid_response_digest_file}
rm ${keypair_file}

set +x
echo "=================================================================="
Expand Down
2 changes: 1 addition & 1 deletion scripts/test_pot_process
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
POT=$1
[ "" == "${POT}" ] && POT="build/src/pot-process"

POT_DATA="testdata/powersoftau_response.4.bin"
POT_DATA="testdata/powersoftau_challenge.4.bin"
POT_DATA_DEGREE=16

set -e
Expand Down
Loading