INNER CODE UNIT · Python

generate_keypair

open-quantum-safe/liboqs-python · oqs/oqs.py:488

    def generate_keypair(self) -> bytes:
        """
        Generate a new keypair and returns the public key.

        If needed, the secret key can be obtained with export_secret_key().
        """
        public_key = ct.create_string_buffer(self._kem.contents.length_public_key)
        self.secret_key = ct.create_string_buffer(self._kem.contents.length_secret_key)
        rv = native().OQS_KEM_keypair(
            self._kem,
            ct.byref(public_key),
            ct.byref(self.secret_key),
        )
        if rv == OQS_SUCCESS:
            return bytes(public_key)
        msg = "Can not generate keypair"
        raise RuntimeError(msg)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…