# tamperEnvelope

> **tamperEnvelope**(`bytes`, `reason`): `Uint8Array`

Defined in: [packages/wire/src/envelope.ts:324](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/wire/src/envelope.ts#L324)

Copy a valid artifact and damage the copy so that decoding it fails for exactly `reason`.

Every reason but `unsupported-payload-version` is raised by [deserializeEnvelope](/reference/knotkit/wire/functions/deserializeenvelope/); that one yields a valid envelope carrying another payload version, for the owning package’s gate to refuse.

## Parameters

### bytes

`Uint8Array`

### reason

`"invalid-magic"` | `"unsupported-envelope-version"` | `"unsupported-payload-version"` | `"invalid-section-geometry"` | `"nonzero-padding"` | `"misaligned-section"` | `"truncated-payload"` | `"unstable-buffer"` | `"integrity-mismatch"`

## Returns

`Uint8Array`

## Throws

With `INVALID_ARGUMENT` when `bytes` is not a valid envelope, when it has no section for `invalid-section-geometry` or `misaligned-section` to damage, or when `unstable-buffer` is asked of a runtime that exposes no `SharedArrayBuffer`.
