Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)