Skip to content

Commit 1ed8e26

Browse files
committed
# This is a combination of 22 commits.
# 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]>
1 parent 5835b8c commit 1ed8e26

File tree

27 files changed

+722
-17
lines changed

27 files changed

+722
-17
lines changed

.bazelrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
try-import user.bazelrc
2+
3+
# enable platform-based toolchain resolution:
4+
build --incompatible_enable_cc_toolchain_resolution
5+
6+
build --color=yes
7+
# build --subcommands=pretty_print
8+
# build --verbose_failures
9+
# build --sandbox_debug
10+
# build --toolchain_resolution_debug
11+
# build --show_timestamps
12+
# build --keep_going
13+
# build --jobs 600
14+
# query --keep_going

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1+
.bazel
2+
bazel-*
3+
user.bazelrc
4+
5+
confdefs.h
6+
config.log
7+
conftest.one
8+
conftest.two
9+
110
/build/
211
/.idea/

BUILD.bazel

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
2+
3+
## PLATFORMS (for cross-platform builds)
4+
5+
platform(
6+
name = "x86_64-unknown-linux-gnu",
7+
constraint_values = [
8+
"@platforms//os:linux",
9+
"@platforms//cpu:x86_64",
10+
],
11+
)
12+
13+
platform(
14+
name = "armv8-rpi3-linux-gnueabihf",
15+
constraint_values = [
16+
"@platforms//os:linux",
17+
"@platforms//cpu:arm",
18+
],
19+
)
20+
21+
platform(
22+
name = "x86_64-linux-musl",
23+
constraint_values = [
24+
"@platforms//os:linux",
25+
"@platforms//cpu:x86_64",
26+
"//tc:clib_musl",
27+
],
28+
)

WORKSPACE

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
3+
4+
http_archive(
5+
name = "rules_foreign_cc",
6+
strip_prefix="rules_foreign_cc-master",
7+
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/master.zip",
8+
# sha256 = "3fc764c7084da14cff812ae42327d19c8d6e99379f8b3e310b3213e1d5f0e7e8"
9+
)
10+
11+
load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
12+
rules_foreign_cc_dependencies()
13+
14+
all_content = """filegroup(name = "all", srcs = glob(["**"]), visibility = ["//visibility:public"])"""
15+
16+
# ate-pairing already includes libgmp, but Bazel does not yet support
17+
# transitive external deps, so we need to repeat the dep here.
18+
# Specifically, ate-pairing build rules refer to @libgmp, which bazel
19+
# resolves to the root repo, which is determined by this WORKSPACE
20+
# file, rather than the one in the ate-pairing repo. So we need to
21+
# copy ate-pairing's repo rule into this file. The build logic will
22+
# come from ate-pairing; we just need to make the repo available here,
23+
# in the root repo. Build rules for this repo can then refer to
24+
# libgmp using '@libgmp//:libgmp' (here) or '@ate-pairing//:libgmp' (a
25+
# target that indirectly refers to the repo defined here). We use the
26+
# latter, in case Bazel ever gets around to supporting transitive
27+
# workspaces.
28+
http_archive(
29+
name="libgmp",
30+
url="https://gmplib.org/download/gmp/gmp-6.2.0.tar.xz",
31+
sha256="258e6cd51b3fbdfc185c716d55f82c08aff57df0c6fbd143cf6ed561267a1526",
32+
strip_prefix = "gmp-6.2.0",
33+
build_file_content = all_content
34+
# build_file = "@//external:libgmp.BUILD"
35+
)
36+
37+
http_archive(
38+
name="openssl",
39+
url="https://www.openssl.org/source/openssl-1.1.1g.tar.gz",
40+
sha256="ddb04774f1e32f0c49751e21b67216ac87852ceb056b75209af2443400636d46",
41+
strip_prefix="openssl-1.1.1g",
42+
build_file_content = all_content
43+
)
44+
45+
################################################################
46+
http_archive(
47+
name = "ate_pairing",
48+
urls = ["https://github.com/obazl/ate-pairing/archive/bazel-e698901.zip"],
49+
strip_prefix = "ate-pairing-bazel-e698901",
50+
sha256 = "26002e265ace5c636af4c22af36deb825b9f70a29c6da7903c5a228b89b75665"
51+
)
52+
53+

bzl/BUILD.bazel

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
load("@rules_foreign_cc//tools/build_defs:configure.bzl", "configure_make")
2+
3+
configure_make(
4+
name = "openssl",
5+
configure_command = "config",
6+
configure_env_vars =
7+
select({
8+
"//bzl/host:macos": { "AR": "" },
9+
"//conditions:default": {}
10+
}),
11+
configure_options = [
12+
"no-shared",
13+
] + select({
14+
"//conditions:default": [],
15+
}),
16+
# select({
17+
# ":darwin_build": [
18+
# "shared",
19+
# "ARFLAGS=r",
20+
# "enable-ec_nistp_64_gcc_128",
21+
# "no-ssl2", "no-ssl3", "no-comp"
22+
# ],
23+
# "//conditions:default": [
24+
# ]}),
25+
# #defines = ["NDEBUG"], Don't know how to use -D; NDEBUG seems to be the default anyway
26+
lib_source = "@openssl//:all",
27+
static_libraries = [
28+
"libssl.a",
29+
"libcrypto.a",
30+
],
31+
visibility = ["//visibility:public"],
32+
)
33+

