Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated fork to use v0.3.11 & made points public #1

Closed
wants to merge 94 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
308c119
bindings/go/blst_minpk_test.go: drop deprecated import.
dot-asm Mar 4, 2023
764b3da
bindings/go/blst.go: re-generate.py.
dot-asm Mar 4, 2023
d334254
bindings/node.js/run.me: refine node version detection.
dot-asm Mar 4, 2023
6464ce8
build/bindings_trim.pl: replace ::std:: with ::core:: in Rust bindings.
dot-asm Mar 10, 2023
296b0da
bindings/rust/build.rs: prepare for bare-metal targets.
dot-asm Mar 10, 2023
9f5536a
bindings/rust/src/lib.rs: move pippenger_mult_impl to a separate file.
dot-asm Mar 10, 2023
0b92a22
pentaroot.c: fix typos in private prototypes.
dot-asm Mar 15, 2023
411e1c6
bindings/blst.hpp: modernize memory handling.
dot-asm Mar 15, 2023
f4a7953
bindings/blst[_aux].h: make in compile with -Wstrict-prototypes
dot-asm Mar 15, 2023
7911e7b
bindings/go/blst.go: add CoreVerifyPkInG{1,2}.
dot-asm Mar 15, 2023
6366474
blst_t.hpp: make operator^ work with larger powers.
dot-asm Mar 15, 2023
a7fd1f5
blst_t.hpp: add czero() method.
dot-asm Mar 15, 2023
c9e57e9
bindings/rust/README.md: fix the exmaple snippets.
gyuho Mar 18, 2023
e9dfc5e
bindings/blst_aux.h: fix MSVC compilation error.
dot-asm Apr 6, 2023
9bf52f8
bindings/rust/build.rs: prioritize explicit --codegen target-cpu=*.
dot-asm Apr 24, 2023
63d5886
bindings/rust/build.rs: fix clippy nits.
dot-asm Apr 24, 2023
97b180e
.github/workflows/ci.yml: resolve Actions deprecation warnings.
dot-asm Apr 24, 2023
9347d5f
build.sh: fix ADX detection on Darwin.
dot-asm Apr 24, 2023
80da888
bindings/emscripten/run.me: use ${EMSDK_NODE} as a fallback.
dot-asm Apr 24, 2023
bf83cb6
bindings/c#/run.me: utilize ResolvingUnmanagedDll event.
dot-asm Apr 24, 2023
42865fa
.github/workflows/codeql-analysis.yml: fix globs in paths.
dot-asm Apr 24, 2023
d3f9bd3
blst_t.hpp: add degree, mem_t and one(or_zero) method.
dot-asm Apr 28, 2023
0bec08c
blst_t.hpp: make it compile with clang.
dot-asm May 3, 2023
53a303f
blst_t.hpp: add is_one() methods.
dot-asm May 4, 2023
a7a560d
bingings/blst.h: move blst_fr_pentaroot to blst_aux.h.
dot-asm May 8, 2023
97479e7
pairing.c: add add blst_miller_loop_n.
dot-asm May 8, 2023
056e391
bindings/blst.h: add blst_miller_loop_n declaration.
dot-asm May 8, 2023
36f694f
Execute build/refresh.sh.
dot-asm May 8, 2023
392c738
bindings/go/blst.go: add Fp12MillerLoopN.
dot-asm May 8, 2023
f0b107b
bindings/rust/src/pippenger.rs: facilitate $points' slicing.
dot-asm May 8, 2023
fceea3e
bindings/rust/src/lib.rs: add blst_fp12::miller_loop_n.
dot-asm May 8, 2023
d933031
blst_t.hpp: add csel() methods.
dot-asm May 9, 2023
2647fec
blst_t.hpp: make no assumptions about pre-included headers.
dot-asm May 18, 2023
fd2d501
vect.h: respect -ffreestanding compiler flag.
dot-asm May 18, 2023
ed27791
.github/workflows/*: refresh.
dot-asm May 18, 2023
2300b50
export.c: add blst_fr_{ct|gs}_bfly.
dot-asm May 18, 2023
a870734
bindings/blst_aux.h: add blst_fr_{ct|gs}_bfly declarations.
dot-asm May 18, 2023
1e9e050
Execute build/refresh.sh.
dot-asm May 18, 2023
b4ebf88
exports.c: refactor blst_sk_mul_n_check.
dot-asm May 18, 2023
2f2ce71
blst_t.hpp: declare is_zero() as int for constant-time-ness.
dot-asm May 25, 2023
4e27aac
exports.c: minor cleanup.
dot-asm Jun 5, 2023
dbe7da8
asm/x86_64-xlate.pl: sync with cryptogams.
dot-asm Jun 5, 2023
936b6b3
Execute build/refresh.sh.
dot-asm Jun 5, 2023
1e8ce30
asm/sha256*-x86_64.pl: sync up with cryptogams (make it profiler-frie…
dot-asm Jun 5, 2023
a8cd361
Execute build/refresh.sh.
dot-asm Jun 5, 2023
bc9245f
asm/*-x86_64.pl: disambiguate local labels.
dot-asm May 26, 2023
0dbc2ce
asm/mul{qx}_mont_384-x86_64.pl: add __ADX__ run-time switch.
dot-asm May 28, 2023
54389c1
asm/mul{qx}_mont_256-x86_64.pl: add __ADX__ run-time switch.
dot-asm May 28, 2023
5fa162f
asm/ct{qx}_inverse_mod_384-x86_64.pl: add __ADX__ run-time switch.
dot-asm May 28, 2023
c7a477e
asm/sha256*-x86_64.pl: add __SHA__ run-time switch.
dot-asm Jun 5, 2023
72924d1
asm/sha256-armv8.pl: add HWCAP_CE_SHA256 run-time switch.
dot-asm Jun 5, 2023
9557550
Execute build/refresh.sh.
dot-asm Jun 5, 2023
0e0ebaf
Refactor build/assembly.S.
dot-asm Jun 5, 2023
f8af94a
Add cpuid.c.
dot-asm Jun 5, 2023
af4ba68
.github/workflows/ci.yml: exercise --features=portable.
dot-asm Jun 5, 2023
39e1fd1
bindings/rust/README.md: clarify the lack of established MSRV policy.
dot-asm Jun 14, 2023
96ea02c
build/refresh.sh,bindings_trim.pl: update to newer rust-bindgen.
dot-asm Jun 14, 2023
1d197e7
build/bindings_trim.pl: add types sanity check.
dot-asm Jun 14, 2023
689c11c
Execute build/refresh.sh.
dot-asm Jun 14, 2023
4d25a1a
bindings/rust: add serde support, gated by "serde" feature.
kwantam Mar 3, 2023
60e416a
bindings/rust/build.rs: issue warning when "serde-secret" is enabled.
dot-asm Jun 15, 2023
330d007
asm/div3w-x86_64.pl: add Win64 stack unwinding.
dot-asm Jun 16, 2023
8beba09
Execute build/refresh.sh.
dot-asm Jun 16, 2023
b6500ec
bulk_addition.c: limit stack utilization on wasm platforms.
dot-asm Jun 16, 2023
d84a1ae
bindings/rust/src/pippenger.rs: add batch addition method.
dot-asm Jun 16, 2023
7063803
.github/workflows/ci.yml: annotate cargo test invocations.
dot-asm Jun 16, 2023
6424186
bindings/rust/src/lib.rs: mask std-dependent functions and engage no_…
dot-asm Mar 10, 2023
38fbd11
bindings/rust: add pippenger-no_std.rs [and deduplicate tests].
dot-asm Mar 15, 2023
16de009
bindings/rust/build.rs: refine no_std detection.
dot-asm Jun 16, 2023
6b837a0
.github/workflows/ci.yml: exercise no-std [with limited stack size].
dot-asm Jun 16, 2023
1d11baf
bindings/rust/Cargo.toml: harmonize with detection logic in build.rs.
dot-asm Jun 23, 2023
5358144
bindings/rust/build.rs: default to clang when targeting uefi.
dot-asm Jun 23, 2023
e0f3398
asm/arm-xlate.pl: handle .comm on 64-bit Apple OSes.
dot-asm Jun 30, 2023
8714a9a
Execute build/refresh.sh.
dot-asm Jun 30, 2023
c205f7a
vect.h: omit redundant declaration.
dot-asm Jun 30, 2023
5176127
vect.h: secure vec_cswap.
dot-asm Jun 30, 2023
d5a3b78
blst_t.hpp: harmonize with <sppark>/ff/mont_t.cuh.
dot-asm Jul 7, 2023
121ad65
exports.c: refactor blst_scalar_from_{lb}e_bytes.
dot-asm Jul 7, 2023
4967efe
bindings/go: deduplicate cgo files.
dot-asm Jul 9, 2023
327d30a
bindings/blst.hpp: resolve -Wmismatched-new-delete.
dot-asm Jul 18, 2023
168ff67
multi_scalar.c: handle small amount of points in Pippenger MSM differ…
dot-asm Jul 28, 2023
92628b7
bindings/rust/src/pippenger-test_mod.rs: exercize new code path.
dot-asm Jul 28, 2023
8e5ecc9
*: fix some typos
jtraglia May 19, 2023
dce883b
Execute build/refresh.sh.
dot-asm Jul 28, 2023
701e42a
asm/ct_*: add missing .hidden directives.
dot-asm Aug 2, 2023
6dd7aa4
Execute build/refresh.sh.
dot-asm Aug 2, 2023
492319a
cpuid.c: adjust symbol visibility.
dot-asm Aug 2, 2023
e1a44c9
build.sh: drop --version-script linker argument.
dot-asm Aug 2, 2023
5aa7ce1
bindings/<swig-based>/*: minimize dynamic library symbol pollution.
dot-asm Aug 2, 2023
9fa8bcf
vect.h: tolerate compilation with -std=cNM flag.
dot-asm Aug 7, 2023
c6a3cc0
build.sh: don't pass -mno-avx unless actually required.
dot-asm Aug 7, 2023
fb91221
bindings/go/blst.go: fix logical error in SigValidate.
dot-asm Aug 9, 2023
3dd0f80
bindings/rust/Cargo.toml: bump the version number.
dot-asm Aug 9, 2023
afdb0a4
make points public
ToufeeqP Sep 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ jobs:
steps:
- uses: actions/checkout@v3

- id: get-date
run: echo "::set-output name=date::$(date -u +%Y-%m)"
- name: Get date
id: get-date
run: echo "date=$(date -u +%Y-%m)" >> $GITHUB_OUTPUT
shell: bash

- uses: actions/cache@v3
Expand All @@ -44,20 +45,44 @@ jobs:
shell: bash
run: |
rustc --version --verbose
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
cd bindings/rust
if [ "$GITHUB_EVENT_NAME" != "pull_request" ]; then
cargo update
fi
cargo test --release
echo '--- test portable'
echo
cargo test --release --features=portable
echo '--- test no-threads'
echo
cargo test --release --features=no-threads
echo '--- test serde-secret'
echo
cargo test --release --features=serde-secret
echo '--- test no_std'
echo
echo 'set -e' > ulimit-s
echo 'export RUST_MIN_STACK=$(($1 * 1024)); shift' >> ulimit-s
echo 'exec "$@"' >> ulimit-s
triple=`rustc -vV | awk '/host:/ {print $2}' | tr 'a-z-' 'A-Z_'`
stack_size=`[ $OSTYPE = "msys" ] && echo 65 || echo 56`
env BLST_TEST_NO_STD= \
CARGO_TARGET_${triple}_RUNNER="bash ulimit-s $stack_size" \
cargo test --release
if [ `uname -s` = "Linux" ]; then
echo '--- test wasm32-wasi'
echo
rustup target add wasm32-wasi
curl https://wasmtime.dev/install.sh -sSf | bash
env PATH=$PATH:~/.wasmtime/bin:`clang -print-search-dirs | awk -F= '/^programs:/{print$2}'` \
AR=llvm-ar CARGO_TARGET_WASM32_WASI_RUNNER=wasmtime \
cargo test --release --target=wasm32-wasi
cargo clean -p blst --release --target=wasm32-wasi
echo '--- dry-run publish'
echo
./publish.sh --dry-run
fi
[ `uname -s` = "Linux" ] && ./publish.sh --dry-run
cargo clean -p blst
cargo clean -p blst --release
rm -rf target/.rustc_info.json
Expand Down Expand Up @@ -88,13 +113,14 @@ jobs:
path: ~/swig
key: ${{ runner.os }}-swig-github

- uses: actions/setup-java@v1
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11

- uses: actions/setup-node@v3
with:
node-version: '12.x'
node-version: '16.x'

- name: Environment
run: |
Expand Down Expand Up @@ -167,6 +193,6 @@ jobs:
bindings/c#/run.me;
if which dotnet > /dev/null 2>&1; then
cd bindings/c#
env LD_LIBRARY_PATH=`pwd` dotnet run -c Release
dotnet run -c Release
fi
fi
10 changes: 5 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ on:
branches:
- '**'
paths:
- 'src'
- 'bindings/c#'
- 'src/*'
- 'bindings/c#/*'
- '.github/workflows/codeql-analysis.yml'
pull_request:
branches:
- master
paths:
- 'src'
- 'bindings/c#'
- 'src/*'
- 'bindings/c#/*'
#schedule:
# - cron: '0 23+ * * 4'

Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:

- if: matrix.language == 'cpp'
name: Custom build
run: ./build.sh -m32 -D__wasm__
run: ./build.sh -m32 -ffreestanding

- if: matrix.language != 'cpp'
name: Autobuild
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ script:
REF=.cargo/registry/index/*/.last-updated;
THEN=`(stat -c %Y "$TRAVIS_HOME"/$REF || stat -f %m "$TRAVIS_HOME"/$REF) 2>/dev/null`;
if [ $(($NOW - ${THEN:-0})) -gt 604800 ]; then
cargo update;
env CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse cargo update;
fi;
cargo test --release )
fi
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ The most-significant three bits of a G1 or G2 encoding should be masked away bef
* The third-most significant bit is set if (and only if) this point is in compressed form _and_ it is not the point at infinity _and_ its y-coordinate is the lexicographically largest of the two associated with the encoded x-coordinate.

## Build
The build process is very simple and only requires a C complier. It's integrated into the Go and Rust ecosystems, so that respective users would go about as they would with any other external module. Otherwise, a binary library would have to be compiled.
The build process is very simple and only requires a C compiler. It's integrated into the Go and Rust ecosystems, so that respective users would go about as they would with any other external module. Otherwise, a binary library would have to be compiled.

### C static library
A static library called libblst.a can be built in the current working directory of the user's choice:
Expand Down
19 changes: 9 additions & 10 deletions bindings/blst.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,6 @@ void blst_fr_sqr(blst_fr *ret, const blst_fr *a);
void blst_fr_cneg(blst_fr *ret, const blst_fr *a, bool flag);
void blst_fr_eucl_inverse(blst_fr *ret, const blst_fr *a);
void blst_fr_inverse(blst_fr *ret, const blst_fr *a);
#ifdef BLST_FR_PENTAROOT
void blst_fr_pentaroot(blst_fr *ret, const blst_fr *a);
void blst_fr_pentapow(blst_fr *ret, const blst_fr *a);
#endif

void blst_fr_from_uint64(blst_fr *ret, const uint64_t a[4]);
void blst_uint64_from_fr(uint64_t ret[4], const blst_fr *a);
Expand Down Expand Up @@ -159,7 +155,7 @@ void blst_fp12_frobenius_map(blst_fp12 *ret, const blst_fp12 *a, size_t n);
bool blst_fp12_is_equal(const blst_fp12 *a, const blst_fp12 *b);
bool blst_fp12_is_one(const blst_fp12 *a);
bool blst_fp12_in_group(const blst_fp12 *a);
const blst_fp12 *blst_fp12_one();
const blst_fp12 *blst_fp12_one(void);
#endif // SWIG

