cf-ruby-libecp 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MmU3Y2MyZGM1OTk2MDJmYWY3MzA3MTg1YzM3ODliMjg3OTE3MjQxYg==
5
- data.tar.gz: !binary |-
6
- N2U5NTU1NzQyMDI4NmJiMDc0ODhmYTc5MmU2NWYyNDhlMTg2ZTBmNA==
2
+ SHA1:
3
+ metadata.gz: 8dd57ce470ce52c97d77b1e7676656b577b26f63
4
+ data.tar.gz: ecd54d40dcdd125ea0bce6390232658f0ff3cadf
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NjUxZDRjNmQwZjE5NjJiMzM4ZDk1ZTMzM2Q5ZDExMTEyMTMyOWNhNTVhYWM2
10
- NjFkNDJmYmU1YWNhOTE4NjJlMWIzMTUwNTRiNjk3MWRjMzJmYWYwNDk5NjM0
11
- MGE3Nzk4MmE1NDY0OWU5ZDhjNDczMzc3YTIyMDEzNjE4MjhlNDQ=
12
- data.tar.gz: !binary |-
13
- MjJkZmE5ZWNjYjA5ZDk3MjU1YjRkMWM1ODllNzUwNzQ2NzgxOWYyZWQ4Y2I3
14
- YzI0YzQwMDU1NTY1ZWI4OGMzM2MxN2ViNWNkZTUwOTg4NGY3ZDgxZTBkM2Vi
15
- MzAzZWZiNmNlZmEzZGQyODU4MWI5Nzc0ZTkyOWIwMjU4ZDc3NWI=
6
+ metadata.gz: 4d9e7a9435fbf696a4ba2601dca1391452f94c2f42e6b077269b383ca35a5b2711e71c43b1c24f4556b4609c85b09d67e98ac38a517d572ee8099572d83739ab
7
+ data.tar.gz: af12ed6d16b99295749d6055fc2e85cf9db9eed9de800edd08b85883df6632bf6307f5e2d82c7d82646c8af998787fe80bdd898d48823619e5a8ee4bbd28a78e
data/.gitignore CHANGED
@@ -1 +1,3 @@
1
1
  /lib/libecp.so
2
+ Gemfile.lock
3
+ .idea/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in chainalysis.gemspec
4
+ gemspec
data/README.md CHANGED
@@ -27,7 +27,9 @@ used in Unix.
27
27
 
28
28
  #### OS X with Homebrew
29
29
 
30
- $ brew install gmp
30
+ $ brew tap homebrew/versions
31
+ $ brew install gmp4
32
+ $ CPPFLAGS=-I/usr/local/opt/gmp4/include LDFLAGS=-L/usr/local/opt/gmp4/lib gem install cf-ruby-libecp
31
33
 
32
34
  #### OS X with MacPorts
33
35
 
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'pry'
5
+
6
+ require_relative '../lib/libecp'
7
+
8
+ Pry.start
@@ -37,12 +37,21 @@ module LibEcp
37
37
 
38
38
  # Generates user id as a bytestring
39
39
  def self.gen_uid(user_id)
40
- (user_id >> 56 & 0xFF).chr + (user_id >> 48 & 0xFF).chr + (user_id >> 40 & 0xFF).chr + (user_id >> 32 & 0xFF).chr + (user_id >> 24 & 0xFF).chr + (user_id >> 16 & 0xFF).chr + (user_id >> 8 & 0xFF).chr + (user_id & 0xFF).chr
40
+ (
41
+ (user_id >> 56 & 0xFF).chr +
42
+ (user_id >> 48 & 0xFF).chr +
43
+ (user_id >> 40 & 0xFF).chr +
44
+ (user_id >> 32 & 0xFF).chr +
45
+ (user_id >> 24 & 0xFF).chr +
46
+ (user_id >> 16 & 0xFF).chr +
47
+ (user_id >> 8 & 0xFF).chr +
48
+ (user_id & 0xFF).chr
49
+ ).encode("ASCII-8BIT")
41
50
  end
42
51
 
43
52
  # Generates users private key, Arguments: user id bytestring (from gen_uid), password String
44
53
  def self.private_key(uid, pass)
45
- OpenSSL::Digest.digest("SHA224", uid + pass)
54
+ OpenSSL::Digest.digest("SHA224", uid + pass.encode("UTF-8").force_encoding("ASCII-8BIT"))
46
55
  end
47
56
 
48
57
  # Generates public key from private key
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cf-ruby-libecp"
3
- s.version = "0.2.0"
3
+ s.version = "0.2.2"
4
4
  s.summary = "Ruby LibECP Wrapper"
5
5
  s.description = "Ruby LibECP is a wrapper around LibECP, an elliptic-curve cryptography library for producing and verifying ECDSA signatures."
6
6
  s.email = "development@coinfloor.co.uk"
