ó Û_e[c@`sÌddlmZmZmZddlmZddlmZm Z ddl m Z e j ƒZ e jƒdZe jƒZe jƒZe jƒZd„Zd„Zd„Zd „Zd „Zd „Zd S( i(tabsolute_importtdivisiontprint_function(t exceptions(tffitlib(tensureicC`svtjdtƒ}tjdtƒ}tj||ƒ}t|dkddtjƒtj |tƒtj |tƒfS(su Returns a randomly generated public key and secret key. :rtype: (bytes(public_key), bytes(secret_key)) sunsigned char[]isUnexpected library errortraising( Rtnewtcrypto_sign_PUBLICKEYBYTEStcrypto_sign_SECRETKEYBYTESRtcrypto_sign_keypairRtexct RuntimeErrortbuffer(tpktsktrc((s;/tmp/pip-install-KP2Jbq/pynacl/nacl/bindings/crypto_sign.pyR s  cC`st|ƒtkr$tjdƒ‚ntjdtƒ}tjdtƒ}tj |||ƒ}t |dkddtj ƒtj |tƒtj |tƒfS(s  Computes and returns the public key and secret key using the seed ``seed``. :param seed: bytes :rtype: (bytes(public_key), bytes(secret_key)) s Invalid seedsunsigned char[]isUnexpected library errorR( tlentcrypto_sign_SEEDBYTESR t ValueErrorRRR R Rtcrypto_sign_seed_keypairRR R(tseedRRR((s;/tmp/pip-install-KP2Jbq/pynacl/nacl/bindings/crypto_sign.pyR3s  cC`s}tjdt|ƒtƒ}tjdƒ}tj|||t|ƒ|ƒ}t|dkddtjƒtj ||dƒS(s© Signs the message ``message`` using the secret key ``sk`` and returns the signed message. :param message: bytes :param sk: bytes :rtype: bytes sunsigned char[]sunsigned long long *isUnexpected library errorR( RRRtcrypto_sign_BYTESRt crypto_signRR R R(tmessageRtsignedt signed_lenR((s;/tmp/pip-install-KP2Jbq/pynacl/nacl/bindings/crypto_sign.pyRKs !  cC`sutjdt|ƒƒ}tjdƒ}tj|||t|ƒ|ƒdkr`tjdƒ‚ntj||dƒS(sÄ Verifies the signature of the signed message ``signed`` using the public key ``pk`` and returns the unsigned message. :param signed: bytes :param pk: bytes :rtype: bytes sunsigned char[]sunsigned long long *isSignature was forged or corrupt(RRRRtcrypto_sign_openR tBadSignatureErrorR(RRRt message_len((s;/tmp/pip-install-KP2Jbq/pynacl/nacl/bindings/crypto_sign.pyR_s !cC`s{t|ƒtkr$tjdƒ‚nt}tjd|ƒ}tj||ƒ}t |dkddtj ƒtj ||ƒS(s Converts a public Ed25519 key (encoded as bytes ``public_key_bytes``) to a public Curve25519 key as bytes. Raises a ValueError if ``public_key_bytes`` is not of length ``crypto_sign_PUBLICKEYBYTES`` :param public_key_bytes: bytes :rtype: bytes sInvalid curve public keysunsigned char[]isUnexpected library errorR( RR R Rtcrypto_sign_curve25519_BYTESRRRt$crypto_sign_ed25519_pk_to_curve25519RR R(tpublic_key_bytestcurve_public_key_lentcurve_public_keyR((s;/tmp/pip-install-KP2Jbq/pynacl/nacl/bindings/crypto_sign.pyR rs     cC`s{t|ƒtkr$tjdƒ‚nt}tjd|ƒ}tj||ƒ}t |dkddtj ƒtj ||ƒS(s Converts a secret Ed25519 key (encoded as bytes ``secret_key_bytes``) to a secret Curve25519 key as bytes. Raises a ValueError if ``secret_key_bytes``is not of length ``crypto_sign_SECRETKEYBYTES`` :param public_key_bytes: bytes :rtype: bytes sInvalid curve public keysunsigned char[]isUnexpected library errorR( RR R RRRRRt$crypto_sign_ed25519_sk_to_curve25519RR R(tsecret_key_bytestcurve_secret_key_lentcurve_secret_keyR((s;/tmp/pip-install-KP2Jbq/pynacl/nacl/bindings/crypto_sign.pyR$Œs     N(t __future__RRRtnaclRR t nacl._sodiumRRtnacl.exceptionsRtcrypto_sign_bytesRtcrypto_sign_secretkeybytesRtcrypto_sign_publickeybytesR R tcrypto_box_secretkeybytesRR RRRR R$(((s;/tmp/pip-install-KP2Jbq/pynacl/nacl/bindings/crypto_sign.pyts