rbsecp256k1 3.0.1 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -5
- data/Rakefile +2 -0
- data/documentation/context.md +81 -0
- data/documentation/index.md +319 -0
- data/documentation/key_pair.md +28 -0
- data/documentation/private_key.md +25 -0
- data/documentation/public_key.md +32 -0
- data/documentation/recoverable_signature.md +30 -0
- data/documentation/secp256k1.md +19 -0
- data/documentation/shared_secret.md +16 -0
- data/documentation/signature.md +42 -0
- data/documentation/util.md +17 -0
- data/ext/rbsecp256k1/extconf.rb +11 -56
- data/ext/rbsecp256k1/rbsecp256k1.c +291 -297
- data/lib/rbsecp256k1/context.rb +29 -0
- data/lib/rbsecp256k1/util.rb +2 -0
- data/lib/rbsecp256k1/version.rb +3 -1
- data/lib/rbsecp256k1.rb +3 -0
- metadata +29 -19
data/ext/rbsecp256k1/extconf.rb
CHANGED
@@ -1,27 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'mini_portile2'
|
2
4
|
require 'mkmf'
|
3
5
|
require 'zip'
|
4
6
|
|
5
|
-
# Indicates the platform on which the package is being installed
|
6
|
-
INSTALLING_OS =
|
7
|
-
if RUBY_PLATFORM =~ /darwin/
|
8
|
-
:macos
|
9
|
-
elsif RUBY_PLATFORM =~ /linux/
|
10
|
-
:linux
|
11
|
-
else
|
12
|
-
:unknown
|
13
|
-
end
|
14
|
-
|
15
|
-
# Fixed path to Homebrew OpenSSL pkgconfig file
|
16
|
-
HOMEBREW_OPENSSL_PKGCONFIG = '/usr/local/opt/openssl/lib/pkgconfig'.freeze
|
17
|
-
|
18
7
|
# Recipe for downloading and building libsecp256k1 as part of installation
|
19
8
|
class Secp256k1Recipe < MiniPortile
|
20
|
-
# Hard-coded URL for libsecp256k1 zipfile (HEAD of master as of
|
21
|
-
LIBSECP256K1_ZIP_URL = 'https://github.com/bitcoin-core/secp256k1/archive/
|
9
|
+
# Hard-coded URL for libsecp256k1 zipfile (HEAD of master as of 24-11-2021)
|
10
|
+
LIBSECP256K1_ZIP_URL = 'https://github.com/bitcoin-core/secp256k1/archive/fecf436d5327717801da84beb3066f5a9b80ea8e.zip'
|
22
11
|
|
23
12
|
# Expected SHA-256 of the zipfile above (computed using sha256sum)
|
24
|
-
LIBSECP256K1_SHA256 = '
|
13
|
+
LIBSECP256K1_SHA256 = '188c6252ab9e829da02c962fe59a329f798c615577ac128ae1f0697126ebb2fc'
|
25
14
|
|
26
15
|
WITH_RECOVERY = ENV.fetch('WITH_RECOVERY', '1') == '1'
|
27
16
|
WITH_ECDH = ENV.fetch('WITH_ECDH', '1') == '1'
|
@@ -49,6 +38,7 @@ class Secp256k1Recipe < MiniPortile
|
|
49
38
|
# Windows doesn't recognize the shebang.
|
50
39
|
execute('autogen', %w[sh ./autogen.sh])
|
51
40
|
else
|
41
|
+
execute('chmod', %w[chmod +x ./autogen.sh])
|
52
42
|
execute('autogen', %w[./autogen.sh])
|
53
43
|
end
|
54
44
|
|
@@ -82,46 +72,6 @@ class Secp256k1Recipe < MiniPortile
|
|
82
72
|
end
|
83
73
|
end
|
84
74
|
|
85
|
-
# OpenSSL flags
|
86
|
-
message("checking for OpenSSL\n")
|
87
|
-
results = pkg_config('openssl')
|
88
|
-
|
89
|
-
# Failed to find package OpenSSL
|
90
|
-
unless results && results[1]
|
91
|
-
# Check if the user happens to have OpenSSL installed via Homebrew on a path
|
92
|
-
# we know about.
|
93
|
-
# rubocop:disable Style/GlobalVars
|
94
|
-
if INSTALLING_OS == :macos && File.exist?(HOMEBREW_OPENSSL_PKGCONFIG)
|
95
|
-
begin
|
96
|
-
require 'rubygems'
|
97
|
-
gem 'pkg-config', (gem_ver = '~> 1.3')
|
98
|
-
require 'pkg-config'
|
99
|
-
rescue LoadError
|
100
|
-
message(
|
101
|
-
"pkg-config could not be used to find openssl\n" \
|
102
|
-
"Please install either `pkg-config` or the pkg-config gem via\n" \
|
103
|
-
"gem install pkg-config -v #{gem_ver.inspect}\n\n"
|
104
|
-
)
|
105
|
-
else
|
106
|
-
message("Initial check failed. Trying homebrew openssl path...\n")
|
107
|
-
message("Using pkg-config gem version #{PKGConfig::VERSION}\n")
|
108
|
-
PKGConfig.add_path(HOMEBREW_OPENSSL_PKGCONFIG)
|
109
|
-
|
110
|
-
cflags = PKGConfig.cflags('openssl')
|
111
|
-
ldflags = PKGConfig.libs_only_L('openssl')
|
112
|
-
libs = PKGConfig.libs_only_l('openssl')
|
113
|
-
|
114
|
-
$CFLAGS += " " << cflags if cflags
|
115
|
-
$libs += " " << libs if libs
|
116
|
-
$LDFLAGS = [$LDFLAGS, ldflags].join(' ')
|
117
|
-
|
118
|
-
results = [cflags, libs, ldflags]
|
119
|
-
end
|
120
|
-
end
|
121
|
-
# rubocop:enable Style/GlobalVars
|
122
|
-
end
|
123
|
-
abort "missing openssl pkg-config information" unless results && results[1]
|
124
|
-
|
125
75
|
if with_config('system-library')
|
126
76
|
# Require that libsecp256k1 be installed using `make install` or similar.
|
127
77
|
message("checking for libsecp256k1\n")
|
@@ -142,6 +92,11 @@ else
|
|
142
92
|
"-Wall"
|
143
93
|
]
|
144
94
|
)
|
95
|
+
append_ldflags(
|
96
|
+
[
|
97
|
+
"-Wl,--no-as-needed"
|
98
|
+
]
|
99
|
+
)
|
145
100
|
# rubocop:disable Style/GlobalVars
|
146
101
|
$LIBPATH = ["#{recipe.path}/lib"] | $LIBPATH
|
147
102
|
# rubocop:enable Style/GlobalVars
|