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

GoLang bindings for v1.x #386

Merged
merged 19 commits into from
Feb 22, 2024
Merged

GoLang bindings for v1.x #386

merged 19 commits into from
Feb 22, 2024

Conversation

jeremyfelder
Copy link
Collaborator

@jeremyfelder jeremyfelder commented Feb 21, 2024

Describe the changes

This PR updates the GoLand bindings to be compatible with v1.x versions of ICICLE.

Structure of the bindings

The bindings can be broken down into four areas:

  • cuda_runtime - This package binds with the cuda_runtime and adds functionality on top providing an easy way to interact with the cuda API
  • core - This package provides core functionality that is used by all curves - HostDeviceSlice, MSM and NTT checks
    • There is an internal package that provides MockField, MockProjective, and MockAffine types for testing the core package without needing the curves package.
  • curves - This directory provides multiple curves, each as its own package.
  • internal - This directory provides templates that are used to generate the curves as most of the code is repetitive with the exception of needing to change some types, function names (for C linking), and constant values for Field sizes.

Generating the curves

To generate the curves run the following from the wrappers/golang/internal/generator dir:

go run main.go

Remaining Tasks

  • Add VecOps bindings
  • MultiGPU Capability
  • Add ECNTT bindings
  • Add Poseidon bindings

Linked Issues

Resolves #202
Resolves #203
Resolves #265
Resolves #304
Resolves #311

go.mod Show resolved Hide resolved
go.mod Show resolved Hide resolved
wrappers/golang/build.sh Outdated Show resolved Hide resolved
@jeremyfelder jeremyfelder marked this pull request as ready for review February 22, 2024 06:28
Copy link
Contributor

@DmytroTym DmytroTym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @jeremyfelder!

wrappers/golang/core/internal/curve.go Outdated Show resolved Hide resolved
)

type MockField struct {
limbs [BASE_LIMBS]uint32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not urgent or super important but gnark (not sure about other libraries) uses uint64 for limbs. In Rust the situation is similar and we moved to u64 there too. Was wondering if it would make sense here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally with uint64 but it wasn't working, i think, due to the memory not aligning. Granted it was when I was also trying with slices and not arrays so maybe uint64 arrays would work as well.

wrappers/golang/core/ntt.go Show resolved Hide resolved
wrappers/golang/core/slice_test.go Show resolved Hide resolved
wrappers/golang/curves/bls12377/bls12_377.go Show resolved Hide resolved
wrappers/golang/curves/bls12377/curve_test.go Show resolved Hide resolved
wrappers/golang/curves/bls12377/ntt.go Outdated Show resolved Hide resolved
wrappers/golang/curves/bw6761/scalar_field.go Show resolved Hide resolved
icicle/appUtils/ntt/ntt.cu Show resolved Hide resolved
false, // IsAsync
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the user need to manually change the values in GetDefaultMSMConfig - or is all the relevant data included on HostOrDeviceSlice?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any attribute that is publicly accessible (Capitalized) can and should be updated by the user according to their needs. Anything that is private (camelCase) is set internally on MSMCheck and MSM functions

@jeremyfelder jeremyfelder merged commit e8cd2d7 into dev Feb 22, 2024
19 checks passed
@jeremyfelder jeremyfelder deleted the feat/golang-bindings-newapi branch February 22, 2024 18:52
@jeremyfelder jeremyfelder mentioned this pull request Feb 22, 2024
jeremyfelder added a commit that referenced this pull request Feb 23, 2024
# Contents of this release

Examples: multi-gpu example #381
Examples: updates example compares Radix2 and MixedRadix NTTs #383
Feat: add vector operations bindings to Rust #384 
Examples: update examples with new vec ops #388 
Feat: Grumpkin curve implementation #379 
Feat: mixed-radix NTT fast twiddles mode #382 
Docs: Update README.md #385 #387 
README: Update Hall of Fame section #394 
Examples: add rust poseidon example #392 
Feat: GoLang bindings for v1.x #386
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants