-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(math): implement
QuadraticExtensionField
- Loading branch information
Showing
17 changed files
with
722 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tachyon/math/finite_fields/generator/prime_field_generator/BUILD.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
load("//bazel:tachyon_cc.bzl", "tachyon_cc_binary") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
tachyon_cc_binary( | ||
name = "prime_field_generator", | ||
srcs = ["prime_field_generator.cc"], | ||
deps = [ | ||
"//tachyon/base/console", | ||
"//tachyon/base/files:file_path_flag", | ||
"//tachyon/base/flag:flag_parser", | ||
"//tachyon/build:cc_writer", | ||
"//tachyon/math/base:bit_iterator", | ||
"//tachyon/math/base/gmp:bit_traits", | ||
"//tachyon/math/finite_fields:prime_field_util", | ||
"//tachyon/math/finite_fields/generator:generator_util", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
tachyon/math/finite_fields/generator/quadratic_extension_field_generator/BUILD.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
load("//bazel:tachyon_cc.bzl", "tachyon_cc_binary") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
tachyon_cc_binary( | ||
name = "quadratic_extension_field_generator", | ||
srcs = ["quadratic_extension_field_generator.cc"], | ||
deps = [ | ||
"//tachyon/base/console", | ||
"//tachyon/base/files:file_path_flag", | ||
"//tachyon/base/flag:flag_parser", | ||
"//tachyon/build:cc_writer", | ||
"//tachyon/math/base:big_int", | ||
"//tachyon/math/base:bit_iterator", | ||
], | ||
) |
70 changes: 70 additions & 0 deletions
70
tachyon/math/finite_fields/generator/quadratic_extension_field_generator/build_defs.bzl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
load("//bazel:tachyon_cc.bzl", "tachyon_cc_library") | ||
|
||
def _generate_quadratic_extension_field_impl(ctx): | ||
arguments = [ | ||
"--out=%s" % (ctx.outputs.out.path), | ||
"--namespace=%s" % (ctx.attr.namespace), | ||
"--class=%s" % (ctx.attr.class_name), | ||
"--non_residue=%s" % (ctx.attr.non_residue), | ||
"--base_field_hdr=%s" % (ctx.attr.base_field_hdr), | ||
"--base_field=%s" % (ctx.attr.base_field), | ||
] | ||
|
||
ctx.actions.run( | ||
tools = [ctx.executable._tool], | ||
executable = ctx.executable._tool, | ||
outputs = [ctx.outputs.out], | ||
arguments = arguments, | ||
) | ||
|
||
return [DefaultInfo(files = depset([ctx.outputs.out]))] | ||
|
||
generate_quadratic_extension_field = rule( | ||
implementation = _generate_quadratic_extension_field_impl, | ||
attrs = { | ||
"out": attr.output(mandatory = True), | ||
"namespace": attr.string(mandatory = True), | ||
"class_name": attr.string(mandatory = True), | ||
"non_residue": attr.int(mandatory = True), | ||
"base_field_hdr": attr.string(mandatory = True), | ||
"base_field": attr.string(mandatory = True), | ||
"_tool": attr.label( | ||
# TODO(chokobole): Change it to "exec" we can build it on macos. | ||
cfg = "target", | ||
executable = True, | ||
allow_single_file = True, | ||
default = Label("@kroma_network_tachyon//tachyon/math/finite_fields/generator/quadratic_extension_field_generator"), | ||
), | ||
}, | ||
) | ||
|
||
def generate_quadratic_extension_fields( | ||
name, | ||
namespace, | ||
class_name, | ||
non_residue, | ||
base_field_hdr = "", | ||
base_field = "", | ||
deps = [], | ||
**kwargs): | ||
for n in [ | ||
("{}_gen_hdr".format(name), "{}.h".format(name)), | ||
]: | ||
generate_quadratic_extension_field( | ||
namespace = namespace, | ||
class_name = class_name, | ||
non_residue = non_residue, | ||
base_field_hdr = base_field_hdr, | ||
base_field = base_field, | ||
name = n[0], | ||
out = n[1], | ||
) | ||
|
||
tachyon_cc_library( | ||
name = name, | ||
hdrs = [":{}_gen_hdr".format(name)], | ||
deps = deps + [ | ||
"//tachyon/math/finite_fields:quadratic_extension_field", | ||
], | ||
**kwargs | ||
) |
Oops, something went wrong.