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

Optimizations in bn254 ECMUL #207

Merged

Conversation

garyschulte
Copy link
Contributor

Optimizations for ecmul in gnark-crypto eip196 imple for ECMUL:

  • use .Double() when ecmul when scalar == 2
  • if point is infinity encoding, just return infinity

…doing multiplication

Signed-off-by: garyschulte <garyschulte@gmail.com>
@garyschulte garyschulte changed the title Optimizations for infinity and scalar == 2 in bn254 ECMUL Optimizations in bn254 ECMUL Aug 23, 2024
Copy link

@pinges pinges left a comment

Choose a reason for hiding this comment

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

LGTM

@garyschulte
Copy link
Contributor Author

waiting on fuzz testing results before merging

@@ -128,6 +127,11 @@ func eip196altbn128G1Mul(javaInputBuf, javaOutputBuf, javaErrorBuf *C.char, cInp
// Convert input C pointers to Go slice
input := (*[EIP196PreallocateForG1 + EIP196PreallocateForScalar]byte)(unsafe.Pointer(javaInputBuf))[:inputLen:inputLen]

// inifinity check:
if isAllZeroEIP196(input, 0, 64) {
return 0

Choose a reason for hiding this comment

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

Add *outputLen = EIP196PreallocateForG1

@@ -128,6 +127,11 @@ func eip196altbn128G1Mul(javaInputBuf, javaOutputBuf, javaErrorBuf *C.char, cInp
// Convert input C pointers to Go slice
input := (*[EIP196PreallocateForG1 + EIP196PreallocateForScalar]byte)(unsafe.Pointer(javaInputBuf))[:inputLen:inputLen]

// inifinity check:

Choose a reason for hiding this comment

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

typo

Signed-off-by: garyschulte <garyschulte@gmail.com>
@garyschulte garyschulte merged commit 833822b into hyperledger:main Aug 28, 2024
11 checks passed
@garyschulte garyschulte deleted the feature/ecmul-are-we-fast-yet branch August 28, 2024 19:48
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.

3 participants