rsa-accumulator 0.2.0 → 0.3.0

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
  SHA256:
3
- metadata.gz: 9f38593cbe657293995ebc98f360b248664b552acaf748201f5fa5d4bf27d6aa
4
- data.tar.gz: b6d45c16e546ba04b788c41b9426943266cd5bff76b848f1f6fb5eac1e8ad193
3
+ metadata.gz: 3cd67f53e0e5ea3506878a26976007fe1a02e7727b9fba6ecc9fa88078dc9a99
4
+ data.tar.gz: d55e288f32e4cd7ef8691a9e9a15cb72ae8c6477969e1a4e110882fad751e58e
5
5
  SHA512:
6
- metadata.gz: 4b43ce23e5961c58adfab5a752a599117a2d13733fdbdab01f2cf608df8a2a99e949edee002e140dcaa3ab94664793b877420c9c9bdc14faa400e6aa6ab9f94f
7
- data.tar.gz: 24d9067f9931519c80159879ef4d5d0b125807d197c0ea3985e6f7ff8b0321915fa61e14463378856b8683f16d973a49d292d858b8cc332e51d89955bff82eb7
6
+ metadata.gz: 7eac33383c6998b3d4ece9c4ae554d3dea8359a12691f7e08b631a28d833e5a6ca10eec21b2b7c0b6cf3271d9b5b4b34c5f3a8b7a23f1bf1d699a15613470f8e
7
+ data.tar.gz: cc87f12d335f15e97dbdbb93175f1420928da5074ee489ca42cc60c729cea3ecda36ffa3ae5b56f756019f726131b4b978210e44382274ed970533402439266a
@@ -1,5 +1,5 @@
1
1
  module RSA
2
2
  module ACC
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -23,7 +23,7 @@ module RSA
23
23
  # Generate accumulator using RSA2048 modulus.
24
24
  # @return [RSA::Accumulator]
25
25
  def self.generate_rsa2048(hold_elements: false)
26
- new(RSA2048_MODULUS, RSA2048_UNKNOWN_ELEM, hold_elements)
26
+ new(RSA2048_MODULUS, RSA2048_UNKNOWN_ELEM, RSA2048_UNKNOWN_ELEM, hold_elements)
27
27
  end
28
28
 
29
29
  # Generate accumulator with random modulus.
@@ -31,20 +31,23 @@ module RSA
31
31
  # @return [RSA::Accumulator]
32
32
  def self.generate_random(bit_length = 3072, hold_elements: false)
33
33
  n = OpenSSL::PKey::RSA.generate(bit_length).n.to_i
34
- new(n, SecureRandom.random_number(n), hold_elements)
34
+ initial_value = SecureRandom.random_number(n)
35
+ new(n, initial_value, initial_value, hold_elements)
35
36
  end
36
37
 
37
38
  # Initialize accumulator
38
39
  # @param [Integer] n modulus
39
- # @param [Integer] value initial value
40
+ # @param [Integer] value a value of acc.
41
+ # @param [Integer] initial_acc a value of initial acc.
40
42
  # @param [Boolean] hold_elements
43
+ # @param [Integer] products product of all elements in acc, this param is enable only +hold_elements+ set true.
41
44
  # @return [RSA::Accumulator]
42
- def initialize(n, value, hold_elements)
45
+ def initialize(n, value, initial_acc, hold_elements, products = 1)
43
46
  @n = n
44
47
  @value = value
45
- @g = value
48
+ @g = initial_acc
46
49
  @hold_elements = hold_elements
47
- @products = 1 if hold_elements
50
+ @products = products if hold_elements
48
51
  puts "The feature which hold product of all elements is practical feature." if hold_elements
49
52
  end
50
53
 
@@ -155,8 +158,8 @@ module RSA
155
158
  def root_factor(*f)
156
159
  return [value] if f.size == 1
157
160
  half_n = f.size / 2
158
- g_l = RSA::Accumulator.new(n, value.pow(f[0...half_n].map.inject(:*), n), false)
159
- g_r = RSA::Accumulator.new(n, value.pow(f[half_n..-1].map.inject(:*), n), false)
161
+ g_l = RSA::Accumulator.new(n, value.pow(f[0...half_n].map.inject(:*), n), g, false)
162
+ g_r = RSA::Accumulator.new(n, value.pow(f[half_n..-1].map.inject(:*), n), g, false)
160
163
  l = g_r.root_factor(*f[0...half_n])
161
164
  r = g_l.root_factor(*f[half_n..-1])
162
165
  [l, r].flatten
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsa-accumulator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-14 00:00:00.000000000 Z
11
+ date: 2020-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbnacl