Skip to content

Commit

Permalink
submodule: update zeth (adopting compatible proto structure)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtebbs committed Sep 1, 2020
1 parent 5b636dd commit 2d76039
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 26 deletions.
10 changes: 4 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,21 @@ set(
PROTO_SRC_DIR
${PROJECT_BINARY_DIR}
)
#file(MAKE_DIRECTORY ${PROTO_SRC_DIR})

# Get the proto files
file(
GLOB
PROTO_FILES
${PROJECT_SOURCE_DIR}/api/*.proto
${PROJECT_SOURCE_DIR}/proto/zecale/api/*.proto
)

# Set the import path to be able to re-use the Zeth proto files
set(PROTOBUF_IMPORT_DIRS ${PROJECT_SOURCE_DIR}/depends/zeth/)
set(PROTOBUF_IMPORT_DIRS ${PROJECT_SOURCE_DIR}/depends/zeth/proto)

set(PROTOBUF_PROTO_PATH ${PROJECT_SOURCE_DIR})
set(PROTOBUF_APPEND_DEST_PATH "/api")
set(PROTOBUF_PROTO_PATH ${PROJECT_SOURCE_DIR}/proto)
set(PROTOBUF_APPEND_DEST_PATH "/zecale/api")
set(PROTOBUF_GENERATE_CPP_APPEND_PATH OFF)
set(GRPC_GENERATE_CPP_APPEND_PATH OFF)
set(Protobuf_DEBUG ON)

# By default, compile with all warning flags
add_compile_options(-Wall -Wextra)
Expand Down
2 changes: 1 addition & 1 deletion aggregator_server/aggregator_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "libzecale/serialization/proto_utils.hpp"
#include "zecale_config.h"

#include <api/aggregator.grpc.pb.h>
#include <boost/program_options.hpp>
#include <fstream>
#include <grpc/grpc.h>
Expand All @@ -29,6 +28,7 @@
#include <memory>
#include <stdio.h>
#include <string>
#include <zecale/api/aggregator.grpc.pb.h>

namespace proto = google::protobuf;
namespace po = boost::program_options;
Expand Down
16 changes: 7 additions & 9 deletions client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,26 @@

ZETH_DIR:=../depends/zeth
ZETH_CLIENT_DIR:=$(ZETH_DIR)/client
ZETH_API_DIR:=$(ZETH_DIR)/api
ZETH_API_FILES:=$(wildcard $(ZETH_API_DIR)/*.proto)
ZETH_PROTO_DIR:=$(ZETH_DIR)/proto

ZECALE_API_DIR:=../../zecale/api
ZECALE_API_FILES:=$(wildcard $(ZECALE_API_DIR)/*.proto)
ZECALE_PROTO_DIR:=../proto
ZECALE_PROTO_FILES:=$(wildcard $(ZECALE_PROTO_DIR)/zecale/api/*.proto)

API_DEST_DIR:=zecale/api
API_OUTPUT:= $(addprefix $(API_DEST_DIR)/, \
aggregator_pb2.py aggregator_pb2_grpc.py)
API_OUTPUT:= $(addprefix $(API_DEST_DIR)/, aggregator_pb2.py)

# Create rule to build a grpc file from a source file. Params:
# 1 - .proto file
define grpc_build
$(API_DEST_DIR)/$(notdir $(basename $1))_pb2.py \
$(API_DEST_DIR)/$(notdir $(basename $1))_pb2_grpc.py : $(1)
python -m grpc_tools.protoc -I$(ZETH_DIR) -I.. --proto_path ../.. \
python -m grpc_tools.protoc -I$(ZETH_PROTO_DIR) -I.. --proto_path $(ZECALE_PROTO_DIR) \
--python_out=. --grpc_python_out=. --mypy_out=. \
$(subst $(ZETH_DIR)/,,$1)
$(subst $(ZECALE_PROTO_DIR)/,,$1)

endef

$(foreach src,$(ZECALE_API_FILES) $(ZETH_API_FILES),$(eval \
$(foreach src,$(ZECALE_PROTO_FILES),$(eval \
$(call grpc_build,$(src)) \
))

Expand Down
4 changes: 2 additions & 2 deletions client/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
install_requires=[
"mypy==0.720",
"mypy-protobuf==1.16",
"flake8==3.7.8",
"flake8==3.8.*",
"pylint==2.4.3",
"click==7.0",
"click-default-group==1.2",
"grpcio==1.24",
"grpcio==1.30",
"grpcio-tools==1.24",
],
scripts=[
Expand Down
2 changes: 1 addition & 1 deletion client/zecale/commands/command_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .defaults import \
AGGREGATOR_SERVER_ENDPOINT_DEFAULT, ZKSNARK_NAME_DEFAULT
from ..core.aggregator_client import AggregatorClient
from zeth.zksnark import get_zksnark_provider
from zeth.core.zksnark import get_zksnark_provider
from typing import Optional


Expand Down
2 changes: 1 addition & 1 deletion client/zecale/commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: LGPL-3.0+

from zeth.zksnark import GenericVerificationKey, GenericProof
from zeth.core.zksnark import GenericVerificationKey, GenericProof
import json


Expand Down
3 changes: 2 additions & 1 deletion client/zecale/core/aggregator_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from zecale.api import aggregator_pb2_grpc
from zecale.api import aggregator_pb2
import grpc
from zeth.zksnark import IZKSnarkProvider, GenericVerificationKey, GenericProof
from zeth.core.zksnark import \
IZKSnarkProvider, GenericVerificationKey, GenericProof
from google.protobuf import empty_pb2
from typing import Dict

Expand Down
2 changes: 1 addition & 1 deletion depends/zeth
Submodule zeth updated 90 files
+3 −3 .gitignore
+4 −5 CMakeLists.txt
+16 −16 client/Makefile
+47 −26 client/README.md
+0 −18 client/commands/constants.py
+0 −35 client/commands/zeth_token_approve.py
+1 −1 client/mypy.ini
+2 −2 client/setup.py
+59 −24 client/test_commands/deploy_test_token.py
+70 −0 client/test_commands/fund_eth_address.py
+0 −30 client/test_commands/get_balance.py
+6 −5 client/test_commands/mock.py
+23 −19 client/test_commands/scenario.py
+3 −3 client/test_commands/test_contract_base_mixer.py
+17 −12 client/test_commands/test_erc_token_mixing.py
+14 −12 client/test_commands/test_ether_mixing.py
+3 −3 client/test_commands/test_merkle_tree_contract.py
+0 −0 client/tests/__init__.py
+5 −5 client/tests/test_contracts.py
+2 −2 client/tests/test_encryption.py
+1 −1 client/tests/test_ethervalue.py
+3 −3 client/tests/test_joinsplit.py
+2 −2 client/tests/test_merkle_tree.py
+1 −1 client/tests/test_mimc.py
+1 −1 client/tests/test_signing.py
+3 −6 client/tests/test_zksnark.py
+0 −2 client/zeth/__init__.py
+0 −0 client/zeth/api/__init__.py
+0 −0 client/zeth/api/py.typed
+0 −0 client/zeth/cli/__init__.py
+30 −0 client/zeth/cli/constants.py
+0 −0 client/zeth/cli/py.typed
+115 −19 client/zeth/cli/utils.py
+21 −20 client/zeth/cli/zeth
+11 −9 client/zeth/cli/zeth_deploy.py
+2 −2 client/zeth/cli/zeth_gen_address.py
+3 −3 client/zeth/cli/zeth_ls_commits.py
+2 −2 client/zeth/cli/zeth_ls_notes.py
+39 −19 client/zeth/cli/zeth_mix.py
+5 −3 client/zeth/cli/zeth_sync.py
+5 −0 client/zeth/core/__init__.py
+0 −0 client/zeth/core/constants.py
+88 −38 client/zeth/core/contracts.py
+1 −1 client/zeth/core/encryption.py
+0 −0 client/zeth/core/errors.py
+1 −1 client/zeth/core/merkle_tree.py
+1 −1 client/zeth/core/mimc.py
+46 −36 client/zeth/core/mixer_client.py
+2 −1 client/zeth/core/ownership.py
+3 −3 client/zeth/core/prover_client.py
+0 −0 client/zeth/core/py.typed
+2 −2 client/zeth/core/signing.py
+2 −2 client/zeth/core/testing_utils.py
+0 −0 client/zeth/core/timer.py
+7 −7 client/zeth/core/utils.py
+8 −8 client/zeth/core/wallet.py
+2 −2 client/zeth/core/zeth_address.py
+9 −7 client/zeth/core/zksnark.py
+3 −0 client/zeth/helper/__init__.py
+46 −0 client/zeth/helper/eth_gen_address.py
+54 −0 client/zeth/helper/eth_gen_network_config.py
+34 −0 client/zeth/helper/eth_get_balance.py
+69 −0 client/zeth/helper/eth_send.py
+50 −0 client/zeth/helper/token_approve.py
+56 −0 client/zeth/helper/zeth_helper
+10 −10 libzeth/core/extended_proof.tcc
+2 −2 libzeth/core/field_element_utils.hpp
+19 −19 libzeth/core/field_element_utils.tcc
+10 −8 libzeth/serialization/filesystem_util.cpp
+5 −3 libzeth/serialization/filesystem_util.hpp
+2 −2 libzeth/serialization/proto_utils.hpp
+3 −3 libzeth/serialization/r1cs_serialization.hpp
+60 −57 libzeth/serialization/r1cs_serialization.tcc
+1 −1 libzeth/snarks/groth16/groth16_api_handler.hpp
+3 −2 libzeth/snarks/groth16/groth16_snark.hpp
+30 −29 libzeth/snarks/groth16/groth16_snark.tcc
+1 −1 libzeth/snarks/pghr13/pghr13_api_handler.hpp
+7 −6 libzeth/snarks/pghr13/pghr13_snark.tcc
+0 −0 proto/zeth/api/ec_group_messages.proto
+1 −1 proto/zeth/api/groth16_messages.proto
+1 −1 proto/zeth/api/pghr13_messages.proto
+2 −2 proto/zeth/api/prover.proto
+2 −2 proto/zeth/api/snark_messages.proto
+0 −0 proto/zeth/api/zeth_messages.proto
+86 −91 prover_server/prover_server.cpp
+35 −0 scripts/recover_keypair.sh
+19 −14 scripts/test_zeth_cli
+28 −20 scripts/test_zeth_cli_common.sh
+28 −18 scripts/test_zeth_cli_token
+5 −0 zeth_contracts/truffle.js
3 changes: 2 additions & 1 deletion libzecale/serialization/proto_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#ifndef __ZECALE_SERIALIZATION_PROTO_UTILS_HPP__
#define __ZECALE_SERIALIZATION_PROTO_UTILS_HPP__

#include "api/aggregator.pb.h"
#include "libzecale/core/transaction_to_aggregate.hpp"

#include <zecale/api/aggregator.pb.h>

namespace libzecale
{

Expand Down
4 changes: 2 additions & 2 deletions libzecale/tests/serialization/proto_utils_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
//
// SPDX-License-Identifier: LGPL-3.0+

#include "api/aggregator.pb.h"
#include "api/ec_group_messages.pb.h"
#include "libzecale/serialization/proto_utils.hpp"

#include "gtest/gtest.h"
Expand All @@ -16,6 +14,8 @@
#include <libzeth/snarks/groth16/groth16_api_handler.hpp>
#include <libzeth/snarks/pghr13/pghr13_api_handler.hpp>
#include <stdio.h>
#include <zecale/api/aggregator.pb.h>
#include <zeth/api/ec_group_messages.pb.h>

using namespace libzecale;

Expand Down
2 changes: 1 addition & 1 deletion api/aggregator.proto → proto/zecale/api/aggregator.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package zecale_proto;

import "google/protobuf/empty.proto";

import "api/snark_messages.proto";
import "zeth/api/snark_messages.proto";

service Aggregator {
// Fetch the verification key corresponding to the aggregator statement
Expand Down

0 comments on commit 2d76039

Please sign in to comment.