Class: Secp256k1Recipe

Inherits:
MiniPortile
  • Object
show all
Defined in:
ext/secp256k1zkp/extconf.rb

Constant Summary collapse

LIBSECP256K1_ZIP_URL =
'https://github.com/syalon/secp256k1-zkp/archive/bd067945ead3b514fba884abd0de95fc4b5db9ae.zip'
LIBSECP256K1_SHA256 =
'379f7920d382d2b54bc5c092bb6c39b03c7f74508369cac5464cb9cbd8459dc0'

Instance Method Summary collapse

Constructor Details

#initializeSecp256k1Recipe

Returns a new instance of Secp256k1Recipe.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'ext/secp256k1zkp/extconf.rb', line 12

def initialize
  super('libsecp256k1', '0.0.0')
  @tarball = File.join(Dir.pwd, "/ports/archives/libsecp256k1.zip")
  @files = ["file://#{@tarball}"]
  self.configure_options += [
    "--disable-benchmark",
    "--disable-exhaustive-tests",
    "--disable-tests",
    "--disable-debug",
    "--enable-experimental",
    "--with-pic=yes"
  ]
end

Instance Method Details

#configureObject



26
27
28
29
30
31
32
33
# File 'ext/secp256k1zkp/extconf.rb', line 26

def configure
  if RUBY_PLATFORM =~ /mingw|mswin/
    execute('autogen', %w[sh ./autogen.sh])
  else
    execute('autogen', %w[./autogen.sh])
  end
  super
end

#downloadObject



35
36
37
38
# File 'ext/secp256k1zkp/extconf.rb', line 35

def download
  download_file_http(LIBSECP256K1_ZIP_URL, @tarball)
  verify_file(local_path: @tarball, sha256: LIBSECP256K1_SHA256) if LIBSECP256K1_SHA256
end

#downloaded?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'ext/secp256k1zkp/extconf.rb', line 40

def downloaded?
  File.exist?(@tarball)
end

#extractObject



55
56
57
58
59
# File 'ext/secp256k1zkp/extconf.rb', line 55

def extract
  files_hashs.each do |file|
    extract_zip_file(file[:local_path], tmp_path)
  end
end

#extract_zip_file(file, destination) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'ext/secp256k1zkp/extconf.rb', line 44

def extract_zip_file(file, destination)
  FileUtils.mkdir_p(destination)

  Zip::File.open(file) do |zip_file|
    zip_file.each do |f|
      fpath = File.join(destination, f.name)
      zip_file.extract(f, fpath) unless File.exist?(fpath)
    end
  end
end