σ Ϋ_e[c@`sΫddlmZmZmZddlZddlZddlmZddlmZ ddl m Z m ZddlmZmZdejfd„ƒYZd ejeefd „ƒYZd ejeefd „ƒYZdS( i(tabsolute_importtdivisiontprint_functionN(tencoding(t exceptions(t PrivateKeyt PublicKey(t StringFixertrandomt SignedMessagecB`s;eZdZed„ƒZed„ƒZed„ƒZRS(sc A bytes subclass that holds a messaged that has been signed by a :class:`SigningKey`. cC`s"||ƒ}||_||_|S(N(t _signaturet_message(tclst signaturetmessagetcombinedtobj((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyt _from_parts!s   cC`s|jS(sL The signature contained within the :class:`SignedMessage`. (R (tself((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyR (scC`s|jS(sJ The message contained within the :class:`SignedMessage`. (R (R((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyR/s(t__name__t __module__t__doc__t classmethodRtpropertyR R(((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyR st VerifyKeycB`s\eZdZejd„Zd„Zd„Zd„Zd„Z dejd„Z d„Z RS( sΰ The public key counterpart to an Ed25519 SigningKey for producing digital signatures. :param key: [:class:`bytes`] Serialized Ed25519 public key :param encoder: A class that is able to decode the `key` cC`sq|j|ƒ}t|tƒs0tjdƒ‚nt|ƒtjjkrdtj dtjjƒ‚n||_ dS(Ns'VerifyKey must be created from 32 bytess%The key must be exactly %s bytes long( tdecodet isinstancetbytestexct TypeErrortlentnacltbindingstcrypto_sign_PUBLICKEYBYTESt ValueErrort_key(Rtkeytencoder((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyt__init__@scC`s|jS(N(R#(R((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyt __bytes__NscC`stt|ƒƒS(N(thashR(R((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyt__hash__QscC`s5t||jƒstStjjt|ƒt|ƒƒS(N(Rt __class__tFalseRR t sodium_memcmpR(Rtother((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyt__eq__TscC`s ||k S(N((RR-((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyt__ne__YscC`s>|dk r||}n|j|ƒ}tjj||jƒS(sS Verifies the signature of a signed message, returning the message if it has not been tampered with else raising :class:`~nacl.signing.BadSignatureError`. :param smessage: [:class:`bytes`] Either the original messaged or a signature and message concated together. :param signature: [:class:`bytes`] If an unsigned message is given for smessage then the detached signature must be provided. :param encoder: A class that is able to decode the secret message and signature. :rtype: :class:`bytes` N(tNoneRRR tcrypto_sign_openR#(RtsmessageR R%((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pytverify\s  cC`stjj|jƒ}t|ƒS(s› Converts a :class:`~nacl.signing.VerifyKey` to a :class:`~nacl.public.PublicKey` :rtype: :class:`~nacl.public.PublicKey` (RR t$crypto_sign_ed25519_pk_to_curve25519R#t_Curve25519_PublicKey(Rtraw_pk((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pytto_curve25519_public_keytsN( RRRRt RawEncoderR&R'R)R.R/R0R3R7(((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyR7s    t SigningKeycB`sheZdZejd„Zd„Zd„Zd„Zd„Z e d„ƒZ ejd„Z d„Z RS( sΩ Private key for producing digital signatures using the Ed25519 algorithm. Signing keys are produced from a 32-byte (256-bit) random seed value. This value can be passed into the :class:`~nacl.signing.SigningKey` as a :func:`bytes` whose length is 32. .. warning:: This **must** be protected and remain secret. Anyone who knows the value of your :class:`~nacl.signing.SigningKey` or it's seed can masquerade as you. :param seed: [:class:`bytes`] Random 32-byte value (i.e. private key) :param encoder: A class that is able to decode the seed :ivar: verify_key: [:class:`~nacl.signing.VerifyKey`] The verify (i.e. public) key that corresponds with this signing key. cC`s‘|j|ƒ}t|tƒs0tjdƒ‚nt|ƒtjjkrdtj dtjjƒ‚ntjj |ƒ\}}||_ ||_ t |ƒ|_dS(Ns.SigningKey must be created from a 32 byte seeds&The seed must be exactly %d bytes long(RRRRRRRR tcrypto_sign_SEEDBYTESR"tcrypto_sign_seed_keypairt_seedt _signing_keyRt verify_key(RtseedR%t public_keyt secret_key((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyR&’s   cC`s|jS(N(R<(R((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyR'¦scC`stt|ƒƒS(N(R(R(R((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyR)©scC`s5t||jƒstStjjt|ƒt|ƒƒS(N(RR*R+RR R,R(RR-((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyR.¬scC`s ||k S(N((RR-((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyR/±scC`s|ttjjƒdtjƒS(s Generates a random :class:`~nacl.signing.SigningKey` object. :rtype: :class:`~nacl.signing.SigningKey` R%(RRR R:RR8(R ((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pytgenerate΄scC`sltjj||jƒ}tjj}|j|| ƒ}|j||ƒ}|j|ƒ}tj|||ƒS(sρ Sign a message using this key. :param message: [:class:`bytes`] The data to be signed. :param encoder: A class that is used to encode the signed message. :rtype: :class:`~nacl.signing.SignedMessage` (RR t crypto_signR=tcrypto_sign_BYTEStencodeR R(RRR%t raw_signedRDR tsigned((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pytsignΐs  cC`s%|j}tjj|ƒ}t|ƒS(sž Converts a :class:`~nacl.signing.SigningKey` to a :class:`~nacl.public.PrivateKey` :rtype: :class:`~nacl.public.PrivateKey` (R=RR t$crypto_sign_ed25519_sk_to_curve25519t_Curve25519_PrivateKey(Rtskt raw_private((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pytto_curve25519_private_keyΡs (RRRRR8R&R'R)R.R/RRBRHRM(((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyR9s     (t __future__RRRtsixt nacl.bindingsRRRRt nacl.publicRRJRR5t nacl.utilsRRt binary_typeR t EncodabletobjectRR9(((s./tmp/pip-install-KP2Jbq/pynacl/nacl/signing.pyts  H