Browse Source

Single-Pass Walking Onions now works

including picking relays with a (simulated) VRF
Ian Goldberg 4 years ago
parent
commit
9562f0a4d6
1 changed files with 15 additions and 0 deletions
  1. 15 0
      client.py

+ 15 - 0
client.py

@@ -207,6 +207,21 @@ class SinglePassCreatedHandler:
                         self.channelmgr.perfstats)
                 # TODO: compute the index, check the VRF, ensure the
                 # SNIP is the correct one
+                pathsel_rand, next_blindkey = relay.Sphinx.client(
+                        self.client_key, blinding_keys,
+                        onionkey, b'pathsel',
+                        nextlayer is None, self.channelmgr.perfstats)
+                if nextlayer is not None:
+                    blinding_keys.append(next_blindkey)
+
+                index = int.from_bytes(relay.VRF.check_output(pathselkey,
+                                        pathsel_rand, vrfout,
+                                        self.channelmgr.perfstats)[:4],
+                                    'big', signed=False)
+
+                indexrange = snip.snipdict["range"]
+                if index < indexrange[0] or index >= indexrange[1]:
+                    logging.error("Incorrect SNIP received")
 
                 circhandler.circuit_descs.append(snip)
                 cell = nextlayer