@@ -16,4 +16,9 @@ Gem::Specification.new do |s|
16
16
  s.add_dependency "ffi", "~> 1.9", ">= 1.9.3"
17
17
 
18
18
  s.required_ruby_version = ">= 1.9.3"
19
+
20
+ s.add_development_dependency "bundler", "~> 1.13"
21
+ s.add_development_dependency "rake"
22
+ s.add_development_dependency "rspec"
23
+ s.add_development_dependency "pry"
19
24
  end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe LibEcp do
4
+ let(:libecp) { described_class }
5
+
6
+ describe '.gen_uid' do
7
+ subject { libecp.gen_uid(1) }
8
+
9
+ it 'generates uid as bytestring and ensures ASCII-8BIT encoding' do
10
+ expect(subject).to eq("\x00\x00\x00\x00\x00\x00\x00\x01")
11
+ end
12
+
13
+ it 'ensures right encoding' do
14
+ expect(subject.encoding).to be Encoding::ASCII_8BIT
15
+ end
16
+ end
17
+
18
+ describe '.private_key' do
19
+ let(:user_id) { 1 }
20
+ let(:password) { 'password' }
21
+ let(:sha224_hash) { "\xD6i\xB5\"\xC6ea\n\xB6\x99\xA1h\x97V\xA87R\"\xC4\x88/\x15\x86\xD1\x86\xB0\x83\xB0".force_encoding('ASCII-8BIT') }
22
+
23
+ subject { libecp.private_key(libecp.gen_uid(user_id), password) }
24
+
25
+ it 'generates private key using SHA224' do
26
+ expect(subject).to eq(sha224_hash)
27
+ end
28
+
29
+ context 'when providing special characters' do
30
+ let(:user_id) { 128 }
31
+ let(:password) { "COPAú€rowentaú€#£ęćżźłów~!@#$%^&*()_+`-=[]{}:\";'<>?,./!\"£eqQWRTYEYUIOPLKJHGFDSAZXCVBNM#£ęćżźłów" }
32
+ let(:sha224_hash) { "\x9C\xC7\xB56D5|\x14\f\x80;\x9AI}2>') \x10\x1C\xC3\\1\xF7\x84\xDE\x01".force_encoding('ASCII-8BIT') }
33
+
34
+ it 'ensures proper processing' do
35
+ expect(subject).to eq(sha224_hash)
36
+ expect(subject.encoding).to be Encoding::ASCII_8BIT
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,6 @@
1
+ require 'pry'
2
+ require './lib/libecp'
3
+
4
+ RSpec.configure do |config|
5
+ config.order = :random
6
+ end
metadata CHANGED
@@ -1,35 +1,91 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cf-ruby-libecp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Coinfloor LTD
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-13 00:00:00.000000000 Z
11
+ date: 2017-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.9'
20
- - - ! '>='
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: 1.9.3
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ~>
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.9'
30
- - - ! '>='
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.9.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.13'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.13'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: pry
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
33
89
  description: Ruby LibECP is a wrapper around LibECP, an elliptic-curve cryptography
34
90
  library for producing and verifying ECDSA signatures.
35
91
  email: development@coinfloor.co.uk
@@ -38,11 +94,15 @@ extensions:
38
94
  - configure
39
95
  extra_rdoc_files: []
40
96
  files:
41
- - .gitignore
42
- - .gitmodules
97
+ - ".gitignore"
98
+ - ".gitmodules"
99
+ - ".rspec"
100
+ - Gemfile
43
101
  - LICENCE
44
102
  - Makefile
45
103
  - README.md
104
+ - Rakefile
105
+ - bin/console
46
106
  - configure
47
107
  - ext/libecp/.gitignore
48
108
  - ext/libecp/Makefile
@@ -53,6 +113,8 @@ files:
53
113
  - ext/libecp/libecp.h
54
114
  - lib/libecp.rb
55
115
  - libecp.gemspec
116
+ - spec/libecp/libecp_spec.rb
117
+ - spec/spec_helper.rb
56
118
  homepage: https://github.com/coinfloor/ruby-libecp
57
119
  licenses:
58
120
  - Apache License Version 2.0
@@ -63,17 +125,17 @@ require_paths:
63
125
  - lib
64
126
  required_ruby_version: !ruby/object:Gem::Requirement
65
127
  requirements:
66
- - - ! '>='
128
+ - - ">="
67
129
  - !ruby/object:Gem::Version
68
130
  version: 1.9.3
69
131
  required_rubygems_version: !ruby/object:Gem::Requirement
70
132
  requirements:
71
- - - ! '>='
133
+ - - ">="
72
134
  - !ruby/object:Gem::Version
73
135
  version: '0'
74
136
  requirements: []
75
137
  rubyforge_project:
76
- rubygems_version: 2.4.5
138
+ rubygems_version: 2.5.1
77
139
  signing_key:
78
140
  specification_version: 4
79
141
  summary: Ruby LibECP Wrapper