diff --git a/.github/ISSUE_TEMPLATE/bug_issue.md b/.github/ISSUE_TEMPLATE/bug_issue.md new file mode 100644 index 0000000..818d00e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_issue.md @@ -0,0 +1,32 @@ +--- +name: ":bug: Bug Report" +about: Create a bug report to help us improve the repo +title: "[BUG]: " +labels: bug +--- + +## Description + +Please provide a clear and concise description of the bug. + +### Reproduce + +Please list the steps to reproduce the issue. + +## Expected Behavior + +Please provide a clear and concise description of what you expected to happen. + +## Environment + +Please complete the following information: + +OS + Version: + +Cargo Version: + +GPU type: + +## Additional context + +Please provide any additional context that may be helpful in confirming and resolving this issue. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..02a4be3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,14 @@ +--- +name: ":sparkles: Feature Request" +about: Request the inclusion of a new feature or functionality +title: "[FEAT]: " +labels: enhancement +--- + +## Description + +Please provide a clear and concise description of the feature you would like included. + +## Motivation + +Please provide a clear and concise description of the motivation for adding this feature. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..560e03e --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,7 @@ +## Describe the changes + +This PR... + +## Linked Issues + +Resolves # diff --git a/.github/workflows/main-lint.yml b/.github/workflows/main-lint.yml new file mode 100644 index 0000000..9dc28f1 --- /dev/null +++ b/.github/workflows/main-lint.yml @@ -0,0 +1,16 @@ +name: Lint + +on: + pull_request: + branches: + - main + +jobs: + formatting-golang: + name: Check Golang Code Formatting + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Check gofmt + run: if [[ $(go list ./... | xargs go fmt) ]]; then echo "Please run go fmt"; exit 1; fi diff --git a/.github/workflows/main-test.yml b/.github/workflows/main-test.yml new file mode 100644 index 0000000..ec67a8e --- /dev/null +++ b/.github/workflows/main-test.yml @@ -0,0 +1,32 @@ +name: Test + +on: + pull_request: + branches: + - main + +env: + CARGO_TERM_COLOR: always + ARCH_TYPE: sm_70 + +jobs: + test-golang-linux: + name: Test Golang on Linux + runs-on: [self-hosted, Linux, X64, icicle] + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + - name: Build CUDA libs + run: | + git clone https://github.com/username/another-repo.git + cd another-repo/goicicle + make all + cd ~/go/pkg/mod/github.com/ingonyama-zk/icicle@v0.0.0-20230817090824-e04bd928e658/goicicle + chmod +x setup.sh + + echo "Compiling all ICICLE curves..." + make all + echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/goicicle" >> $GITHUB_ENV + - name: Run Golang Tests + run: | + go test ./bn254 ./bls12377 -count=1 diff --git a/README.md b/README.md new file mode 100644 index 0000000..ea1bf89 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +## ICICLE-GNARK WRAPPER + +This repo contains wrappers for common ICICLE methods used within the ICICLE <> Gnark integration. diff --git a/curves/bn254/g1_test.go b/curves/bn254/g1_test.go index cac90c9..fd88fe5 100644 --- a/curves/bn254/g1_test.go +++ b/curves/bn254/g1_test.go @@ -11,19 +11,19 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - + // Code generated by Ingonyama DO NOT EDIT package bn254 import ( "fmt" - "testing" "github.com/consensys/gnark-crypto/ecc/bn254" "github.com/consensys/gnark-crypto/ecc/bn254/fp" "github.com/consensys/gnark-crypto/ecc/bn254/fr" - "github.com/stretchr/testify/assert" icicle "github.com/ingonyama-zk/icicle/goicicle/curves/bn254" + "github.com/stretchr/testify/assert" + "testing" ) func TestFieldBN254FromGnark(t *testing.T) { @@ -40,7 +40,7 @@ func BenchmarkBatchConvertFromFrGnarkThreaded(b *testing.B) { // for _, routineAmount := range ROUTINES { routineAmount := 7 - _, scalars_fr := GenerateScalars(1 << 24, false) + _, scalars_fr := GenerateScalars(1<<24, false) b.Run(fmt.Sprintf("Convert %d", routineAmount), func(b *testing.B) { for n := 0; n < b.N; n++ { _ = BatchConvertFromFrGnarkThreaded[icicle.G1ScalarField](scalars_fr, routineAmount) @@ -50,7 +50,7 @@ func BenchmarkBatchConvertFromFrGnarkThreaded(b *testing.B) { } func BenchmarkBatchConvertFromFrGnark(b *testing.B) { - _, scalars_fr := GenerateScalars(1 << 24, false) + _, scalars_fr := GenerateScalars(1<<24, false) b.Run("BatchConvert 2^24", func(b *testing.B) { for n := 0; n < b.N; n++ { _ = BatchConvertFromFrGnark[icicle.G1ScalarField](scalars_fr) @@ -64,7 +64,7 @@ func TestPointBN254FromGnark(t *testing.T) { var f icicle.G1BaseField f.SetOne() var p icicle.G1ProjectivePoint - G1ProjectivePointFromJacGnark(&p,&gnarkP) + G1ProjectivePointFromJacGnark(&p, &gnarkP) z_inv := new(fp.Element) z_invsq := new(fp.Element) @@ -88,9 +88,9 @@ func TestPointAffineNoInfinityBN254ToProjective(t *testing.T) { gnarkP, _ := randG1Jac() var f icicle.G1BaseField var p icicle.G1ProjectivePoint - + f.SetOne() - affine := G1ProjectivePointFromJacGnark(&p,&gnarkP).StripZ() + affine := G1ProjectivePointFromJacGnark(&p, &gnarkP).StripZ() proj := affine.ToProjective() assert.Equal(t, proj.X, affine.X) diff --git a/curves/bn254/msm_test.go b/curves/bn254/msm_test.go index 3efff95..a6ec4ca 100644 --- a/curves/bn254/msm_test.go +++ b/curves/bn254/msm_test.go @@ -1,18 +1,17 @@ +// Copyright 2023 Ingonyama +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. - // Copyright 2023 Ingonyama - // - // Licensed under the Apache License, Version 2.0 (the "License"); - // you may not use this file except in compliance with the License. - // You may obtain a copy of the License at - // - // http://www.apache.org/licenses/LICENSE-2.0 - // - // Unless required by applicable law or agreed to in writing, software - // distributed under the License is distributed on an "AS IS" BASIS, - // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - // See the License for the specific language governing permissions and - // limitations under the License. - // Code generated by Ingonyama DO NOT EDIT package bn254 @@ -32,8 +31,8 @@ import ( "github.com/consensys/gnark-crypto/ecc/bn254" "github.com/consensys/gnark-crypto/ecc/bn254/fr" "github.com/ingonyama-zk/icicle/goicicle" - "github.com/stretchr/testify/assert" icicle "github.com/ingonyama-zk/icicle/goicicle/curves/bn254" + "github.com/stretchr/testify/assert" ) func randG1Jac() (bn254.G1Jac, error) { @@ -95,7 +94,7 @@ func ReadGnarkPointsFromFile(filePath string, size int) (points []icicle.G1Point gnarkPoints[i].X.SetString(scanner.Text()) scanner.Scan() gnarkPoints[i].Y.SetString(scanner.Text()) - + var p icicle.G1ProjectivePoint FromG1AffineGnark(&gnarkPoints[i], &p) @@ -113,7 +112,7 @@ func GeneratePointsProj(count int) ([]icicle.G1ProjectivePoint, []bn254.G1Jac) { // Use a loop to populate the slice for i := 0; i < count; i++ { gnarkP, _ := randG1Jac() - + var p icicle.G1ProjectivePoint G1ProjectivePointFromJacGnark(&p, &gnarkP) diff --git a/curves/bn254/ntt_test.go b/curves/bn254/ntt_test.go index 164ea0f..e8061e8 100644 --- a/curves/bn254/ntt_test.go +++ b/curves/bn254/ntt_test.go @@ -11,19 +11,19 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - + // Code generated by Ingonyama DO NOT EDIT package bn254 import ( "fmt" - "reflect" - "testing" "github.com/consensys/gnark-crypto/ecc/bn254/fr" "github.com/consensys/gnark-crypto/ecc/bn254/fr/fft" - "github.com/stretchr/testify/assert" icicle "github.com/ingonyama-zk/icicle/goicicle/curves/bn254" + "github.com/stretchr/testify/assert" + "reflect" + "testing" ) func TestNttBN254BBB(t *testing.T) { @@ -176,7 +176,7 @@ func TestNttBatchBN254(t *testing.T) { count := 1 << 5 batches := 4 - scalars, _ := GenerateScalars(count * batches, false) + scalars, _ := GenerateScalars(count*batches, false) var scalarVecOfVec [][]icicle.G1ScalarField = make([][]icicle.G1ScalarField, 0)