/*
Expand All @@ -184,13 +180,13 @@ bool blst_p1_on_curve(const blst_p1 *p);
bool blst_p1_in_g1(const blst_p1 *p);
bool blst_p1_is_equal(const blst_p1 *a, const blst_p1 *b);
bool blst_p1_is_inf(const blst_p1 *a);
const blst_p1 *blst_p1_generator();
const blst_p1 *blst_p1_generator(void);

bool blst_p1_affine_on_curve(const blst_p1_affine *p);
bool blst_p1_affine_in_g1(const blst_p1_affine *p);
bool blst_p1_affine_is_equal(const blst_p1_affine *a, const blst_p1_affine *b);
bool blst_p1_affine_is_inf(const blst_p1_affine *a);
const blst_p1_affine *blst_p1_affine_generator();
const blst_p1_affine *blst_p1_affine_generator(void);

typedef struct { blst_fp2 x, y, z; } blst_p2;
typedef struct { blst_fp2 x, y; } blst_p2_affine;
Expand All @@ -211,13 +207,13 @@ bool blst_p2_on_curve(const blst_p2 *p);
bool blst_p2_in_g2(const blst_p2 *p);
bool blst_p2_is_equal(const blst_p2 *a, const blst_p2 *b);
bool blst_p2_is_inf(const blst_p2 *a);
const blst_p2 *blst_p2_generator();
const blst_p2 *blst_p2_generator(void);

bool blst_p2_affine_on_curve(const blst_p2_affine *p);
bool blst_p2_affine_in_g2(const blst_p2_affine *p);
bool blst_p2_affine_is_equal(const blst_p2_affine *a, const blst_p2_affine *b);
bool blst_p2_affine_is_inf(const blst_p2_affine *a);
const blst_p2_affine *blst_p2_affine_generator();
const blst_p2_affine *blst_p2_affine_generator(void);

/*
* Multi-scalar multiplications and other multi-point operations.
Expand Down Expand Up @@ -341,6 +337,9 @@ void blst_sign_pk_in_g2(blst_p1 *out_sig, const blst_p1 *hash,
#ifndef SWIG
void blst_miller_loop(blst_fp12 *ret, const blst_p2_affine *Q,
const blst_p1_affine *P);
void blst_miller_loop_n(blst_fp12 *ret, const blst_p2_affine *const Qs[],
const blst_p1_affine *const Ps[],
size_t n);
void blst_final_exp(blst_fp12 *ret, const blst_fp12 *f);
void blst_precompute_lines(blst_fp6 Qlines[68], const blst_p2_affine *Q);
void blst_miller_loop_lines(blst_fp12 *ret, const blst_fp6 Qlines[68],
Expand All @@ -356,7 +355,7 @@ typedef struct {} blst_pairing;
typedef struct blst_opaque blst_pairing;
#endif

size_t blst_pairing_sizeof();
size_t blst_pairing_sizeof(void);
void blst_pairing_init(blst_pairing *new_ctx, bool hash_or_encode,
const byte *DST DEFNULL, size_t DST_len DEFNULL);
const byte *blst_pairing_get_dst(const blst_pairing *ctx);
Expand Down
39 changes: 19 additions & 20 deletions bindings/blst.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <string>
#include <cstring>
#include <vector>
#include <memory>

#if __cplusplus >= 201703L
# include <string_view>
Expand Down Expand Up @@ -416,19 +417,19 @@ class P1_Affines {

P1 mult(const byte* const scalars[], size_t nbits) const
{ P1 ret;
limb_t* scratch;

if (wbits != 0) {
scratch = new limb_t[blst_p1s_mult_wbits_scratch_sizeof(npoints)/sizeof(limb_t)];
size_t sz = blst_p1s_mult_wbits_scratch_sizeof(npoints);
std::unique_ptr<limb_t[]> scratch{new limb_t[sz/sizeof(limb_t)]};
blst_p1s_mult_wbits(ret, table[0], wbits, npoints,
scalars, nbits, scratch);
scalars, nbits, scratch.get());
} else {
scratch = new limb_t[blst_p1s_mult_pippenger_scratch_sizeof(npoints)/sizeof(limb_t)];
size_t sz = blst_p1s_mult_pippenger_scratch_sizeof(npoints);
std::unique_ptr<limb_t[]> scratch{new limb_t[sz/sizeof(limb_t)]};
const blst_p1_affine* const ptrs[2] = { table[0], nullptr };
blst_p1s_mult_pippenger(ret, ptrs, npoints,
scalars, nbits, scratch);
scalars, nbits, scratch.get());
}
delete[] scratch;
return ret;
}

Expand All @@ -451,12 +452,11 @@ class P1_Affines {
static P1 mult_pippenger(const P1_Affine* const points[], size_t npoints,
const byte* const scalars[], size_t nbits)
{ P1 ret;
limb_t* scratch;
scratch = new limb_t[blst_p1s_mult_pippenger_scratch_sizeof(npoints)/sizeof(limb_t)];
size_t sz = blst_p1s_mult_pippenger_scratch_sizeof(npoints);
std::unique_ptr<limb_t[]> scratch{new limb_t[sz/sizeof(limb_t)]};
blst_p1s_mult_pippenger(ret,
reinterpret_cast<const blst_p1_affine *const*>(points),
npoints, scalars, nbits, scratch);
delete[] scratch;
npoints, scalars, nbits, scratch.get());
return ret;
}
#ifndef SWIG
Expand Down Expand Up @@ -715,19 +715,19 @@ class P2_Affines {

P2 mult(const byte* const scalars[], size_t nbits) const
{ P2 ret;
limb_t* scratch;

if (wbits != 0) {
scratch = new limb_t[blst_p2s_mult_wbits_scratch_sizeof(npoints)/sizeof(limb_t)];
size_t sz = blst_p2s_mult_wbits_scratch_sizeof(npoints);
std::unique_ptr<limb_t[]> scratch{new limb_t[sz/sizeof(limb_t)]};
blst_p2s_mult_wbits(ret, table[0], wbits, npoints,
scalars, nbits, scratch);
scalars, nbits, scratch.get());
} else {
scratch = new limb_t[blst_p2s_mult_pippenger_scratch_sizeof(npoints)/sizeof(limb_t)];
size_t sz = blst_p2s_mult_pippenger_scratch_sizeof(npoints);
std::unique_ptr<limb_t[]> scratch{new limb_t[sz/sizeof(limb_t)]};
const blst_p2_affine* const ptrs[2] = { table[0], nullptr };
blst_p2s_mult_pippenger(ret, ptrs, npoints,
scalars, nbits, scratch);
scalars, nbits, scratch.get());
}
delete[] scratch;
return ret;
}

Expand All @@ -750,12 +750,11 @@ class P2_Affines {
static P2 mult_pippenger(const P2_Affine* const points[], size_t npoints,
const byte* const scalars[], size_t nbits)
{ P2 ret;
limb_t* scratch;
scratch = new limb_t[blst_p2s_mult_pippenger_scratch_sizeof(npoints)/sizeof(limb_t)];
size_t sz = blst_p2s_mult_pippenger_scratch_sizeof(npoints);
std::unique_ptr<limb_t[]> scratch{new limb_t[sz/sizeof(limb_t)]};
blst_p2s_mult_pippenger(ret,
reinterpret_cast<const blst_p2_affine *const*>(points),
npoints, scalars, nbits, scratch);
delete[] scratch;
npoints, scalars, nbits, scratch.get());
return ret;
}
#ifndef SWIG
Expand Down
20 changes: 15 additions & 5 deletions bindings/blst_aux.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
* depending on their proven/unproven worthiness.
*/

