Class: PolyPseudo::Identity
- Inherits:
-
Object
- Object
- PolyPseudo::Identity
show all
- Includes:
- PseudoId
- Defined in:
- lib/poly_pseudo/identity.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
Instance Method Summary
collapse
Methods included from PseudoId
from_asn1, #initialize
Instance Method Details
#decrypt(key) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/poly_pseudo/identity.rb', line 6
def decrypt(key)
PolyPseudo.init!
public_key = key.ec.public_key
raise "Invalid key for decryption" if point_3 != public_key
private_key = key.ec.private_key
identity_point = point_1
.mul(private_key)
.invert!
.add(point_2)
.make_affine!
decoded = Util.oaep_decode(identity_point.x.to_s(2).rjust(40, "\x00"))
@identity = decoded.slice(3, decoded[2].ord).force_encoding("UTF-8")
end
|
#identity ⇒ Object
Also known as:
pseudo_id
25
26
27
|
# File 'lib/poly_pseudo/identity.rb', line 25
def identity
@identity || raise('Identity not decrypted yet. call .decrypt first')
end
|