Module: KZG

Defined in:
lib/kzg.rb,
lib/kzg/setting.rb,
lib/kzg/version.rb,
lib/kzg/commitment.rb,
lib/kzg/polynomial.rb

Overview

KZG Commitment library.

Defined Under Namespace

Classes: Commitment, Error, Polynomial, Setting

Constant Summary collapse

VERSION =
"0.3.1"

Class Method Summary collapse

Class Method Details

.setup_params(secret, n) ⇒ KZG::Setting

Setup elements of elliptic curve from secret. Note: Since the random secret must not be known to anyone, this Trusted Setup usually needs to be performed using an MPC or similar.

Parameters:

  • secret (Integer)

    random secret.

  • n (Integer)

    number of parameters.

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/kzg.rb', line 23

def setup_params(secret, n)
  s1 = Array.new(n)
  s2 = Array.new(n)
  s = BLS::Fr.new(secret)
  s_pow = BLS::Fr::ONE
  n.times do |i|
    s1[i] = BLS::PointG1::BASE * s_pow
    s2[i] = BLS::PointG2::BASE * s_pow
    tmp = s_pow
    s_pow = tmp * s
  end
  Setting.new(s1, s2)
end