def parse_message_signature(self, response, message, pubkey):
     
     # Prepend the message for signing as done inside the card!!
     message = to_bytes(message, 'utf8')
     hash = sha256d(msg_magic(message))
     coordx= pubkey.get_public_key_bytes()
     
     recid=-1
     for id in range(4):
         compsig=self.parse_to_compact_sig(response, id, compressed=True)
         # remove header byte
         compsig2= compsig[1:]
         
         try: 
             pk = ECPubkey.from_sig_string(compsig2, id, hash)
             pkbytes= pk.get_public_key_bytes(compressed=True)
         except InvalidECPointException:
             continue
         
         if coordx==pkbytes:
             recid=id
             break
     
     if recid == -1:
         raise ValueError("Unable to recover public key from signature")        
     
     return compsig
Пример #2
0
 def code_hashid(cls, txt: str) -> str:
     txt = txt.lower()
     x = to_bytes(txt, 'utf8')
     hash = sha256(x).hexdigest()
     return hash[-3:].upper()
Пример #3
0
 def code_hashid(cls, txt: str) -> str:
     txt = txt.lower()
     x = to_bytes(txt, 'utf8')
     hash = sha256(x).hexdigest()
     return hash[-3:].upper()
Пример #4
0
 def code_hashid(self, txt):
     x = to_bytes(txt, 'utf8')
     hash = sha256(x).hexdigest()
     return hash[-3:].upper()