ed25519 1.1.0-jruby → 1.2.0-jruby

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: ffe9a55bb4a20efc99365fc6ed06329de947ce39
4
- data.tar.gz: 7913e3cd83720eb011f69069512f3791f1878839
3
+ metadata.gz: 76ca0515a8683246d8e7fbc1c07146be0e54a792
4
+ data.tar.gz: 86b5e56ebbaa380f439d950e8766c7f04d06b7eb
5
5
  SHA512:
6
- metadata.gz: 3994f501b34ca888050eb0a7e7620a8e3570683d0207c21716c3c5ac27b063133f452fca7d0c658027cd00eeb15d7ed01cf7fcbdfa930791e7354f8c04933c46
7
- data.tar.gz: 184956a2e7e6a414502d3b56fe814e216b622587789f1959b24d55d2c1b329740072a040b8f873385f146bd72da7d853c024a30ca100355c81b35b38b485fcc9
6
+ metadata.gz: 15e69cdf0fe054a0e141110244751cb35c0f35de1ae77255e74ecbdfb1a13db0454865683f3ec9f60d5bc60b5f3c7467808a04768762175feb081123eba86215
7
+ data.tar.gz: eef82ce281c07cba960ff9e49323c54fcb3fd5da313110256a7b838cafd628567c47ae29a25d172e05771232a323a9570bd42b9f9c0d1c98975fb79e79098253
data/CHANGES.md CHANGED
@@ -1,3 +1,13 @@
1
+ # [1.2.0] (2017-12-15)
2
+
3
+ [1.2.0]: https://github.com/cryptosphere/x25519/compare/v1.1.0...v1.2.0
4
+
5
+ * [#13](https://github.com/cryptosphere/ed25519/pull/13)
6
+ Add `Ed25519::SigningKey.from_keypair`
7
+
8
+ * [#12](https://github.com/cryptosphere/ed25519/pull/12)
9
+ Add `Ed25519.validate_key_bytes` method
10
+
1
11
  # [1.1.0] (2017-12-13)
2
12
 
3
13
  [1.1.0]: https://github.com/cryptosphere/x25519/compare/v1.0.0...v1.1.0
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [build-image]: https://travis-ci.org/cryptosphere/ed25519.svg?branch=master
6
6
  [build-link]: https://travis-ci.org/cryptosphere/ed25519
7
7
  [docs-image]: https://img.shields.io/badge/yard-docs-blue.svg
8
- [docs-link]: http://www.rubydoc.info/gems/ed25519
8
+ [docs-link]: http://www.rubydoc.info/gems/ed25519/1.2.0
9
9
  [license-image]: https://img.shields.io/badge/license-MIT-blue.svg
10
10
  [license-link]: https://github.com/cryptosphere/ed25519/blob/master/LICENSE
11
11
 
@@ -35,6 +35,13 @@ module Ed25519
35
35
  self.provider = Ed25519::Provider::Ref10
36
36
  end
37
37
 
38
+ # Ensure a serialized key meets the requirements
39
+ def validate_key_bytes(key_bytes)
40
+ raise TypeError, "expected String, got #{key_bytes.class}" unless key_bytes.is_a?(String)
41
+ return true if key_bytes.bytesize == KEY_SIZE
42
+ raise ArgumentError, "expected #{KEY_SIZE}-byte String, got #{key_bytes.bytesize}"
43
+ end
44
+
38
45
  # Perform a self-test to ensure the selected provider is working
39
46
  def self_test
40
47
  signature_key = Ed25519::SigningKey.new("A" * 32)
@@ -12,13 +12,25 @@ module Ed25519
12
12
  new SecureRandom.random_bytes(Ed25519::KEY_SIZE)
13
13
  end
14
14
 
15
+ # Create a SigningKey from a 64-byte Ed25519 keypair (i.e. public + private)
16
+ #
17
+ # @param keypair [String] 64-byte keypair value containing both seed + public key
18
+ def self.from_keypair(keypair)
19
+ raise TypeError, "expected String, got #{keypair.class}" unless keypair.is_a?(String)
20
+ raise ArgumentError, "expected 64-byte String, got #{keypair.bytesize}" unless keypair.bytesize == 64
21
+
22
+ new(keypair[0, KEY_SIZE]).tap do |key|
23
+ raise ArgumentError, "corrupt keypair" unless keypair[KEY_SIZE, KEY_SIZE] == key.verify_key.to_bytes
24
+ end
25
+ end
26
+
15
27
  # Create a new Ed25519::SigningKey from the given seed value
16
28
  #
17
29
  # @param seed [String] 32-byte seed value from which the key should be derived
18
30
  def initialize(seed)
19
- raise ArgumentError, "seed must be #{KEY_SIZE}-bytes long" unless seed.length == KEY_SIZE
20
- @seed = seed
31
+ Ed25519.validate_key_bytes(seed)
21
32
 
33
+ @seed = seed
22
34
  @keypair = Ed25519.provider.create_keypair(seed)
23
35
  @verify_key = VerifyKey.new(@keypair[32, 32])
24
36
  end
@@ -7,7 +7,7 @@ module Ed25519
7
7
  #
8
8
  # @param key [String] 32-byte string representing a serialized public key
9
9
  def initialize(key)
10
- raise ArgumentError, "seed must be 32 bytes long" unless key.length == KEY_SIZE
10
+ Ed25519.validate_key_bytes(key)
11
11
  @key_bytes = key
12
12
  end
13
13
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ed25519
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ed25519
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: jruby
6
6
  authors:
7
7
  - Tony Arcieri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-13 00:00:00.000000000 Z
11
+ date: 2017-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement