Skip to content

Commit

Permalink
undo exportc of generic functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Richa-iitr committed Oct 20, 2024
1 parent 51d5372 commit 3667f27
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
12 changes: 4 additions & 8 deletions constantine/commitments/eth_verkle_ipa.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ import
constantine/math/io/io_fields,
constantine/platforms/[abstractions, views]

import constantine/zoo_exports

const prefix_ipa = "ctt_eth_verkle_"

## ############################################################
##
## Inner Product Arguments
Expand Down Expand Up @@ -143,7 +139,7 @@ func innerProduct[F](r: var F, a, b: distinct(View[F] or MutableView[F])) =
func ipa_commit*[N: static int, EC, F](
crs: PolynomialEval[N, EC],
r: var EC,
poly: PolynomialEval[N, F]) {.libPrefix: prefix_ipa.} =
poly: PolynomialEval[N, F]) =
crs.pedersen_commit(r, poly)

func ipa_prove*[N, logN: static int, EcAff, F](
Expand Down Expand Up @@ -334,7 +330,7 @@ func ipa_verify*[N, logN: static int, EcAff, F](
commitment: EcAff,
opening_challenge: F,
eval_at_challenge: F,
proof: IpaProof[logN, EcAff, F]): bool {.libPrefix: prefix_ipa.} =
proof: IpaProof[logN, EcAff, F]): bool =
# We want to check ∑ᵢ[uᵢ]Lᵢ + C' + ∑ᵢ[uᵢ⁻¹]Rᵢ = a₀G₀ + [a₀.b₀]Q
# ∑ᵢ[uᵢ]Lᵢ + C' + ∑ᵢ[uᵢ⁻¹]Rᵢ = a₀G₀ + [a₀.b₀]Q
# with
Expand Down Expand Up @@ -665,7 +661,7 @@ func ipa_multi_prove*[N, logN: static int, EcAff, F](
proof: var IpaMultiProof[logN, EcAff, F],
polys: openArray[PolynomialEval[N, F]],
commitments: openArray[EcAff],
opening_challenges_in_domain: openArray[SomeUnsignedInt]) {.libPrefix: prefix_ipa.} =
opening_challenges_in_domain: openArray[SomeUnsignedInt]) =
## Create a combined proof that
## allow verifying the list of triplets
## (polynomial, commitment, opening challenge)
Expand Down Expand Up @@ -842,7 +838,7 @@ func ipa_multi_verify*[N, logN: static int, EcAff, F](
commitments: openArray[EcAff],
opening_challenges_in_domain: openArray[SomeUnsignedInt],
evals_at_challenges: openArray[F],
proof: IpaMultiProof[logN, EcAff, F]): bool {.libPrefix: prefix_ipa.} =
proof: IpaMultiProof[logN, EcAff, F]): bool =
## Batch verification of commitments to multiple polynomials
## using a single multiproof
##
Expand Down
16 changes: 7 additions & 9 deletions constantine/ethereum_verkle_ipa.nim
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import
./serialization/endians,
./math/io/[io_bigints, io_fields]

import ./zoo_exports

const EthVerkleSeed* = "eth_verkle_oct_2021"

func generate_random_points*(r: var openArray[EC_TwEdw_Aff[Fp[Banderwagon]]]) =
Expand Down Expand Up @@ -151,7 +149,7 @@ type

func serialize*(dst: var EthVerkleIpaProofBytes,
src: IpaProof[8, EC_TwEdw[Fp[Banderwagon]], Fr[Banderwagon]]
): cttEthVerkleIpaStatus {.libPrefix: prefix_ipa, discardable.} =
): cttEthVerkleIpaStatus {.discardable.} =
# Note: We store 1 out of 2 coordinates of an EC point, so size(Fp[Banderwagon])
const fpb = sizeof(Fp[Banderwagon])
const frb = sizeof(Fr[Banderwagon])
Expand All @@ -170,7 +168,7 @@ func serialize*(dst: var EthVerkleIpaProofBytes,
return cttEthVerkleIpa_Success

func deserialize*(dst: var EthVerkleIpaProof,
src: EthVerkleIpaProofBytes): cttEthVerkleIpaStatus {.libPrefix: prefix_ipa, discardable.} =
src: EthVerkleIpaProofBytes): cttEthVerkleIpaStatus {.discardable.} =

const fpb = sizeof(Fp[Banderwagon])
const frb = sizeof(Fr[Banderwagon])
Expand All @@ -190,7 +188,7 @@ func deserialize*(dst: var EthVerkleIpaProof,

func serialize*(dst: var EthVerkleIpaMultiProofBytes,
src: IpaMultiProof[8, EC_TwEdw[Fp[Banderwagon]], Fr[Banderwagon]]
): cttEthVerkleIpaStatus {.libPrefix: prefix_ipa, discardable.} =
): cttEthVerkleIpaStatus {.discardable.} =

const frb = sizeof(Fr[Banderwagon])
let D = cast[ptr array[frb, byte]](dst.addr)
Expand All @@ -202,7 +200,7 @@ func serialize*(dst: var EthVerkleIpaMultiProofBytes,

func deserialize*(dst: var EthVerkleIpaMultiProof,
src: EthVerkleIpaMultiProofBytes
): cttEthVerkleIpaStatus {.libPrefix: prefix_ipa.} =
): cttEthVerkleIpaStatus =

const frb = sizeof(Fr[Banderwagon])
let D = cast[ptr array[frb, byte]](src.unsafeAddr)
Expand All @@ -217,7 +215,7 @@ func deserialize*(dst: var EthVerkleIpaMultiProof,
# TODO: refactor, this shouldn't use curves_primitives but internal functions
import ./lowlevel_fields

func map_to_base_field*(dst: var Fp[Banderwagon],p: EC_TwEdw[Fp[Banderwagon]]) {.libPrefix: prefix_ipa, discardable.} =
func map_to_base_field*(dst: var Fp[Banderwagon],p: EC_TwEdw[Fp[Banderwagon]]) {.discardable.} =
## The mapping chosen for the Banderwagon Curve is x/y
##
## This function takes a Banderwagon element & then
Expand All @@ -229,7 +227,7 @@ func map_to_base_field*(dst: var Fp[Banderwagon],p: EC_TwEdw[Fp[Banderwagon]]) {
invY.inv(p.y) # invY = 1/Y
dst.prod(p.x, invY) # dst = (X) * (1/Y)

func map_to_scalar_field*(res: var Fr[Banderwagon], p: EC_TwEdw[Fp[Banderwagon]]): bool {.libPrefix: prefix_ipa, discardable.} =
func map_to_scalar_field*(res: var Fr[Banderwagon], p: EC_TwEdw[Fp[Banderwagon]]): bool {.discardable.} =
## This function takes the x/y value from the above function as Fp element
## and convert that to bytes in Big Endian,
## and then load that to a Fr element
Expand All @@ -248,7 +246,7 @@ func map_to_scalar_field*(res: var Fr[Banderwagon], p: EC_TwEdw[Fp[Banderwagon]]

func batch_map_to_scalar_field*(
res: var openArray[Fr[Banderwagon]],
points: openArray[EC_TwEdw[Fp[Banderwagon]]]): bool {.libPrefix: prefix_ipa, discardable, noinline.} =
points: openArray[EC_TwEdw[Fp[Banderwagon]]]): bool {.discardable, noinline.} =
## This function performs the `mapToScalarField` operation
## on a batch of points
##
Expand Down

0 comments on commit 3667f27

Please sign in to comment.