identity.go raw

   1  package main
   2  
   3  // Identity — pubkey only. No secret key stored.
   4  // All signing/crypto proxied through signer extension.
   5  
   6  var myPubkey string
   7  
   8  func identitySetPubkey(hex string) {
   9  	if myPubkey != "" && hex != myPubkey {
  10  		// Identity change: close all marmot subs, reset relay, notify page.
  11  		closeMarmotSubs()
  12  		busSend("relay", "[\"CLEAR_KEY\"]")
  13  		broadcastToClients("[\"RESUB\"]")
  14  	}
  15  	myPubkey = hex
  16  }
  17  
  18  func identityClearKey() {
  19  	closeMarmotSubs()
  20  	myPubkey = ""
  21  }
  22  
  23  func closeMarmotSubs() {
  24  	for subID := range marmotSubs {
  25  		busSend("relay", "[\"CLOSE\","+jstr(subID)+"]")
  26  	}
  27  	marmotSubs = nil
  28  }
  29