| 189 | } |
| 190 | |
| 191 | func (m *Model) sendInit() tview.Cmd { |
| 192 | return func() tview.Msg { |
| 193 | if m.privateKey == nil { |
| 194 | return newErrMsg(errors.New("missing private key")) |
| 195 | } |
| 196 | spki, err := x509.MarshalPKIXPublicKey(m.privateKey.Public()) |
| 197 | if err != nil { |
| 198 | return newErrMsg(err) |
| 199 | } |
| 200 | encodedPublicKey := base64.StdEncoding.EncodeToString(spki) |
| 201 | data := struct { |
| 202 | Op string `json:"op"` |
| 203 | EncodedPublicKey string `json:"encoded_public_key"` |
| 204 | }{"init", encodedPublicKey} |
| 205 | if err := m.conn.WriteJSON(data); err != nil { |
| 206 | return newErrMsg(err) |
| 207 | } |
| 208 | return nil |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | func (m *Model) sendNonceProof(encryptedNonce string) tview.Cmd { |
| 213 | return func() tview.Msg { |