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

feat: alt_bn128 curve #1028

Merged
merged 9 commits into from
Jun 28, 2023
Merged

feat: alt_bn128 curve #1028

merged 9 commits into from
Jun 28, 2023

Conversation

uint
Copy link
Contributor

@uint uint commented Jun 21, 2023

Picks up where #188 left off to expose alt_bn128 functions to smart contract devs.

The implementation is already there in nearcore: near/nearcore#3971

I tested briefly that these are callable from test smart contracts, but if something's missing, let me know!

Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

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

Let's add tests to these. Also, if there are good examples of how to use these functions and references to the relevant specifications / descriptions about what these "alt" are, please, add links in the doc comment as well

@uint
Copy link
Contributor Author

uint commented Jun 21, 2023

@frol I wasn't sure if we should test the implementation here when it lives in nearcore, but I see it's done for other cyphers. Fair enough.

I'll try to figure out/look up test vectors and explanations. Happy for hints on where to look since I'm not very knowledgeable about cryptography.

@uint
Copy link
Contributor Author

uint commented Jun 21, 2023

The closest I got to finding test vectors is the test cases section here: https://eips.ethereum.org/EIPS/eip-196 Sadly, most of this is way over my head.

@frol
Copy link
Collaborator

frol commented Jun 23, 2023

@uint Fair point. Well, I am not familiar with this topic either, so I looked up nearcore tests: https://github.com/near/nearcore/blob/f5e8746ed85202bea244d3a2d4c698f7739d05bb/runtime/near-test-contracts/estimator-contract/src/lib.rs#L557-L720. Let's try porting those tests, as I am not comfortable shipping new functions without ever running them.

@uint
Copy link
Contributor Author

uint commented Jun 23, 2023

@frol I think (?) what you linked to are gas benchmarks. They don't include expected outputs, but maybe I could get them by performing the same operations using an alternative implementation of this cypher. Worth a shot. At least we'll have the happy path covered.

I still think we should include these correctness tests in nearcore only, since that's where the implementation lives. Since we only have bindings here, I could maybe add some very simple tests asserting that the bindings are pointing to existing host fns. What do you think?

@frol
Copy link
Collaborator

frol commented Jun 26, 2023

They don't include expected outputs, but maybe I could get them by performing the same operations using an alternative implementation of this cypher. Worth a shot. At least we'll have the happy path covered.

Yes, that is exactly what I had in mind. Just test the happy path.

I still think we should include these correctness tests in nearcore only, since that's where the implementation lives.

Totally agree, but I want to catch the situation if nearcore breaks the behavior early.

Since we only have bindings here, I could maybe add some very simple tests asserting that the bindings are pointing to existing host fns. What do you think?

I feel that calling the functions would be exactly the test (I don't suggest we copy all the test vectors from nearcore - call it once to test the interface is enough).

@uint uint requested a review from frol June 27, 2023 12:08
Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

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

@frol frol enabled auto-merge (squash) June 28, 2023 10:21
@frol frol disabled auto-merge June 28, 2023 11:07
@frol frol merged commit 661766f into near:master Jun 28, 2023
13 checks passed
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