pymensago/keycard.py
def sign(self, signing_key: CryptoString, sigtype: str) -> RetVal:
		'''Adds a signature to the  Note that for any change in the keycard fields, this 
		call must be made afterward. Note that successive signatures are deleted, such that 
		updating a User signature will delete the Organization signature which depends on it. The 
		sigtype must be Custody, User, or Organization, and the type is case-sensitive.'''
		if not signing_key.is_valid():
			return RetVal(ErrBadValue, 'signing key')
		
		if signing_key.prefix != 'ED25519':
			return RetVal(UnsupportedEncryptionType, signing_key.prefix)
		
		sig_names = [x['name'] for x in self.signature_info]
		if sigtype not in sig_names:
			return RetVal(ErrBadValue, 'sigtype')
		
		key = nacl.signing.SigningKey(signing_key.as_raw())

		# Clear all signatures which follow the current one. This expects that the signature_info
		# field lists the signatures in the order that they are required to appear.		
		clear_sig = False
		sigtype_index = 0

		# We really do need to use an index here instead of just an iterator. Sheesh.
		for i in range(len(sig_names)): # pylint: disable=consider-using-enumerate
			name = sig_names[i]
			if name == sigtype:
				clear_sig = True
				sigtype_index = i

			if clear_sig:
				self.signatures[name] = ''

		data = self.make_bytestring(sigtype_index + 1)
		signed = key.sign(data, Base85Encoder)
		self.signatures[sigtype] = 'ED25519:' + signed.signature.decode()
		return RetVal()
Adds a signature to the  Note that for any change in the keycard fields, this 
		call must be made afterward. Note that successive signatures are deleted, such that 
		updating a User signature will delete the Organization signature which depends on it. The 
		sigtype must be Custody, User, or Organization, and the type is case-sensitive.
Adds a signature to the  Note that for any change in the keycard fields, this
call must be made afterward. Note that successive signatures are deleted, such that
updating a User signature will delete the Organization signature which depends on it. The
sigtype must be Custody, User, or Organization, and the type is case-sensitive.
Adds a signature to the Note that for any change in the keycard fields this call must be made afterward . Note that successive signatures are deleted such that updating a User signature will delete the Organization signature which depends on it . The sigtype must be Custody User or Organization and the type is case - sensitive .
def sign(self, signing_key: CryptoString, sigtype: str) -> RetVal:
		if not signing_key.is_valid():
			return RetVal(ErrBadValue, 'signing key')
		if signing_key.prefix != 'ED25519':
			return RetVal(UnsupportedEncryptionType, signing_key.prefix)
		sig_names = [x['name'] for x in self.signature_info]
		if sigtype not in sig_names:
			return RetVal(ErrBadValue, 'sigtype')
		key = nacl.signing.SigningKey(signing_key.as_raw())
		clear_sig = False
		sigtype_index = 0
		for i in range(len(sig_names)): 
			name = sig_names[i]
			if name == sigtype:
				clear_sig = True
				sigtype_index = i
			if clear_sig:
				self.signatures[name] = ''
		data = self.make_bytestring(sigtype_index + 1)
		signed = key.sign(data, Base85Encoder)
		self.signatures[sigtype] = 'ED25519:' + signed.signature.decode()
		return RetVal()
def sign ( self , signing_key : CryptoString , sigtype : str ) -> RetVal : if not signing_key . is_valid ( ) : return RetVal ( ErrBadValue , 'signing key' ) if signing_key . prefix != 'ED25519' : return RetVal ( UnsupportedEncryptionType , signing_key . prefix ) sig_names = [ x [ 'name' ] for x in self . signature_info ] if sigtype not in sig_names : return RetVal ( ErrBadValue , 'sigtype' ) key = nacl . signing . SigningKey ( signing_key . as_raw ( ) ) clear_sig = False sigtype_index = 0 for i in range ( len ( sig_names ) ) : name = sig_names [ i ] if name == sigtype : clear_sig = True sigtype_index = i if clear_sig : self . signatures [ name ] = '' data = self . make_bytestring ( sigtype_index + 1 ) signed = key . sign ( data , Base85Encoder ) self . signatures [ sigtype ] = 'ED25519:' + signed . signature . decode ( ) return RetVal ( )
Adds a signature to the  Note that for any change in the keycard fields, this
call must be made afterward.
Adds a signature to the Note that for any change in the keycard fields this call must be made afterward .
'''Adds a signature to the  Note that for any change in the keycard fields, this 
		call must be made afterward. Note that successive signatures are deleted, such that 
		updating a User signature will delete the Organization signature which depends on it. The 
		sigtype must be Custody, User, or Organization, and the type is case-sensitive.''' # Clear all signatures which follow the current one. This expects that the signature_info # field lists the signatures in the order that they are required to appear.		 # We really do need to use an index here instead of just an iterator. Sheesh. # pylint: disable=consider-using-enumerate
self
signing_key
CryptoString
sigtype
str