Class: Paillier::PrivateKey

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(l, m) ⇒ PrivateKey

:nodoc:



5
6
7
8
# File 'lib/paillier/keys.rb', line 5

def initialize(l,m) # :nodoc:
	@l = l
	@m = m
end

Instance Attribute Details

#lObject (readonly)

:nodoc:



3
4
5
# File 'lib/paillier/keys.rb', line 3

def l
  @l
end

#mObject (readonly)

:nodoc:



3
4
5
# File 'lib/paillier/keys.rb', line 3

def m
  @m
end

Class Method Details

.from_s(string) ⇒ Object

De-serialize a private key string back into object form

Example: >> s = priv.to_s >> newPriv = Paillier::PrivateKey.from_s(s)

> #<Paillier::PrivateKey>

Arguments: string (String)



30
31
32
33
# File 'lib/paillier/keys.rb', line 30

def PrivateKey.from_s(string)
	l,m = string.split(",")
	return PrivateKey.new(l.to_i, m.to_i)
end

Instance Method Details

#to_sObject

Serialize a private key to string form

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

> “110107191408889682017277609474037601699496910…”



17
18
19
# File 'lib/paillier/keys.rb', line 17

def to_s
	return "#{@l},#{@m}"
end