class Paillier::ZKP::ZKPCommit
Wrapper class used for containing the components of the ZKP
commitment
Public Class Methods
from_s(string)
click to toggle source
Deserializes a commitment
Example:
>> commit = Paillier::ZKP::ZKPCommit.from_s(commitment_string) => #<Paillier::ZKP::ZKPCommit: @a_s=[<a1>,<a2>, .. ,<an>], @e_s=[<e1>,<e2>, .. ,<en>], @z_s=[<z1>,<z2>, .. ,<zn>]>
Arguments:
commitment_string: Serialization of a commitment (String)
# File lib/paillier/zkp.rb, line 249 def ZKPCommit.from_s(string) # these will hold the final result from string-parsing a_s = Array.new e_s = Array.new z_s = Array.new # separate at the semicolons a_s_string, e_s_string, z_s_string = string.split(";") # separate at the commas a_s_strings = a_s_string.split(",") e_s_strings = e_s_string.split(",") z_s_strings = z_s_string.split(",") # convert into arrays of bignums for a in a_s_strings do a_s.push(OpenSSL::BN.new(a)) end for e in e_s_strings do e_s.push(OpenSSL::BN.new(e)) end for z in z_s_strings do z_s.push(OpenSSL::BN.new(z)) end # create the object with these arrays return ZKPCommit.new(a_s, e_s, z_s) end
Public Instance Methods
to_s()
click to toggle source
Serializes a commitment
Example:
>> myZKP = Paillier::ZKP.new(key, 65, [23, 38, 52, 65, 77, 94]) => [#<@p = plaintext>, #<@pubkey = <key>>, #<@ciphertext = <ciphertext>>, #<@cyphertext = <ciphertext>>, #<@commitment = <commitment>>] >> myZKP.commitment.to_s => "<a1>,<a2>,<a3>,<a4>,<a5>,<a6>,;<e1>,<e2>,<e3>,<e4>,<e5>,;<z1>,<z2>,<z3>,<z4>,<z5>,"
# File lib/paillier/zkp.rb, line 233 def to_s() a_s_string = @a_s.join(',') e_s_string = @e_s.join(',') z_s_string = @z_s.join(',') return "#{a_s_string};#{e_s_string};#{z_s_string}" end