void blst_fr_ct_bfly(blst_fr *x0, blst_fr *x1, const blst_fr *twiddle);
void blst_fr_gs_bfly(blst_fr *x0, blst_fr *x1, const blst_fr *twiddle);
void blst_fr_to(blst_fr *ret, const blst_fr *a);
void blst_fr_from(blst_fr *ret, const blst_fr *a);
#ifdef BLST_FR_PENTAROOT
void blst_fr_pentaroot(blst_fr *ret, const blst_fr *a);
void blst_fr_pentapow(blst_fr *ret, const blst_fr *a);
#endif

void blst_fp_to(blst_fp *ret, const blst_fp *a);
void blst_fp_from(blst_fp *ret, const blst_fp *a);
Expand Down Expand Up @@ -50,7 +56,11 @@ void blst_sk_to_pk2_in_g2(byte out[192], blst_p2_affine *out_pk,
void blst_sign_pk2_in_g2(byte out[96], blst_p1_affine *out_sig,
const blst_p1 *hash, const blst_scalar *SK);

#ifdef __BLST_RUST_BINDGEN__
typedef struct {} blst_uniq;
#else
typedef struct blst_opaque blst_uniq;
#endif

size_t blst_uniq_sizeof(size_t n_nodes);
void blst_uniq_init(blst_uniq *tree);
Expand Down Expand Up @@ -94,11 +104,11 @@ void blst_scalar_from_hexascii(blst_scalar *out, const byte *hex);
void blst_fr_from_hexascii(blst_fr *ret, const byte *hex);
void blst_fp_from_hexascii(blst_fp *ret, const byte *hex);

size_t blst_p1_sizeof();
size_t blst_p1_affine_sizeof();
size_t blst_p2_sizeof();
size_t blst_p2_affine_sizeof();
size_t blst_fp12_sizeof();
size_t blst_p1_sizeof(void);
size_t blst_p1_affine_sizeof(void);
size_t blst_p2_sizeof(void);
size_t blst_p2_affine_sizeof(void);
size_t blst_fp12_sizeof(void);

/*
* Single-shot SHA-256 hash function.
Expand Down
35 changes: 35 additions & 0 deletions bindings/c#/run.me
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,43 @@ using System.Numerics;
using System.Runtime.InteropServices;
using size_t = System.UIntPtr;

#if NET5_0_OR_GREATER
using System.Runtime.Loader;
using System.Reflection;
using System.IO;
#endif

namespace supranational { public static class blst {

#if NET5_0_OR_GREATER
private static string dll;

static blst()
{
if (String.IsNullOrEmpty(dll)) {
var name = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "blst.dll"
: RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "libblst.dll.dylib"
: "libblst.dll.so";

var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var arch = RuntimeInformation.ProcessArchitecture switch {
Architecture.X64 => "x64",
Architecture.Arm64 => "arm64",
_ => "unsupported"
};
dll = Path.Combine(dir, arch, name);

if (!File.Exists(dll))
dll = Path.Combine(Environment.CurrentDirectory, name);

if (File.Exists(dll)) {
AssemblyLoadContext.Default.ResolvingUnmanagedDll += (asm, needs) =>
(needs == "blst.dll" ? NativeLibrary.Load(dll) : IntPtr.Zero);
}
}
}
#endif

public enum ERROR {
SUCCESS = 0,
BAD_ENCODING,
Expand Down
Loading
Loading