Class: Paillier::PublicKey

Inherits:
Object
  • Object
show all
Defined in:
lib/paillier/keys.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(n) ⇒ PublicKey

:nodoc:



39
40
41
42
43
# File 'lib/paillier/keys.rb', line 39

def initialize(n) # :nodoc:
  @n = n
  @n_sq = n * n
  @g = n+1
end

Instance Attribute Details

#gObject (readonly)

:nodoc:



37
38
39
# File 'lib/paillier/keys.rb', line 37

def g
  @g
end

#nObject (readonly)

:nodoc:



37
38
39
# File 'lib/paillier/keys.rb', line 37

def n
  @n
end

#n_sqObject (readonly)

:nodoc:



37
38
39
# File 'lib/paillier/keys.rb', line 37

def n_sq
  @n_sq
end

Class Method Details

.from_s(string) ⇒ Object

De-serialize a public key string back into object form

Example: >> s = pub.to_s >> newPub = Paillier::PublicKey.from_s(s)

> #<Paillier::PublicKey>

Arguments: string (String)



65
66
67
# File 'lib/paillier/keys.rb', line 65

def PublicKey.from_s(string)
  return PublicKey.new(string.to_i)
end

Instance Method Details

#to_sObject

Serialize a public key to string form

Example: >> priv, pub = Paillier.generateKeypair(2048) >> pub.to_s

> “110107191408889682017277609474037601699496910…”



52
53
54
# File 'lib/paillier/keys.rb', line 52

def to_s
  return "#{@n}"
end