pymensago/keycard.py
def verify_signature(self, verify_key: CryptoString, sigtype: str) -> RetVal:
		'''Verifies a signature, given a verification key'''
	
		if not verify_key.is_valid():
			return RetVal(ErrBadValue, 'bad verify key')
		
		sig_names = [x['name'] for x in self.signature_info]
		if sigtype not in sig_names:
			return RetVal(ErrBadValue, 'bad signature type')
		
		if verify_key.prefix != 'ED25519':
			return RetVal(UnsupportedEncryptionType, verify_key.prefix)

		if sigtype in self.signatures and not self.signatures[sigtype]:
			return RetVal(NotCompliant, 'empty signature ' + sigtype)
		
		sig = CryptoString()
		if not sig.set(self.signatures[sigtype]):
			return RetVal(ErrBadData, 'entry signature is bad')

		try:
			vkey = nacl.signing.VerifyKey(verify_key.as_raw())
		except Exception as e:
			return RetVal.wrap_exception(e)

		try:
			data = self.make_bytestring(sig_names.index(sigtype))
			vkey.verify(data, sig.as_raw())
		except nacl.exceptions.BadSignatureError:
			return RetVal(InvalidKeycard)
		
		return RetVal()
Verifies a signature, given a verification key
Verifies a signature, given a verification key
Verifies a signature given a verification key
def verify_signature(self, verify_key: CryptoString, sigtype: str) -> RetVal:
		if not verify_key.is_valid():
			return RetVal(ErrBadValue, 'bad verify key')
		sig_names = [x['name'] for x in self.signature_info]
		if sigtype not in sig_names:
			return RetVal(ErrBadValue, 'bad signature type')
		if verify_key.prefix != 'ED25519':
			return RetVal(UnsupportedEncryptionType, verify_key.prefix)
		if sigtype in self.signatures and not self.signatures[sigtype]:
			return RetVal(NotCompliant, 'empty signature ' + sigtype)
		sig = CryptoString()
		if not sig.set(self.signatures[sigtype]):
			return RetVal(ErrBadData, 'entry signature is bad')
		try:
			vkey = nacl.signing.VerifyKey(verify_key.as_raw())
		except Exception as e:
			return RetVal.wrap_exception(e)
		try:
			data = self.make_bytestring(sig_names.index(sigtype))
			vkey.verify(data, sig.as_raw())
		except nacl.exceptions.BadSignatureError:
			return RetVal(InvalidKeycard)
		return RetVal()
def verify_signature ( self , verify_key : CryptoString , sigtype : str ) -> RetVal : if not verify_key . is_valid ( ) : return RetVal ( ErrBadValue , 'bad verify key' ) sig_names = [ x [ 'name' ] for x in self . signature_info ] if sigtype not in sig_names : return RetVal ( ErrBadValue , 'bad signature type' ) if verify_key . prefix != 'ED25519' : return RetVal ( UnsupportedEncryptionType , verify_key . prefix ) if sigtype in self . signatures and not self . signatures [ sigtype ] : return RetVal ( NotCompliant , 'empty signature ' + sigtype ) sig = CryptoString ( ) if not sig . set ( self . signatures [ sigtype ] ) : return RetVal ( ErrBadData , 'entry signature is bad' ) try : vkey = nacl . signing . VerifyKey ( verify_key . as_raw ( ) ) except Exception as e : return RetVal . wrap_exception ( e ) try : data = self . make_bytestring ( sig_names . index ( sigtype ) ) vkey . verify ( data , sig . as_raw ( ) ) except nacl . exceptions . BadSignatureError : return RetVal ( InvalidKeycard ) return RetVal ( )
Verifies a signature, given a verification key
Verifies a signature given a verification key
'''Verifies a signature, given a verification key'''
self
verify_key
CryptoString
sigtype
str