U q` @sddlmZmZmZddlmZddlmZm Z ddl m Z e e j Ze Ze ZdZdZerre Ze ZddZddZd d Zd d Zd dZddZdS))absolute_importdivisionprint_function) exceptions)ffilib)ensurecCs@tdt}t||}t|dkdtjdt|t ddS)z Computes and returns the scalar product of a standard group element and an integer ``n``. :param n: bytes :rtype: bytes unsigned char[]rUnexpected library errorZraisingN) rnewcrypto_scalarmult_BYTESrcrypto_scalarmult_baserexc RuntimeErrorbuffercrypto_scalarmult_SCALARBYTESnqrcrF/tmp/pip-target-nv4zd3e_/lib/python/nacl/bindings/crypto_scalarmult.pyr&s  rcCsBtdt}t|||}t|dkdtjdt|t ddS)z Computes and returns the scalar product of the given group element and an integer ``n``. :param p: bytes :param n: bytes :rtype: bytes r rr r N) rr r rcrypto_scalarmultrrrrrrprrrrrr8s rcCsxttdtjdtt|to&t|tkddtj dt dt }t ||}t|dkdtjdt |t ddS) a Computes and returns the scalar product of a standard group element and an integer ``n`` on the edwards25519 curve. :param n: a :py:data:`.crypto_scalarmult_ed25519_SCALARBYTES` long bytes sequence representing a scalar :type n: bytes :return: a point on the edwards25519 curve, represented as a :py:data:`.crypto_scalarmult_ed25519_BYTES` long bytes sequence :rtype: bytes :raises nacl.exceptions.UnavailableError: If called when using a minimal build of libsodium. Not available in minimal buildr &Input must be a {} long bytes sequence%crypto_scalarmult_ed25519_SCALARBYTESr rr N)rhas_crypto_scalarmult_ed25519rUnavailableError isinstancebyteslenrformat TypeErrorrr crypto_scalarmult_ed25519_BYTESrcrypto_scalarmult_ed25519_baserrrrrrr'Ks$    r'cCsxttdtjdtt|to&t|tkddtj dt dt }t ||}t|dkdtjdt |t ddS) a: Computes and returns the scalar product of a standard group element and an integer ``n`` on the edwards25519 curve. The integer ``n`` is not clamped. :param n: a :py:data:`.crypto_scalarmult_ed25519_SCALARBYTES` long bytes sequence representing a scalar :type n: bytes :return: a point on the edwards25519 curve, represented as a :py:data:`.crypto_scalarmult_ed25519_BYTES` long bytes sequence :rtype: bytes :raises nacl.exceptions.UnavailableError: If called when using a minimal build of libsodium. rr rrr rr N)rrrr r!r"r#rr$r%rr r&r&crypto_scalarmult_ed25519_base_noclamprrrrrrr(ms$    r(cCsttdtjdtt|to&t|tkddtj dtt|toNt|t kddtj dt dt }t |||}t|dkdtjdt |t d d S) aq Computes and returns the scalar product of a *clamped* integer ``n`` and the given group element on the edwards25519 curve. The scalar is clamped, as done in the public key generation case, by setting to zero the bits in position [0, 1, 2, 255] and setting to one the bit in position 254. :param n: a :py:data:`.crypto_scalarmult_ed25519_SCALARBYTES` long bytes sequence representing a scalar :type n: bytes :param p: a :py:data:`.crypto_scalarmult_ed25519_BYTES` long bytes sequence representing a point on the edwards25519 curve :type p: bytes :return: a point on the edwards25519 curve, represented as a :py:data:`.crypto_scalarmult_ed25519_BYTES` long bytes sequence :rtype: bytes :raises nacl.exceptions.UnavailableError: If called when using a minimal build of libsodium. rr rrr&r rr N)rrrr r!r"r#rr$r%r&rr rcrypto_scalarmult_ed25519rrrrrrr)s2     r)cCsttdtjdtt|to&t|tkddtj dtt|toNt|t kddtj dt dt }t |||}t|dkdtjdt |t d d S) a Computes and returns the scalar product of an integer ``n`` and the given group element on the edwards25519 curve. The integer ``n`` is not clamped. :param n: a :py:data:`.crypto_scalarmult_ed25519_SCALARBYTES` long bytes sequence representing a scalar :type n: bytes :param p: a :py:data:`.crypto_scalarmult_ed25519_BYTES` long bytes sequence representing a point on the edwards25519 curve :type p: bytes :return: a point on the edwards25519 curve, represented as a :py:data:`.crypto_scalarmult_ed25519_BYTES` long bytes sequence :rtype: bytes :raises nacl.exceptions.UnavailableError: If called when using a minimal build of libsodium. rr rrr&r rr N)rrrr r!r"r#rr$r%r&rr r!crypto_scalarmult_ed25519_noclamprrrrrrr*s2     r*N) __future__rrrZnaclrrZ nacl._sodiumrrZnacl.exceptionsrboolZ$PYNACL_HAS_CRYPTO_SCALARMULT_ED25519rZcrypto_scalarmult_bytesr Zcrypto_scalarmult_scalarbytesrr&rZcrypto_scalarmult_ed25519_bytesZ%crypto_scalarmult_ed25519_scalarbytesrrr'r(r)r*rrrrs(  "".