Class: PolyPseudo::Identity

Inherits:
Object
  • Object
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
# 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!

  @identity = Util.oaep_decode(identity_point.x.to_s(2)).slice(3, 10).force_encoding("UTF-8").strip
end

#identityObject Also known as: pseudo_id



24
25
26
# File 'lib/poly_pseudo/identity.rb', line 24

def identity
  @identity || raise('Identity not decrypted yet. call .decrypt first')
end