|
@@ -892,31 +892,31 @@ class RelayChannelManager(ChannelManager):
|
|
|
deckey = nacl.hash.sha256(secret + b'upstream')
|
|
|
circhandler.add_crypt_layer(enckey, deckey)
|
|
|
|
|
|
+ print("WARNING: Unimplemented! Should check the TTL, if it isn't \
|
|
|
+ zero, decriment it and pass it along. Otherwise, just reply \
|
|
|
+ without extending.")
|
|
|
+
|
|
|
# here, we will directly extend the circuit ourselves, after doing
|
|
|
# the following:
|
|
|
# 1. determining the next relay using the client's path selection
|
|
|
# key in conjunction with our own
|
|
|
- print("server path selection key: " + str(self.path_selection_key))
|
|
|
- print("client path selection key: " +
|
|
|
- str(msg.client_path_selection_key))
|
|
|
- idx = nacl.public.Box(self.path_selection_key, msg.client_path_selection_key).shared_key()
|
|
|
+ # 2. blinding each of the client's public keys to send to the next
|
|
|
+ # hop.
|
|
|
+ idx, blinded_client_pubkey = Sphinx.server(msg.client_path_selection_key,
|
|
|
+ self.path_selection_key, b'circuit', False, perfstats)
|
|
|
+
|
|
|
sys.exit("TODO convert shared secret into integer type modulo alpha")
|
|
|
nexthop = self.relaypicker.pick_relay_by_uniform_index(idx)
|
|
|
if nexthop == None:
|
|
|
print("WARNING: Unimplemented! Need to validate next hop is not null, if it is, we should send a CLOSE cell.")
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- # 2. blinding each of the client's public keys to send to the next
|
|
|
- # hop.
|
|
|
-
|
|
|
# Add a handler for once the next relay replies to say that the
|
|
|
# circuit has been created
|
|
|
# be at most one on this circuit).
|
|
|
-# circhandler.replace_celltype_handler(
|
|
|
-# SinglePassCreatedCircuitCell,
|
|
|
-# SinglePassCreatedCircuitHandler(ntorreply, next_snip))
|
|
|
-#
|
|
|
+ circhandler.replace_celltype_handler(
|
|
|
+ SinglePassCreatedCircuitCell,
|
|
|
+ SinglePassCreatedCircuitHandler(ntorreply, next_hop))
|
|
|
+
|
|
|
# # Allocate a new circuit id to the requested next hop
|
|
|
# channelmgr = circhandler.channel.channelmgr
|
|
|
# nexthopchannel = channelmgr.get_channel_to(next_snip.snipdict["addr"])
|
|
@@ -1076,8 +1076,41 @@ if __name__ == '__main__':
|
|
|
# Initialize the (non-cryptographic) random seed
|
|
|
random.seed(1)
|
|
|
|
|
|
- network.thenetwork.set_wo_style(network.WOMode.TELESCOPING,
|
|
|
- network.SNIPAuthMode.MERKLE)
|
|
|
+ if len(sys.argv) < 3:
|
|
|
+ print("Must pass in network mode and snip auth mode!")
|
|
|
+ print("Network options are vanilla, telescoping, or single-pass.")
|
|
|
+ print("SNIP auth options are merkle or threshold.")
|
|
|
+ sys.exit(0)
|
|
|
+
|
|
|
+ network_mode = network.WOMode.string_to_type(sys.argv[1])
|
|
|
+ if network_mode == -1:
|
|
|
+ print("Not a valid network mode: " + network_mode)
|
|
|
+ sys.exit(0)
|
|
|
+
|
|
|
+ snipauth_mode = network.SNIPAuthMode.string_to_type(sys.argv[2])
|
|
|
+ if network_mode == -1:
|
|
|
+ print("Not a valid SNIP authentication mode: " + snipauth_mode)
|
|
|
+ sys.exit(0)
|
|
|
+
|
|
|
+ if network_mode == network.WOMode.VANILLA:
|
|
|
+ network.thenetwork.set_wo_style(network.WOMode.VANILLA,
|
|
|
+ network.SNIPAuthMode.NONE)
|
|
|
+ elif network_mode == network.WOMode.TELESCOPING:
|
|
|
+ if snipauth_mode == network.SNIPAuthMode.MERKLE:
|
|
|
+ network.thenetwork.set_wo_style(network.WOMode.TELESCOPING,
|
|
|
+ network.SNIPAuthMode.MERKLE)
|
|
|
+ else:
|
|
|
+ network.thenetwork.set_wo_style(network.WOMode.TELESCOPING,
|
|
|
+ network.SNIPAuthMode.THRESHSIG)
|
|
|
+ elif network_mode == network.WOMode.SINGLEPASS:
|
|
|
+ if snipauth_mode == network.SNIPAuthMode.MERKLE:
|
|
|
+ network.thenetwork.set_wo_style(network.WOMode.SINGLEPASS,
|
|
|
+ network.SNIPAuthMode.MERKLE)
|
|
|
+ else:
|
|
|
+ network.thenetwork.set_wo_style(network.WOMode.SINGLEPASS,
|
|
|
+ network.SNIPAuthMode.THRESHSIG)
|
|
|
+ else:
|
|
|
+ sys.exit("Received unsupported network mode, exiting.")
|
|
|
|
|
|
# Start some dirauths
|
|
|
numdirauths = 9
|