ed25519 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1f18b255ad17db79f86a0de5418e50200095c287
4
+ data.tar.gz: 3d323466815a1b2c41df0fd6c85b1e0b7be3bb8e
5
+ SHA512:
6
+ metadata.gz: ba23ff9932cf8c20d9c2e0b1285ebd9aa1a9364be23ac4b4f4ba60ea147400891177add7598f01d4ab9ebf22d6d55e82ff24936294c991c881cf8874076d01a7
7
+ data.tar.gz: 57320689b7535f81d776100e2d92ecaebd3fca3f09018b76734547a7e4b565b4e9018cd575062c6b13043b3d668c9fc48378fb5d8d9dc83ab95726c46064d018
@@ -0,0 +1,15 @@
1
+ /Gemfile.lock
2
+ /.bundle/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.o
11
+ *.so
12
+ *.bundle
13
+
14
+ # rspec failure tracking
15
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,5 @@
1
+ --color
2
+ --format documentation
3
+ --order random
4
+ --warnings
5
+ --require spec_helper
@@ -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
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - jruby-9.1.15.0
5
+ - 2.2.8
6
+ - 2.3.5
7
+ - 2.4.2
8
+
9
+ before_install: gem install bundler -v 1.16.0
10
+
11
+ branches:
12
+ only:
13
+ - master
@@ -0,0 +1,3 @@
1
+ # 0.1.0 (2017-12-11)
2
+
3
+ * Initial release
@@ -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.51.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.
@@ -0,0 +1,156 @@
1
+ # ed25519.rb [![Latest Version][gem-shield]][gem-link] [![Build Status][build-image]][build-link] [![License: LGPL v3][license-image]][license-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/cryptosphere/ed25519.svg?branch=master
6
+ [build-link]: https://travis-ci.org/cryptosphere/ed25519
7
+ [license-image]: https://img.shields.io/badge/license-MIT-blue.svg
8
+ [license-link]: https://github.com/cryptosphere/ed25519/blob/master/LICENSE
9
+
10
+ A Ruby binding to the Ed25519 elliptic curve public-key signature system
11
+ described in [RFC 8032].
12
+
13
+ Two implementations are provided: a MRI C extension which uses the "ref"
14
+ implementation from the SUPERCOP benchmark suite, and a pure Java version
15
+ which is a direct port of the Python implementation.
16
+
17
+ [RFC 8032]: https://tools.ietf.org/html/rfc8032
18
+
19
+ ## What is Ed25519?
20
+
21
+ Ed25519 is a modern implementation of a [Schnorr signature] system using
22
+ elliptic curve groups.
23
+
24
+ Ed25519 provides a 128-bit security level, that is to say, all known attacks
25
+ take at least 2^128 operations, providing the same security level as AES-128,
26
+ NIST P-256, and RSA-3072.
27
+
28
+ ![Ed25519 Diagram](https://raw.github.com/cryptosphere/ed25519/master/ed25519.png)
29
+
30
+ Ed25519 has a number of unique properties that make it one of the best-in-class
31
+ digital signature algorithms:
32
+
33
+ * ***Small keys***: Ed25519 keys are only 256-bits (32 bytes), making them
34
+ small enough to easily copy around. Ed25519 also allows the public key
35
+ to be derived from the private key, meaning that it doesn't need to be
36
+ included in a serialized private key in cases you want both.
37
+ * ***Small signatures***: Ed25519 signatures are only 512-bits (64 bytes),
38
+ one of the smallest signature sizes available.
39
+ * ***Deterministic***: Unlike (EC)DSA, Ed25519 does not rely on an entropy
40
+ source when signing messages. This can be a potential attack vector if
41
+ the entropy source is not generating good random numbers. Ed25519 avoids
42
+ this problem entirely and will always generate the same signature for the
43
+ same data.
44
+ * ***Collision Resistant***: Hash-function collisions do not break this
45
+ system. This adds a layer of defense against the possibility of weakness
46
+ in the selected hash function.
47
+
48
+ You can read more on [Dan Bernstein's Ed25519 site](http://ed25519.cr.yp.to/).
49
+
50
+ [Schnorr signature]: https://en.wikipedia.org/wiki/Schnorr_signature
51
+
52
+ ## Installation
53
+
54
+ Add this line to your application's Gemfile:
55
+
56
+ gem 'ed25519'
57
+
58
+ And then execute:
59
+
60
+ $ bundle
61
+
62
+ Or install it yourself as:
63
+
64
+ $ gem install ed25519
65
+
66
+ # Usage
67
+
68
+ Require **ed25519.rb** in your Ruby program:
69
+
70
+ ```ruby
71
+ require "ed25519"
72
+ ```
73
+
74
+ Generate a new random signing key:
75
+
76
+ ```ruby
77
+ signing_key = Ed25519::SigningKey.generate
78
+ ```
79
+
80
+ Sign a message with the signing key:
81
+
82
+ ```ruby
83
+ signature = signing_key.sign(message)
84
+ ```
85
+
86
+ Obtain the verify key for a given signing key:
87
+
88
+ ```ruby
89
+ verify_key = signing_key.verify_key
90
+ ```
91
+
92
+ Check the validity of a signature:
93
+
94
+ ```ruby
95
+ verify_key.verify(signature, message)
96
+ ```
97
+
98
+ The verify method will return `true` or `false` depending on if the signature matches.
99
+
100
+ ### Serializing Keys
101
+
102
+ Keys can be serialized as 32-byte binary strings as follows:
103
+
104
+ ```ruby
105
+ signature_key_bytes = signing_key.to_bytes
106
+ verify_key_bytes = verify_key.to_bytes
107
+ ```
108
+
109
+ The binary serialization can be passed directly into the constructor for a given key type:
110
+
111
+ ```ruby
112
+ signing_key = Ed25519::SigningKey.new(signature_key_bytes)
113
+ verify_key = Ed25519::VerifyKey.new(verify_key_bytes)
114
+ ```
115
+
116
+ ## Security Notes
117
+
118
+ The Ed25519 "ref" implementation from SUPERCOP was lovingly crafted by expert
119
+ security boffins with great care taken to prevent timing attacks. The same
120
+ cannot be said for the C code used in the **ed25519.rb** C extension or in the
121
+ entirety of the provided Java implementation.
122
+
123
+ Care should be taken to avoid leaking to the attacker how long it takes to
124
+ generate keys or sign messages (at least until **ed25519.rb** itself can be audited
125
+ by experts who can fix any potential timing vulnerabilities)
126
+
127
+ **ed25519.rb** relies on a strong `SecureRandom` for key generation.
128
+ Weaknesses in the random number source can potentially result in insecure keys.
129
+
130
+ ## JRuby Notes
131
+
132
+ **ed25519.rb** provides a pure Java backend, however this backend is much slower
133
+ than the C-based version. While **ed25519.rb** will function on JRuby, it may be
134
+ too slow to be usable for a given use case. You should benchmark your
135
+ application to determine if it will be fast enough for your purposes.
136
+
137
+ ## Contributing
138
+
139
+ Bug reports and pull requests are welcome on GitHub at https://github.com/cryptosphere/ed25519.
140
+ This project is intended to be a safe, welcoming space for collaboration,
141
+ and contributors areexpected to adhere to the [Contributor Covenant](http://contributor-covenant.org)
142
+ code of conduct.
143
+
144
+ ## License
145
+
146
+ Copyright (c) 2012-2017 Tony Arcieri. Distributed under the MIT License. See
147
+ [LICENSE] for further details.
148
+
149
+ [LICENSE]: https://github.com/cryptosphere/ed25519/blob/master/LICENSE
150
+
151
+ ## Code of Conduct
152
+
153
+ Everyone interacting in the **ed25519.rb** project’s codebases, issue trackers, chat
154
+ rooms and mailing lists is expected to follow the [code of conduct].
155
+
156
+ [code of conduct]: https://github.com/cryptosphere/ed25519/blob/master/CODE_OF_CONDUCT.md
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+
5
+ require "rake/clean"
6
+ CLEAN.include("**/*.o", "**/*.so", "**/*.bundle", "pkg", "tmp")
7
+
8
+ if defined? JRUBY_VERSION
9
+ require "rake/javaextensiontask"
10
+ Rake::JavaExtensionTask.new("ed25519_engine") do |ext|
11
+ ext.ext_dir = "ext/ed25519"
12
+ end
13
+ else
14
+ require "rake/extensiontask"
15
+
16
+ Rake::ExtensionTask.new("ed25519_engine") do |ext|
17
+ ext.ext_dir = "ext/ed25519"
18
+ end
19
+ end
20
+
21
+ require "rspec/core/rake_task"
22
+ RSpec::Core::RakeTask.new
23
+
24
+ require "rubocop/rake_task"
25
+ RuboCop::RakeTask.new
26
+
27
+ task default: %w[compile spec rubocop]
@@ -0,0 +1,32 @@
1
+
2
+ # frozen_string_literal: true
3
+
4
+ require File.expand_path("lib/ed25519/version", __dir__)
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ed25519"
8
+ spec.version = Ed25519::VERSION
9
+ spec.authors = ["Tony Arcieri"]
10
+ spec.email = ["tony.arcieri@gmail.com"]
11
+ spec.summary = "An efficient digital signature library providing the Ed25519 algorithm"
12
+ spec.description = <<-DESCRIPTION.strip.gsub(/\s+/, " ")
13
+ A Ruby binding to the Ed25519 elliptic curve public-key signature system
14
+ described in RFC 8032.
15
+ DESCRIPTION
16
+ spec.homepage = "https://github.com/cryptosphere/ed25519"
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ if defined? JRUBY_VERSION
23
+ spec.platform = "jruby"
24
+ spec.files << "lib/ed25519_engine.jar"
25
+ else
26
+ spec.platform = Gem::Platform::RUBY
27
+ spec.extensions = "ext/ed25519/extconf.rb"
28
+ end
29
+
30
+ spec.required_ruby_version = ">= 2.2.2"
31
+ spec.add_development_dependency "bundler", "~> 1.16"
32
+ end
Binary file
@@ -0,0 +1,4 @@
1
+ #define CRYPTO_SECRETKEYBYTES 64
2
+ #define CRYPTO_PUBLICKEYBYTES 32
3
+ #define CRYPTO_BYTES 64
4
+
@@ -0,0 +1,6 @@
1
+ #ifndef crypto_int32_h
2
+ #define crypto_int32_h
3
+
4
+ typedef int crypto_int32;
5
+
6
+ #endif
@@ -0,0 +1,13 @@
1
+ #ifndef crypto_sign_edwards25519sha512batch_H
2
+ #define crypto_sign_edwards25519sha512batch_H
3
+
4
+ #define SECRETKEYBYTES 64
5
+ #define PUBLICKEYBYTES 32
6
+ #define SIGNATUREBYTES 64
7
+
8
+ extern int crypto_sign(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *);
9
+ extern int crypto_sign_open(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *);
10
+ extern int crypto_sign_keypair(unsigned char *,unsigned char *);
11
+ extern int crypto_sign_publickey(unsigned char *pk, unsigned char *sk, unsigned char *seed);
12
+
13
+ #endif