Skip to content

Commit

Permalink
Merge pull request #136 from clearmatics/develop
Browse files Browse the repository at this point in the history
Lydia release: v0.3
  • Loading branch information
AntoineRondelet authored Dec 13, 2019
2 parents 61a224a + f3bc43e commit fdaf14b
Show file tree
Hide file tree
Showing 294 changed files with 25,340 additions and 6,863 deletions.
165 changes: 165 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
{
# .clang-format in root of repository. To run on single file:
#
# $ clang-format -style=file -i <file path>
#
# To run on whole repo:
#
# $ scripts/format

# llvm coding standard is used as a starting point
# https://llvm.org/docs/CodingStandards.html
BasedOnStyle: llvm,

# BASICS

Standard: C++11,
IndentWidth: 4,
AccessModifierOffset: -4,
UseTab: Never,
FixNamespaceComments: "true",
IncludeBlocks: Regroup,
MaxEmptyLinesToKeep: 1,
BreakBeforeTernaryOperators: "true",
SpaceBeforeCpp11BracedList: "false",
Cpp11BracedListStyle: "true",
KeepEmptyLinesAtTheStartOfBlocks: "true",
AllowShortIfStatementsOnASingleLine: "false",
SpaceAfterTemplateKeyword: "false",
AlwaysBreakAfterReturnType: None,
PenaltyReturnTypeOnItsOwnLine: 10000000,
SpaceAfterCStyleCast: "false",
SpaceBeforeAssignmentOperators: "true",

# ARGUMENTS AND PARAMETERS PACKING
# Aligning arguments and parameters to brackets is hard to
# maintain. If arguments span multiple lines, more than one
# argument per line is difficult to parse.
#
# GOOD:
# my_function(a, b, c);
# my_function(
# very,
# long,
# multi,
# line,
# parameter,
# list);
# my_function(
# very, long, parameter, list);
#
# BAD:
# // Hard to maintain and generates unnecessary changes as
# // functions are renamed.
# my_function(very,
# long,
# multi,
# line,
# parameter,
# list);
#
# // Difficult to parse arguments
# my_function(
# very, long, multi, line,
# parameter, list);
#
# (NOTE: this seems to cause breaks in very long template
# parameter lists, but that seems like a reasonable price to
# occasionally pay to avoid ambiguity)

AlignAfterOpenBracket: AlwaysBreak,
AllowAllParametersOfDeclarationOnNextLine: "true",
BinPackArguments: "false",
BinPackParameters: "false",

AlwaysBreakTemplateDeclarations: MultiLine,

# BRACE POSITIONING
# Braces at end of line:
#
# if (cond) {
# x = 0;
# } else {
# x = 1;
# }
#
# except for namespaces, functions, classes, (where indentation
# often does not give us good visual cues):

BreakBeforeBraces: Linux,

# CONSTRUCTOR INITIALIZERS
# Constructor initializer packed similarly to function parameters,
# with separators before the member names.
#
# GOOD:
# my_class::my_class()
# : parent()
# , member1(x)
# , member2(y)
# {
# }
#
# BAD:
# // Annoying to reorder and indent
# my_class::my_class()
# : parent(),
# member1(x),
# member2(y)
# {
# }
#
# // Annoying to reorder
# my_class::my_class() :
# parent(),
# member1(x),
# member2(y)
# {
# }

BreakConstructorInitializers: BeforeComma,
BreakInheritanceList: BeforeComma,
ConstructorInitializerAllOnOneLineOrOnePerLine: "true",
# AllowAllConstructorInitializersOnNextLine: "false",

# ADDITIONAL NOTES
#
# - Long comments at the end of lines cause unnecessary line
# breaks. Better to comment above the line (do not add
# add empty line between the comment and the line).
#
# - Multi-line comments should use `//` style (clang-format
# does not cope well with other styles).
# // Your comment here line 1
# // line 2
#
# - Avoid `using namespace`, even in .cpp files.
#
# - Use `auto` only when it is strictly necessary, avoid otherwise.
#
# - Always use braces with control flow statements (if, for, while...)
# GOOD:
# if (condition) {
# x = 0;
# } else {
# x = 1;
# }
#
# BAD:
# if (condition)
# x = 0;
# else
# x = 1;
#
# - `//` can be used at the end of a line in an initializer to retain
# formatting:
# libsnark::pb_variable_array<FieldT> value = from_bits(
# {
# 0, 0, 1, 0, 1, 1, 1, 1, // <--- these breaks will remain
# 0, 0, 0, 0, 0, 0, 0, 0, //
# 0, 0, 0, 0, 0, 0, 0, 0, //
# 0, 0, 0, 0, 0, 0, 0, 0, //
# ...
#
# - Do not leave whitespace at the end of lines
}
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ root = true

[*]
indent_style = space
indent_size = 2
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
Expand Down
59 changes: 33 additions & 26 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,39 +1,46 @@
jsClient/node_modules/*
jsClient/package-lock.json

# Ignore the virtualenv in the python client
pyClient/zeth-devenv/
/jsClient/node_modules/*
/jsClient/package-lock.json

# Ignore the build repo
build/
/build/

# Ignore the coins we created
coinstore/*.json
/coinstore/

# Ignore the content of the keystore
keystore/*.pem
keystore/*.json
/keystore/*.pem
/keystore/*.json

# Ignore the output of the trusted setup (ie: Proving and Verifying key)
trusted_setup/*.raw
trusted_setup/*.json
/trusted_setup/*.raw
/trusted_setup/*.json

# Ignore the content of the debug folder
debug/*json

# Ignore node_modules
zeth-contracts/node_modules/*

# Ignore grpc code
pyClient/prover_pb2.py
pyClient/prover_pb2_grpc.py
pyClient/pghr13_messages_pb2.py
pyClient/pghr13_messages_pb2_grpc.py
pyClient/groth16_messages_pb2.py
pyClient/groth16_messages_pb2_grpc.py
pyClient/util_pb2.py
pyClient/util_pb2_grpc.py

# Ignore pycash
pyClient/__pycache__/

/zeth-contracts/node_modules/*

# Ignore pyClient env and build directories
/pyClient/api/*_pb2.py
/pyClient/api/*_pb2_grpc.py
/pyClient/api/*_pb2.pyi

# Ignore test files
/_test_contrib_*/
/_test_phase1_contrib_*/
/_test_contributors_from_csv/
/_test_server_phase*/
/_test_phase2_data/

# Ignore python cache dirs

# Python temp files
__pycache__
.mypy_cache
env/
*.egg-info

# Ignore some unix temp files
*~
\#*\#
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "depends/libsnark"]
path = depends/libsnark
url = https://github.com/clearmatics/libsnark.git
[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
43 changes: 43 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
services:
- docker

addons:
apt:
packages:
- clang-format
homebrew:
packages:
- gmp
- grpc
- protobuf
- boost
- openssl
- cmake
- libtool
- autoconf
- automake
- python
# - llvm

matrix:
include:
- env: CI_TASK=pyclient_check CI_USE_DOCKER=1
os: linux
language: minimal
- env: CI_TASK=build CI_CONFIG=Release CI_USE_DOCKER=1
os: linux
language: minimal
- env: CI_TASK=build CI_CONFIG=Debug CI_USE_DOCKER=1 CI_CHECK_FORMAT=1
os: linux
language: minimal
- env: CI_TASK=build CI_CONFIG=Release
os: osx
osx_image: xcode11
- env: CI_TASK=build CI_CONFIG=Debug
os: osx
osx_image: xcode11
- env: CI_TASK=build CI_CONFIG=Release CI_ZKSNARK=PGHR13 CI_USE_DOCKER=1
os: linux
language: minimal

script: CI_USE_DOCKER=${CI_USE_DOCKER} CI_CONFIG=${CI_CONFIG} CI_ZKSNARK=${CI_ZKSNARK} travis_wait 30 scripts/ci ${CI_TASK}
62 changes: 60 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@
# For a tutorial of CMake
cmake_minimum_required(VERSION 3.0)

if(APPLE)
# If custom llvm compilers are available, use them (for openmp
# support), otherwise disable multicore.
if(EXISTS "/usr/local/opt/llvm/bin/clang")
set(CMAKE_C_COMPILER "/usr/local/opt/llvm/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/local/opt/llvm/bin/clang++")
endif()
endif()

# Name of the project
# https://cmake.org/cmake/help/v3.0/command/project.html#command:project
# Sets the env vars PROJECT_SOURCE_DIR, and PROJECT_BINARY_DIR
project(zeth)

# Versionning of the project
set (ZETH_VERSION_MAJOR 0)
set (ZETH_VERSION_MINOR 2)
set (ZETH_VERSION_MINOR 3)

# Configure a header file to pass some of the CMake settings
# to the source code
Expand All @@ -27,6 +36,13 @@ set(
"Default snark: one of PGHR13, GROTH16"
)

# Run only fast test (e.g. on CI machine)
option(
FAST_TESTS_ONLY
"Include only fast-running tests"
OFF
)

# Flags and compilation options for use with libsnark
set(
CURVE # Variable name
Expand Down Expand Up @@ -76,7 +92,37 @@ option(
ON
)

if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
option(
BINARY_OUTPUT
"Binary stream reading and writing"
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
)

if(APPLE)
# These must be disabled to make dependencies build on macos
set(WITH_PROCPS OFF)
set(WITH_SUPERCOP OFF CACHE BOOL "Build libff with supercop")

# (Currently) OpenMP only available with custom llvm compilers
if(${CMAKE_C_COMPILER} MATCHES ".*cc$")
set(MULTICORE OFF)
endif()
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "^(Apple)?Clang$")

# Common compilation flags and warning configuration
# The CMAKE_CXX_FLAGS variable allows to change the compiler settings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wfatal-errors -pthread")
Expand Down Expand Up @@ -108,6 +154,18 @@ if("${MULTICORE}")
add_definitions(-DMULTICORE=1)
endif()

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()

if("${DEBUG}")
add_definitions(-DDEBUG=1)
endif()
Expand Down
Loading

0 comments on commit fdaf14b

Please sign in to comment.