
    dfA                        	 d dl Z	 e d dlZd dlZd dlZd dl	Z	ddl
mZmZmZ ddlmZmZmZmZmZ ddlmZmZmZmZmZmZ ddlmZmZmZmZm Z  ddl!m"Z"m#Z#m$Z$m%Z% ddl&m'Z'  G d	 d
ejP                        Z) G d dejP                        Z* G d dejP                        Z+ G d dejP                        Z,dZ- ee-      Z. e/e.e0      sJ  ejb                  e.      Z2e2jf                  Z4dZ5 e6e5      dz  d k(  sJ  e	jn                         Z7e7jq                  e5       e7js                         Z: e/e:e0      sJ e2jw                  e5e      Z< e/e<e0      sJ e2jw                  e5e      Z= e/e=e0      sJ e2jw                  e5e      Z> e/e>d    e0      sJ g Z?dd fdd fdd fdd fdd fdd  fd!d" fd#d$ ffD ]  \  Z@ZAd%e@v rd& ZBneAZBd'e<ed( fd)e=ed* fd+e>ed, ffD ]g  \  ZCZDZEZFd-e4j                  e5fd.e4j                  e:ffD ]?  \  ZIZJZKe?j                   ej                  eDeEeFeAeJeKd/j                  e@eCeI      0             A i  ej                  j                  d1e?      d2        ZQd3ZR e6eR      d4k(  sJ g ZSdd5 fdefdeTfdd6 fdd7 fdd8 fd!d9 fd#d: ffD ](  \  Z@ZUeSj                   ej                  eUe@0             * ej                  j                  d;eS      d<        ZVdZ- ee-      Z. e/e.e0      sJ ej                  j                  d;eSdd=       d>        ZWd?ZXej                  j                  d;eS      d@        ZYej                  j                  d;eS      dA        ZZej                  j                  d;eS      dB        Z[ej                  j                  d;eS      dC        Z\dD Z]dE Z^dF Z_dG Z`dH Zay# e$ r d dlZY w xY w# e$ r eZY w xY w)I    N   )VerifyingKey
SigningKeyMalformedPointError)unpemUnexpectedDERencode_sequence
encode_oidencode_bitstring)sigencode_stringsigencode_dersigencode_stringssigdecode_stringsigdecode_dersigdecode_strings)NIST256pCurveBRAINPOOLP160r1Ed25519Ed448)PointPointJacobiCurveFpINFINITY)generator_brainpoolp160r1c                   h    e Zd ZdZed        Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zy)TestVerifyingKeyFromStringzc
    Verify that ecdsa.keys.VerifyingKey.from_string() can be used with
    bytes-like objects
    c                 Z    d| _         t        j                  | j                         | _        y )Ns0   LZ
zϗo8}X!h^pIYxao+Gv)	key_bytesr   from_stringvk)clss    H/home/api-vastappli/venv/lib/python3.12/site-packages/ecdsa/test_keys.py
setUpClassz%TestVerifyingKeyFromString.setUpClass+   s&    / 	
 ))#--8    c                 r   | j                  | j                         | j                  | j                  t               | j	                  | j                  j
                  j                  j                         d       | j	                  | j                  j
                  j                  j                         d       y )Nl   !Xp?|}rIWoWeD l   vq.y[Or~Vh]Ip<#'
)	assertIsNotNoner!   assertIsInstancer   assertEqualpubkeypointxyselfs    r#   
test_bytesz%TestVerifyingKeyFromString.test_bytes4   s    TWW%dgg|4GGNN  ""$E	
 	GGNN  ""$F	
r%   c                     t        j                  t        | j                              }| j	                  | j
                  j                         |j                                y N)r   r    bufferr   r)   r!   	to_stringr/   r!   s     r#   test_bytes_memoryviewz0TestVerifyingKeyFromString.test_bytes_memoryview@   s>    %%fT^^&<=**,blln=r%   c                     t        j                  t        | j                              }| j	                  | j
                  j                         |j                                y r2   r   r    	bytearrayr   r)   r!   r4   r5   s     r#   test_bytearrayz)TestVerifyingKeyFromString.test_bytearrayE   s>    %%i&?@**,blln=r%   c                     t        j                  t        t        | j                                    }| j                  | j                  j                         |j                                y r2   )r   r    r3   r9   r   r)   r!   r4   r5   s     r#   test_bytesarray_memoryviewz5TestVerifyingKeyFromString.test_bytesarray_memoryviewJ   sC    %%fYt~~-F&GH**,blln=r%   c                     t        j                   d| j                        }t        j                  |      }| j	                  | j
                  j                         |j                                y NBarrayr   r   r    r)   r!   r4   r/   arrr!   s      r#   test_array_array_of_bytesz4TestVerifyingKeyFromString.test_array_array_of_bytesO   I    kk#t~~.%%c***,blln=r%   c                     t        j                   d| j                        }t        j                  t	        |            }| j                  | j                  j                         |j                                y r>   rA   r   r   r    r3   r)   r!   r4   rB   s      r#   $test_array_array_of_bytes_memoryviewz?TestVerifyingKeyFromString.test_array_array_of_bytes_memoryviewU   M    kk#t~~.%%fSk2**,blln=r%   c                     t        j                   d| j                        }t        j                  |      }| j	                  | j
                  j                         |j                                y NIr@   rB   s      r#   test_array_array_of_intsz3TestVerifyingKeyFromString.test_array_array_of_ints[   rE   r%   c                     t        j                   d| j                        }t        j                  t	        |            }| j                  | j                  j                         |j                                y rK   rG   rB   s      r#   #test_array_array_of_ints_memoryviewz>TestVerifyingKeyFromString.test_array_array_of_ints_memoryviewa   rI   r%   c                     t        j                  d| j                  z         }| j                  | j                  j                         |j                                y N   r   r    r   r)   r!   r4   r5   s     r#   test_bytes_uncompressedz2TestVerifyingKeyFromString.test_bytes_uncompressedg   s>    %%g&>?**,blln=r%   c                     t        j                  t        d| j                  z               }| j	                  | j
                  j                         |j                                y rQ   r8   r5   s     r#   test_bytearray_uncompressedz6TestVerifyingKeyFromString.test_bytearray_uncompressedl   sC    %%i$..0H&IJ**,blln=r%   c                     t        j                  d| j                  d d z         }| j                  | j                  j                         |j                                y N      rS   r5   s     r#   test_bytes_compressedz0TestVerifyingKeyFromString.test_bytes_compressedq   sE    %%gs0C&CD**,blln=r%   c                     t        j                  t        d| j                  d d z               }| j	                  | j
                  j                         |j                                y rX   r8   r5   s     r#   test_bytearray_compressedz4TestVerifyingKeyFromString.test_bytearray_compressedv   sJ    %%i$..":M0M&NO**,blln=r%   N)__name__
