ó
©9Vc           @   s–   d  d l  Z  d  d l Z d  d l m Z d d l m Z d d d d d	 d
 d g Z d Z d Z d Z	 e d d ƒ Z
 d d „ Z d „  Z d „  Z d S(   iÿÿÿÿN(   t
   namedtuplei   (   t   djbect   crypto_signt   crypto_sign_opent   crypto_sign_keypairt   Keypairt   PUBLICKEYBYTESt   SECRETKEYBYTESt   SIGNATUREBYTESi    i@   t   vkt   skc         C   su   |  d k r t j t ƒ }  n t j d t ƒ t |  ƒ d k rO t d ƒ ‚ n  |  } t	 j
 | ƒ } t | | | ƒ S(   sC   Return (verifying, secret) key from a given seed, or os.urandom(32)s$   ed25519ll should choose random seed.i    s%   seed must be 32 random bytes or None.N(   t   Nonet   ost   urandomR   t   warningst   warnt   RuntimeWarningt   lent
   ValueErrorR   t	   publickeyR   (   t   seedt   skbytest   vkbytes(    (    s9   /tmp/pip-build-5Z5nTX/wheel/wheel/signatures/ed25519py.pyR      s    	c         C   s\   t  | ƒ t k r+ t d t  | ƒ ƒ ‚ n  | t } | t  } t j |  | | ƒ } | |  S(   s¦   Return signature+message given message and secret key.
    The signature is the first SIGNATUREBYTES bytes of the return value.
    A copy of msg is in the remainder.s   Bad signing key length %d(   R   R   R   R   R   t	   signature(   t   msgR
   R   R   t   sig(    (    s9   /tmp/pip-build-5Z5nTX/wheel/wheel/signatures/ed25519py.pyR       s    

c         C   sh   t  | ƒ t k r+ t d t  | ƒ ƒ ‚ n  t j |  t  |  t | ƒ } | s` t d | ƒ ‚ n  |  t S(   s=   Return message given signature+message and the verifying key.s   Bad verifying key length %ds
   rc != True(   R   R   R   R   t
   checkvalidR   (   t   signedR	   t   rc(    (    s9   /tmp/pip-build-5Z5nTX/wheel/wheel/signatures/ed25519py.pyR   ,   s    (   s   vks   sk(   R   R   t   collectionsR    t    R   t   __all__R   R   R   R   R   R   R   R   (    (    (    s9   /tmp/pip-build-5Z5nTX/wheel/wheel/signatures/ed25519py.pyt   <module>   s   	