ed25519 1.2.4-java
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 +35 -0
- data/.travis.yml +26 -0
- data/CHANGES.md +70 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +12 -0
- data/LICENSE +22 -0
- data/README.md +170 -0
- data/Rakefile +27 -0
- data/appveyor.yml +21 -0
- data/ed25519.gemspec +32 -0
- data/ed25519.png +0 -0
- data/ext/ed25519_jruby/LICENSE.txt +123 -0
- data/ext/ed25519_jruby/README.md +77 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/EdDSAEngine.java +491 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/EdDSAKey.java +31 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/EdDSAPrivateKey.java +338 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/EdDSAPublicKey.java +275 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/EdDSASecurityProvider.java +59 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/KeyFactory.java +75 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/KeyPairGenerator.java +97 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/Utils.java +103 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Constants.java +23 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Curve.java +100 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Encoding.java +54 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/Field.java +99 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/FieldElement.java +76 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/GroupElement.java +1034 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/ScalarOps.java +34 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/bigint/BigIntegerFieldElement.java +131 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/bigint/BigIntegerLittleEndianEncoding.java +102 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/bigint/BigIntegerScalarOps.java +37 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/bigint/package.html +6 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/ed25519/Ed25519FieldElement.java +988 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/ed25519/Ed25519LittleEndianEncoding.java +256 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/math/ed25519/Ed25519ScalarOps.java +693 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/spec/EdDSAGenParameterSpec.java +32 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/spec/EdDSANamedCurveSpec.java +35 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/spec/EdDSANamedCurveTable.java +71 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/spec/EdDSAParameterSpec.java +97 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/spec/EdDSAPrivateKeySpec.java +133 -0
- data/ext/ed25519_jruby/net/i2p/crypto/eddsa/spec/EdDSAPublicKeySpec.java +61 -0
- data/ext/ed25519_jruby/org/cryptorb/Ed25519Provider.java +95 -0
- data/ext/ed25519_ref10/api.h +4 -0
- data/ext/ed25519_ref10/base.h +1344 -0
- data/ext/ed25519_ref10/base2.h +40 -0
- data/ext/ed25519_ref10/d.h +1 -0
- data/ext/ed25519_ref10/d2.h +1 -0
- data/ext/ed25519_ref10/ed25519_ref10.c +99 -0
- data/ext/ed25519_ref10/ed25519_ref10.h +33 -0
- data/ext/ed25519_ref10/extconf.rb +9 -0
- data/ext/ed25519_ref10/fe.c +1085 -0
- data/ext/ed25519_ref10/fe.h +56 -0
- data/ext/ed25519_ref10/ge.c +407 -0
- data/ext/ed25519_ref10/ge.h +95 -0
- data/ext/ed25519_ref10/ge_add.h +97 -0
- data/ext/ed25519_ref10/ge_madd.h +88 -0
- data/ext/ed25519_ref10/ge_msub.h +88 -0
- data/ext/ed25519_ref10/ge_p2_dbl.h +73 -0
- data/ext/ed25519_ref10/ge_sub.h +97 -0
- data/ext/ed25519_ref10/keypair.c +22 -0
- data/ext/ed25519_ref10/open.c +47 -0
- data/ext/ed25519_ref10/pow22523.h +160 -0
- data/ext/ed25519_ref10/pow225521.h +160 -0
- data/ext/ed25519_ref10/sc.h +17 -0
- data/ext/ed25519_ref10/sc_muladd.c +366 -0
- data/ext/ed25519_ref10/sc_reduce.c +272 -0
- data/ext/ed25519_ref10/sha512.c +304 -0
- data/ext/ed25519_ref10/sha512.h +8 -0
- data/ext/ed25519_ref10/sign.c +41 -0
- data/ext/ed25519_ref10/sqrtm1.h +1 -0
- data/ext/ed25519_ref10/verify.c +40 -0
- data/lib/ed25519.rb +72 -0
- data/lib/ed25519/signing_key.rb +60 -0
- data/lib/ed25519/verify_key.rb +44 -0
- data/lib/ed25519/version.rb +5 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 95314353ef4befcff937f442429eafdb5aaf6e6eff7ea221670fc1ea3f689249
|
4
|
+
data.tar.gz: cbb91899bc61be09807b3f698c3f6e6029c9fd3bddcd8d0d74b9dbebedb4178e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e9e3af36c187bdf1ada42b764477894db274d91ebc3a6ebf86d45c09420c7bd221207d39af72786340214917b6032e97d63a492e1abfb083289b5565da58395
|
7
|
+
data.tar.gz: 644cb48f99fcae140291a0204270539fafa3f0141ee7e1ca1da63ab9a6d6f25afb021dabd0b48f5da4187ac76deea04b4f5eb4cdcad173e20d12ca067e43e0cb
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4
|
3
|
+
DisplayCopNames: true
|
4
|
+
|
5
|
+
#
|
6
|
+
# Style
|
7
|
+
#
|
8
|
+
|
9
|
+
Style/StringLiterals:
|
10
|
+
EnforcedStyle: double_quotes
|
11
|
+
|
12
|
+
#
|
13
|
+
# Metrics
|
14
|
+
#
|
15
|
+
|
16
|
+
Metrics/AbcSize:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Metrics/CyclomaticComplexity:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Metrics/PerceivedComplexity:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Metrics/BlockLength:
|
26
|
+
Max: 100
|
27
|
+
|
28
|
+
Metrics/ClassLength:
|
29
|
+
Max: 100
|
30
|
+
|
31
|
+
Metrics/LineLength:
|
32
|
+
Max: 128
|
33
|
+
|
34
|
+
Metrics/MethodLength:
|
35
|
+
Max: 25
|
data/.travis.yml
ADDED
@@ -0,0 +1,26 @@
|
|
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
|
+
bundler_args: --without development
|
11
|
+
|
12
|
+
rvm:
|
13
|
+
- jruby-9.1.15.0
|
14
|
+
- 2
|
15
|
+
- 2.1
|
16
|
+
- 2.2
|
17
|
+
- 2.3.6
|
18
|
+
- 2.4.3
|
19
|
+
- 2.5.0
|
20
|
+
|
21
|
+
matrix:
|
22
|
+
fast_finish: true
|
23
|
+
|
24
|
+
branches:
|
25
|
+
only:
|
26
|
+
- master
|
data/CHANGES.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
## [1.2.4] (2018-01-04)
|
2
|
+
|
3
|
+
[1.2.4]: https://github.com/crypto-rb/ed25519/compare/v1.2.3...v1.2.4
|
4
|
+
|
5
|
+
* Fix JRuby platform name
|
6
|
+
* Add license information to gemspec
|
7
|
+
|
8
|
+
## [1.2.3] (2017-12-31)
|
9
|
+
|
10
|
+
[1.2.3]: https://github.com/crypto-rb/ed25519/compare/v1.2.2...v1.2.3
|
11
|
+
|
12
|
+
* [#18](https://github.com/crypto-rb/ed25519/pull/18)
|
13
|
+
`ext/ed25519_ref10`: Consolidate fe.c and ge.c
|
14
|
+
|
15
|
+
## [1.2.2] (2017-12-31)
|
16
|
+
|
17
|
+
[1.2.2]: https://github.com/crypto-rb/ed25519/compare/v1.2.1...v1.2.2
|
18
|
+
|
19
|
+
* [#17](https://github.com/crypto-rb/ed25519/pull/17)
|
20
|
+
Test against Ruby 2.5.0
|
21
|
+
|
22
|
+
* [#16](https://github.com/crypto-rb/ed25519/pull/16)
|
23
|
+
Move project to the crypto-rb GitHub organization
|
24
|
+
|
25
|
+
## [1.2.1] (2017-12-15)
|
26
|
+
|
27
|
+
[1.2.1]: https://github.com/crypto-rb/ed25519/compare/v1.2.0...v1.2.1
|
28
|
+
|
29
|
+
* [#14](https://github.com/crypto-rb/ed25519/pull/14)
|
30
|
+
Support MRI 2.0+
|
31
|
+
|
32
|
+
## [1.2.0] (2017-12-15)
|
33
|
+
|
34
|
+
[1.2.0]: https://github.com/crypto-rb/ed25519/compare/v1.1.0...v1.2.0
|
35
|
+
|
36
|
+
* [#13](https://github.com/crypto-rb/ed25519/pull/13)
|
37
|
+
Add `Ed25519::SigningKey.from_keypair`
|
38
|
+
|
39
|
+
* [#12](https://github.com/crypto-rb/ed25519/pull/12)
|
40
|
+
Add `Ed25519.validate_key_bytes` method
|
41
|
+
|
42
|
+
## [1.1.0] (2017-12-13)
|
43
|
+
|
44
|
+
[1.1.0]: https://github.com/crypto-rb/ed25519/compare/v1.0.0...v1.1.0
|
45
|
+
|
46
|
+
* [#11](https://github.com/crypto-rb/ed25519/pull/11)
|
47
|
+
ext/ed25519_java: switch to str4d/ed25519-java implementation (fixes #4)
|
48
|
+
|
49
|
+
* [#9](https://github.com/crypto-rb/ed25519/pull/9)
|
50
|
+
Implement Java backend as a proper JRuby extension
|
51
|
+
|
52
|
+
* [#8](https://github.com/crypto-rb/ed25519/pull/8)
|
53
|
+
Use an attr_accessor for Ed25519.provider
|
54
|
+
|
55
|
+
## [1.0.0] (2017-12-12)
|
56
|
+
|
57
|
+
[1.0.0]: https://github.com/crypto-rb/ed25519/compare/v0.1.0...v1.0.0
|
58
|
+
|
59
|
+
* [#7](https://github.com/crypto-rb/ed25519/pull/7)
|
60
|
+
Keypair refactor
|
61
|
+
|
62
|
+
* [#6](https://github.com/crypto-rb/ed25519/pull/6)
|
63
|
+
Switch from "ref" C implementation to SUPERCOP "ref10"
|
64
|
+
|
65
|
+
* [#5](https://github.com/crypto-rb/ed25519/pull/5)
|
66
|
+
Raise Ed25519::VerifyError if signature verification fails
|
67
|
+
|
68
|
+
# 0.1.0 (2017-12-11)
|
69
|
+
|
70
|
+
* Initial release
|
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,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gemspec
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "rake", require: false
|
9
|
+
gem "rake-compiler", "~> 1.0", require: false
|
10
|
+
gem "rspec", "~> 3.7", require: false
|
11
|
+
gem "rubocop", "0.50.0", require: false
|
12
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012-2017 Tony Arcieri
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
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
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
# ed25519.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: MIT][license-image]][license-link] [![Gitter Chat][gitter-image]][gitter-link]
|
2
|
+
|
3
|
+
[gem-shield]: https://badge.fury.io/rb/ed25519.svg
|
4
|
+
[gem-link]: https://rubygems.org/gems/ed25519
|
5
|
+
[build-image]: https://travis-ci.org/crypto-rb/ed25519.svg?branch=master
|
6
|
+
[build-link]: https://travis-ci.org/crypto-rb/ed25519
|
7
|
+
[appveyor-image]: https://ci.appveyor.com/api/projects/status/4s05bcae0mow85v1?svg=true
|
8
|
+
[appveyor-link]: https://ci.appveyor.com/project/tarcieri/ed25519
|
9
|
+
[docs-image]: https://img.shields.io/badge/yard-docs-blue.svg
|
10
|
+
[docs-link]: http://www.rubydoc.info/gems/ed25519/1.2.3
|
11
|
+
[license-image]: https://img.shields.io/badge/license-MIT-blue.svg
|
12
|
+
[license-link]: https://github.com/crypto-rb/ed25519/blob/master/LICENSE
|
13
|
+
[gitter-image]: https://badges.gitter.im/badge.svg
|
14
|
+
[gitter-link]: https://gitter.im/crypto-rb/Lobby
|
15
|
+
|
16
|
+
A Ruby binding to the Ed25519 elliptic curve public-key signature system
|
17
|
+
described in [RFC 8032].
|
18
|
+
|
19
|
+
Two implementations are provided: a MRI C extension which uses the "ref10"
|
20
|
+
implementation from the SUPERCOP benchmark suite, and a pure Java version
|
21
|
+
based on [str4d/ed25519-java].
|
22
|
+
|
23
|
+
Ed25519 is one of two notable algorithms implemented atop the Curve25519
|
24
|
+
elliptic curve. The [x25519 gem] is a related project of this one,
|
25
|
+
and implements the X25519 Diffie-Hellman key exchange algorithm on the
|
26
|
+
Montgomery form of Curve25519.
|
27
|
+
|
28
|
+
[RFC 8032]: https://tools.ietf.org/html/rfc8032
|
29
|
+
[str4d/ed25519-java]: https://github.com/str4d/ed25519-java
|
30
|
+
[x25519 gem]: https://github.com/crypto-rb/x25519
|
31
|
+
|
32
|
+
## What is Ed25519?
|
33
|
+
|
34
|
+
Ed25519 is a modern implementation of a [Schnorr signature] system using
|
35
|
+
elliptic curve groups.
|
36
|
+
|
37
|
+
Ed25519 provides a 128-bit security level, that is to say, all known attacks
|
38
|
+
take at least 2^128 operations, providing the same security level as AES-128,
|
39
|
+
NIST P-256, and RSA-3072.
|
40
|
+
|
41
|
+
![Ed25519 Diagram](https://raw.github.com/crypto-rb/ed25519/master/ed25519.png)
|
42
|
+
|
43
|
+
Ed25519 has a number of unique properties that make it one of the best-in-class
|
44
|
+
digital signature algorithms:
|
45
|
+
|
46
|
+
* ***Small keys***: Ed25519 keys are only 256-bits (32 bytes), making them
|
47
|
+
small enough to easily copy around. Ed25519 also allows the public key
|
48
|
+
to be derived from the private key, meaning that it doesn't need to be
|
49
|
+
included in a serialized private key in cases you want both.
|
50
|
+
* ***Small signatures***: Ed25519 signatures are only 512-bits (64 bytes),
|
51
|
+
one of the smallest signature sizes available.
|
52
|
+
* ***Deterministic***: Unlike (EC)DSA, Ed25519 does not rely on an entropy
|
53
|
+
source when signing messages. This can be a potential attack vector if
|
54
|
+
the entropy source is not generating good random numbers. Ed25519 avoids
|
55
|
+
this problem entirely and will always generate the same signature for the
|
56
|
+
same data.
|
57
|
+
* ***Collision Resistant***: Hash-function collisions do not break this
|
58
|
+
system. This adds a layer of defense against the possibility of weakness
|
59
|
+
in the selected hash function.
|
60
|
+
|
61
|
+
You can read more on [Dan Bernstein's Ed25519 site](http://ed25519.cr.yp.to/).
|
62
|
+
|
63
|
+
[Schnorr signature]: https://en.wikipedia.org/wiki/Schnorr_signature
|
64
|
+
|
65
|
+
## Requirements
|
66
|
+
|
67
|
+
**ed25519.rb** is supported on and tested against the following platforms:
|
68
|
+
|
69
|
+
* MRI 2.0, 2.1, 2.2, 2.3, 2.4, 2.5
|
70
|
+
* JRuby 9000+
|
71
|
+
|
72
|
+
## Installation
|
73
|
+
|
74
|
+
Add this line to your application's Gemfile:
|
75
|
+
|
76
|
+
gem 'ed25519'
|
77
|
+
|
78
|
+
And then execute:
|
79
|
+
|
80
|
+
$ bundle
|
81
|
+
|
82
|
+
Or install it yourself as:
|
83
|
+
|
84
|
+
$ gem install ed25519
|
85
|
+
|
86
|
+
# Usage
|
87
|
+
|
88
|
+
Require **ed25519.rb** in your Ruby program:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
require "ed25519"
|
92
|
+
```
|
93
|
+
|
94
|
+
Generate a new random signing key:
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
signing_key = Ed25519::SigningKey.generate
|
98
|
+
```
|
99
|
+
|
100
|
+
Sign a message with the signing key:
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
signature = signing_key.sign(message)
|
104
|
+
```
|
105
|
+
|
106
|
+
Obtain the verify key for a given signing key:
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
verify_key = signing_key.verify_key
|
110
|
+
```
|
111
|
+
|
112
|
+
Check the validity of a signature:
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
verify_key.verify(signature, message)
|
116
|
+
```
|
117
|
+
|
118
|
+
The verify method will return `true` if the signature verifies, or raise
|
119
|
+
`Ed25519::VerifyError` if verification fails.
|
120
|
+
|
121
|
+
### Serializing Keys
|
122
|
+
|
123
|
+
Keys can be serialized as 32-byte binary strings as follows:
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
signature_key_bytes = signing_key.to_bytes
|
127
|
+
verify_key_bytes = verify_key.to_bytes
|
128
|
+
```
|
129
|
+
|
130
|
+
The binary serialization can be passed directly into the constructor for a given key type:
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
signing_key = Ed25519::SigningKey.new(signature_key_bytes)
|
134
|
+
verify_key = Ed25519::VerifyKey.new(verify_key_bytes)
|
135
|
+
```
|
136
|
+
|
137
|
+
## Security Notes
|
138
|
+
|
139
|
+
The Ed25519 "ref10" implementation from SUPERCOP was lovingly crafted by expert
|
140
|
+
security boffins with great care taken to prevent timing attacks. The same
|
141
|
+
cannot be said for the C code used in the **ed25519.rb** C extension or in the
|
142
|
+
entirety of the provided Java implementation.
|
143
|
+
|
144
|
+
Care should be taken to avoid leaking to the attacker how long it takes to
|
145
|
+
generate keys or sign messages (at least until **ed25519.rb** itself can be audited
|
146
|
+
by experts who can fix any potential timing vulnerabilities)
|
147
|
+
|
148
|
+
**ed25519.rb** relies on a strong `SecureRandom` for key generation.
|
149
|
+
Weaknesses in the random number source can potentially result in insecure keys.
|
150
|
+
|
151
|
+
## Contributing
|
152
|
+
|
153
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/crypto-rb/ed25519.
|
154
|
+
This project is intended to be a safe, welcoming space for collaboration,
|
155
|
+
and contributors areexpected to adhere to the [Contributor Covenant](http://contributor-covenant.org)
|
156
|
+
code of conduct.
|
157
|
+
|
158
|
+
## License
|
159
|
+
|
160
|
+
Copyright (c) 2012-2018 Tony Arcieri. Distributed under the MIT License. See
|
161
|
+
[LICENSE] for further details.
|
162
|
+
|
163
|
+
[LICENSE]: https://github.com/crypto-rb/ed25519/blob/master/LICENSE
|
164
|
+
|
165
|
+
## Code of Conduct
|
166
|
+
|
167
|
+
Everyone interacting in the **ed25519.rb** project’s codebases, issue trackers, chat
|
168
|
+
rooms and mailing lists is expected to follow the [code of conduct].
|
169
|
+
|
170
|
+
[code of conduct]: https://github.com/crypto-rb/ed25519/blob/master/CODE_OF_CONDUCT.md
|