iota/crypto/types.py
def sign_input_transactions(self, bundle, start_index):
        # type: (Bundle, int) -> None
        """
        Signs the inputs starting at the specified index.

        :param bundle:
            The bundle that contains the input transactions to sign.

        :param start_index:
            The index of the first input transaction.

            If necessary, the resulting signature will be split across
            subsequent transactions automatically.
        """

        if not bundle.hash:
            raise with_context(
                exc=ValueError('Cannot sign inputs without a bundle hash!'),

                context={
                    'bundle': bundle,
                    'key_index': self.key_index,
                    'start_index': start_index,
                },
            )

        from iota.crypto.signing import SignatureFragmentGenerator
        signature_fragment_generator = (
            SignatureFragmentGenerator(self, bundle.hash)
        )

        # We can only fit one signature fragment into each transaction,
        # so we have to split the entire signature.
        for j in range(self.security_level):
            # Do lots of validation before we attempt to sign the
            # transaction, and attach lots of context info to any
            # exception.
            #
            # This method is likely to be invoked at a very low level in
            # the application, so if anything goes wrong, we want to
            # make sure it's as easy to troubleshoot as possible!
            try:
                txn = bundle[start_index + j]
            except IndexError as e:
                raise with_context(
                    exc=e,

                    context={
                        'bundle': bundle,
                        'key_index': self.key_index,
                        'current_index': start_index + j,
                    },
                )

            # Only inputs can be signed.
            if txn.value > 0:
                raise with_context(
                    exc=ValueError(
                        'Attempting to sign non-input transaction #{i} '
                        '(value={value}).'.format(
                            i=txn.current_index,
                            value=txn.value,
                        ),
                    ),

                    context={
                        'bundle': bundle,
                        'key_index': self.key_index,
                        'start_index': start_index,
                    },
                )

            if txn.signature_message_fragment:
                raise with_context(
                    exc=ValueError(
                        'Attempting to sign input transaction #{i}, '
                        'but it has a non-empty fragment '
                        '(is it already signed?).'.format(
                            i=txn.current_index,
                        ),
                    ),

                    context={
                        'bundle': bundle,
                        'key_index': self.key_index,
                        'start_index': start_index,
                    },
                )

            txn.signature_message_fragment = next(signature_fragment_generator)
def sign_input_transactions(self, bundle, start_index):
        # type: (Bundle, int) -> None
        if not bundle.hash:
            raise with_context(
                exc=ValueError('Cannot sign inputs without a bundle hash!'),

                context={
                    'bundle': bundle,
                    'key_index': self.key_index,
                    'start_index': start_index,
                },
            )

        from iota.crypto.signing import SignatureFragmentGenerator
        signature_fragment_generator = (
            SignatureFragmentGenerator(self, bundle.hash)
        )

        # We can only fit one signature fragment into each transaction,
        # so we have to split the entire signature.
        for j in range(self.security_level):
            # Do lots of validation before we attempt to sign the
            # transaction, and attach lots of context info to any
            # exception.
            #
            # This method is likely to be invoked at a very low level in
            # the application, so if anything goes wrong, we want to
            # make sure it's as easy to troubleshoot as possible!
            try:
                txn = bundle[start_index + j]
            except IndexError as e:
                raise with_context(
                    exc=e,

                    context={
                        'bundle': bundle,
                        'key_index': self.key_index,
                        'current_index': start_index + j,
                    },
                )

            # Only inputs can be signed.
            if txn.value > 0:
                raise with_context(
                    exc=ValueError(
                        'Attempting to sign non-input transaction #{i} '
                        '(value={value}).'.format(
                            i=txn.current_index,
                            value=txn.value,
                        ),
                    ),

                    context={
                        'bundle': bundle,
                        'key_index': self.key_index,
                        'start_index': start_index,
                    },
                )

            if txn.signature_message_fragment:
                raise with_context(
                    exc=ValueError(
                        'Attempting to sign input transaction #{i}, '
                        'but it has a non-empty fragment '
                        '(is it already signed?).'.format(
                            i=txn.current_index,
                        ),
                    ),

                    context={
                        'bundle': bundle,
                        'key_index': self.key_index,
                        'start_index': start_index,
                    },
                )

            txn.signature_message_fragment = next(signature_fragment_generator)
def sign_input_transactions ( self , bundle , start_index ) : # type: (Bundle, int) -> None if not bundle . hash : raise with_context ( exc = ValueError ( 'Cannot sign inputs without a bundle hash!' ) , context = { 'bundle' : bundle , 'key_index' : self . key_index , 'start_index' : start_index , } , ) from iota . crypto . signing import SignatureFragmentGenerator signature_fragment_generator = ( SignatureFragmentGenerator ( self , bundle . hash ) ) # We can only fit one signature fragment into each transaction, # so we have to split the entire signature. for j in range ( self . security_level ) : # Do lots of validation before we attempt to sign the # transaction, and attach lots of context info to any # exception. # # This method is likely to be invoked at a very low level in # the application, so if anything goes wrong, we want to # make sure it's as easy to troubleshoot as possible! try : txn = bundle [ start_index + j ] except IndexError as e : raise with_context ( exc = e , context = { 'bundle' : bundle , 'key_index' : self . key_index , 'current_index' : start_index + j , } , ) # Only inputs can be signed. if txn . value > 0 : raise with_context ( exc = ValueError ( 'Attempting to sign non-input transaction #{i} ' '(value={value}).' . format ( i = txn . current_index , value = txn . value , ) , ) , context = { 'bundle' : bundle , 'key_index' : self . key_index , 'start_index' : start_index , } , ) if txn . signature_message_fragment : raise with_context ( exc = ValueError ( 'Attempting to sign input transaction #{i}, ' 'but it has a non-empty fragment ' '(is it already signed?).' . format ( i = txn . current_index , ) , ) , context = { 'bundle' : bundle , 'key_index' : self . key_index , 'start_index' : start_index , } , ) txn . signature_message_fragment = next ( signature_fragment_generator )
Signs the inputs starting at the specified index.

        :param bundle:
            The bundle that contains the input transactions to sign.

        :param start_index:
            The index of the first input transaction.

            If necessary, the resulting signature will be split across
            subsequent transactions automatically.
Signs the inputs starting at the specified index .