x25519 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e14a38927066f9bf0bb89efc17aa433b42d3fbd
4
- data.tar.gz: 7ccda465a96b34ada8f593b1461861a72f2ec253
3
+ metadata.gz: ea3f150ae564aadb87e3bb463b2f4b7d8d8756b9
4
+ data.tar.gz: be24c272b97043d3f1385def5543fca88b9ff859
5
5
  SHA512:
6
- metadata.gz: 0540a115042091e9bd19b45db8b44fa3e0453720ed5d03cb0379e217ebe7a75b784df3510118820fe4e5277de369dfb3c095b1bb4f57975aa2876dff3445be39
7
- data.tar.gz: 3b230f900fac4f7b183b62a7e53c2385b9e7581fc39ded633a8f0e766f68a5f06805421b0c16f7cb38cad14ed430659a4eed845f8cee02ecfab6aa0ef2e0f78e
6
+ metadata.gz: 2b598f77e90d1fafbcb0b820d29966ba259a68c3bc1b44674f955a6ccbf010c30a8cc4339321bb55ddc3d27b3b3bce5e19ff1b4540855ee81235e8a55bf85675
7
+ data.tar.gz: 577ed0233e0a4a73452798c344531df9fbb498625c85526c02ca6658782559dce24538574b23a8eafb2f5adaf500331243ebd0a29dfb80a5bef6c03ee264c2e8
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [1.0.1] (2017-12-12)
2
+
3
+ [1.0.1]: https://github.com/cryptosphere/x25519/compare/v1.0.0...v1.0.1
4
+
5
+ * Have `X25519.self_test` return true on success
6
+
1
7
  # [1.0.0] (2017-12-12)
2
8
 
3
9
  [1.0.0]: https://github.com/cryptosphere/x25519/compare/v0.2.0...v1.0.0
data/README.md CHANGED
@@ -70,68 +70,66 @@ bob_secret = bob_sk.diffie_hellman(alice_pk).to_bytes
70
70
  alice_secret == bob_secret # true
71
71
  ```
72
72
 
73
- ## API
74
-
75
- ### `X25519::Scalar`: private keys
73
+ ## X25519::Scalar: private keys
76
74
 
77
75
  The `X25519::Scalar` class represents secret integers used as X25519 private
78
76
  keys. These secret integers are multiplied by a well-known base point to
79
77
  obtain X25519 public keys (`X25519::MontgomeryU`).
80
78
 
81
- #### `X25519::Scalar.generate()`: make a random private key
79
+ ### `X25519::Scalar.generate()`: make a random private key
82
80
 
83
81
  Generate a random private scalar (using `SecureRandom`)
84
82
 
85
- ##### Example
83
+ **Example:**
86
84
 
87
85
  ```ruby
88
86
  secret_key = X25519::Scalar.generate
89
87
  ```
90
88
 
91
- #### `X25519::Scalar.new(bytes)`: load existing private key
89
+ ### `X25519::Scalar.new(bytes)`: load existing private key
92
90
 
93
91
  * `bytes`: a 32-byte `String` value containing the private key
94
92
 
95
- ##### Example
93
+ **Example:**
96
94
 
97
95
  ```ruby
98
96
  secret_key = X25519::Scalar.new(File.read("alice.key"))
99
97
  ```
100
98
 
101
- #### `X25519::Scalar#public_key()`: obtain public key for this scalar
99
+ ### `X25519::Scalar#public_key()`: obtain public key for this scalar
102
100
 
103
101
  NOTE: The `#multiply_base` method is an alias of this one.
104
102
 
105
103
  Performs fixed-base scalar multiplication (i.e. calculates public key)
106
104
 
107
- ##### Return Value
105
+ **Return Value:**
108
106
 
109
107
  Returns a `X25519::MontgomeryU` object which represents the public key for this private key/scalar.
110
108
 
111
- ##### Example
109
+ **Example:**
112
110
 
113
111
  ```ruby
114
112
  secret_key = X25519::Scalar.generate
115
113
  public_key = secret_key.public_key
116
114
  ```
117
115
 
118
- #### `X25519::Scalar#diffie_hellman(other_public_key)`: obtain public key for this scalar
116
+ ### `X25519::Scalar#diffie_hellman(other_public_key)`: obtain public key for this scalar
119
117
 
120
118
  NOTE: The `#multiply` method is an alias of this one.
121
119
 
122
120
  Performs variable-base scalar multiplication, computing a shared secret between
