Method: Tem::Admin::Emit.emit_keygen_seclosure

Defined in:
lib/tem/admin/emit.rb

.emit_keygen_seclosureObject

The SEClosure that performs key generation for the TEM.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/tem/admin/emit.rb', line 14

def self.emit_keygen_seclosure
  Tem::Assembler.assemble { |s|
    # Generate Endorsement Key pair, should end up in slots (0, 1).
    s.genkp :type => 0
    s.ldbc 1
    s.sub
    s.jne :to => :not_ok
    s.ldbc 0
    s.sub
    s.jne :to => :not_ok
    
    # Generate and output random authorization for PrivEK.
    s.ldbc 20
    s.dupn :n => 1
    s.outnew
    s.ldwc :privek_auth
    s.dupn :n => 2
    s.rnd
    s.outvb
    # Set authorizations for PrivEK and PubkEK.
    s.ldbc 0
    s.authk :auth => :privek_auth
    s.ldbc 1 # PubEK always has its initial authorization be all zeroes.
    s.authk :auth => :pubek_auth
    s.halt
    
    # Emitting didn't go well, return nothing and leave.
    s.label :not_ok
    s.ldbc 0
    s.outnew
    s.halt
    
    s.label :privek_auth
    s.zeros :tem_ubyte, 20
    s.label :pubek_auth
    s.zeros :tem_ubyte, 20
    s.stack 4    
  }
end