@@ -58,10 +58,10 @@ def decode_seed(src):
5858 base32_decoded = base64 .b32decode (src + padding )
5959 raw = base32_decoded [:(len (base32_decoded ) - 2 )]
6060 except binascii .Error :
61- raise ErrInvalidSeed ()
61+ raise InvalidSeedError ()
6262
6363 if len (raw ) < 32 :
64- raise ErrInvalidSeed ()
64+ raise InvalidSeedError ()
6565
6666 # 248 = 11111000
6767 b1 = raw [0 ] & 248
@@ -70,9 +70,9 @@ def decode_seed(src):
7070 b2 = (raw [0 ] & 7 ) << 5 | ((raw [1 ] & 248 ) >> 3 )
7171
7272 if b1 != PREFIX_BYTE_SEED :
73- raise ErrInvalidSeed ()
73+ raise InvalidSeedError ()
7474 elif not valid_public_prefix_byte (b2 ):
75- raise ErrInvalidPrefixByte ()
75+ raise InvalidPrefixByteError ()
7676
7777 prefix = b2
7878 result = raw [2 :(len (raw ))]
@@ -93,10 +93,10 @@ def encode_seed(src, prefix):
9393 """
9494
9595 if not valid_public_prefix_byte (prefix ):
96- raise ErrInvalidPrefixByte ()
96+ raise InvalidPrefixByteError ()
9797
9898 if len (src ) != 32 :
99- raise ErrInvalidSeedLen ()
99+ raise InvalidSeedLengthError ()
100100
101101 # The first five bits of the first byte
102102 # contain the first base32 character,
@@ -155,21 +155,21 @@ def verifying_nkey_to_ed25519(public_nkey):
155155 try :
156156 decoded_nkey = base64 .b32decode (public_nkey )
157157 except Exception :
158- raise ErrInvalidEncoding ()
158+ raise InvalidEncodingError ()
159159
160160 if len (decoded_nkey ) != 35 :
161- raise ErrInvalidPublicKey ()
161+ raise InvalidPublicKeyError ()
162162
163163 prefix = decoded_nkey [0 ]
164164 if not valid_public_prefix_byte (prefix ):
165- raise ErrInvalidPrefixByte ()
165+ raise InvalidPrefixByteError ()
166166
167167 # the first byte of the base32 decoded nkey is the prefix
168168 # the last two bytes of the base32 decoded nkey is the crc16 checksum
169169 key_without_checksum , checksum = decoded_nkey [:- 2 ], decoded_nkey [- 2 :]
170170
171171 if checksum != crc16_checksum (key_without_checksum ):
172- raise ErrInvalidCheckSum ()
172+ raise InvalidChecksumError ()
173173
174174 # remove the nkey prefix to produce the bare ED25519 verifying key
175175 bare_key = key_without_checksum [1 :]
@@ -190,7 +190,7 @@ def verify(public_nkey, input, sig):
190190 vk .verify (input , sig )
191191 return True
192192 except nacl .exceptions .BadSignatureError :
193- raise ErrInvalidSignature ()
193+ raise InvalidSignatureError ()
194194
195195
196196class KeyPair (object ):
@@ -287,7 +287,7 @@ def private_key(self):
287287 @property
288288 def seed (self ):
289289 if not hasattr (self , "_seed" ):
290- raise ErrInvalidSeed ()
290+ raise InvalidSeedError ()
291291 return self ._seed
292292
293293 def wipe (self ):
@@ -573,61 +573,106 @@ class NkeysError(Exception):
573573 pass
574574
575575
576- class ErrInvalidSeed (NkeysError ):
576+ class InvalidSeedError (NkeysError ):
577577
578578 def __str__ (self ):
579579 return "nkeys: invalid seed"
580580
581581
582- class ErrInvalidPrefixByte (NkeysError ):
582+ class InvalidPrefixByteError (NkeysError ):
583583
584584 def __str__ (self ):
585585 return "nkeys: invalid prefix byte"
586586
587587
588- class ErrInvalidKey (NkeysError ):
588+ class InvalidKeyError (NkeysError ):
589589
590590 def __str__ (self ):
591591 return "nkeys: invalid key"
592592
593593
594- class ErrInvalidPublicKey (NkeysError ):
594+ class InvalidPublicKeyError (NkeysError ):
595595
596596 def __str__ (self ):
597597 return "nkeys: invalid public key"
598598
599599
600- class ErrInvalidSeedLen (NkeysError ):
600+ class InvalidSeedLengthError (NkeysError ):
601601
602602 def __str__ (self ):
603603 return "nkeys: invalid seed length"
604604
605605
606- class ErrInvalidEncoding (NkeysError ):
606+ class InvalidEncodingError (NkeysError ):
607607
608608 def __str__ (self ):
609609 return "nkeys: invalid encoded key"
610610
611611
612- class ErrInvalidCheckSum (NkeysError ):
612+ class InvalidChecksumError (NkeysError ):
613613
614614 def __str__ (self ):
615615 return "nkeys: invalid crc16 checksum"
616616
617617
618- class ErrInvalidSignature (NkeysError ):
618+ class InvalidSignatureError (NkeysError ):
619619
620620 def __str__ (self ):
621621 return "nkeys: signature verification failed"
622622
623623
624- class ErrCannotSign (NkeysError ):
624+ class CannotSignError (NkeysError ):
625625
626626 def __str__ (self ):
627627 return "nkeys: can not sign, no private key available"
628628
629629
630- class ErrPublicKeyOnly (NkeysError ):
630+ class PublicKeyOnlyError (NkeysError ):
631631
632632 def __str__ (self ):
633633 return "nkeys: no seed or private key available"
634+
635+
636+ # Deprecated aliases for backward compatibility.
637+ # These names do not follow Python naming conventions and will be removed in a future version.
638+ # Use the new names (suffixed with 'Error') instead.
639+
640+ #: .. deprecated::
641+ #: Use :class:`InvalidSeedError` instead.
642+ ErrInvalidSeed = InvalidSeedError
643+
644+ #: .. deprecated::
645+ #: Use :class:`InvalidPrefixByteError` instead.
646+ ErrInvalidPrefixByte = InvalidPrefixByteError
647+
648+ #: .. deprecated::
649+ #: Use :class:`InvalidKeyError` instead.
650+ ErrInvalidKey = InvalidKeyError
651+
652+ #: .. deprecated::
653+ #: Use :class:`InvalidPublicKeyError` instead.
654+ ErrInvalidPublicKey = InvalidPublicKeyError
655+
656+ #: .. deprecated::
657+ #: Use :class:`InvalidSeedLengthError` instead.
658+ ErrInvalidSeedLen = InvalidSeedLengthError
659+
660+ #: .. deprecated::
661+ #: Use :class:`InvalidEncodingError` instead.
662+ ErrInvalidEncoding = InvalidEncodingError
663+
664+ #: .. deprecated::
665+ #: Use :class:`InvalidChecksumError` instead.
666+ ErrInvalidCheckSum = InvalidChecksumError
667+
668+ #: .. deprecated::
669+ #: Use :class:`InvalidSignatureError` instead.
670+ ErrInvalidSignature = InvalidSignatureError
671+
672+ #: .. deprecated::
673+ #: Use :class:`CannotSignError` instead.
674+ ErrCannotSign = CannotSignError
675+
676+ #: .. deprecated::
677+ #: Use :class:`PublicKeyOnlyError` instead.
678+ ErrPublicKeyOnly = PublicKeyOnlyError
0 commit comments