123
121
  our private scalar and someone else's public key/point.
124
122
 
125
- ##### Return Value
126
-
127
- Returns a `X25519::MontgomeryU` object which represents the shared secret.
128
-
129
- ##### Arguments
123
+ **Arguments:**
130
124
 
131
125
  * `other_public_key`: a `X25519::MontgomeryU` object containing the public key
132
126
  with which we'd like to compute a shared secret.
133
127
 
134
- ##### Example
128
+ **Return Value:**
129
+
130
+ Returns a `X25519::MontgomeryU` object which represents the shared secret.
131
+
132
+ **Example:**
135
133
 
136
134
  ```ruby
137
135
  secret_key = X25519::Scalar.generate
@@ -144,63 +142,63 @@ shared_secret = secret_key.multiply(public_key)
144
142
  shared_secret_bytes = shared_secret.to_bytes
145
143
  ```
146
144
 
147
- #### `X25519::Scalar#to_bytes`: serialize a scalar as a `String`
145
+ ### `X25519::Scalar#to_bytes`: serialize a scalar as a `String`
148
146
 
149
- ##### Return Value
147
+ **Return Value:**
150
148
 
151
149
  Returns a `String` containing a byte representation of this scalar:
152
150
 
153
- ##### Example
151
+ **Example:**
154
152
 
155
153
  ```ruby
156
154
  secret_key = X25519::Scalar.new(...)
157
155
  File.write("alice.key", secret_key.to_bytes)
158
156
  ```
159
157
 
160
- ### `X25519::MontgomeryU`: public keys and shared secrets
158
+ ## X25519::MontgomeryU: public keys and shared secrets
161
159
 
162
160
  The `X25519::MontgomeryU` class represents a coordinate (specifically a
163
161
  Montgomery-u coordinate) on the elliptic curve. In the X25519 Diffie-Hellman
164
162
  function, these serve both as public keys and as shared secrets.
165
163
 
166
- #### `X25519::MontgomeryU.new(bytes)`: load existing public key
164
+ ### `X25519::MontgomeryU.new(bytes)`: load existing public key
167
165
 
168
- ##### Arguments
166
+ **Arguments:**
169
167
 
170
168
  * `bytes`: a 32-byte `String` value containing the public key
171
169
 
172
- ##### Example
170
+ **Example:**
173
171
 
174
172
  ```ruby
175
173
  public_key = X25519::MontgomeryU.new(File.read("bob.pub"))
176
174
  ```
177
175
 
178
- #### `X25519::MontgomeryU#to_bytes`: serialize a Montgomery-u coordinate as a `String`
176
+ ### `X25519::MontgomeryU#to_bytes`: serialize a Montgomery-u coordinate as a `String`
179
177
 
180
- ##### Return Value
178
+ **Return Value:**
181
179
 
182
180
  Returns a `String` containing a byte representation of a compressed Montgomery-u coordinate:
183
181
 
184
- ##### Example
182
+ **Example:**
185
183
 
186
184
  ```ruby
187
185
  public_key = X25519::MontgomeryU..new(...)
188
186
  File.write("bob.pub", public_key.to_bytes)
189
187
  ```
190
188
 
191
- ### `X25519`: module-level functionality
189
+ ## X25519: module-level functionality
192
190
 
193
- #### `X25519.diffie_hellman(secret_key, public_key)`: shorthand `String`-oriented API
191
+ ### `X25519.diffie_hellman(secret_key, public_key)`: shorthand `String`-oriented API
194
192
 
195
193
  If you'd like to avoid the object-oriented API, you can use a simplified API which
196
194
  acts entirely on bytestrings.
197
195
 
198
- ##### Arguments
196
+ **Arguments:**
199
197
 
200
198
  * `secret_key`: a 32-byte `String` containing a private scalar
201
199
  * `public_key`: a 32-byte `String` containing a compressed Montgomery-u coordinate
202
200
 
203
- ##### Return Value
201
+ **Return Value:**
204
202
 
205
203
  Returns a `String` containing a 32-byte compressed Montgomery-u coordinate
206
204
 
data/lib/x25519.rb CHANGED
@@ -63,6 +63,8 @@ module X25519
63
63
  public_key = provider.scalarmult_base([v.scalar].pack("H*"))
64
64
  raise "self test failed!" unless public_key.unpack("H*").first == v.output_coord
65
65
  end
66
+
67
+ true
66
68
  end
67
69
  end
68
70
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module X25519
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: x25519
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri