Skip to content

Commit

Permalink
# This is a combination of 22 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

bazel support, initial commit

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#2:

gitignore .bazelrc, bazel-*

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#3:

remove sha256 from rule_foreign_cc rule

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#4:

rename target ff to libff

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#5:

put curves/mnt/mnt4, 6 in separate packages

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#6:

bn128: drop "depends" from include prefix, for bazel compatibility

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#7:

fix refs to targets mnt4, mnt6, libff

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#8:

fix refs to @ate_pairing//:libgmp

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#9:

change @// to //

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#10:

delete obsolete mnt4, mnt6 targets from curves/mnt/BUILD.bazel

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#11:

add target scalar_multiplication:multiexp_profile

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#12:

list headers explicitly

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#13:

dead code elim

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#14:

dead code elim

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#15:

BUILD files: explicitate srcs/hdrs, DCE, buildifier reformat

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#16:

change @ate_pairing//:zm to @ate_pairing//ate-pairing

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#17:

switch obazl repos from local to git

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#18:

pin xbyak, ate-pairing repos to versions, to match upstream

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#19:

delete git submodules, not needed with Bazel

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#20:

add sha256 for xbyak, ate-pairing external repos

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#21:

remove xbyak dep - it's included in ate-pairing

Signed-off-by: Gregg Reynolds <[email protected]>

# This is the commit message scipr-lab#22:

restore depends dirs

Signed-off-by: Gregg Reynolds <[email protected]>
  • Loading branch information
mobileink committed Jul 20, 2020
1 parent 5835b8c commit 1ed8e26
Show file tree
Hide file tree
Showing 27 changed files with 722 additions and 17 deletions.
14 changes: 14 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
try-import user.bazelrc

# enable platform-based toolchain resolution:
build --incompatible_enable_cc_toolchain_resolution

build --color=yes
# build --subcommands=pretty_print
# build --verbose_failures
# build --sandbox_debug
# build --toolchain_resolution_debug
# build --show_timestamps
# build --keep_going
# build --jobs 600
# query --keep_going
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
.bazel
bazel-*
user.bazelrc

confdefs.h
config.log
conftest.one
conftest.two

/build/
/.idea/
28 changes: 28 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")

## PLATFORMS (for cross-platform builds)

platform(
name = "x86_64-unknown-linux-gnu",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
)

platform(
name = "armv8-rpi3-linux-gnueabihf",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:arm",
],
)

platform(
name = "x86_64-linux-musl",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
"//tc:clib_musl",
],
)
53 changes: 53 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

http_archive(
name = "rules_foreign_cc",
strip_prefix="rules_foreign_cc-master",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/master.zip",
# sha256 = "3fc764c7084da14cff812ae42327d19c8d6e99379f8b3e310b3213e1d5f0e7e8"
)

load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
rules_foreign_cc_dependencies()

all_content = """filegroup(name = "all", srcs = glob(["**"]), visibility = ["//visibility:public"])"""

# ate-pairing already includes libgmp, but Bazel does not yet support
# transitive external deps, so we need to repeat the dep here.
# Specifically, ate-pairing build rules refer to @libgmp, which bazel
# resolves to the root repo, which is determined by this WORKSPACE
# file, rather than the one in the ate-pairing repo. So we need to
# copy ate-pairing's repo rule into this file. The build logic will
# come from ate-pairing; we just need to make the repo available here,
# in the root repo. Build rules for this repo can then refer to
# libgmp using '@libgmp//:libgmp' (here) or '@ate-pairing//:libgmp' (a
# target that indirectly refers to the repo defined here). We use the
# latter, in case Bazel ever gets around to supporting transitive
# workspaces.
http_archive(
name="libgmp",
url="https://gmplib.org/download/gmp/gmp-6.2.0.tar.xz",
sha256="258e6cd51b3fbdfc185c716d55f82c08aff57df0c6fbd143cf6ed561267a1526",
strip_prefix = "gmp-6.2.0",
build_file_content = all_content
# build_file = "@//external:libgmp.BUILD"
)

http_archive(
name="openssl",
url="https://www.openssl.org/source/openssl-1.1.1g.tar.gz",
sha256="ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46",
strip_prefix="openssl-1.1.1g",
build_file_content = all_content
)