__module____qualname____doc__classmethodr$   r0   r6   r:   r<   rD   rH   rM   rO   rT   rV   r[   r]    r%   r#   r   r   %   sW    
 9 9

>
>
>
>>>>>
>
>
>r%   r   c                       e Zd ZdZed        Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d  Z#d! Z$d" Z%y#)$TestVerifyingKeyFromDerza
    Verify that ecdsa.keys.VerifyingKey.from_der() can be used with
    bytes-like objects.
    c                 b   d}d}|| _         t        |      | _        t        | j                  t              sJ t        j                  |      | _        t        j                  |      | _	        d}t        j                  |      | _
        t        j                  t        j                        | _        y )N-----BEGIN EC PRIVATE KEY-----
MF8CAQEEGF7IQgvW75JSqULpiQQ8op9WH6Uldw6xxaAKBggqhkjOPQMBAaE0AzIA
BLiBd9CE7xf15FY5QIAoNg+fWbSk1yZOYtoGUdzkejWkxbRc9RWTQjqLVXucIJnz
bA==
-----END EC PRIVATE KEY-----
z-----BEGIN PUBLIC KEY-----
MEkwEwYHKoZIzj0CAQYIKoZIzj0DAQEDMgAEuIF30ITvF/XkVjlAgCg2D59ZtKTX
Jk5i2gZR3OR6NaTFtFz1FZNCOotVe5wgmfNs
-----END PUBLIC KEY-----
z-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE4H3iRbG4TSrsSRb/gusPQB/4YcN8
Poqzgjau4kfxBPyZimeRfuY/9g/wMmPuhGl4BUve51DsnKJFRr8psk0ieA==
-----END PUBLIC KEY-----
)key_pemr   r   
isinstancebytesr   from_pemr!   r   skvk2generatecurvesk2)r"   prv_key_strkey_strs      r#   r$   z"TestVerifyingKeyFromDer.setUpClass   s    - 	) 	 g#--//&&w/$$[1) 	 ''0%%bhh/r%   c                     d}t        j                  |      }t        j                  dt              }| j	                  ||       y )N  -----BEGIN PUBLIC KEY-----
MIIBSzCCAQMGByqGSM49AgEwgfcCAQEwLAYHKoZIzj0BAQIhAP////8AAAABAAAA
AAAAAAAAAAAA////////////////MFsEIP////8AAAABAAAAAAAAAAAAAAAA////
///////////8BCBaxjXYqjqT57PrvVV2mIa8ZR0GsMxTsPY7zjw+J9JgSwMVAMSd
NgiG5wSTamZ44ROdJreBn36QBEEEaxfR8uEsQkf4vOblY6RA8ncDfYEt6zOg9KE5
RdiYwpZP40Li/hp/m47n60p8D54WK84zV2sxXs7LtkBoN79R9QIhAP////8AAAAA
//////////+85vqtpxeehPO5ysL8YyVRAgEBA0IABIr1UkgYs5jmbFc7it1/YI2X
T//IlaEjMNZft1owjqpBYH2ErJHk4U5Pp4WvWq1xmHwIZlsH7Ig4KmefCfR6SmU=
-----END PUBLIC KEY-----sA   RHlW;`Oȕ#0_Z0A`}NOZq|f[8*g	zJero   )r   rk   r    r   r)   )r/   pub_key_strpkpk_exps       r#   &test_load_key_with_explicit_parametersz>TestVerifyingKeyFromDer.test_load_key_with_explicit_parameters   sJ    ' 	 "";/))$
 
 	V$r%   c                     d}| j                  t              5  t        j                  |dg       d d d        y # 1 sw Y   y xY w)Nrt   named_curvevalid_curve_encodings)assertRaisesr   r   rk   )r/   rv   s     r#   2test_load_key_with_explicit_with_explicit_disabledzJTestVerifyingKeyFromDer.test_load_key_with_explicit_with_explicit_disabled   sF    ' 	 }- 	!!M?	 	 		   :Ac                     | j                  t              5 }t        j                  | j                  dg       d d d        | j                  dt        j                               y # 1 sw Y   /xY w)Nraw)valid_encodingszenabled (raw) encodings)r~   r   r   from_derr   assertInstr	exceptionr/   es     r#   "test_load_key_with_disabled_formatz:TestVerifyingKeyFromDer.test_load_key_with_disabled_format   s\    23 	Kq!!$..5'J	K 	/Q[[1AB	K 	Ks   #A''A0c                     t        j                  | j                  t        j                        }| j                  |j                  t        j                         y r2   )r   r   r   hashlibsha256assertIsdefault_hashfuncr5   s     r#   test_custom_hashfuncz,TestVerifyingKeyFromDer.test_custom_hashfunc   s4    ""4>>7>>Bb))7>>:r%   c                     t        j                  | j                  t        j                        }| j                  |j                  t        j                         y r2   )r   rk   rh   r   r   r   r   r5   s     r#   "test_from_pem_with_custom_hashfuncz:TestVerifyingKeyFromDer.test_from_pem_with_custom_hashfunc   s4    ""4<<@b))7>>:r%   c                     t        j                  | j                        }| j                  | j                  j                         |j                                y r2   )r   r   r   r)   r!   r4   r5   s     r#   r0   z"TestVerifyingKeyFromDer.test_bytes   s9    ""4>>2**,blln=r%   c                     t        j                  t        | j                              }| j	                  | j
                  j                         |j                                y r2   )r   r   r3   r   r)   r!   r4   r5   s     r#   r6   z-TestVerifyingKeyFromDer.test_bytes_memoryview   s>    ""6$..#9:**,blln=r%   c                     t        j                  t        | j                              }| j	                  | j
                  j                         |j                                y r2   )r   r   r9   r   r)   r!   r4   r5   s     r#   r:   z&TestVerifyingKeyFromDer.test_bytearray   s>    ""9T^^#<=**,blln=r%   c                     t        j                  t        t        | j                                    }| j                  | j                  j                         |j                                y r2   )r   r   r3   r9   r   r)   r!   r4   r5   s     r#   r<   z2TestVerifyingKeyFromDer.test_bytesarray_memoryview   sC    ""6)DNN*C#DE**,blln=r%   c                     t        j                   d| j                        }t        j                  |      }| j	                  | j
                  j                         |j                                y r>   )rA   r   r   r   r)   r!   r4   rB   s      r#   rD   z1TestVerifyingKeyFromDer.test_array_array_of_bytes   sI    kk#t~~.""3'**,blln=r%   c                     t        j                   d| j                        }t        j                  t	        |            }| j                  | j                  j                         |j                                y r>   )rA   r   r   r   r3   r)   r!   r4   rB   s      r#   rH   z<TestVerifyingKeyFromDer.test_array_array_of_bytes_memoryview   sM    kk#t~~.""6#;/**,blln=r%   c                 l    | j                  | j                  | j                  j                                y r2   )r)   r!   rl   get_verifying_keyr.   s    r#   test_equality_on_verifying_keysz7TestVerifyingKeyFromDer.test_equality_on_verifying_keys   s#    $''";";"=>r%   c                 P    | j                  | j                  | j                         y r2   )assertNotEqualr!   rm   r.   s    r#   !test_inequality_on_verifying_keysz9TestVerifyingKeyFromDer.test_inequality_on_verifying_keys       DGGTXX.r%   c                 <    | j                  | j                  d        y r2   )r   r!   r.   s    r#   1test_inequality_on_verifying_keys_not_implementedzITestVerifyingKeyFromDer.test_inequality_on_verifying_keys_not_implemented  s    DGGT*r%   c                 d    | j                  | j                  | j                  j                         y r2   )r   r!   rp   verifying_keyr.   s    r#   *test_VerifyingKey_inequality_on_same_curvezBTestVerifyingKeyFromDer.test_VerifyingKey_inequality_on_same_curve  s     DGGTXX%;%;<r%   c                 P    | j                  | j                  | j                         y r2   )r   rl   rp   r.   s    r#   (test_SigningKey_inequality_on_same_curvez@TestVerifyingKeyFromDer.test_SigningKey_inequality_on_same_curve  r   r%   c                 P    | j                  | j                  | j                         y r2   )r   r!   rl   r.   s    r#   test_inequality_on_wrong_typesz6TestVerifyingKeyFromDer.test_inequality_on_wrong_types
  s    DGGTWW-r%   c                 >   | j                   j                  j                  }t        |j	                         |j                         |j                               }t        j                  || j                   j                        }| j                  || j                          y r2   )
r!   r*   r+   r   ro   r,   r-   r   from_public_pointr)   )r/   pjr+   r!   s       r#   test_from_public_point_oldz2TestVerifyingKeyFromDer.test_from_public_point_old  sc    WW^^!!bhhj"$$&"$$&1++E477==ATWW%r%   c                     t        j                  t        j                  j	                         t              }t        |j                        }| j                  d|       y )NzVerifyingKey.from_string(bytearray(b'K\x0c\xfbZH\x8e\x8c\x8c\x07\xee\xda\xfb\xe1\x97\xcd\x90\x18\x02\x15h]\xfe\xbe\xcbB\xba\xe6r\x10\xae\xf1P'), Ed25519, None))r   r    r   	generatorto_bytesreprr   r)   )r/   rl   strings      r#    test_ed25519_VerifyingKey_repr__z8TestVerifyingKeyFromDer.test_ed25519_VerifyingKey_repr__  sK    ##G$5$5$>$>$@'Jb&&'1 	
r%   c                     t         j                  }| j                  t              5 }t	        j
                  |t                d d d        | j                  dt        j                               y # 1 sw Y   /xY w)Nzincompatible with Edwards)	r   r   r~   
ValueErrorr   r   r   r   r   )r/   r+   r   s      r#   test_edwards_from_public_pointz6TestVerifyingKeyFromDer.test_edwards_from_public_point!  s\    !!z* 	;a**5':	; 	13q{{3CD	; 	;s   A//A8c                    t        j                  t        j                  j	                         t              }|j
                  }t        j                  |j                         t              }|j                          | j                  ||       y r2   )
r   r    r   r   r   r   r   r4   
precomputer)   r/   rl   r!   rm   s       r#   &test_edwards_precompute_no_side_effectz>TestVerifyingKeyFromDer.test_edwards_precompute_no_side_effect(  s_    ##G$5$5$>$>$@'J&&r||~w?
S!r%   c           	         t        t        t        t        j                         t	        t        t        j                  j                               d      t	        dd            }| j                  t              5 }t        j                  |       d d d        | j                  dt        j                               y # 1 sw Y   /xY w)Nr       ztrailing junk after public key)r	   r
   r   oidr   rj   r   r   r~   r   r   r   r   r   r   )r/   der_strr   s      r#   $test_parse_malfomed_eddsa_der_pubkeyz<TestVerifyingKeyFromDer.test_parse_malfomed_eddsa_der_pubkey0  s    !J45U7#4#4#=#=#?@!DWa(
 }- 	+!!'*	+ 	6AKK8HI	+ 	+s   9B==Cc                     | j                  t              5 }t        j                  ddt               d d d        | j                  dt        j                               y # 1 sw Y   /xY wNr%   zunsupported for Edwards)r~   r   r   from_public_key_recoveryr   r   r   r   r   s     r#   %test_edwards_from_public_key_recoveryz=TestVerifyingKeyFromDer.test_edwards_from_public_key_recovery<  sW    z* 	Ea11#sGD	E 	/Q[[1AB	E 	E   A  A)c                     | j                  t              5 }t        j                  ddt               d d d        | j                  dt        j                               y # 1 sw Y   /xY wr   )r~   r   r   $from_public_key_recovery_with_digestr   r   r   r   r   s     r#   1test_edwards_from_public_key_recovery_with_digestzITestVerifyingKeyFromDer.test_edwards_from_public_key_recovery_with_digestB  sV    z* 	a==S'	
 	/Q[[1AB	 	r   c                    d}t        j                  |      }| j                  |j                  t               | j                  |j                  t               d}t        j                  |t              }| j                  ||       y )Nq-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAIwBQ0NZkIiiO41WJfm5BV42u3kQm7lYnvIXmCy8qy2U=
-----END PUBLIC KEY-----
    # Pd"(U~nAWD&V'/*e)	r   rk   r(   ro   r   r   r   r    r)   )r/   vk_pemr!   vk_strvk_2s        r#   test_load_ed25519_from_pemz2TestVerifyingKeyFromDer.test_load_ed25519_from_pemJ  ss    ) 	 ""6*bhh.bhh(P 	
 ''8T"r%   c                     d}t        j                  |t              }d}| j                  ||j	                                y )Nr   sq   -----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAIwBQ0NZkIiiO41WJfm5BV42u3kQm7lYnvIXmCy8qy2U=
-----END PUBLIC KEY-----
)r   r    r   r)   to_pemr/   r   r!   r   s       r#   test_export_ed255_to_pemz0TestVerifyingKeyFromDer.test_export_ed255_to_pem_  sC    P 	
 %%fg6* 	 	-r%   c                     t        j                  t              }|j                  }t	        j
                  |j                               }| j                  ||       y r2   )r   rn   r   r   r   rk   r   r)   r   s       r#   test_ed25519_export_importz2TestVerifyingKeyFromDer.test_ed25519_export_importo  sC      )##BIIK0S!r%   c                 |    d}t        j                  |      }d}d}| j                  |j                  ||             y )Nr      data
s@   dGj3yEl PǏ`u/'ӖXF\P)խF<hMꍨyr   rk   
assertTrueverify)r/   r   r!   datasigs        r#   test_ed25519_sig_verifyz/TestVerifyingKeyFromDer.test_ed25519_sig_verifyw  sG    ) 	 ""6*P 	 			#t,-r%   c                    d}t        j                  |      }| j                  |j                  t               | j                  |j                  t               d}t        j                  |t              }| j                  ||       y )N-----BEGIN PUBLIC KEY-----
MEMwBQYDK2VxAzoAeQtetSu7CMEzE+XWB10Bg47LCA0giNikOxHzdp+tZ/eK/En0
dTdYD2ll94g58MhSnBiBQB9A1MMA
-----END PUBLIC KEY-----
9   y^+3] ؤ;vgIu7Xie9R@@ )	r   rk   r(   ro   r   r   r   r    r)   )r/   pem_strr!   r   rm   s        r#   test_ed448_from_pemz+TestVerifyingKeyFromDer.test_ed448_from_pem  sr    ) 	 ""7+bhh.bhh&4 	 &&vu5S!r%   c                     d}t        j                  |t              }d}| j                  ||j	                                y )Nr   s   -----BEGIN PUBLIC KEY-----
MEMwBQYDK2VxAzoAeQtetSu7CMEzE+XWB10Bg47LCA0giNikOxHzdp+tZ/eK/En0
dTdYD2ll94g58MhSnBiBQB9A1MMA
-----END PUBLIC KEY-----
)r   r    r   r)   r   r   s       r#   test_ed448_to_pemz)TestVerifyingKeyFromDer.test_ed448_to_pem  sB    4 	 %%fe4* 	 	-r%   c                     t        j                  t              }|j                  }t	        j
                  |j                               }| j                  ||       y r2   )r   rn   r   r   r   rk   r   r)   r   s       r#   test_ed448_export_importz0TestVerifyingKeyFromDer.test_ed448_export_import  sC      '##BIIK0S!r%   c                 |    d}t        j                  |      }d}d}| j                  |j                  ||             y )Nr   r   sr   h,p5"5Q3= To0WE>Q`jC_28k	 x{]~1?0/U!L-LbS0fK@Э
 r   )r/   r   r!   r   r   s        r#   test_ed448_sig_verifyz-TestVerifyingKeyFromDer.test_ed448_sig_verify  sF    ) 	 ""7+ 	 			#t,-r%   N)&r^   r_   r`   ra   rb   r$   ry   r   r   r   r   r0   r6   r:   r<   rD   rH   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rc   r%   r#   re   re   |   s    
 0 0>%0"C;
;
>
>
>
>
>>?/+=/.&

E"
JCC#*. ".*"0.$".r%   re   c                   z    e Zd ZdZed        Zd Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zy)TestSigningKeyz_
    Verify that ecdsa.keys.SigningKey.from_der() can be used with
    bytes-like objects.
    c                     d}t        j                  |      | _        d}t        j                  |      | _        d}t        j                  |      | _        y )Nrg   z-----BEGIN PRIVATE KEY-----
MG8CAQAwEwYHKoZIzj0CAQYIKoZIzj0DAQEEVTBTAgEBBBheyEIL1u+SUqlC6YkE
PKKfVh+lJXcOscWhNAMyAAS4gXfQhO8X9eRWOUCAKDYPn1m0pNcmTmLaBlHc5Ho1
pMW0XPUVk0I6i1V7nCCZ82w=
-----END PRIVATE KEY-----
z-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIKlL2EAm5NPPZuXwxRf4nXMk0A80y6UUbiQ17be/qFhRoAoGCCqGSM49
AwEHoUQDQgAE4H3iRbG4TSrsSRb/gusPQB/4YcN8Poqzgjau4kfxBPyZimeRfuY/
9g/wMmPuhGl4BUve51DsnKJFRr8psk0ieA==
-----END EC PRIVATE KEY-----
)r   rk   sk1	sk1_pkcs8rp   )r"   rq   s     r#   r$   zTestSigningKey.setUpClass  s\    - 	 %%k2* 	 #++K8- 	 %%k2r%   c                     d}t        j                  |      }t        j                  dt              }| j	                  ||       y )N:  -----BEGIN PRIVATE KEY-----
MIIBeQIBADCCAQMGByqGSM49AgEwgfcCAQEwLAYHKoZIzj0BAQIhAP////8AAAAB
AAAAAAAAAAAAAAAA////////////////MFsEIP////8AAAABAAAAAAAAAAAAAAAA
///////////////8BCBaxjXYqjqT57PrvVV2mIa8ZR0GsMxTsPY7zjw+J9JgSwMV
AMSdNgiG5wSTamZ44ROdJreBn36QBEEEaxfR8uEsQkf4vOblY6RA8ncDfYEt6zOg
9KE5RdiYwpZP40Li/hp/m47n60p8D54WK84zV2sxXs7LtkBoN79R9QIhAP////8A
AAAA//////////+85vqtpxeehPO5ysL8YyVRAgEBBG0wawIBAQQgIXtREfUmR16r
ZbmvDGD2lAEFPZa2DLPyz0czSja58yChRANCAASK9VJIGLOY5mxXO4rdf2CNl0//
yJWhIzDWX7daMI6qQWB9hKyR5OFOT6eFr1qtcZh8CGZbB+yIOCpnnwn0ekpl
-----END PRIVATE KEY-----
s    !{Q&G^e`=G3J6 ru   )r   rk   r    r   r)   )r/   rq   rl   rp   s       r#   'test_decoding_explicit_curve_parametersz6TestSigningKey.test_decoding_explicit_curve_parameters  sJ    	* 	   -$$ 	
 	S!r%   c                     d}| j                  t              5  t        j                  |dg       d d d        y # 1 sw Y   y xY w)Nr   r{   r|   )r~   r   r   rk   )r/   rq   s     r#   >test_decoding_explicit_curve_parameters_with_explicit_disabledzMTestSigningKey.test_decoding_explicit_curve_parameters_with_explicit_disabled  sF    	* 	 }- 	M?	 	 	r   c                    t        j                  | j                  j                  j                  | j                  j
                        }| j                  | j                  |       | j                  | j                  |       y r2   )r   from_secret_exponentr   privkeysecret_multiplierro   r)   r   )r/   rl   s     r#   test_equality_on_signing_keysz,TestSigningKey.test_equality_on_signing_keys(  sY    ,,HH..
 	2&,r%   c                     | j                   j                  d      }| j                  |       | j                   j                  }| j                  |j	                  |d             y )Nr%   )r   signr   r   r   r/   r   r!   s      r#   test_verify_with_empty_messagez-TestSigningKey.test_verify_with_empty_message/  sF    hhmmC XX##		#s+,r%   c                     | j                   j                  d      }| j                   j                  }|j                          | j	                  |j                  |d             y )N   message)r   r   r   r   r   r   r   s      r#   test_verify_with_precomputez*TestSigningKey.test_verify_with_precompute8  sC    hhmmJ'XX##
		#z23r%   c                     | j                   j                  }|j                          | j                  j                  }| j	                  ||       y r2   )r   r   r   r   r)   )r/   vk1rm   s      r#   *test_compare_verifying_key_with_precomputez9TestSigningKey.test_compare_verifying_key_with_precomputeA  s:    hh$$nn**c"r%   c                     | j                   j                  d      }| j                   j                  }|j                  d       | j	                  |j                  |d             y )Ns   other messageT)lazy)rp   r   r   r   r   r   r   s      r#    test_verify_with_lazy_precomputez/TestSigningKey.test_verify_with_lazy_precomputeI  sJ    hhmm,-XX##
4 		#'789r%   c                 P    | j                  | j                  | j                         y r2   )r   r   rp   r.   s    r#   test_inequality_on_signing_keysz.TestSigningKey.test_inequality_on_signing_keysR  s    DHHdhh/r%   c                 <    | j                  | j                  d        y r2   )r   r   r.   s    r#   /test_inequality_on_signing_keys_not_implementedz>TestSigningKey.test_inequality_on_signing_keys_not_implementedU  s    DHHd+r%   c                     d}t        j                  |      }t        j                  dt              }| j	                  ||       y )Nzw-----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEIDS6x9FO1PG8T4xIPg8Zd0z8uL6sVGZFEZrX17gHC/XU
-----END PRIVATE KEY-----
    4NOH>wLTfE׸)r   rk   r    r   r)   r/   r   rl   sk_strs       r#   test_ed25519_from_pemz$TestSigningKey.test_ed25519_from_pemX  sI    * 	   )''P
 	V$r%   c                     t        j                  dt              }d}| j                  |j	                  d      |       y )Nr  sw   -----BEGIN PRIVATE KEY-----
MC4CAQAwBQYDK2VwBCIEIDS6x9FO1PG8T4xIPg8Zd0z8uL6sVGZFEZrX17gHC/XU
-----END PRIVATE KEY-----
pkcs8format)r   r    r   r)   r   r/   rl   r   s      r#   test_ed25519_to_pemz"TestSigningKey.test_ed25519_to_pemi  sB    ##P
+ 	 	'2G<r%   c                     t        j                  t              }t        j                  |j	                  d            }| j                  ||       y Nr  r  )r   rn   r   rk   r   r)   r/   rl   decodeds      r#   test_ed25519_to_and_from_pemz+TestSigningKey.test_ed25519_to_and_from_pemx  s=      )%%biiwi&?@W%r%   c                     d}t        j                  |      }t        j                  dt              }| j	                  ||       y )Nz-----BEGIN PRIVATE KEY-----
MEcCAQAwBQYDK2VxBDsEOTyFuXqFLXgJlV8uDqcOw9nG4IqzLiZ/i5NfBDoHPzmP
OP0JMYaLGlTzwovmvCDJ2zLaezu9NLz9aQ==
-----END PRIVATE KEY-----
9   <z-x	_..&_:?98	1T 2{;4i)r   rk   r    r   r)   r	  s       r#   r   z"TestSigningKey.test_ed448_from_pem  sJ    * 	   )''4 
 	V$r%   c                     t        j                  dt              }d}| j                  |j	                  d      |       y )Nr  s   -----BEGIN PRIVATE KEY-----
MEcCAQAwBQYDK2VxBDsEOTyFuXqFLXgJlV8uDqcOw9nG4IqzLiZ/i5NfBDoHPzmP
OP0JMYaLGlTzwovmvCDJ2zLaezu9NLz9aQ==
-----END PRIVATE KEY-----
r  r  )r   r    r   r)   r   r  s      r#   r   z TestSigningKey.test_ed448_to_pem  sC    ##4 
+ 	 	'2G<r%   c                     t        j                  t              }t        j                  |j	                  d            }| j                  ||       y r  )r   rn   r   rk   r   r)   r  s      r#   test_ed448_encode_decodez'TestSigningKey.test_ed448_encode_decode  s=      '%%biiwi&?@"%r%   N)r^   r_   r`   ra   rb   r$   r   r   r   r   r   r   r  r  r  r  r  r  r   r   r  rc   r%   r#   r   r     sf    
 3 38"2&--4#:0,%"=&%&="&r%   r   c                   @    e Zd Zed        Zd Zd Zd Zd Zd Z	d Z
y)	TestTrivialCurvec                     t        ddd      }t        |ddddd	      }t        d
||d      | _        t	        j
                  d| j                  t        j                        | _        y )N   T   :      W   r      T)r   toy_p8)r   r"  r      )hashfunc)	r   r   r   	toy_curver   r   r   sha1rl   )r"   ro   gens      r#   r$   zTestTrivialCurve.setUpClass  s[     R$%B3$?hsI>00MM\\
r%   c                 ~    | j                   j                  }| j                  ||j                         z  t               y r2   )r(  r   r)   orderr   )r/   r*  s     r#   test_generator_sanityz&TestTrivialCurve.test_generator_sanity  s,    nn&&syy{*H5r%   c                 l    | j                  | j                  j                  j                         d       y )Ns   )r)   rl   r   r4   r.   s    r#   test_public_key_sanityz'TestTrivialCurve.test_public_key_sanity  s%    ..88:KHr%   c                     | j                   j                  d      }| j                  |d       | j                  | j                   j                  j                  |d             y )Nr   s   -.rl   sign_deterministicr)   r   r   r   )r/   r   s     r#   test_deterministic_signz(TestTrivialCurve.test_deterministic_sign  sI    gg((4e$--44S*EFr%   c                    t        j                  d      }| j                  j                  |      }| j	                  t        |      d       | j                  | j                  j                  j                  ||             y )N    r"  )	osurandomrl   r2  r)   lenr   r   r   r/   msgr   s      r#   &test_deterministic_sign_random_messagez7TestTrivialCurve.test_deterministic_sign_random_message  sZ    jjngg((-S1%--44S#>?r%   c                     d}| j                   j                  |      }| j                  |d       | j                  | j                   j                  j                  ||             y )Ns    Os   6r1  r9  s      r#   /test_deterministic_sign_that_rises_R_zero_errorz@TestTrivialCurve.test_deterministic_sign_that_rises_R_zero_error  sP     gg((-k*--44S#>?r%   c                     d}| j                   j                  |      }| j                  |d       | j                  | j                   j                  j                  ||             y )Ns   ms   Ilr1  r9  s      r#   /test_deterministic_sign_that_rises_S_zero_errorz@TestTrivialCurve.test_deterministic_sign_that_rises_S_zero_error  sN    gg((-k*--44S#>?r%   N)r^   r_   r`   rb   r$   r-  r/  r3  r;  r=  r?  rc   r%   r#   r  r    s7    
 
"6
IG@@@r%   r  rg   sd   some string for signingcontents don't really matterbut do include also some crazy values:  	
      )	sigencoderj   c                     | S r2   rc   r,   s    r#   <lambda>rD         r%   zbytes memoryviewc                     t        |       S r2   )r3   rC  s    r#   rD  rD    s
    6!9 r%   r9   c                     t        |       S r2   )r9   rC  s    r#   rD  rD    s
    IaL r%   zbytearray memoryviewc                 *    t        t        |             S r2   r3   r9   rC  s    r#   rD  rD        vil'; r%   zarray.array of bytesc                 .    t        j                   d|       S r>   rA   rC  s    r#   rD  rD        u{{3': r%   zarray.array of bytes memoryviewc                 @    t        t        j                  d|             S r>   r3   rA   rC  s    r#   rD  rD        &S!9L2M r%   zarray.array of intsc                 .    t        j                   d|       S rK   rL  rC  s    r#   rD  rD  	      ekk#q&9 r%   zarray.array of ints memoryviewc                 @    t        t        j                  d|             S rK   rO  rC  s    r#   rD  rD  
      C8K1L r%   intsc                     | S r2   rc   rC  s    r#   rD  rD    s     r%   r   c                     t        |       S r2   convrC  s    r#   rD  rD    s
    T!W r%   derc                     t        |       S r2   rX  rC  s    r#   rD  rD    s
    $q' r%   stringsc                 &    t        d | D              S )Nc              3   2   K   | ]  }t        |        y wr2   rX  ).0is     r#   	<genexpr>z<lambda>.<locals>.<genexpr>  s     /DG/s   )tuplerC  s    r#   rD  rD    s    e/Q// r%   r   verify_digestz{2}-{0}-{1})idz1signature,decoder,mod_apply,fun,vrf_mthd,vrf_datac                 :     ||       } || ||      |      sJ y )N)	sigdecoderc   )	signaturedecoder	mod_applyfunvrf_mthdvrf_datar   s          r#   test_VerifyingKey_verifyrm  +  s$     I
CCX':::r%   s   ^BRB<V%wrZ   c                     | S r2   rc   rC  s    r#   rD  rD  >  rE  r%   c                 *    t        t        |             S r2   rI  rC  s    r#   rD  rD  A  rJ  r%   c                 .    t        j                   d|       S r>   rL  rC  s    r#   rD  rD  B  rM  r%   c                 @    t        t        j                  d|             S r>   rO  rC  s    r#   rD  rD  C  rP  r%   c                 .    t        j                   d|       S rK   rL  rC  s    r#   rD  rD  D  rR  r%   c                 @    t        t        j                  d|             S rK   rO  rC  s    r#   rD  rD  E  rT  r%   convertc                 x     | t               }t        j                  |      }|j                         t         k(  sJ y r2   )prv_key_bytesr   r    r4   rt  keyrl   s      r#   test_SigningKey_from_stringry  J  s0    
-
 C				$B<<>]***r%   c                 x     | t               }t        j                  |      }|j                         t        k(  sJ y r2   )r   r   r   r4   rv  rw  s      r#   test_SigningKey_from_derr|  _  s0    
)
C			S	!B<<>]***r%   s   
c                     t         j                   | t               | t                    }t        j                  |t               y N)extra_entropy)rl   r2  r   r  r!   r   rt  r   s     r#   "test_SigningKey_sign_deterministicr  k  s5    


W]%;   C IIc4r%   c                     t         j                   | t               | t                    }t        j                  |t               y r~  )rl   sign_digest_deterministic	data_hashr  r!   r   r   r  s     r#   )test_SigningKey_sign_digest_deterministicr  u  s6    

&
&	'-*@ ' C IIc4r%   c                 v    t         j                   | t                    }t        j	                  |t               y r2   )rl   r   r   r!   r   r  s     r#   test_SigningKey_signr  ~  s"    
'''$-
 CIIc4r%   c                 v    t         j                   | t                    }t        j	                  |t
               y r2   )rl   sign_digestr  r!   r   r   r  s     r#   test_SigningKey_sign_digestr    s#    
..+
,CIIc4r%   c                      t        j                  t        j                  dz
  t              } | j                  }| j                  d      }|j                  |d      sJ y )Nr   ru   s   hello)r   r   r   r,  r   r   r   )rl   r!   r   s      r#   #test_SigningKey_with_unlikely_valuer    sJ    		(	(!);8	LB			B
''(
C99S(###r%   c                  j   t         } t        | j                         | j                         | j	                         | j                               } t        d| j                         | d      }t        j                  d|      }t        j                  dt              }|j                  |j                  k(  sJ y )Nr   )
r      $   r  r  r"     r   r   r      )r   r   ro   r,   r-   r,  r   r   r   r   r   )r   ro   rl   rp   s       r#   +test_SigningKey_with_custom_curve_old_pointr    s    )I	I '	E 
	(	(U	3B

)
)"o
>C::$$$r%   c                      t        j                  dt              } t        j                  dt              }| j                  |j                  k7  sJ y )Nr"  )r   r   r   r   r   r   rp   s     r#   2test_VerifyingKey_inequality_with_different_curvesr    s@    

)
)!_
=C

)
)!X
6C 1 1111r%   c                      t        j                  dt              } t        j                  dt              }| j                  |j                  k7  sJ y )Nr"  r  )r   r   r   r   r  s     r#   9test_VerifyingKey_inequality_with_different_secret_pointsr    s@    

)
)!_
=C

)
)!_
=C 1 1111r%   c                  \    d} t        j                  |       }|j                  t        k(  sJ y )Nz-----BEGIN PRIVATE KEY-----
    MFMCAQEwBQYDK2VwBCIEICc2F2ag1n1QP0jY+g9qWx5sDkx0s/HdNi3cSRHw+zsI
    oSMDIQA+HQ2xCif8a/LMWR2m5HaCm5I2pKe/cc8OiRANMHxjKQ==
    -----END PRIVATE KEY-----)r   rk   ro   r   )pemrl   s     r#   &test_SigningKey_from_pem_pkcs8v2_EdDSAr    s-    !C
 
		S	!B88wr%   )b	unittest2unittestImportErrorr3   	NameError
memoryviewr6  rA   pytestr   keysr   r   r   rZ  r   r   r	   r
   r   utilr   r   r   r   r   r   curvesr   r   r   r   r   ellipticcurver   r   r   r   ecdsar   TestCaser   re   r   r  rq   r   ri   rj   r   rl   r   r!   r   r8  r)  updatedigestr  r   sig_rawsig_dersig_strings	verifiersmodifierrj  rY  
sig_formatrg  rh  ri  r   rc  method_namerk  rl  appendparamr  markparametrizerm  rv  
convertersr9   rt  ry  r|  r  r  r  r  r  r  r  r  r  r  rc   r%   r#   <module>r     s   
 
    ? ?   E D @ @ ,T>!2!2 T>nZ.h// Z.z
O&X&& O&d4@x(( 4@r%  +	)U# #Z#*  4y1} w||~ D KKM	)U# #
''$"2'
3'5! !
''$-'
0'5! !ggd&7g8+a.%( (	k,-();<:;&(MN9:%'LM	 &MHc 	)+<=	(9:/		
	6 1
Iw	 ryy$'b..	:0
 	+K8 $++Hj+N
		&R 7;;#  =R 
k );<:;&(MN9:%'LM	 
:Hg lfll7x89
: J/+ 0+%  +	)U# # JsO4+ 5+ 4 J/ 0 J/ 0 J/ 0 J/ 0$%.22k  
  Fs"   N< O <	O	O	OO