-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add verifier contract using constantine library #174
Conversation
a7f3132
to
d697556
Compare
d697556
to
d2be87c
Compare
d2be87c
to
1af5d65
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minimize the presence of duplicate files.
contracts/cosmos/verifier-constantine/lib/nim/contract_interactions/config.nim
Outdated
Show resolved
Hide resolved
e9bb284
to
a6713bd
Compare
9fe22de
to
457180b
Compare
…ompile time check
- Remove file duplication - Fix utils using target for light-client - Move rust src to parent folder Co-authored-by: Kristin Kirkov <[email protected]>
457180b
to
e8e9fe5
Compare
contracts/cosmos/verifier/lib/typescript/verifier-make-update.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multipairings can optimize speed by almost 2x.
prod(sum, alphaBetaPairing, preparedInputsGammaPairing) | ||
prod(sum, sum, proofCVkDeltaPairing) | ||
|
||
if (sum == aBPairing).bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be almost 2x faster if multipairings were used there and the result checked for one:
with the signature
func pairing*[N: static int, C](
gt: var Fp12[C],
Ps: array[N, ECP_ShortW_Aff[Fp[C], G1]],
Qs: array[N, ECP_ShortW_Aff[Fp2[C], G2]]) =
from https://github.com/mratsim/constantine/blob/d69c7bf/constantine/math/pairings/pairings_generic.nim#L16C1-L22
forwarding to https://github.com/mratsim/constantine/blob/d69c7bf/constantine/math/pairings/pairings_bn.nim#L178-L181
prf.a
needs to be negated beforehand because:
e(prf.a, prf.b) = e(vk.alpha, vk.beta).e(preparedInputs.data, vk.gamma).e(prf.c,vk.delta)
is equivalent to
e(-prf.a, prf.b).e(vk.alpha, vk.beta).e(preparedInputs.data, vk.gamma).e(prf.c,vk.delta) = 1
see BLS signatures: https://github.com/mratsim/constantine/blob/d69c7bf/constantine/signatures/bls_signatures.nim#L123-L127
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the advice! #184
Gas usage:
using Bncurve - around 1695k
using Constantine(no multipairings) - around 1400k
using Constantine(with) - around 870k
@@ -3,7 +3,7 @@ import | |||
std/[strutils,json] | |||
|
|||
import | |||
../../../contracts/cosmos/verifier/lib/nim/verify/verify_helpers | |||
../../../contracts/cosmos/verifier/verifier-bncurve/lib/nim/verify/verify_helpers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised the dash is accepted
No description provided.