Skip to content

Commit

Permalink
refactor(eth-verkle-ipa): delete barycentric_form and use polynomials…
Browse files Browse the repository at this point in the history
… impl as IPA backend
  • Loading branch information
mratsim committed Jun 11, 2024
1 parent 73b2b8a commit 00b918b
Show file tree
Hide file tree
Showing 15 changed files with 321 additions and 588 deletions.
36 changes: 33 additions & 3 deletions constantine/commitments/pedersen_commitments.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,52 @@

import
../math/[ec_shortweierstrass, arithmetic],
../math/elliptic/ec_multi_scalar_mul
../math/elliptic/ec_multi_scalar_mul,
../platforms/views


## ############################################################
##
## Pedersen Commitments
##
## ############################################################

func pedersen_commit*[EC, ECaff](
r: var EC,
messages: openArray[Fr],
public_generators: openArray[ECaff]) {.inline.} =
## Vector Pedersen Commitment with elliptic curves
##
## Inputs
## - messages m=(m₀,...,mₙ₋₁)
## - public generators G=(G₀,...,Gₙ₋₁)
##
## Computes: Commit(m, r) := ∑[mᵢ]Gᵢ
r.multiScalarMul_reference_vartime(messages, public_generators)

func pedersen_commit*[EC, ECaff, F](
r: var EC,
messages: StridedView[F],
public_generators: StridedView[ECaff]) =
## Vector Pedersen Commitment with elliptic curves
##
## Inputs
## - messages m=(m₀,...,mₙ₋₁)
## - public generators G=(G₀,...,Gₙ₋₁)
##
## Computes: Commit(m, r) := ∑[mᵢ]Gᵢ
r.pedersen_commit(messages.toOpenArray(), public_generators.toOpenArray())

func pedersen_commit*[EC, ECaff](
r: var EC,
messages: openArray[Fr],
public_generators: openArray[ECaff],
blinding_factor: Fr,
hiding_generator: ECaff) =
## Blinded Vector Pedersen Commitment with elliptic curves
## - messages m=(m₀,...,mₙ₋₁)
##
## Inputs
## - messages m=(m₀,...,mₙ₋₁)=(G₀,...,Gₙ₋₁)
## - public generators G
## - blinding factor r
## - hiding generator H
Expand All @@ -46,7 +76,7 @@ func pedersen_commit*[EC, ECaff](
#
# - https://dankradfeist.de/ethereum/2021/07/27/inner-product-arguments.html

r.multiScalarMul_reference_vartime(messages, public_generators)
r.pedersen_commit(messages, public_generators)

# We could run the following in MSM, but that would require extra alloc and copy
var rH {.noInit.}: EC
Expand Down
178 changes: 0 additions & 178 deletions constantine/eth_verkle_ipa/barycentric_form.nim

This file was deleted.

Loading

0 comments on commit 00b918b

Please sign in to comment.