ring_sig 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 99fef8c39d8ec2e0d7fc86ed6f25a09625940dfd
4
- data.tar.gz: 9e989018593339b1148a858c2b508c6cc17fc016
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWJjNzNiMmVjMTJjMDY1YzU2M2QyY2MxM2ExZDkwYTQxNzUwMmE5MA==
5
+ data.tar.gz: !binary |-
6
+ MDhiZDVlZTVmYzc2YWZkYTIxY2U1NjgyOWNlMzY2YWIyM2E0MDAxMQ==
5
7
  SHA512:
6
- metadata.gz: 5f0f5ec506578ffa6e9a6a7593f4418303a9f65be9b9cac64a3176cbf253de76f956efe56c935ecd065bba18f19508972c2ff06f0df9d710f94274fc779e58a0
7
- data.tar.gz: e8527bea3482085ea27a8a77334f497b4922cc14f969f98a27981d5d239c6e129386fe40229b90ea35f4b23a75e5a3fe7823e9c44ff822af6a632256fd9785c0
8
+ metadata.gz: !binary |-
9
+ YzdiMzZkNzBlNTY2M2U3NzY1NmE5NTViZTJkYWY5ZjFjMzg5MjIyYzNiM2E3
10
+ MjBhN2EyNmVmOTdiMTQwYzdmODliOGIyNzJkMzdiYzIzMmVkMGZiNThiZTQ2
11
+ MmFhZDcwZWZjMDY2ZDcyZDgxOWI4ZjY1ZDUzM2IzNTA4NWI2YzU=
12
+ data.tar.gz: !binary |-
13
+ ZWMxNjk0YzE3NzM0YmQzYjcwMDdjM2NiODBhYWFlNTA1MmQ5MmQxNWY4MDQ1
14
+ Njk4M2E1ZGM4OTA3MmQ5ZTMwZThiYmY4ZTRhZTA4ZmE2MmNlZTZiMTYzMGY4
15
+ ZWU1MTQ2ZmZlNDk2ZTUzMjUyMmRjMTFhOWY2OGU4ZGU1NjFlMmE=
data/.travis.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  script: "rspec"
2
2
  rvm:
3
+ - 1.9.3
3
4
  - 2.0.0
4
5
  - 2.1.0
5
- - ruby-head
6
+ - jruby-19mode
7
+ - rbx
data/.yardopts CHANGED
@@ -1,3 +1,7 @@
1
1
  --readme README.md
2
2
  --markup markdown
