rbsecp256k1 6.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbd0a847d061c266d044174528f14b1351484f58a703e7ec76719122689ae6d4
4
- data.tar.gz: c7bbdaf0dc9bdaf24dd5de7c40d95c16f08b72d466216af6789e523ee14bba8b
3
+ metadata.gz: 6a9f1c61d2e9881ffc8ba67ad800fe73d5b54b0e03728a18886c11cb865e00d4
4
+ data.tar.gz: 007d212fbc0d6a669f2fc9fc944c9e6b823c67cca59d98401c1840bc424f1944
5
5
  SHA512:
6
- metadata.gz: cf695d750f38e4d27de61caa0e1ec8d9160925d7c10cc556691c7335478137f71f7f49901d50ade3c9e2c917779b38a3d4ee49ca931a8691cc99e7a751fd8243
7
- data.tar.gz: 7b5a75562a90c3e845a0b42477873562991d19ca610b89aef95581e0f7dc010f123e8ed4055225978cb2ad4b6667e184d18915114f69cfdaabb993bfcf4b06a7
6
+ metadata.gz: 35c81811e74cecf9d268d447296956aefccb8de97dbf877b83b43f9ad09fcdccd8c4e93ae55dd24939227933835715336d6eac42753a9d762c2e939df0859580
7
+ data.tar.gz: f86d36d6c52ff5c9ed2d08c90d62170dd9dc66c411ff6c374c3904c57497940137415f5281a3f0080f54b53478813494f289ad3a66300f8ffe0ad896879112e4
data/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org>
data/README.md CHANGED
@@ -1,129 +1,129 @@
1
- # rbsecp256k1
2
-
3
- [![Spec](https://github.com/etscrivner/rbsecp256k1/actions/workflows/spec.yml/badge.svg?branch=master)](https://github.com/etscrivner/rbsecp256k1/actions/workflows/spec.yml) [![Gem Version](https://badge.fury.io/rb/rbsecp256k1.svg)](https://badge.fury.io/rb/rbsecp256k1) [![Maintainability](https://api.codeclimate.com/v1/badges/d4b6e27bfa00030ca412/maintainability)](https://codeclimate.com/github/etscrivner/rbsecp256k1/maintainability)
4
-
5
- Native extension gem for secp256k1 ECDSA and Schnorr signatures. Wraps [libsecp256k1](https://github.com/bitcoin-core/secp256k1) without the need for FFI.
6
-
7
- * [Documentation](https://github.com/etscrivner/rbsecp256k1/blob/master/documentation/index.md)
8
- * [Examples](https://github.com/etscrivner/rbsecp256k1/blob/master/examples/README.md)
9
-
10
- ### Features
11
-
12
- * Native extension gem wrapping [libsecp256k1](https://github.com/bitcoin-core/secp256k1), no FFI.
13
- * Schnorr signature support.
14
-
15
- ### Why wrap libsecp256k1?
16
-
17
- [libsecp256k1](https://github.com/bitcoin-core/secp256k1) is an extremely optimized implementation of public key derivation,
18
- signing, and verification with the secp256k1 elliptic curve. It comes with its
19
- own set of benchmarks, but from [benchmarking done by Peter Wuille](https://www.reddit.com/r/Bitcoin/comments/2weymr/experiment_bitcoin_core_0100_initial_sync_time/coqghm2) it is ~4.9x
20
- faster than the OpenSSL implementation of the same curve. It is the only library
21
- that provides constant time signing of this curve and has been deployed as part
22
- of Bitcoin since [v0.10.0](https://bitcoin.org/en/release/v0.10.0#improved-signing-security)
23
-
24
- Natively wrapping the library in an extension gem means users don't have to
25
- worry about compiling or locating the library, unlike many [FFI](https://github.com/ffi/ffi) based gems.
26
-
27
- ## Installation
28
-
29
- The simplest installation:
30
-
31
- ```
32
- gem install rbsecp256k1
33
- ```
34
-
35
- ## Requirements
36
-
37
- If you want to use your system version of libsecp256k1 rather than the bundled
38
- version use the `--with-system-libraries` flag:
39
-
40
- ```
41
- gem install rbsecp256k1 -- --with-system-libraries
42
- ```
43
-
44
- #### Linux
45
-
46
- Install the dependencies for building libsecp256k1 and this library:
47
-
48
- ```
49
- sudo apt-get install build-essential automake pkg-config libtool \
50
- libffi-dev libssl-dev libgmp-dev python3-dev
51
- ```
52
-
53
- **NOTE:** If you have installed libsecp256k1 but the gem cannot find it. Ensure
54
- you have run `ldconfig` so that your library load paths have been updated.
55
-
56
- #### macOS
57
-
58
- Dependencies for building libsecp256k1 and this library:
59
-
60
- ```
61
- brew install automake openssl libtool pkg-config gmp libffi
62
- ```
63
-
64
- ## Features
65
-
66
- See [rbsecp256k1 documentation](https://github.com/etscrivner/rbsecp256k1/blob/master/documentation/index.md) for examples and complete list of supported functionality.
67
-
68
- ## Development
69
-
70
- ### Cloning
71
-
72
- To clone the repository and its submodules you'll need to the following:
73
-
74
- ```
75
- git clone git@github.com:etscrivner/rbsecp256k1.git
76
- ```
77
-
78
- ### Setup
79
-
80
- Development is largely facilitated by a makefile. After download you should run
81
- the following command to set up your local environment:
82
-
83
- ```
84
- make setup
85
- ```
86
-
87
- ### Compiling Extension
88
-
89
- To compile the extension gem run the following (this is required to run tests):
90
-
91
- ```
92
- make build
93
- ```
94
-
95
- ### Running Tests
96
-
97
- ```
98
- make test
99
- ```
100
-
101
- To test with recovery functionality disabled run:
102
-
103
- ```
104
- make test WITH_RECOVERY=0
105
- ```
106
-
107
- ### Uninstall Gem Locally
108
-
109
- You can similarly uninstall the local gem by running the following:
110
-
111
- ```
112
- make uninstall
113
- ```
114
-
115
- ### Cleaning Up
116
-
117
- To clean up and do a fresh build:
118
-
119
- ```
120
- make clean
121
- ```
122
-
123
- ### Running YARD Documentation Server
124
-
125
- To run the [YARD](https://yardoc.org/) documentation server:
126
-
127
- ```
128
- make docserver
129
- ```
1
+ # rbsecp256k1
2
+
3
+ [![Spec](https://github.com/etscrivner/rbsecp256k1/actions/workflows/spec.yml/badge.svg?branch=master)](https://github.com/etscrivner/rbsecp256k1/actions/workflows/spec.yml) [![Gem Version](https://badge.fury.io/rb/rbsecp256k1.svg)](https://badge.fury.io/rb/rbsecp256k1) [![Maintainability](https://api.codeclimate.com/v1/badges/d4b6e27bfa00030ca412/maintainability)](https://codeclimate.com/github/etscrivner/rbsecp256k1/maintainability)
4
+
5
+ Native extension gem for secp256k1 ECDSA and Schnorr signatures. Wraps [libsecp256k1](https://github.com/bitcoin-core/secp256k1) without the need for FFI.
6
+
7
+ * [Documentation](https://github.com/etscrivner/rbsecp256k1/blob/master/documentation/index.md)
8
+ * [Examples](https://github.com/etscrivner/rbsecp256k1/blob/master/examples/README.md)
9
+
10
+ ### Features
11
+
12
+ * Native extension gem wrapping [libsecp256k1](https://github.com/bitcoin-core/secp256k1), no FFI.
13
+ * Schnorr signature support.
14
+
15
+ ### Why wrap libsecp256k1?
16
+
17
+ [libsecp256k1](https://github.com/bitcoin-core/secp256k1) is an extremely optimized implementation of public key derivation,
18
+ signing, and verification with the secp256k1 elliptic curve. It comes with its
19
+ own set of benchmarks, but from [benchmarking done by Peter Wuille](https://www.reddit.com/r/Bitcoin/comments/2weymr/experiment_bitcoin_core_0100_initial_sync_time/coqghm2) it is ~4.9x
20
+ faster than the OpenSSL implementation of the same curve. It is the only library
21
+ that provides constant time signing of this curve and has been deployed as part
22
+ of Bitcoin since [v0.10.0](https://bitcoin.org/en/release/v0.10.0#improved-signing-security)
23
+
24
+ Natively wrapping the library in an extension gem means users don't have to
25
+ worry about compiling or locating the library, unlike many [FFI](https://github.com/ffi/ffi) based gems.
26
+
27
+ ## Installation
28
+
29
+ The simplest installation:
30
+
31
+ ```
32
+ gem install rbsecp256k1
33
+ ```
34
+
35
+ ## Requirements
36
+
37
+ If you want to use your system version of libsecp256k1 rather than the bundled
38
+ version use the `--with-system-libraries` flag:
39
+
40
+ ```
41
+ gem install rbsecp256k1 -- --with-system-libraries
42
+ ```
43
+
44
+ #### Linux
45
+
46
+ Install the dependencies for building libsecp256k1 and this library:
47
+
48
+ ```
49
+ sudo apt-get install build-essential automake pkg-config libtool \
50
+ libffi-dev libssl-dev libgmp-dev python3-dev
51
+ ```
52
+
53
+ **NOTE:** If you have installed libsecp256k1 but the gem cannot find it. Ensure
54
+ you have run `ldconfig` so that your library load paths have been updated.
55
+
56
+ #### macOS
57
+
58
+ Dependencies for building libsecp256k1 and this library:
59
+
60
+ ```
61
+ brew install automake openssl libtool pkg-config gmp libffi
62
+ ```
63
+
64
+ ## Features
65
+
66
+ See [rbsecp256k1 documentation](https://github.com/etscrivner/rbsecp256k1/blob/master/documentation/index.md) for examples and complete list of supported functionality.
67
+
68
+ ## Development
69
+
70
+ ### Cloning
71
+
72
+ To clone the repository and its submodules you'll need to the following:
73
+
74
+ ```
75
+ git clone git@github.com:etscrivner/rbsecp256k1.git
76
+ ```
77
+
78
+ ### Setup
79
+
80
+ Development is largely facilitated by a makefile. After download you should run
81
+ the following command to set up your local environment:
82
+
83
+ ```
84
+ make setup
85
+ ```
86
+
87
+ ### Compiling Extension
88
+
89
+ To compile the extension gem run the following (this is required to run tests):
90
+
91
+ ```
92
+ make build
93
+ ```
94
+
95
+ ### Running Tests
96
+
97
+ ```
98
+ make test
99
+ ```
100
+
101
+ To test with recovery functionality disabled run:
102
+
103
+ ```
104
+ make test WITH_RECOVERY=0
105
+ ```
106
+
107
+ ### Uninstall Gem Locally
108
+
109
+ You can similarly uninstall the local gem by running the following:
110
+
111
+ ```
112
+ make uninstall
113
+ ```
114
+
115
+ ### Cleaning Up
116
+
117
+ To clean up and do a fresh build:
118
+
119
+ ```
120
+ make clean
121
+ ```
122
+
123
+ ### Running YARD Documentation Server
124
+
125
+ To run the [YARD](https://yardoc.org/) documentation server:
126
+
127
+ ```
128
+ make docserver
129
+ ```
data/Rakefile CHANGED
@@ -1,18 +1,18 @@
1
- # frozen_string_literal: true
2
-
3
- require "rake/extensiontask"
4
- require "ruby_memcheck"
5
- require "rspec/core/rake_task"
6
- require 'ruby_memcheck/rspec/rake_task'
7
-
8
- RubyMemcheck.config(binary_name: "rbsecp256k1")
9
-
10
- # See: https://guides.rubygems.org/gems-with-extensions/
11
- Rake::ExtensionTask.new "rbsecp256k1" do |ext|
12
- ext.lib_dir = 'lib/rbsecp256k1'
13
- end
14
-
15
- RSpec::Core::RakeTask.new(:spec)
16
- namespace :spec do
17
- RubyMemcheck::RSpec::RakeTask.new(valgrind: :spec)
18
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "rake/extensiontask"
4
+ require "ruby_memcheck"
5
+ require "rspec/core/rake_task"
6
+ require 'ruby_memcheck/rspec/rake_task'
7
+
8
+ RubyMemcheck.config(binary_name: "rbsecp256k1")
9
+
10
+ # See: https://guides.rubygems.org/gems-with-extensions/
11
+ Rake::ExtensionTask.new "rbsecp256k1" do |ext|
12
+ ext.lib_dir = 'lib/rbsecp256k1'
13
+ end
14
+
15
+ RSpec::Core::RakeTask.new(:spec)
16
+ namespace :spec do
17
+ RubyMemcheck::RSpec::RakeTask.new(valgrind: :spec)
18
+ end
@@ -1,98 +1,98 @@
1
- [Index](index.md)
2
-
3
- Secp256k1::Context
4
- ==================
5
-
6
- Secp256k1::Context represents a libsecp256k1 context object. Contexts are
7
- thread-safe and initialization is expensive, so a single context should be used
8
- for multiple operations as much as possible.
9
-
10
- Initializers
11
- ------------
12
-
13
- #### new(context_randomization_bytes: nil)
14
-
15
- Returns a newly initialized libsecp256k1 context. The context is randomized at
16
- initialization if given `context_randomization_bytes`. The
17
- `context_randomization_bytes` argument can optionally take a string containing
18
- 32 bytes of random data, if not provided then the Context is not randomized and
19
- may be vulnerable to side-channel attacks.
20
-
21
- Class Methods
22
- -------------
23
-
24
- #### create
25
-
26
- Creates and returns a new randomized `Context` using `SecureRandom` for the
27
- random initialization bytes. This is the recommended method for initialization.
28
-
29
- #### create_unrandomized
30
-
31
- Creates a new unrandomized `Context`.
32
-
33
- Instance Methods
34
- ----------------
35
-
36
- #### ecdh(point, scalar)
37
-
38
- Takes a `point` ([PublicKey](public_key.md)) and a `scalar` ([PrivateKey](private_key.md)) and returns a new
39
- [SharedSecret](shared_secret.md) containing the 32-byte shared secret. Raises a `Secp256k1::Error` if
40
- the `scalar` is invalid (zero or causes an overflow).
41
-
42
- #### generate_key_pair
43
-
44
- Generates and returns a new [KeyPair](key_pair.md) using Ruby's built-in
45
- `SecureRandom` cryptographically secure random number generator. This method
46
- simply invokes `key_pair_from_private_key` with the value from
47
- `SecureRandom.random_bytes`.
48
-
49
- #### key_pair_from_private_key(private_key_data)
50
-
51
- Returns a new [KeyPair](key_pair.md) from the given `private_key_data`. The
52
- `private_key_data` is expected to be a binary string. Raises a `Secp256k1::Error`
53
- if the private key is invalid or key derivation fails.
54
-
55
- #### recoverable_signature_from_compact(compact_signature, recovery_id)
56
-
57
- **Requires:** libsecp256k1 was build with recovery module.
58
-
59
- Attempts to load a [RecoverableSignature](recoverable_signature.md) from the given `compact_signature`
60
- and `recovery_id`. Raises a `Secp256k1::DeserializationError` if the signature data or recovery ID are invalid.
61
-
62
- #### sign(private_key, hash32)
63
-
64
- Signs the SHA-256 hash given by `hash32` using `private_key` and returns a new
65
- [Signature](signature.md). The `private_key` is expected to be a [PrivateKey](private_key.md)
66
- object and `data` can be either a binary string or text.
67
-
68
- #### sign_recoverable(private_key, hash32)
69
-
70
- **Requires:** libsecp256k1 was build with recovery module.
71
-
72
- Signs the data represented by the SHA-256 hash `hash32` using `private_key` and returns a
73
- new [RecoverableSignature](recoverable_signature.md). The `private_key` is expected to be a [PrivateKey](private_key.md) and
74
- `data` can be either a binary string or text.
75
-
76
- #### sign_schnorr(keypair, message)
77
-
78
- Same as `sign_schnorr_custom(keypair, message, auxrand)` but generates
79
- `auxrand` for you using `SecureRandom`. This should almost always be the method
80
- used for Schnorr signing.
81
-
82
- #### sign_schnorr_custom(keypair, message, auxrand)
83
-
84
- Sign the given 32-byte binary string `message` using the given `keypair`. It is
85
- recommend that `message` be generated using `tagged_sha256`. `auxrand` should
86
- be 32-bytes of fresh randomness, but can optionally be `nil` if generating
87
- randomness is expensive.
88
-
89
- #### tagged_sha256(tag, message)
90
-
91
- Computes the tagged hash as defined in [BIP-340](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki). Returns the 32-byte binary string tagged hash.
92
-
93
- #### verify(signature, public_key, hash32)
94
-
95
- Verifies the given `signature` ([Signature](signature.md)) was signed by
96
- the private key corresponding to `public_key` ([PublicKey](public_key.md)) and signed `hash32`. Returns `true`
97
- if `signature` is valid or `false` otherwise. Note that `data` can be either a
98
- text or binary string.
1
+ [Index](index.md)
2
+
3
+ Secp256k1::Context
4
+ ==================
5
+
6
+ Secp256k1::Context represents a libsecp256k1 context object. Contexts are
7
+ thread-safe and initialization is expensive, so a single context should be used
8
+ for multiple operations as much as possible.
9
+
10
+ Initializers
11
+ ------------
12
+
13
+ #### new(context_randomization_bytes: nil)
14
+
15
+ Returns a newly initialized libsecp256k1 context. The context is randomized at
16
+ initialization if given `context_randomization_bytes`. The
17
+ `context_randomization_bytes` argument can optionally take a string containing
18
+ 32 bytes of random data, if not provided then the Context is not randomized and
19
+ may be vulnerable to side-channel attacks.
20
+
21
+ Class Methods
22
+ -------------
23
+
24
+ #### create
25
+
26
+ Creates and returns a new randomized `Context` using `SecureRandom` for the
27
+ random initialization bytes. This is the recommended method for initialization.
28
+
29
+ #### create_unrandomized
30
+
31
+ Creates a new unrandomized `Context`.
32
+
33
+ Instance Methods
34
+ ----------------
35
+
36
+ #### ecdh(point, scalar)
37
+
38
+ Takes a `point` ([PublicKey](public_key.md)) and a `scalar` ([PrivateKey](private_key.md)) and returns a new
39
+ [SharedSecret](shared_secret.md) containing the 32-byte shared secret. Raises a `Secp256k1::Error` if
40
+ the `scalar` is invalid (zero or causes an overflow).
41
+
42
+ #### generate_key_pair
43
+
44
+ Generates and returns a new [KeyPair](key_pair.md) using Ruby's built-in
45
+ `SecureRandom` cryptographically secure random number generator. This method
46
+ simply invokes `key_pair_from_private_key` with the value from
47
+ `SecureRandom.random_bytes`.
48
+
49
+ #### key_pair_from_private_key(private_key_data)
50
+
51
+ Returns a new [KeyPair](key_pair.md) from the given `private_key_data`. The
52
+ `private_key_data` is expected to be a binary string. Raises a `Secp256k1::Error`
53
+ if the private key is invalid or key derivation fails.
54
+
55
+ #### recoverable_signature_from_compact(compact_signature, recovery_id)
56
+
57
+ **Requires:** libsecp256k1 was build with recovery module.
58
+
59
+ Attempts to load a [RecoverableSignature](recoverable_signature.md) from the given `compact_signature`
60
+ and `recovery_id`. Raises a `Secp256k1::DeserializationError` if the signature data or recovery ID are invalid.
61
+
62
+ #### sign(private_key, hash32)
63
+
64
+ Signs the SHA-256 hash given by `hash32` using `private_key` and returns a new
65
+ [Signature](signature.md). The `private_key` is expected to be a [PrivateKey](private_key.md)
66
+ object and `data` can be either a binary string or text.
67
+
68
+ #### sign_recoverable(private_key, hash32)
69
+
70
+ **Requires:** libsecp256k1 was build with recovery module.
71
+
72
+ Signs the data represented by the SHA-256 hash `hash32` using `private_key` and returns a
73
+ new [RecoverableSignature](recoverable_signature.md). The `private_key` is expected to be a [PrivateKey](private_key.md) and
74
+ `data` can be either a binary string or text.
75
+
76
+ #### sign_schnorr(keypair, message)
77
+
78
+ Same as `sign_schnorr_custom(keypair, message, auxrand)` but generates
79
+ `auxrand` for you using `SecureRandom`. This should almost always be the method
80
+ used for Schnorr signing.
81
+
82
+ #### sign_schnorr_custom(keypair, message, auxrand)
83
+
84
+ Sign the given 32-byte binary string `message` using the given `keypair`. It is
85
+ recommend that `message` be generated using `tagged_sha256`. `auxrand` should
86
+ be 32-bytes of fresh randomness, but can optionally be `nil` if generating
87
+ randomness is expensive.
88
+
89
+ #### tagged_sha256(tag, message)
90
+
91
+ Computes the tagged hash as defined in [BIP-340](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki). Returns the 32-byte binary string tagged hash.
92
+
93
+ #### verify(signature, public_key, hash32)
94
+
95
+ Verifies the given `signature` ([Signature](signature.md)) was signed by
96
+ the private key corresponding to `public_key` ([PublicKey](public_key.md)) and signed `hash32`. Returns `true`
97
+ if `signature` is valid or `false` otherwise. Note that `data` can be either a
98
+ text or binary string.