How to use the @iota/transaction.signatureOrMessage function in @iota/transaction

To help you get started, we’ve selected a few @iota/transaction examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iotaledger / iota.js / packages / multisig / src / multisig.ts View on Github external
public addSignature(bundle: Int8Array, inputAddress: string, keyTrits: Int8Array, callback: Callback) {
        const bundleHashTrits = bundleHash(bundle)
        const normalizedBundleHash = normalizedBundle(bundleHashTrits)
        let signatureIndex = 0

        for (const offset = 0; offset < bundle.length * TRANSACTION_LENGTH; offset + TRANSACTION_LENGTH) {
            if (tritsToTrytes(address(bundle)) === inputAddress && isNinesTrytes(signatureOrMessage(bundle))) {
                const signature = new Int8Array(keyTrits.length)

                for (let i = 0; i < keyTrits.length / FRAGMENT_LENGTH; i++) {
                    signature.set(
                        signatureFragment(
                            normalizedBundleHash.slice(
                                i * NORMALIZED_FRAGMENT_LENGTH,
                                (i + 1) * NORMALIZED_FRAGMENT_LENGTH
                            ),
                            keyTrits.slice(i * FRAGMENT_LENGTH, (i + 1) * FRAGMENT_LENGTH)
                        ),
                        i * FRAGMENT_LENGTH
                    )
                }

                const bundleTrits = addSignatureOrMessage(bundle, signature, signatureIndex)