Class: PolyPseudo::Pseudonym
- Inherits:
-
Object
- Object
- PolyPseudo::Pseudonym
show all
- Includes:
- PseudoId
- Defined in:
- lib/poly_pseudo/pseudonym.rb
Instance Attribute Summary
Attributes included from PseudoId
#creator, #point_1, #point_2, #point_3, #recipient, #recipient_key_set_version, #schema_key_version, #schema_version, #type
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from PseudoId
#initialize
Class Method Details
.from_asn1(asn1) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/poly_pseudo/pseudonym.rb', line 5
def self.from_asn1(asn1)
attributes = {}
attributes["Type"] = asn1.value[0].value.to_s
attributes["SchemaVersion"] = asn1.value[1].value.to_i
attributes["SchemaKeyVersion"] = asn1.value[2].value.to_i
attributes["Creator"] = asn1.value[3].value.to_s
attributes["Recipient"] = asn1.value[4].value.to_s
attributes["RecipientKeySetVersion"] = asn1.value[5].value.to_i
attributes["Point1"] = OpenSSL::PKey::EC::Point.new(PolyPseudo.config.group, OpenSSL::BN.new(asn1.value[7].value[0].value, 2))
attributes["Point2"] = OpenSSL::PKey::EC::Point.new(PolyPseudo.config.group, OpenSSL::BN.new(asn1.value[7].value[1].value, 2))
attributes["Point3"] = OpenSSL::PKey::EC::Point.new(PolyPseudo.config.group, OpenSSL::BN.new(asn1.value[7].value[2].value, 2))
new(attributes)
end
|
Instance Method Details
#decrypt(decryption_key, closing_key) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/poly_pseudo/pseudonym.rb', line 21
def decrypt(decryption_key, closing_key)
PolyPseudo.init!
decryption_private_key = decryption_key.ec.private_key
closing_private_key = closing_key.ec.private_key
product = decryption_private_key.mod_mul(closing_private_key, PolyPseudo.config.group.order)
point_2_multiplied = point_2.mul(closing_private_key)
pseudo_point = point_1
.mul(product)
.invert!
.add(point_2_multiplied)
.make_affine!
@pseudonym = closing_key.recipient_key_set_version.to_s + pseudo_point.to_hex
end
|
#pseudonym ⇒ Object
Also known as:
pseudo_id
38
39
40
|
# File 'lib/poly_pseudo/pseudonym.rb', line 38
def pseudonym
@pseudonym || raise("Pseudonym not decrypted yet. call .decrypt first")
end
|