x25519-termux 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +5 -0
- data/.rubocop.yml +38 -0
- data/.travis.yml +21 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +13 -0
- data/LICENSE +32 -0
- data/README.md +301 -0
- data/Rakefile +25 -0
- data/appveyor.yml +20 -0
- data/ext/extconf_helpers.rb +20 -0
- data/ext/x25519_precomputed/cputest.c +74 -0
- data/ext/x25519_precomputed/extconf.rb +19 -0
- data/ext/x25519_precomputed/fp25519_x64.c +943 -0
- data/ext/x25519_precomputed/fp25519_x64.h +122 -0
- data/ext/x25519_precomputed/table_ladder_x25519.h +544 -0
- data/ext/x25519_precomputed/x25519_precomputed.c +99 -0
- data/ext/x25519_precomputed/x25519_precomputed.h +58 -0
- data/ext/x25519_precomputed/x25519_x64.c +251 -0
- data/ext/x25519_ref10/api.h +2 -0
- data/ext/x25519_ref10/base.c +9 -0
- data/ext/x25519_ref10/extconf.rb +13 -0
- data/ext/x25519_ref10/fe.c +912 -0
- data/ext/x25519_ref10/fe.h +44 -0
- data/ext/x25519_ref10/montgomery.h +140 -0
- data/ext/x25519_ref10/pow225521.h +160 -0
- data/ext/x25519_ref10/scalarmult.c +47 -0
- data/ext/x25519_ref10/x25519_ref10.c +82 -0
- data/ext/x25519_ref10/x25519_ref10.h +15 -0
- data/lib/x25519-termux.rb +99 -0
- data/lib/x25519-termux/montgomery_u.rb +34 -0
- data/lib/x25519-termux/scalar.rb +56 -0
- data/lib/x25519-termux/test_vectors.rb +38 -0
- data/lib/x25519-termux/version.rb +5 -0
- data/x25519-termux.gemspec +30 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ee5eb8bfcee462043f9c9c8aef984036bd5b34ce725773daa3059a15c816aeaa
|
4
|
+
data.tar.gz: 7c7999df6f486669061284c5a6b5effd1db5fc79d84de6805b9621b5b261a25e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d85751d67074a4505ad6804f0828b9ef550d6e83170c12d8800f9d24ad5040994d38add58b07448f81f2c8e4829c274cff87487d6f0f3aad5cfc52f71371d5e7
|
7
|
+
data.tar.gz: 9995df92c30c9db2362aa1af1ee0a931ca91fa3bd6b1b1a2bfd019f573804ad4f8ccdb3249b1fde4444db2c31c53994a0c34115f3f43f1aff78c7e2231cdae05
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.2
|
3
|
+
DisplayCopNames: true
|
4
|
+
|
5
|
+
#
|
6
|
+
# Metrics
|
7
|
+
#
|
8
|
+
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Metrics/CyclomaticComplexity:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Metrics/PerceivedComplexity:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Metrics/BlockLength:
|
19
|
+
Max: 100
|
20
|
+
|
21
|
+
Metrics/ClassLength:
|
22
|
+
Max: 100
|
23
|
+
|
24
|
+
Metrics/LineLength:
|
25
|
+
Max: 128
|
26
|
+
|
27
|
+
Metrics/MethodLength:
|
28
|
+
Max: 25
|
29
|
+
|
30
|
+
#
|
31
|
+
# Style
|
32
|
+
#
|
33
|
+
|
34
|
+
Style/FrozenStringLiteralComment:
|
35
|
+
Enabled: true
|
36
|
+
|
37
|
+
Style/StringLiterals:
|
38
|
+
EnforcedStyle: double_quotes
|
data/.travis.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
|
4
|
+
before_install:
|
5
|
+
- gem update --system
|
6
|
+
- gem --version
|
7
|
+
- gem install bundler -v 1.16.1
|
8
|
+
- bundle --version
|
9
|
+
|
10
|
+
rvm:
|
11
|
+
- 2.2
|
12
|
+
- 2.3
|
13
|
+
- 2.4.3
|
14
|
+
- 2.5.0
|
15
|
+
|
16
|
+
matrix:
|
17
|
+
fast_finish: true
|
18
|
+
|
19
|
+
branches:
|
20
|
+
only:
|
21
|
+
- master
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at bascule@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "coveralls", require: false
|
9
|
+
gem "rake", require: false
|
10
|
+
gem "rake-compiler", "~> 1.0", require: false
|
11
|
+
gem "rspec", "~> 3.7", require: false
|
12
|
+
gem "rubocop", "0.52.1", require: false
|
13
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
BSD-3 License.
|
2
|
+
|
3
|
+
Copyright (c) 2017, Armando Faz <armfazh@ic.unicamp.br>. All rights reserved.
|
4
|
+
Institute of Computing.
|
5
|
+
University of Campinas, Brazil.
|
6
|
+
|
7
|
+
Redistribution and use in source and binary forms, with or without
|
8
|
+
modification, are permitted provided that the following conditions
|
9
|
+
are met:
|
10
|
+
|
11
|
+
* Redistributions of source code must retain the above copyright
|
12
|
+
notice, this list of conditions and the following disclaimer.
|
13
|
+
* Redistributions in binary form must reproduce the above
|
14
|
+
copyright notice, this list of conditions and the following
|
15
|
+
disclaimer in the documentation and/or other materials provided
|
16
|
+
with the distribution.
|
17
|
+
* Neither the name of University of Campinas nor the names of its
|
18
|
+
contributors may be used to endorse or promote products derived
|
19
|
+
from this software without specific prior written permission.
|
20
|
+
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
24
|
+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
25
|
+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
26
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
27
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
28
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
29
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
30
|
+
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
32
|
+
OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,301 @@
|
|
1
|
+
# x25519.rb [![Latest Version][gem-shield]][gem-link] [![Build Status][build-image]][build-link] [![Appveyor CI Status][appveyor-image]][appveyor-link] [![Yard Docs][docs-image]][docs-link] [![License: BSD 3-Clause][license-image]][license-link] [![Gitter Chat][gitter-image]][gitter-link]
|
2
|
+
|
3
|
+
[gem-shield]: https://badge.fury.io/rb/x25519.svg
|
4
|
+
[gem-link]: https://rubygems.org/gems/x25519
|
5
|
+
[build-image]: https://travis-ci.org/crypto-rb/x25519.svg?branch=master
|
6
|
+
[build-link]: https://travis-ci.org/crypto-rb/x25519
|
7
|
+
[appveyor-image]: https://ci.appveyor.com/api/projects/status/4s05bcae0mow85v1?svg=true
|
8
|
+
[appveyor-link]: https://ci.appveyor.com/project/tarcieri/x25519
|
9
|
+
[docs-image]: https://img.shields.io/badge/yard-docs-blue.svg
|
10
|
+
[docs-link]: http://www.rubydoc.info/gems/x25519/1.0.6
|
11
|
+
[license-image]: https://img.shields.io/badge/License-BSD%203--Clause-blue.svg
|
12
|
+
[license-link]: https://spdx.org/licenses/BSD-3-Clause.html
|
13
|
+
[gitter-image]: https://badges.gitter.im/badge.svg
|
14
|
+
[gitter-link]: https://gitter.im/crypto-rb/Lobby
|
15
|
+
|
16
|
+
An efficient public key cryptography library for Ruby providing key
|
17
|
+
exchange/agreement.
|
18
|
+
|
19
|
+
This gem implements X25519 (a.k.a. Curve25519) Elliptic Curve Diffie-Hellman
|
20
|
+
function as described in [RFC7748] as a C extension using the
|
21
|
+
high performance [rfc7748_precomputed] implementation based on the paper
|
22
|
+
[How to (pre-)compute a ladder]
|
23
|
+
(with fallback to the ref10 C implementation).
|
24
|
+
|
25
|
+
X25519 is one of two notable algorithms implemented atop the Curve25519
|
26
|
+
elliptic curve. The [ed25519 gem] is a related project of this one,
|
27
|
+
and implements the Ed25519 signature scheme on the twisted Edwards form of
|
28
|
+
Curve25519.
|
29
|
+
|
30
|
+
[RFC7748]: https://tools.ietf.org/html/rfc7748
|
31
|
+
[How to (pre-)compute a ladder]: https://eprint.iacr.org/2017/264
|
32
|
+
[rfc7748_precomputed]: https://github.com/armfazh/rfc7748_precomputed
|
33
|
+
[ed25519 gem]: https://github.com/crypto-rb/ed25519
|
34
|
+
|
35
|
+
### Is it any good?
|
36
|
+
|
37
|
+
[Yes.](http://news.ycombinator.com/item?id=3067434)
|
38
|
+
|
39
|
+
### What is it useful for?
|
40
|
+
|
41
|
+
X25519 is a key exchange/agreement algorithm generally used as a low-level
|
42
|
+
building block in cryptographic protocols.
|
43
|
+
|
44
|
+
### Can I use X25519 to encrypt things?
|
45
|
+
|
46
|
+
Please use [RbNaCl::Box] or the (experimental) [XSTREAM] library if you would
|
47
|
+
like to use X25519 for public-key encryption. Otherwise, the X25519 algorithm
|
48
|
+
is not directly useful for encryption without a higher-level encryption protocol
|
49
|
+
built on top of it.
|
50
|
+
|
51
|
+
[RbNaCl::Box]: https://github.com/crypto-rb/rbnacl/wiki/Public-Key-Encryption
|
52
|
+
[XSTREAM]: https://github.com/miscreant/xstream
|
53
|
+
|
54
|
+
## Help and Discussion
|
55
|
+
|
56
|
+
Have questions? Want to suggest a feature or change? Join a discussion group:
|
57
|
+
|
58
|
+
* [Crypto.rb Gitter]: web-based chat about Ruby crypto projects including **x25519**.
|
59
|
+
* [Crypto.rb Google Group]: join via web or email ([crypto-rb+subscribe@googlegroups.com])
|
60
|
+
|
61
|
+
[Crypto.rb Gitter]: https://gitter.im/crypto-rb/Lobby
|
62
|
+
[Crypto.rb Google Group]: https://groups.google.com/forum/#!forum/crypto-rb
|
63
|
+
[crypto-rb+subscribe@googlegroups.com]: mailto:crypto-rb+subscribe@googlegroups.com?subject=subscribe
|
64
|
+
|
65
|
+
## Requirements
|
66
|
+
|
67
|
+
**x25519.rb** is supported on and tested against the following platforms:
|
68
|
+
|
69
|
+
* MRI 2.2, 2.3, 2.4, 2.5
|
70
|
+
|
71
|
+
## Installation
|
72
|
+
|
73
|
+
Add this line to your application's Gemfile:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
gem "x25519"
|
77
|
+
```
|
78
|
+
|
79
|
+
And then execute:
|
80
|
+
|
81
|
+
$ bundle
|
82
|
+
|
83
|
+
Or install it yourself as:
|
84
|
+
|
85
|
+
$ gem install x25519
|
86
|
+
|
87
|
+
## Usage
|
88
|
+
|
89
|
+
The example below shows how to perform a full Diffie-Hellman key exchange:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
require "x25519"
|
93
|
+
|
94
|
+
# Alice generates random scalar (private key)
|
95
|
+
alice_sk = X25519::Scalar.generate
|
96
|
+
|
97
|
+
# Alice obtains public key for her private key/scalar
|
98
|
+
alice_pk = alice_sk.public_key
|
99
|
+
|
100
|
+
# Bob generates random scalar (private key)
|
101
|
+
# Ostensibly this would be on a different computer somewhere
|
102
|
+
bob_sk = X25519::Scalar.generate
|
103
|
+
bob_pk = bob_sk.public_key
|
104
|
+
|
105
|
+
# Alice can perform Diffie-Hellman with Bob's public key
|
106
|
+
alice_secret = alice_sk.diffie_hellman(bob_pk).to_bytes
|
107
|
+
|
108
|
+
# Bob can perform Diffie-Hellman with Alice's public key
|
109
|
+
bob_secret = bob_sk.diffie_hellman(alice_pk).to_bytes
|
110
|
+
|
111
|
+
# The resulting secrets should be the same
|
112
|
+
alice_secret == bob_secret # true
|
113
|
+
```
|
114
|
+
|
115
|
+
## X25519::Scalar: private keys
|
116
|
+
|
117
|
+
The `X25519::Scalar` class represents secret integers used as X25519 private
|
118
|
+
keys. These secret integers are multiplied by a well-known base point to
|
119
|
+
obtain X25519 public keys (`X25519::MontgomeryU`).
|
120
|
+
|
121
|
+
### `X25519::Scalar.generate()`: make a random private key
|
122
|
+
|
123
|
+
Generate a random private scalar (using `SecureRandom`)
|
124
|
+
|
125
|
+
**Example:**
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
secret_key = X25519::Scalar.generate
|
129
|
+
```
|
130
|
+
|
131
|
+
### `X25519::Scalar.new(bytes)`: load existing private key
|
132
|
+
|
133
|
+
* `bytes`: a 32-byte `String` value containing the private key
|
134
|
+
|
135
|
+
**Example:**
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
secret_key = X25519::Scalar.new(File.read("alice.key"))
|
139
|
+
```
|
140
|
+
|
141
|
+
### `X25519::Scalar#public_key()`: obtain public key for this scalar
|
142
|
+
|
143
|
+
NOTE: The `#multiply_base` method is an alias of this one.
|
144
|
+
|
145
|
+
Performs fixed-base scalar multiplication (i.e. calculates public key)
|
146
|
+
|
147
|
+
**Return Value:**
|
148
|
+
|
149
|
+
Returns a `X25519::MontgomeryU` object which represents the public key for this private key/scalar.
|
150
|
+
|
151
|
+
**Example:**
|
152
|
+
|
153
|
+
```ruby
|
154
|
+
secret_key = X25519::Scalar.generate
|
155
|
+
public_key = secret_key.public_key
|
156
|
+
```
|
157
|
+
|
158
|
+
### `X25519::Scalar#diffie_hellman(other_public_key)`: obtain public key for this scalar
|
159
|
+
|
160
|
+
NOTE: The `#multiply` method is an alias of this one.
|
161
|
+
|
162
|
+
Performs variable-base scalar multiplication, computing a shared secret between
|
163
|
+
our private scalar and someone else's public key/point.
|
164
|
+
|
165
|
+
**Arguments:**
|
166
|
+
|
167
|
+
* `other_public_key`: a `X25519::MontgomeryU` object containing the public key
|
168
|
+
with which we'd like to compute a shared secret.
|
169
|
+
|
170
|
+
**Return Value:**
|
171
|
+
|
172
|
+
Returns a `X25519::MontgomeryU` object which represents the shared secret.
|
173
|
+
|
174
|
+
**Example:**
|
175
|
+
|
176
|
+
```ruby
|
177
|
+
secret_key = X25519::Scalar.generate
|
178
|
+
public_key = X25519::MontgomeryU.new(File.read("bob.pub"))
|
179
|
+
|
180
|
+
# Returns an X25519::MontgomeryU
|
181
|
+
shared_secret = secret_key.multiply(public_key)
|
182
|
+
|
183
|
+
# Obtain the shared secret as a serialized byte representation
|
184
|
+
shared_secret_bytes = shared_secret.to_bytes
|
185
|
+
```
|
186
|
+
|
187
|
+
### `X25519::Scalar#to_bytes`: serialize a scalar as a `String`
|
188
|
+
|
189
|
+
**Return Value:**
|
190
|
+
|
191
|
+
Returns a `String` containing a byte representation of this scalar:
|
192
|
+
|
193
|
+
**Example:**
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
secret_key = X25519::Scalar.new(...)
|
197
|
+
File.write("alice.key", secret_key.to_bytes)
|
198
|
+
```
|
199
|
+
|
200
|
+
## X25519::MontgomeryU: public keys and shared secrets
|
201
|
+
|
202
|
+
The `X25519::MontgomeryU` class represents a coordinate (specifically a
|
203
|
+
Montgomery-u coordinate) on the elliptic curve. In the X25519 Diffie-Hellman
|
204
|
+
function, these serve both as public keys and as shared secrets.
|
205
|
+
|
206
|
+
### `X25519::MontgomeryU.new(bytes)`: load existing public key
|
207
|
+
|
208
|
+
**Arguments:**
|
209
|
+
|
210
|
+
* `bytes`: a 32-byte `String` value containing the public key
|
211
|
+
|
212
|
+
**Example:**
|
213
|
+
|
214
|
+
```ruby
|
215
|
+
public_key = X25519::MontgomeryU.new(File.read("bob.pub"))
|
216
|
+
```
|
217
|
+
|
218
|
+
### `X25519::MontgomeryU#to_bytes`: serialize a Montgomery-u coordinate as a `String`
|
219
|
+
|
220
|
+
**Return Value:**
|
221
|
+
|
222
|
+
Returns a `String` containing a byte representation of a compressed Montgomery-u coordinate:
|
223
|
+
|
224
|
+
**Example:**
|
225
|
+
|
226
|
+
```ruby
|
227
|
+
public_key = X25519::MontgomeryU..new(...)
|
228
|
+
File.write("bob.pub", public_key.to_bytes)
|
229
|
+
```
|
230
|
+
|
231
|
+
## X25519: module-level functionality
|
232
|
+
|
233
|
+
### `X25519.diffie_hellman(secret_key, public_key)`: shorthand `String`-oriented API
|
234
|
+
|
235
|
+
If you'd like to avoid the object-oriented API, you can use a simplified API which
|
236
|
+
acts entirely on bytestrings.
|
237
|
+
|
238
|
+
**Arguments:**
|
239
|
+
|
240
|
+
* `secret_key`: a 32-byte `String` containing a private scalar
|
241
|
+
* `public_key`: a 32-byte `String` containing a compressed Montgomery-u coordinate
|
242
|
+
|
243
|
+
**Return Value:**
|
244
|
+
|
245
|
+
Returns a `String` containing a 32-byte compressed Montgomery-u coordinate
|
246
|
+
|
247
|
+
## Contributing
|
248
|
+
|
249
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/crypto-rb/x25519.
|
250
|
+
This project is intended to be a safe, welcoming space for collaboration,
|
251
|
+
and contributors are expected to adhere to the [Contributor Covenant](https://contributor-covenant.org)
|
252
|
+
code of conduct.
|
253
|
+
|
254
|
+
## Implementation Details
|
255
|
+
|
256
|
+
This gem contains two implementations of X25519: an optimized assembly
|
257
|
+
implementation and a portable C implementation. Implementations are selected
|
258
|
+
based on available CPU features.
|
259
|
+
|
260
|
+
### [rfc7748_precomputed]: optimized assembly implementation
|
261
|
+
|
262
|
+
* Prime field arithmetic is optimized for the 4th and 6th generation of Intel Core processors
|
263
|
+
(Haswell and Skylake micro-architectures).
|
264
|
+
* Efficient integer multiplication using MULX instruction.
|
265
|
+
* Integer additions accelerated with ADCX/ADOX instructions.
|
266
|
+
* Key generation uses a read-only table of 8 KB for X25519.
|
267
|
+
|
268
|
+
### ref10: portable C implementation
|
269
|
+
|
270
|
+
* Taken from the [SUPERCOP] cryptographic benchmarking suite (supercop-20171020)
|
271
|
+
* Portable C code which should compile on any architecture
|
272
|
+
|
273
|
+
[SUPERCOP]: https://bench.cr.yp.to/supercop.html
|
274
|
+
|
275
|
+
## Designers
|
276
|
+
|
277
|
+
The X25519 Diffie-Hellman function was originally designed by Dan Bernstein:
|
278
|
+
|
279
|
+
https://cr.yp.to/ecdh.html
|
280
|
+
|
281
|
+
The optimized [rfc7748_precomputed] implementation was designed by:
|
282
|
+
|
283
|
+
* Thomaz Oliveira, Computer Science Department, Cinvestav-IPN, Mexico.
|
284
|
+
* Julio López, University of Campinas, Brazil.
|
285
|
+
* Hüseyin Hisil, Yasar University, Turkey.
|
286
|
+
* Armando Faz-Hernández, University of Campinas, Brazil.
|
287
|
+
* Francisco Rodríguez-Henríquez, Computer Science Department, Cinvestav-IPN, Mexico.
|
288
|
+
|
289
|
+
## License
|
290
|
+
|
291
|
+
Copyright (c) 2017-2018 Armando Faz, Tony Arcieri
|
292
|
+
|
293
|
+
This gem is available as open source under the terms of the
|
294
|
+
BSD-3 Clause License ([LICENSE](./LICENSE))
|
295
|
+
|
296
|
+
## Code of Conduct
|
297
|
+
|
298
|
+
Everyone interacting in the x25519.rb project’s codebases, issue trackers, chat
|
299
|
+
rooms and mailing lists is expected to follow the [code of conduct].
|
300
|
+
|
301
|
+
[code of conduct]: https://github.com/crypto-rb/x25519/blob/master/CODE_OF_CONDUCT.md
|