mirror of
https://github.com/status-im/c-kzg-4844.git
synced 2025-02-17 04:27:08 +00:00
Export methods; test on multiple platforms (#289)
Properly export functions on Windows; test on multiple OS
This commit is contained in:
parent
fd24cf8e1e
commit
5b727e5c3e
39
.github/workflows/csharp-tests.yml
vendored
39
.github/workflows/csharp-tests.yml
vendored
@ -15,6 +15,7 @@ env:
|
||||
|
||||
jobs:
|
||||
build-ckzg:
|
||||
name: Build ckzg
|
||||
runs-on: ${{ matrix.target.host }}
|
||||
strategy:
|
||||
matrix:
|
||||
@ -61,9 +62,38 @@ jobs:
|
||||
name: ckzg-library-wrapper-${{ matrix.target.location }}
|
||||
path: bindings/csharp/Ckzg.Bindings/runtimes/${{ matrix.target.location }}/native
|
||||
|
||||
build-ckzg-dotnet:
|
||||
runs-on: ubuntu-latest
|
||||
test-ckzg-dotnet:
|
||||
name: Test .NET wrapper
|
||||
runs-on: ${{ matrix.target.host }}
|
||||
needs: build-ckzg
|
||||
strategy:
|
||||
matrix:
|
||||
target:
|
||||
- host: ubuntu-22.04
|
||||
location: linux-x64
|
||||
- host: macos-latest
|
||||
location: osx-x64
|
||||
- host: windows-latest
|
||||
location: win-x64
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Set up .NET
|
||||
uses: actions/setup-dotnet@v3
|
||||
- name: Install dependencies
|
||||
run: cd bindings/csharp && dotnet restore
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ckzg-library-wrapper-${{ matrix.target.location }}
|
||||
path: bindings/csharp/Ckzg.Bindings/runtimes/${{ matrix.target.location }}/native
|
||||
- name: Test
|
||||
run: dotnet test -c release bindings/csharp/Ckzg.sln
|
||||
|
||||
build-ckzg-dotnet:
|
||||
name: Build .NET wrapper
|
||||
runs-on: ubuntu-latest
|
||||
needs: test-ckzg-dotnet
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/download-artifact@v3
|
||||
@ -86,13 +116,10 @@ jobs:
|
||||
with:
|
||||
name: ckzg-library-wrapper-linux-arm64
|
||||
path: bindings/csharp/Ckzg.Bindings/runtimes/linux-arm64/native
|
||||
|
||||
- name: Set up .NET
|
||||
uses: actions/setup-dotnet@v3
|
||||
- name: Install dependencies
|
||||
run: cd bindings/csharp && dotnet restore
|
||||
- name: Test
|
||||
run: cd bindings/csharp && dotnet test -c release --no-restore
|
||||
- name: Build
|
||||
run: cd bindings/csharp && dotnet pack -c release --no-restore -o nupkgs -p:Version=${{ inputs.version || env.binding_build_number_based_version }} -p:ContinuousIntegrationBuild=true
|
||||
- name: Upload package
|
||||
@ -100,6 +127,6 @@ jobs:
|
||||
with:
|
||||
name: Ckzg.Bindings-${{ inputs.version || env.binding_build_number_based_version }}
|
||||
path: bindings/csharp/nupkgs/Ckzg.Bindings.*.nupkg
|
||||
- name: Publish package
|
||||
- name: Publish .NET package
|
||||
if: github.ref == 'refs/heads/main'
|
||||
run: dotnet nuget push bindings/csharp/nupkgs/*.nupkg -k ${{ secrets.CSHARP_NUGET_APIKEY }} -s https://api.nuget.org/v3/index.json
|
||||
|
3
bindings/csharp/.gitignore
vendored
3
bindings/csharp/.gitignore
vendored
@ -3,9 +3,10 @@
|
||||
|
||||
.vs
|
||||
.vscode
|
||||
*.DotSettings.user
|
||||
|
||||
Ckzg.Bindings/runtimes/*/native/*
|
||||
!**/.gitkeep
|
||||
test_ckzg*
|
||||
*.so
|
||||
*.dll
|
||||
*.dll
|
||||
|
@ -1,32 +1,37 @@
|
||||
ifeq ($(OS),Windows_NT)
|
||||
BLST_BUILDSCRIPT = ./build.bat
|
||||
BLST_OBJ = blst.lib
|
||||
LOCATION ?= win-x64
|
||||
CLANG_EXECUTABLE = clang
|
||||
CKZG_LIBRARY_PATH = Ckzg.Bindings\runtimes\$(LOCATION)\native\ckzg.dll
|
||||
ifneq (,$(findstring Git/,$(SHELL)))
|
||||
BLST_BUILDSCRIPT = ./build.bat
|
||||
else
|
||||
BLST_BUILDSCRIPT = .\build.bat
|
||||
endif
|
||||
BLST_OBJ = blst.lib
|
||||
LOCATION ?= win-x64
|
||||
CLANG_EXECUTABLE = clang
|
||||
CKZG_LIBRARY_PATH = Ckzg.Bindings\runtimes\$(LOCATION)\native\ckzg.dll
|
||||
CFLAGS += -Wl,/def:ckzg.def
|
||||
else
|
||||
BLST_BUILDSCRIPT = ./build.sh
|
||||
BLST_OBJ = libblst.a
|
||||
CLANG_EXECUTABLE = clang
|
||||
BLST_BUILDSCRIPT = ./build.sh
|
||||
BLST_OBJ = libblst.a
|
||||
CLANG_EXECUTABLE = clang
|
||||
|
||||
UNAME_S := $(shell uname -s)
|
||||
UNAME_M := $(shell uname -m)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
ifeq ($(UNAME_M),x86_64)
|
||||
LOCATION ?= linux-x64
|
||||
else
|
||||
LOCATION ?= linux-arm64
|
||||
endif
|
||||
endif
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
ifeq ($(UNAME_M),arm64)
|
||||
LOCATION ?= osx-arm64
|
||||
else
|
||||
LOCATION ?= osx-x64
|
||||
endif
|
||||
endif
|
||||
UNAME_S := $(shell uname -s)
|
||||
UNAME_M := $(shell uname -m)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
ifeq ($(UNAME_M),x86_64)
|
||||
LOCATION ?= linux-x64
|
||||
else
|
||||
LOCATION ?= linux-arm64
|
||||
endif
|
||||
endif
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
ifeq ($(UNAME_M),arm64)
|
||||
LOCATION ?= osx-arm64
|
||||
else
|
||||
LOCATION ?= osx-x64
|
||||
endif
|
||||
endif
|
||||
|
||||
CKZG_LIBRARY_PATH = Ckzg.Bindings/runtimes/$(LOCATION)/native/ckzg.so
|
||||
CKZG_LIBRARY_PATH = Ckzg.Bindings/runtimes/$(LOCATION)/native/ckzg.so
|
||||
endif
|
||||
|
||||
FIELD_ELEMENTS_PER_BLOB ?= 4096
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "c_kzg_4844.h"
|
||||
#include "ckzg.h"
|
||||
#include "c_kzg_4844.h"
|
||||
|
||||
KZGSettings* load_trusted_setup_wrap(const char* file) {
|
||||
KZGSettings* out = malloc(sizeof(KZGSettings));
|
||||
|
15
bindings/csharp/ckzg.def
Normal file
15
bindings/csharp/ckzg.def
Normal file
@ -0,0 +1,15 @@
|
||||
LIBRARY ckzg
|
||||
|
||||
EXPORTS
|
||||
load_trusted_setup_wrap
|
||||
free_trusted_setup_wrap
|
||||
load_trusted_setup
|
||||
load_trusted_setup_file
|
||||
free_trusted_setup
|
||||
blob_to_kzg_commitment
|
||||
compute_kzg_proof
|
||||
compute_blob_kzg_proof
|
||||
verify_kzg_proof
|
||||
verify_blob_kzg_proof
|
||||
verify_blob_kzg_proof_batch
|
||||
|
@ -1,26 +1,9 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "c_kzg_4844.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define DLLEXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define DLLEXPORT
|
||||
#endif
|
||||
KZGSettings* load_trusted_setup_wrap(const char* file);
|
||||
|
||||
DLLEXPORT KZGSettings* load_trusted_setup_wrap(const char* file);
|
||||
|
||||
DLLEXPORT void free_trusted_setup_wrap(KZGSettings *s);
|
||||
|
||||
DLLEXPORT C_KZG_RET blob_to_kzg_commitment(KZGCommitment *out, const Blob *blob, const KZGSettings *s);
|
||||
|
||||
DLLEXPORT C_KZG_RET compute_kzg_proof(KZGProof *proof_out, Bytes32 *y_out, const Blob *blob, const Bytes32 *z_bytes, const KZGSettings *s);
|
||||
|
||||
DLLEXPORT C_KZG_RET compute_blob_kzg_proof(KZGProof *out, const Blob *blob, const Bytes48 *commitment, const KZGSettings *s);
|
||||
|
||||
DLLEXPORT C_KZG_RET verify_kzg_proof(bool *result, const Bytes48 *commitments_bytes, const Bytes32 *z_bytes, const Bytes32 *y_bytes, const Bytes48 *proof_bytes, const KZGSettings *s);
|
||||
|
||||
DLLEXPORT C_KZG_RET verify_blob_kzg_proof(bool *result, const Blob *blob, const Bytes48 *commitment_bytes, const Bytes48 *proof_bytes, const KZGSettings *s);
|
||||
|
||||
DLLEXPORT C_KZG_RET verify_blob_kzg_proof_batch(bool *result, const Blob *blobs, const Bytes48 *commitments_bytes, const Bytes48 *proofs_bytes, size_t count, const KZGSettings *s);
|
||||
void free_trusted_setup_wrap(KZGSettings *s);
|
||||
|
Loading…
x
Reference in New Issue
Block a user