Skip to content

Conversation

ChickenLover
Copy link
Contributor

@ChickenLover ChickenLover commented Mar 30, 2025

No description provided.

}

template <typename Config>
typename Config::Fp6 add_in_place(typename Config::Fp6& r, const typename Config::G2Affine& q)
Copy link
Contributor

Choose a reason for hiding this comment

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

add documentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's basically just reciting the algorithms from the paper

Copy link
Contributor

Choose a reason for hiding this comment

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

i understood it, link to the paper and relevant sections

@ChickenLover ChickenLover marked this pull request as ready for review April 9, 2025 10:46
@LeonHibnik LeonHibnik changed the title Feat/pairings [FEAT] Curve Pairings Apr 9, 2025
@@ -0,0 +1,25 @@
#pragma once
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not put it in curve_config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea was to not compile anything related to pairings in other compilation units. But I might be mistaken, won't static functions defined inside pairing_config be recompiled locally for every object file?

* - The map preserves the bilinear property: e(aP, bQ) = e(P,Q)^(ab)
*/
template <typename A, typename A2, typename PairingConfig, typename TargetField = typename PairingConfig::TargetField>
eIcicleError pairing(const A& p, const A2& q, TargetField* output);
Copy link
Collaborator

Choose a reason for hiding this comment

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

(1) Why output is not a reference too? I mean why inputs are reference but output is pointer?
(2) batch not relevant here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

1 - At first they were all references, because I was thinking adding batch and making it a cpu backend function. But yeah, now it should be a reference.
2 - Actually, I don't know which is better, to have one function for both single pairing and multi-pairing or have two separate functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO 1 func with batch support


namespace {
template <typename Config>
typename Config::Fp6 double_in_place(typename Config::Fp6& r, const typename Config::Fp& two_inv)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you need 'typename Config' everywhere rather than just 'Config'? I noticed it in other places too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't compile without it

*/
template <typename PairingConfig>
eIcicleError pairing(
const typename PairingConfig::G1Affine& p,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here too I suggest removing the 'typename' from the params

Copy link
Contributor Author

Choose a reason for hiding this comment

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

error: missing 'typename' prior to dependent type name 'PairingConfig::G1Affine'
    const PairingConfig::G1Affine& p,

@@ -1060,7 +1087,9 @@ TEST_F(PolynomialTest, Groth16)

groth16_example.setup();
auto proof = groth16_example.prove(witness);
// groth16_example.verify(proof); // cannot implement without pairing
#ifdef PAIRING
groth16_example.verify(proof, witness);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please assert true here

Copy link
Collaborator

@yshekel yshekel left a comment

Choose a reason for hiding this comment

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

Great work!
I left a few small comments

@LeonHibnik LeonHibnik merged commit 02bc039 into main Apr 10, 2025
19 checks passed
@LeonHibnik LeonHibnik deleted the feat/pairings branch April 10, 2025 16:18
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.

4 participants