################################################################
http_archive(
name = "ate_pairing",
urls = ["https://github.com/obazl/ate-pairing/archive/bazel-e698901.zip"],
strip_prefix = "ate-pairing-bazel-e698901",
sha256 = "26002e265ace5c636af4c22af36deb825b9f70a29c6da7903c5a228b89b75665"
)


33 changes: 33 additions & 0 deletions bzl/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
load("@rules_foreign_cc//tools/build_defs:configure.bzl", "configure_make")

configure_make(
name = "openssl",
configure_command = "config",
configure_env_vars =
select({
"//bzl/host:macos": { "AR": "" },
"//conditions:default": {}
}),
configure_options = [
"no-shared",
] + select({
"//conditions:default": [],
}),
# select({
# ":darwin_build": [
# "shared",
# "ARFLAGS=r",
# "enable-ec_nistp_64_gcc_128",
# "no-ssl2", "no-ssl3", "no-comp"
# ],
# "//conditions:default": [
# ]}),
# #defines = ["NDEBUG"], Don't know how to use -D; NDEBUG seems to be the default anyway
lib_source = "@openssl//:all",
static_libraries = [
"libssl.a",
"libcrypto.a",
],
visibility = ["//visibility:public"],
)

23 changes: 23 additions & 0 deletions bzl/host/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
config_setting(
name = "linux_arm",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:arm",
]
)

config_setting(
name = "linux_x64",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
]
)

config_setting(
name = "macos",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:x86_64",
]
)
11 changes: 0 additions & 11 deletions depends/CMakeLists.txt

This file was deleted.

64 changes: 64 additions & 0 deletions libff/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")

load("@bazel_skylib//rules:common_settings.bzl", "string_flag")

string_flag(
name = "curve",
values = ["bn128", "alt_bn128", "edwards", ""],
build_setting_default = "",
)

config_setting(
name = "curve_bn128",
flag_values = {
":curve": "bn128"
}
)

cc_library(
name = "libff",
visibility = ["//visibility:public"],
# srcs = ["zm.cpp", "zm2.cpp"],
# strip_include_prefix = "bzl",
# include_prefix = "depends/ate-pairing/include",
include_prefix = "depends/ate-pairing/include",
includes = ["depends/ate-pairing/include"],
# srcs = ["foo.cpp", "foo.h"],
hdrs = glob(["external/ate_pairing/include/bn.h",
]),
# includes = ["external/ate_pairing/include"],
copts = ["-Iexternal/ate_pairing/include",
],
deps = [
"@ate_pairing//ate-pairing",
# "@ate_pairing//bzl/third_party:libgmp",
"//libff/algebra/curves/alt_bn128",
"//libff/algebra/curves/edwards",
"//libff/algebra/curves/mnt/mnt4",
"//libff/algebra/curves/mnt/mnt6",
"//libff/common",
] + select({
# if(${CURVE} STREQUAL "BN128")
# bazel flag: --//libff:curve=bn128
"//libff:curve_bn128": ["//libff/algebra/curves/bn128"],
"//conditions:default": [],
})
)

# cc_library(
# name = "foobar",
# visibility = ["//libff/algebra/curves/bn128:__pkg__"],
# # srcs = ["zm.cpp", "zm2.cpp"],
# # strip_include_prefix = "bzl",
# # include_prefix = "depends/ate-pairing/include",
# include_prefix = "depends/ate-pairing/include",
# includes = ["depends/ate-pairing/include"],
# srcs = ["foo.cpp", "foo.h"],
# hdrs = glob(["external/ate_pairing/include/bn.h",
# ]) + ["foo.h"],
# # includes = ["external/ate_pairing/include"],
# copts = ["-Iexternal/ate_pairing/include",
# ],
# deps = ["@ate_pairing//src:libzm"]
# # data = ["@ate_pairing//src:libzm"]
# )
11 changes: 11 additions & 0 deletions libff/algebra/curves/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")

