Esempio n. 1
0
    def __init__(self, crypto: Crypto, key: bytes) -> None:
        """Constructor."""

        # Set the Crypto class.
        self.crypto: Crypto = crypto

        # Set the keys.
        self.private_spend_key: bytes = ed.encodeint(ed.decodeint(key) % ed.l)
        self.public_spend_key: bytes = ed.public_from_secret(
            self.private_spend_key)
        self.private_view_key: bytes = ed.Hs(self.private_spend_key)
        self.public_view_key: bytes = ed.public_from_secret(
            self.private_view_key)
    def generate_input_key(
        self,
        output: OutputInfo,
        private_view_key: bytes,
        private_spend_key: bytes,
    ) -> bytes:
        """Generate the one-time private key associated with an input."""

        if isinstance(output, MoneroOutputInfo):
            return ed.encodeint((ed.decodeint(output.amount_key) +
                                 ed.decodeint(private_spend_key)) % ed.l)
        else:
            raise Exception("MoneroCrypto handed a non-Monero OutputInfo.")