rbsecp256k1 6.0.1 → 6.0.2

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: 6a9f1c61d2e9881ffc8ba67ad800fe73d5b54b0e03728a18886c11cb865e00d4
4
- data.tar.gz: 007d212fbc0d6a669f2fc9fc944c9e6b823c67cca59d98401c1840bc424f1944
3
+ metadata.gz: 713b484c223a4c3fec618c6d8050c964657a26ff73d9f4022a87b26b6009812b
4
+ data.tar.gz: c87b25bee566a967d8d3f9f28b5f99a4841942bb46ee062fbf9734e8082b02dc
5
5
  SHA512:
6
- metadata.gz: 35c81811e74cecf9d268d447296956aefccb8de97dbf877b83b43f9ad09fcdccd8c4e93ae55dd24939227933835715336d6eac42753a9d762c2e939df0859580
7
- data.tar.gz: f86d36d6c52ff5c9ed2d08c90d62170dd9dc66c411ff6c374c3904c57497940137415f5281a3f0080f54b53478813494f289ad3a66300f8ffe0ad896879112e4
6
+ metadata.gz: ad34fd4905564c2afd5694966ff783a05e851048530c255996f496db35f5ef109558609a2a28d944b9a7c6a9b4c3a9d4cc0d95b4e5be63473bfc4d489913fae3
7
+ data.tar.gz: a8b5a50de652d42050f42d38a3dbc87b7c2a923747d9cedd1b2c5651fbf995131b1a43cd0fb9253bfed304eb6e3215ca80dc73906a053f080c391a36e7542c2c
data/LICENSE CHANGED
@@ -1,24 +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>
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,134 @@
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
+ ### Line Endings
88
+
89
+ .gitattributes keeps text files in Unix LF format across Windows, Linux, and
90
+ macOS. Git detects binary files automatically and leaves their contents unchanged.
91
+
92
+ ### Compiling Extension
93
+
94
+ To compile the extension gem run the following (this is required to run tests):
95
+
96
+ ```
97
+ make build
98
+ ```
99
+
100
+ ### Running Tests
101
+
102
+ ```
103
+ make test
104
+ ```
105
+
106
+ To test with recovery functionality disabled run:
107
+
108
+ ```
109
+ make test WITH_RECOVERY=0
110
+ ```
111
+
112
+ ### Uninstall Gem Locally
113
+
114
+ You can similarly uninstall the local gem by running the following:
115
+
116
+ ```
117
+ make uninstall
118
+ ```
119
+
120
+ ### Cleaning Up
121
+
122
+ To clean up and do a fresh build:
123
+
124
+ ```
125
+ make clean
126
+ ```
127
+
128
+ ### Running YARD Documentation Server
129
+
130
+ To run the [YARD](https://yardoc.org/) documentation server:
131
+
132
+ ```
133
+ make docserver
134
+ ```
data/Rakefile CHANGED
@@ -1,18 +1,23 @@
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
+ require 'shellwords'
8
+
9
+ memcheck_options = RubyMemcheck::Configuration::DEFAULT_VALGRIND_OPTIONS.dup
10
+ if ENV['MEMCHECK_DEBUGINFO_PATH']
11
+ memcheck_options << "--extra-debuginfo-path=#{Shellwords.escape(File.expand_path(ENV['MEMCHECK_DEBUGINFO_PATH']))}"
12
+ end
13
+ RubyMemcheck.config(binary_name: "rbsecp256k1", valgrind_options: memcheck_options)
14
+
15
+ # See: https://guides.rubygems.org/gems-with-extensions/
16
+ Rake::ExtensionTask.new "rbsecp256k1" do |ext|
17
+ ext.lib_dir = 'lib/rbsecp256k1'
18
+ end
19
+
20
+ RSpec::Core::RakeTask.new(:spec)
21
+ namespace :spec do
22
+ RubyMemcheck::RSpec::RakeTask.new(valgrind: :spec)
23
+ end
@@ -1,98 +1,125 @@
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
+ `dup` and `clone` create independently owned native contexts using
22
+ `secp256k1_context_clone`. The original and copy can be used and collected
23
+ independently. Copying preserves the source context state; it does not provide
24
+ fresh randomization. Use `Context.create` for a newly randomized context.
25
+ Normal Ruby copy behavior applies: `clone` preserves frozen state, while `dup`
26
+ returns an unfrozen copy. Copying an uninitialized context raises
27
+ `Secp256k1::Error`.
28
+
29
+ Native operations on an allocated context that has not completed initialization raise
30
+ `Secp256k1::Error`. Reinitializing an existing context also raises
31
+ `Secp256k1::Error` and leaves the existing context usable.
32
+
33
+ Class Methods
34
+ -------------
35
+
36
+ #### create
37
+
38
+ Creates and returns a new randomized `Context` using `SecureRandom` for the
39
+ random initialization bytes. This is the recommended method for initialization.
40
+
41
+ #### create_unrandomized
42
+
43
+ Creates a new unrandomized `Context`.
44
+
45
+ Instance Methods
46
+ ----------------
47
+
48
+ #### ecdh(point, scalar)
49
+
50
+ Takes a `point` ([PublicKey](public_key.md)) and a `scalar` ([PrivateKey](private_key.md)) and returns a new
51
+ [SharedSecret](shared_secret.md) containing the 32-byte shared secret. Raises a `Secp256k1::Error` if
52
+ the `scalar` is invalid (zero or causes an overflow).
53
+
54
+ #### generate_key_pair
55
+
56
+ Generates and returns a new [KeyPair](key_pair.md) using Ruby's built-in
57
+ `SecureRandom` cryptographically secure random number generator. This method
58
+ simply invokes `key_pair_from_private_key` with the value from
59
+ `SecureRandom.random_bytes`.
60
+
61
+ #### key_pair_from_private_key(private_key_data)
62
+
63
+ Returns a new [KeyPair](key_pair.md) from the given `private_key_data`. The
64
+ `private_key_data` is expected to be a binary string. Raises a `Secp256k1::Error`
65
+ if the private key is invalid or key derivation fails.
66
+
67
+ #### recoverable_signature_from_compact(compact_signature, recovery_id)
68
+
69
+ **Requires:** libsecp256k1 was build with recovery module.
70
+
71
+ Attempts to load a [RecoverableSignature](recoverable_signature.md) from the given `compact_signature`
72
+ and `recovery_id`. Raises a `Secp256k1::DeserializationError` if the signature data or recovery ID are invalid.
73
+
74
+ #### sign(private_key, hash32)
75
+
76
+ Signs the SHA-256 hash given by `hash32` using `private_key` and returns a new
77
+ [Signature](signature.md). The `private_key` is expected to be a [PrivateKey](private_key.md)
78
+ object and `data` can be either a binary string or text.
79
+
80
+ #### sign_recoverable(private_key, hash32)
81
+
82
+ **Requires:** libsecp256k1 was build with recovery module.
83
+
84
+ Signs the data represented by the SHA-256 hash `hash32` using `private_key` and returns a
85
+ new [RecoverableSignature](recoverable_signature.md). The `private_key` is expected to be a [PrivateKey](private_key.md) and
86
+ `data` can be either a binary string or text.
87
+
88
+ #### sign_schnorr(keypair, message)
89
+
90
+ Signs a Ruby `String` containing any number of bytes, including zero bytes.
91
+
92
+ Same as `sign_schnorr_custom(keypair, message, auxrand)` but generates
93
+ `auxrand` for you using `SecureRandom`. This should almost always be the method
94
+ used for Schnorr signing.
95
+
96
+ #### sign_schnorr_custom(keypair, message, auxrand)
97
+
98
+ Signs the bytes of the Ruby `String` `message` using the given [KeyPair](key_pair.md)
99
+ and returns a [SchnorrSignature](schnorr_signature.md). Messages may have any byte
100
+ length, including zero, and may contain null bytes. String encoding does not
101
+ change the bytes being signed.
102
+
103
+ The message is signed directly, without implicit hashing, padding, or truncation.
104
+ If your protocol requires a tagged hash for domain separation, compute it
105
+ explicitly with `tagged_sha256` before signing. Verification must use the same
106
+ message bytes.
107
+
108
+ `auxrand` must be a `String` containing exactly 32 bytes of fresh randomness,
109
+ or `nil`. With `nil`, the default BIP-340 nonce function treats auxiliary
110
+ randomness as 32 zero bytes. Prefer `sign_schnorr`, which generates fresh
111
+ randomness automatically.
112
+
113
+ Non-string messages or non-string, non-`nil` randomness raise `TypeError`.
114
+ Randomness strings with a byte length other than 32 raise `Secp256k1::Error`.
115
+
116
+ #### tagged_sha256(tag, message)
117
+
118
+ 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.
119
+
120
+ #### verify(signature, public_key, hash32)
121
+
122
+ Verifies the given `signature` ([Signature](signature.md)) was signed by
123
+ the private key corresponding to `public_key` ([PublicKey](public_key.md)) and signed `hash32`. Returns `true`
124
+ if `signature` is valid or `false` otherwise. Note that `data` can be either a
125
+ text or binary string.