Browse Source

Clients verify received SNIPs

Ian Goldberg 4 years ago
parent
commit
3b5b84961c
2 changed files with 5 additions and 2 deletions
  1. 4 2
      client.py
  2. 1 0
      dirauth.py

+ 4 - 2
client.py

@@ -114,8 +114,10 @@ class TelescopingExtendedHandler:
     def received_cell(self, circhandler, cell):
         print("LOG: Received cell in TelescopingExtendedHandler")
 
-        #TODO validate the SNIP
-        print("WARNING: Unimplemented! Need to validate the SNIP before proceeding.")
+        # Validate the SNIP
+        dirauth.SNIP.verify(cell.snip, self.channelmgr.consensus,
+                network.thenetwork.dirauthkeys()[0],
+                self.channelmgr.perfstats)
 
         onionkey = cell.snip.snipdict['onionkey']
         idkey = cell.snip.snipdict['idkey']

+ 1 - 0
dirauth.py

@@ -103,6 +103,7 @@ class SNIP:
     def verify(snip, consensus, verifykey, perfstats):
         if network.thenetwork.snipauthmode == network.SNIPAuthMode.THRESHSIG:
             assert(type(snip) is SNIP and type(consensus) is Consensus)
+            assert(consensus.consdict["epoch"] == snip.snipdict["epoch"])
             serialized = snip.__str__(False)
             perfstats.verifs += 1
             verifykey.verify(serialized.encode("ascii"),