Browse Source

master_share: replace 'use_master' argument with master_share=None

MMGen 5 years ago
parent
commit
fb655ed5bf
2 changed files with 9 additions and 9 deletions
  1. 6 6
      mmgen/seed.py
  2. 3 3
      test/unit_tests_d/ut_seedsplit.py

+ 6 - 6
mmgen/seed.py

@@ -214,11 +214,11 @@ class Seed(SeedBase):
 	def subseed_by_seed_id(self,sid,last_idx=None,print_msg=False):
 		return self.subseeds.get_subseed_by_seed_id(sid,last_idx=last_idx,print_msg=print_msg)
 
-	def split(self,count,id_str=None,use_master=False,master_idx=MasterShareIdx.min_val):
-		return SeedShareList(self,count,id_str,master_idx if use_master else None)
+	def split(self,count,id_str=None,master_idx=None):
+		return SeedShareList(self,count,id_str,master_idx)
 
 	@staticmethod
-	def join_shares(seed_list,use_master=False,master_idx=MasterShareIdx.min_val,id_str=None):
+	def join_shares(seed_list,master_idx=None,id_str=None):
 		if not hasattr(seed_list,'__next__'): # seed_list can be iterator or iterable
 			seed_list = iter(seed_list)
 
@@ -233,13 +233,13 @@ class Seed(SeedBase):
 			d.ret ^= int(ss.data.hex(),16)
 			d.count += 1
 
-		if use_master:
+		if master_idx:
 			master_share = next(seed_list)
 
 		for ss in seed_list:
 			add_share(ss)
 
-		if use_master:
+		if master_idx:
 			add_share(SeedShareMasterJoining(master_idx,master_share,id_str,d.count+1).derived_seed)
 
 		SeedShareCount(d.count)
@@ -407,7 +407,7 @@ class SeedShareMaster(SeedBase):
 	def make_base_seed_bin(self):
 		seed = self.parent_list.parent_seed
 		# field maximums: idx: 65535 (1024)
-		scramble_key  = b'master_share:' + self.idx.to_bytes(2,'big') + self.nonce.to_bytes(2,'big')
+		scramble_key = b'master_share:' + self.idx.to_bytes(2,'big') + self.nonce.to_bytes(2,'big')
 		return scramble_seed(seed.data,scramble_key)[:seed.byte_len]
 
 	def make_derived_seed_bin(self,id_str,count):

+ 3 - 3
test/unit_tests_d/ut_seedsplit.py

@@ -58,7 +58,7 @@ class unit_test(object):
 
 					for share_count,j,k,l,m in ((2,c,c,d,i),(5,e,f,h,p)):
 
-						shares = seed.split(share_count,id_str,bool(master_idx),master_idx)
+						shares = seed.split(share_count,id_str,master_idx)
 						A = len(shares)
 						assert A == share_count, A
 
@@ -88,7 +88,7 @@ class unit_test(object):
 
 						if master_idx:
 							slist = [shares.get_share_by_idx(i+1,base_seed=True) for i in range(len(shares))]
-							A = Seed.join_shares(slist,True,master_idx,id_str).sid
+							A = Seed.join_shares(slist,master_idx,id_str).sid
 							assert A == b, A
 
 				msg('OK')
@@ -124,7 +124,7 @@ class unit_test(object):
 			seed = Seed(seed_bin)
 
 			SeedShareIdx.max_val = ss_count
-			shares = seed.split(ss_count,use_master=bool(master_idx),master_idx=master_idx)
+			shares = seed.split(ss_count,master_idx=master_idx)
 			A = shares.get_share_by_idx(ss_count).sid
 			B = shares.get_share_by_seed_id(last_sid).sid
 			assert A == last_sid, A