3
- lib/ring_sig/**/*.rb
3
+ lib/ring_sig.rb
4
+ lib/ring_sig/*.rb
5
+ -
6
+ CHANGELOG.md
7
+ LICENSE
data/CHANGELOG.md ADDED
@@ -0,0 +1,61 @@
1
+ Change log
2
+ ====
3
+
4
+ This gem follows [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html).
5
+ All classes and public methods are part of the public API, unless explicitly
6
+ noted otherwise in their documentation.
7
+
8
+ 0.2.0
9
+ ----
10
+ Released on 2014-09-12
11
+
12
+ This release breaks API compatibility with version 0.1.0.
13
+
14
+ - Add support for ruby 1.9, including jruby-19mode.
15
+ - Add `RingSig.default_group` and `RingSig.defaut_hash_algorithm` attributes.
16
+ - Change `Hasher` constructor so that `group` and `hash_algorithm` attributes
17
+ are passed in as options rather than explicit arguments.
18
+
19
+
20
+ 0.1.0
21
+ ----
22
+ Released on 2014-09-11
23
+
24
+ This release breaks API compatibility with version 0.0.1.
25
+
26
+ - Split the `Key` class into `PrivateKey` and `PublicKey`, which better
27
+ encapsulate the functionality of each.
28
+ - The `sign` and `key_image` methods are placed in the `PrivateKey` class.
29
+ - Remove the `drop_private_key` method from `Key`. Instead, a new method simply
30
+ called `public_key` is included in both `PrivateKey` and `PublicKey`.
31
+ - Add methods `to_hex`, `to_octet`, `from_hex`, and `from_octet` to both
32
+ `PrivateKey` and `PublicKey` classes.
33
+ - Add `==` methods to `PrivateKey` and `PublicKey`
34
+ - Add `point` attribute to `PublicKey` which stores the actual public key.
35
+ - Add `point` method to `PrivateKey` which references the public key's point.
36
+ - Add `value` attribute to `PrivateKey` which stores the actual private key.
37
+
38
+ 0.0.1
39
+ ----
40
+ Released on 2014-09-09
41
+
42
+ All core functionality is implemented:
43
+
44
+ - `Key` class
45
+ - `sign` method
46
+ - `key_image` method
47
+ - `drop_private_key` method
48
+ - `public_key` and `private_key` attributes
49
+ - `group` and `hash_algorithm` attributes
50
+ - `Signature` class
51
+ - `verify` method
52
+ - `components` method
53
+ - `to_hex`, `to_der`, `from_hex`, and `from_der` methods
54
+ - `key_image`, `c_array`, and `r_array` attributes
55
+ - `group` and `hash_algorithm` attributes
56
+ - `Hasher` class
57
+ - `hash_string` method
58
+ - `hash_array` method
59
+ - `hash_point` method
60
+ - `shuffle` method
61
+ - `group` and `algorithm` attributes
data/README.md CHANGED
@@ -92,6 +92,15 @@ ECDSA group. You can specify alternates if you'd like:
92
92
  key = RingSig::PrivateKey.new(1, group: ECDSA::Group::Secp256r1, hash_algorithm: OpenSSL::Digest::RIPEMD160)
93
93
  ```
94
94
 
95
+ You can also specify module-wide alternate defaults:
96
+ ```ruby
97
+ RingSig.default_group = ECDSA::Group::Secp256r1
98
+ RingSig.default_hash_algorithm = OpenSSL::Digest::RIPEMD160
99
+ key = RingSig::PrivateKey.new(1)
100
+ puts key.group # ECDSA::Group::Secp256r1
101
+ puts key.hash_algorithm # OpenSSL::Digest::RIPEMD160
102
+ ```
103
+
95
104
  ## Standards
96
105
 
97
106
  There currently aren't any standards around Ring Signatures that I know of. This
@@ -111,7 +120,7 @@ If you'd like to contribute code, these are the general steps:
111
120
 
112
121
  1. Fork and clone the repository
113
122
  2. Create your feature branch (`git checkout -b my-new-feature`)
114
- 3. Commit your changes (`git commit -a 'Added some feature'`)
123
+ 3. Commit your changes (`git commit -m 'Added some feature'`)
115
124
  4. Push to the branch (`git push origin my-new-feature`)
116
125
  5. Create a Pull Request
117
126
 
data/lib/ring_sig.rb CHANGED
@@ -9,4 +9,18 @@ require 'ring_sig/ecdsa/point'
9
9
 
10
10
  # The top-level module for the RingSig gem.
11
11
  module RingSig
12
+ class << self
13
+ # @return [ECDSA::Group] the default group. This group will be used in any
14
+ # method in the RingSig library that calls for a group, if none is
15
+ # specified. Starts as `ECDSA::Group::Secp256k1`.
16
+ attr_accessor :default_group
17
+
18
+ # @return [#digest] the default hash algorithm. This hash algorithm will be
19
+ # used in any method in the RingSig library that calls for a hash
20
+ # algorithm, if none is specified. Starts as `OpenSSL::Digest::SHA256`.
21
+ attr_accessor :default_hash_algorithm
22
+ end
23
+
24
+ self.default_group = ECDSA::Group::Secp256k1
25
+ self.default_hash_algorithm = OpenSSL::Digest::SHA256
12
26
  end
@@ -5,16 +5,17 @@ module RingSig
5
5
  attr_reader :group
6
6
 
7
7
  # @return [#digest]
8
- attr_reader :algorithm
9
-
8
+ attr_reader :hash_algorithm
10
9
 
11
10
  # Creates a new instance of {Hasher}.
12
11
  #
13
- # @param group [ECDSA::Group]
14
- # @param algorithm [#digest]
15
- def initialize(group, algorithm)
16
- @group = group
17
- @algorithm = algorithm
12
+ # @param opts [Hash]
13
+ # @option opts :group [ECDSA::Group]
14
+ # @option opts :hash_algorithm [#digest]
15
+ def initialize(opts = {})
16
+ @group = opts.delete(:group) { RingSig.default_group }
17
+ @hash_algorithm = opts.delete(:hash_algorithm) { RingSig.default_hash_algorithm }
18
+ raise ArgumentError, "Unknown options #{opts.keys.join(', ')}" unless opts.empty?
18
19
  end
19
20
 
20
21
  # Continuously hashes until a value less than the group's order is found.
@@ -24,7 +25,7 @@ module RingSig
24
25
  def hash_string(s)
25
26
  n = nil
26
27
  loop do
27
- s = @algorithm.digest(s)
28
+ s = @hash_algorithm.digest(s)
28
29
  n = s.unpack('H*').first.to_i(16)
29
30
  break if n < @group.order
30
31
  end
@@ -20,38 +20,50 @@ module RingSig
20
20
  # Creates a new instance of {PrivateKey}.
21
21
  #
22
22
  # @param value [Integer]
23
- # @param group [ECDSA::Group]
24
- # @param hash_algorithm [#digest]
25
- def initialize(value, group: ECDSA::Group::Secp256k1, hash_algorithm: OpenSSL::Digest::SHA256)
23
+ # @param opts [Hash]
24
+ # @option opts :group [ECDSA::Group]
25
+ # @option opts :hash_algorithm [#digest]
26
+ def initialize(value, opts = {})
27
+ @group = opts.delete(:group) { RingSig.default_group }
28
+ @hash_algorithm = opts.delete(:hash_algorithm) { RingSig.default_hash_algorithm }
29
+ raise ArgumentError, "Unknown opts: #{opts.keys.join(', ')}" unless opts.empty?
30
+
26
31
  raise ArgumentError, "Value is not an integer" unless value.is_a?(Integer)
27
32
  raise ArgumentError, "Value is too small" if value < 1
28
33
  raise ArgumentError, "Value is too large" if value >= group.order
29
34
 
30
35
  @value = value
31
36
  @public_key = PublicKey.new(group.generator.multiply_by_scalar(value), group: group)
32
-
33
- @group = group
34
- @hash_algorithm = hash_algorithm
35
- @hasher = Hasher.new(group, hash_algorithm)
37
+ @hasher = Hasher.new(group: group, hash_algorithm: hash_algorithm)
36
38
  end
37
39
 
38
40
  # Creates a new instance of {PrivateKey} from a hex string.
39
41
  #
40
- # @param octet_string [String]
41
- # @param group [ECDSA::Group]
42
- # @param hash_algorithm [#digest]
42
+ # @param hex_string [String]
43
+ # @param opts [Hash]
44
+ # @option opts :group [ECDSA::Group]
45
+ # @option opts :hash_algorithm [#digest]
43
46
  # @return [PrivateKey]
44
- def self.from_hex(hex_string, group: ECDSA::Group::Secp256k1, hash_algorithm: OpenSSL::Digest::SHA256)
47
+ def self.from_hex(hex_string, opts = {})
48
+ group = opts.delete(:group) { RingSig.default_group }
49
+ hash_algorithm = opts.delete(:hash_algorithm) { RingSig.default_hash_algorithm }
50
+ raise ArgumentError, "Unknown opts: #{opts.keys.join(', ')}" unless opts.empty?
51
+
45
52
  self.from_octet([hex_string].pack('H*'), group: group, hash_algorithm: hash_algorithm)
46
53
  end
47
54
 
48
55
  # Creates a new instance of {PrivateKey} from an octet string.
49
56
  #
50
57
  # @param octet_string [String]
51
- # @param group [ECDSA::Group]
52
- # @param hash_algorithm [#digest]
58
+ # @param opts [Hash]
59
+ # @option opts :group [ECDSA::Group]
60
+ # @option opts :hash_algorithm [#digest]
53
61
  # @return [PrivateKey]
54
- def self.from_octet(octet_string, group: ECDSA::Group::Secp256k1, hash_algorithm: OpenSSL::Digest::SHA256)
62
+ def self.from_octet(octet_string, opts = {})
63
+ group = opts.delete(:group) { RingSig.default_group }
64
+ hash_algorithm = opts.delete(:hash_algorithm) { RingSig.default_hash_algorithm }
65
+ raise ArgumentError, "Unknown opts: #{opts.keys.join(', ')}" unless opts.empty?
66
+
55
67
  value = ECDSA::Format::FieldElementOctetString.decode(octet_string, group.field)
56
68
  PrivateKey.new(value, group: group, hash_algorithm: hash_algorithm)
57
69
  end
@@ -96,7 +108,7 @@ module RingSig
96
108
  c_array, r_array = generate_c_r(all_keys, q_array, w_array, challenge)
97
109
 
98
110
  public_keys = all_keys.map(&:public_key)
99
- signature = Signature.new(key_image, c_array, r_array, group: group, hash_algorithm: @hasher.algorithm)
111
+ signature = Signature.new(key_image, c_array, r_array, group: group, hash_algorithm: hash_algorithm)
100
112
 
101
113
  [signature, public_keys]
102
114
  end
@@ -13,30 +13,41 @@ module RingSig
13
13
  # Creates a new instance of {PublicKey}.
14
14
  #
15
15
  # @param point [ECDSA::Point]
16
- # @param group [ECDSA::Group]
17
- def initialize(point, group: ECDSA::Group::Secp256k1)
16
+ # @param opts [Hash]
17
+ # @option opts :group [ECDSA::Group]
18
+ def initialize(point, opts = {})
19
+ @group = opts.delete(:group) { RingSig.default_group }
20
+ raise ArgumentError, "Unknown opts: #{opts.keys.join(', ')}" unless opts.empty?
21
+
18
22
  raise ArgumentError, "Point is not an ECDSA::Point" unless point.is_a?(ECDSA::Point)
19
23
  raise ArgumentError, "Point is not on the group's curve" unless group.include?(point)
20
24
 
21
25
  @point = point
22
- @group = group
23
26
  end
24
27
 
25
28
  # Creates a new instance of {PublicKey} from a hex string.
26
29
  #
27
30
  # @param hex_string [String]
28
- # @param group [ECDSA::Group]
31
+ # @param opts [Hash]
32
+ # @option opts :group [ECDSA::Group]
29
33
  # @return [PublicKey]
30
- def self.from_hex(hex_string, group: ECDSA::Group::Secp256k1)
34
+ def self.from_hex(hex_string, opts = {})
35
+ group = opts.delete(:group) { RingSig.default_group }
36
+ raise ArgumentError, "Unknown opts: #{opts.keys.join(', ')}" unless opts.empty?
37
+
31
38
  self.from_octet([hex_string].pack('H*'), group: group)
32
39
  end
33
40
 
34
41
  # Creates a new instance of {PublicKey} from an octet string.
35
42
  #
36
43
  # @param octet_string [String]
37
- # @param group [ECDSA::Group]
44
+ # @param opts [Hash]
45
+ # @option opts :group [ECDSA::Group]
38
46
  # @return [PublicKey]
39
- def self.from_octet(octet_string, group: ECDSA::Group::Secp256k1)
47
+ def self.from_octet(octet_string, opts = {})
48
+ group = opts.delete(:group) { RingSig.default_group }
49
+ raise ArgumentError, "Unknown opts: #{opts.keys.join(', ')}" unless opts.empty?
50
+
40
51
  point = ECDSA::Format::PointOctetString.decode(octet_string, group)
41
52
  PublicKey.new(point, group: group)
42
53
  end
@@ -44,18 +55,26 @@ module RingSig
44
55
  # Encodes this public key into an octet string. The encoded data contains
45
56
  # only the point. It does not contain the group.
46
57
  #
47
- # @param compression [Boolean]
58
+ # @param opts [Hash]
59
+ # @option opts :compression [Boolean]
48
60
  # @return [String]
49
- def to_hex(compression: true)
61
+ def to_hex(opts = {})
62
+ compression = opts.delete(:compression) { true }
63
+ raise ArgumentError, "Unknown opts: #{opts.keys.join(', ')}" unless opts.empty?
64
+
50
65
  to_octet(compression: compression).unpack('H*').first
51
66
  end
52
67
 
53
68
  # Encodes this public key into a hex string. The encoded data contains
54
69
  # only the point. It does not contain the group.
55
70
  #
56
- # @param compression [Boolean]
71
+ # @param opts [Hash]
72
+ # @option opts :compression [Boolean]
57
73
  # @return [String]
58
- def to_octet(compression: true)
74
+ def to_octet(opts = {})
75
+ compression = opts.delete(:compression) { true }
76
+ raise ArgumentError, "Unknown opts: #{opts.keys.join(', ')}" unless opts.empty?
77
+
59
78
  ECDSA::Format::PointOctetString.encode(point, compression: compression)
60
79
  end
61
80
 
@@ -21,26 +21,34 @@ module RingSig
21
21
  # @param key_image [ECDSA::Point]
22
22
  # @param c_array [Array<Integer>]
23
23
  # @param r_array [Array<Integer>]
24
- # @param group [ECDSA::Group]
25
- # @param hash_algorithm [#digest]
26
- def initialize(key_image, c_array, r_array, group: ECDSA::Group::Secp256k1, hash_algorithm: OpenSSL::Digest::SHA256)
24
+ # @param opts [Hash]
25
+ # @option opts :group [ECDSA::Group]
26
+ # @option opts :hash_algorithm [#digest]
27
+ def initialize(key_image, c_array, r_array, opts = {})
28
+ @group = opts.delete(:group) { RingSig.default_group }
29
+ @hash_algorithm = opts.delete(:hash_algorithm) { RingSig.default_hash_algorithm }
30
+ raise ArgumentError, "Unknown opts: #{opts.keys.join(', ')}" unless opts.empty?
31
+
27
32
  @key_image, @c_array, @r_array = key_image, c_array, r_array
28
33
  key_image.is_a?(ECDSA::Point) or raise ArgumentError, 'key_image is not an ECDSA::Point.'
29
34
  c_array.is_a?(Array) or raise ArgumentError, 'c_array is not an array.'
30
35
  r_array.is_a?(Array) or raise ArgumentError, 'r_array is not an array.'
31
36
 
32
- @group = group
33
- @hash_algorithm = hash_algorithm
34
- @hasher = Hasher.new(group, hash_algorithm)
37
+ @hasher = Hasher.new(group: group, hash_algorithm: hash_algorithm)
35
38
  end
36
39
 
37
40
  # Creates a new instance of {Signature} from a der string.
38
41
  #
39
42
  # @param der_string [String]
40
- # @param group [ECDSA::Group]
41
- # @param hash_algorithm [#digest]
43
+ # @param opts [Hash]
44
+ # @option opts :group [ECDSA::Group]
45
+ # @option opts :hash_algorithm [#digest]
42
46
  # @return [Signature]
43
- def self.from_der(der_string, group: ECDSA::Group::Secp256k1, hash_algorithm: OpenSSL::Digest::SHA256)
47
+ def self.from_der(der_string, opts = {})
48
+ group = opts.delete(:group) { RingSig.default_group }
49
+ hash_algorithm = opts.delete(:hash_algorithm) { RingSig.default_hash_algorithm }
50
+ raise ArgumentError, "Unknown opts: #{opts.keys.join(', ')}" unless opts.empty?
51
+
44
52
  asn1 = OpenSSL::ASN1.decode(der_string)
45
53
 
46
54
  key_image = ECDSA::Format::PointOctetString.decode(asn1.value[0].value, group)
@@ -53,10 +61,15 @@ module RingSig
53
61
  # Creates a new instance of {Signature} from a hex string.
54
62
  #
55
63
  # @param hex_string [String]
56
- # @param group [ECDSA::Group]
57
- # @param hash_algorithm [#digest]
64
+ # @param opts [Hash]
65
+ # @option opts :group [ECDSA::Group]
66
+ # @option opts :hash_algorithm [#digest]
58
67
  # @return [Signature]
59
- def self.from_hex(hex_string, group: ECDSA::Group::Secp256k1, hash_algorithm: OpenSSL::Digest::SHA256)
68
+ def self.from_hex(hex_string, opts = {})
69
+ group = opts.delete(:group) { RingSig.default_group }
70
+ hash_algorithm = opts.delete(:hash_algorithm) { RingSig.default_hash_algorithm }
71
+ raise ArgumentError, "Unknown opts: #{opts.keys.join(', ')}" unless opts.empty?
72
+
60
73
  Signature.from_der([hex_string].pack('H*'), group: group, hash_algorithm: hash_algorithm)
61
74
  end
62
75
 
@@ -64,9 +77,13 @@ module RingSig
64
77
  # the key_image, c_array, and r_array. It does not contain the group
65
78
  # or hash_algorithm.
66
79
  #
67
- # @param compression [Boolean]
80
+ # @param opts [Hash]
81
+ # @option opts :compression [Boolean]
68
82
  # @return [String]
69
- def to_der(compression: true)
83
+ def to_der(opts = {})
84
+ compression = opts.delete(:compression) { true }
85
+ raise ArgumentError, "Unknown opts: #{opts.keys.join(', ')}" unless opts.empty?
86
+
70
87
  OpenSSL::ASN1::Sequence.new([
71
88
  OpenSSL::ASN1::OctetString.new(ECDSA::Format::PointOctetString.encode(key_image, compression: compression)),
72
89
  OpenSSL::ASN1::Sequence.new(c_array.map{|i| OpenSSL::ASN1::Integer.new(i)}),
@@ -78,9 +95,13 @@ module RingSig
78
95
  # the key_image, c_array, and r_array. It does not contain the group
79
96
  # or hash_algorithm.
80
97
  #
81
- # @param compression [Boolean]
98
+ # @param opts [Hash]
99
+ # @option opts :compression [Boolean]
82
100
  # @return [String]
83
- def to_hex(compression: true)
101
+ def to_hex(opts = {})
102
+ compression = opts.delete(:compression) { true }
103
+ raise ArgumentError, "Unknown opts: #{opts.keys.join(', ')}" unless opts.empty?
104
+
84
105
  to_der(compression: compression).unpack('H*').first
85
106
  end
86
107
 
@@ -1,3 +1,4 @@
1
1
  module RingSig
2
- VERSION = '0.1.0'
2
+ # This gem's version.
3
+ VERSION = '0.2.0'
3
4
  end
data/ring_sig.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.add_development_dependency 'simplecov', '~> 0'
21
21
  s.add_development_dependency 'yard', '~> 0'
22
22
  s.add_development_dependency 'markdown', '~> 1'
23
- s.add_development_dependency 'redcarpet', '~> 3'
23
+ s.add_development_dependency 'redcarpet', '~> 3' unless RUBY_PLATFORM == 'java'
24
24
 
25
25
  s.add_runtime_dependency 'ecdsa', '~> 1.1'
26
26
  end
data/spec/hasher_spec.rb CHANGED
@@ -4,7 +4,7 @@ describe RingSig::Hasher do
4
4
  context 'Standard: SHA256 hash algorithm, secp256k1 group' do
5
5
  group = ECDSA::Group::Secp256k1
6
6
  hash_algorithm = OpenSSL::Digest::SHA256
7
- hasher = RingSig::Hasher.new(group, hash_algorithm)
7
+ hasher = RingSig::Hasher.new(group: group, hash_algorithm: hash_algorithm)
8
8
 
9
9
  describe '#hash_string' do
10
10
  it 'hashes "a"' do
@@ -67,7 +67,7 @@ describe RingSig::Hasher do
67
67
  SimpleHashAlgorithm
68
68
  end
69
69
 
70
- let(:hasher) { RingSig::Hasher.new(group, hash_algorithm) }
70
+ let(:hasher) { RingSig::Hasher.new(group: group, hash_algorithm: hash_algorithm) }
71
71
 
72
72
  # We test the hash_algorithm itself in this context, since we implemented our own simple hash_algorithm.
73
73
  shared_examples_for 'hash algorithm' do |input, expected_value|
@@ -104,4 +104,38 @@ describe RingSig::PrivateKey do
104
104
  expect(sig.verify(message, public_keys)).to be true
105
105
  end
106
106
  end
107
+
108
+ context 'alternate defaults' do
109
+ before(:all) do
110
+ @old_default_group = RingSig.default_group
111
+ @old_default_hash_algorithm = RingSig.default_hash_algorithm
112
+ RingSig.default_group = ECDSA::Group::Secp256r1
113
+ RingSig.default_hash_algorithm = OpenSSL::Digest::RIPEMD160
114
+
115
+ @key = RingSig::PrivateKey.new(1)
116
+ @foreign_keys = [
117
+ RingSig::PrivateKey.new(2).public_key,
118
+ RingSig::PrivateKey.new(3).public_key,
119
+ RingSig::PrivateKey.new(4).public_key,
120
+ ]
121
+ end
122
+
123
+ after(:all) do
124
+ RingSig.default_group = @old_default_group
125
+ RingSig.default_hash_algorithm = @old_default_hash_algorithm
126
+ end
127
+
128
+ describe '#sign' do
129
+ it 'signs and verifies' do
130
+ sig, public_keys = @key.sign(message, @foreign_keys)
131
+
132
+ expect(sig.to_hex).to eq '3081e804210242ea46f23d6dc4e4515f2b1001734cf2c4a09b9ab169a588bf01a13b9e553de03067022100ffffffff00000000fffffffe714565846c5397cd4e5e24b41dfd02b75761d074021500881bf1e9c67d05c7a8a6ef93552a785246603436021500e17e885e1b5c59e80a5ed90ae26bea5067b3314a02146655e2724456f7d8d21238d797e0a809a3013337305a02150198482b6231394361df3ad5b577c70953b2572c9f02141cd9f8cc0df48519ecd6ad6e354ca634c8b604c20214361d1207afcdb5c041df20efac5496b26243403a0215008fddaf160ecfaed0c2048e6f018c933fc398e33b'
133
+
134
+ expected_public_keys = [0, 2, 1, 3].map{|i| ([@key] + @foreign_keys)[i].public_key}
135
+ expect(public_keys).to eq expected_public_keys
136
+
137
+ expect(sig.verify(message, public_keys)).to be true
138
+ end
139
+ end
140
+ end
107
141
  end
metadata CHANGED
@@ -1,125 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ring_sig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McCarthy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-11 00:00:00.000000000 Z
11
+ date: 2014-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: simplecov
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: markdown
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: redcarpet
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - "~>"
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
103
  version: '3'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - "~>"
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: '3'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: ecdsa
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ~>
116
116
  - !ruby/object:Gem::Version
117
117
  version: '1.1'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ~>
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.1'
125
125
  description: Ring Signatures allow someone to non-interactively sign a message which
@@ -129,9 +129,10 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
- - ".gitignore"
133
- - ".travis.yml"
134
- - ".yardopts"
132
+ - .gitignore
133
+ - .travis.yml
134
+ - .yardopts
135
+ - CHANGELOG.md
135
136
  - Gemfile
136
137
  - LICENSE
137
138
  - README.md
@@ -159,12 +160,12 @@ require_paths:
159
160
  - lib
160
161
  required_ruby_version: !ruby/object:Gem::Requirement
161
162
  requirements:
162
- - - ">="
163
+ - - ! '>='
163
164
  - !ruby/object:Gem::Version
164
165
  version: '0'
165
166
  required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  requirements:
167
- - - ">="
168
+ - - ! '>='
168
169
  - !ruby/object:Gem::Version
169
170
  version: '0'
170
171
  requirements: []