bzl/host/BUILD.bazel

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
config_setting(
2+
name = "linux_arm",
3+
constraint_values = [
4+
"@platforms//os:linux",
5+
"@platforms//cpu:arm",
6+
]
7+
)
8+
9+
config_setting(
10+
name = "linux_x64",
11+
constraint_values = [
12+
"@platforms//os:linux",
13+
"@platforms//cpu:x86_64",
14+
]
15+
)
16+
17+
config_setting(
18+
name = "macos",
19+
constraint_values = [
20+
"@platforms//os:macos",
21+
"@platforms//cpu:x86_64",
22+
]
23+
)

depends/CMakeLists.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

libff/BUILD.bazel

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
2+
3+
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
4+
5+
string_flag(
6+
name = "curve",
7+
values = ["bn128", "alt_bn128", "edwards", ""],
8+
build_setting_default = "",
9+
)
10+
11+
config_setting(
12+
name = "curve_bn128",
13+
flag_values = {
14+
":curve": "bn128"
15+
}
16+
)
17+
18+
cc_library(
19+
name = "libff",
20+
visibility = ["//visibility:public"],
21+
# srcs = ["zm.cpp", "zm2.cpp"],
22+
# strip_include_prefix = "bzl",
23+
# include_prefix = "depends/ate-pairing/include",
24+
include_prefix = "depends/ate-pairing/include",
25+
includes = ["depends/ate-pairing/include"],
26+
# srcs = ["foo.cpp", "foo.h"],
27+
hdrs = glob(["external/ate_pairing/include/bn.h",
28+
]),
29+
# includes = ["external/ate_pairing/include"],
30+
copts = ["-Iexternal/ate_pairing/include",
31+
],
32+
deps = [
33+
"@ate_pairing//ate-pairing",
34+
# "@ate_pairing//bzl/third_party:libgmp",
35+
"//libff/algebra/curves/alt_bn128",
36+
"//libff/algebra/curves/edwards",
37+
"//libff/algebra/curves/mnt/mnt4",
38+
"//libff/algebra/curves/mnt/mnt6",
39+
"//libff/common",
40+
] + select({
41+
# if(${CURVE} STREQUAL "BN128")
42+
# bazel flag: --//libff:curve=bn128
43+
"//libff:curve_bn128": ["//libff/algebra/curves/bn128"],
44+
"//conditions:default": [],
45+
})
46+
)
47+
48+
# cc_library(
49+
# name = "foobar",
50+
# visibility = ["//libff/algebra/curves/bn128:__pkg__"],
51+
# # srcs = ["zm.cpp", "zm2.cpp"],
52+
# # strip_include_prefix = "bzl",
53+
# # include_prefix = "depends/ate-pairing/include",
54+
# include_prefix = "depends/ate-pairing/include",
55+
# includes = ["depends/ate-pairing/include"],
56+
# srcs = ["foo.cpp", "foo.h"],
57+
# hdrs = glob(["external/ate_pairing/include/bn.h",
58+
# ]) + ["foo.h"],
59+
# # includes = ["external/ate_pairing/include"],
60+
# copts = ["-Iexternal/ate_pairing/include",
61+
# ],
62+
# deps = ["@ate_pairing//src:libzm"]
63+
# # data = ["@ate_pairing//src:libzm"]
64+
# )

libff/algebra/curves/BUILD.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
2+
3+
cc_library(
4+
name = "curves",
5+
visibility = ["//visibility:public"],
6+
hdrs = ["curve_utils.hpp",
7+
"curve_utils.tcc",
8+
"public_params.hpp"],
9+
include_prefix = "libff/algebra/curves",
10+
deps = ["//libff/algebra/fields:bigint"]
11+
)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_library")
2+
3+
cc_library(
4+
name = "alt_bn128",
5+
srcs = [
6+
"alt_bn128_g1.cpp",
7+
"alt_bn128_g2.cpp",
8+
"alt_bn128_init.cpp",
9+
"alt_bn128_pairing.cpp",
10+
"alt_bn128_pp.cpp",
11+
],
12+
hdrs = [
13+
"alt_bn128_g1.hpp",
14+
"alt_bn128_g2.hpp",
15+
"alt_bn128_init.hpp",
16+
"alt_bn128_pairing.hpp",
17+
"alt_bn128_pp.hpp",
18+
],
19+
copts = ["-I."],
20+
include_prefix = "libff/algebra/curves/alt_bn128",
21+
linkstatic = True,
22+
visibility = ["//visibility:public"],
23+
deps = [
24+
"//libff/algebra/curves",
25+
"//libff/algebra/fields",
26+
],
27+
)

0 commit comments

Comments
 (0)