cc_library(
name = "curves",
visibility = ["//visibility:public"],
hdrs = ["curve_utils.hpp",
"curve_utils.tcc",
"public_params.hpp"],
include_prefix = "libff/algebra/curves",
deps = ["//libff/algebra/fields:bigint"]
)
27 changes: 27 additions & 0 deletions libff/algebra/curves/alt_bn128/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "alt_bn128",
srcs = [
"alt_bn128_g1.cpp",
"alt_bn128_g2.cpp",
"alt_bn128_init.cpp",
"alt_bn128_pairing.cpp",
"alt_bn128_pp.cpp",
],
hdrs = [
"alt_bn128_g1.hpp",
"alt_bn128_g2.hpp",
"alt_bn128_init.hpp",
"alt_bn128_pairing.hpp",
"alt_bn128_pp.hpp",
],
copts = ["-I."],
include_prefix = "libff/algebra/curves/alt_bn128",
linkstatic = True,
visibility = ["//visibility:public"],
deps = [
"//libff/algebra/curves",
"//libff/algebra/fields",
],
)
34 changes: 34 additions & 0 deletions libff/algebra/curves/bn128/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "bn128",
srcs = glob([
"bn128_g1.cpp",
"bn128_g2.cpp",
"bn128_gt.cpp",
"bn128_init.cpp",
"bn128_pairing.cpp",
"bn128_pp.cpp",
"bn_utils.cpp",
"bn_utils.tcc",
]),
hdrs = glob([
"bn128_g1.hpp",
"bn128_g2.hpp",
"bn128_gt.hpp",
"bn128_init.hpp",
"bn128_pairing.hpp",
"bn128_pp.hpp",
"bn_utils.hpp",
"bn_utils.tcc",
]),
copts = ["-I."],
include_prefix = "libff/algebra/curves/bn128",
linkstatic = True,
visibility = ["//visibility:public"],
deps = [
"//libff/algebra/curves",
"//libff/algebra/fields:utils",
"@ate_pairing//ate-pairing",
],
)
2 changes: 1 addition & 1 deletion libff/algebra/curves/bn128/bn128_g1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define BN128_G1_HPP_
#include <vector>

#include "depends/ate-pairing/include/bn.h"
#include "ate-pairing/include/bn.h"

#include <libff/algebra/curves/bn128/bn128_init.hpp>
#include <libff/algebra/curves/curve_utils.hpp>
Expand Down
2 changes: 1 addition & 1 deletion libff/algebra/curves/bn128/bn128_g2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <iostream>
#include <vector>

#include "depends/ate-pairing/include/bn.h"
#include "ate-pairing/include/bn.h"

#include <libff/algebra/curves/bn128/bn128_init.hpp>
#include <libff/algebra/curves/curve_utils.hpp>
Expand Down
2 changes: 1 addition & 1 deletion libff/algebra/curves/bn128/bn128_gt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define BN128_GT_HPP_
#include <iostream>

#include "depends/ate-pairing/include/bn.h"
#include "ate-pairing/include/bn.h"

#include <libff/algebra/fields/field_utils.hpp>
#include <libff/algebra/fields/fp.hpp>
Expand Down
2 changes: 1 addition & 1 deletion libff/algebra/curves/bn128/bn128_init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#ifndef BN128_INIT_HPP_
#define BN128_INIT_HPP_
#include "depends/ate-pairing/include/bn.h"
#include "ate-pairing/include/bn.h"

#include <libff/algebra/curves/public_params.hpp>
#include <libff/algebra/fields/fp.hpp>
Expand Down
2 changes: 1 addition & 1 deletion libff/algebra/curves/bn128/bn128_pairing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#ifndef BN128_PAIRING_HPP_
#define BN128_PAIRING_HPP_
#include "depends/ate-pairing/include/bn.h"
#include "ate-pairing/include/bn.h"

#include <libff/algebra/curves/bn128/bn128_g1.hpp>
#include <libff/algebra/curves/bn128/bn128_g2.hpp>
Expand Down
2 changes: 1 addition & 1 deletion libff/algebra/curves/bn128/bn_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define BN_UTILS_HPP_
#include <vector>

#include "depends/ate-pairing/include/bn.h"
#include "ate-pairing/include/bn.h"

namespace libff {

Expand Down
Loading

0 comments on commit 1ed8e26

Please sign in to comment.