Rule

generic-witness-maybe-abi

Shared generic optional witness dispatch has incompatible mandatory bigint/byte-array payload guards; profile-specific compatibility review.

Release v0.1.1View Markdown

Specimen 60 of 96 · Other active opt-ins / Privacy and cryptographic derivations

Severity
low
Confidence
low
Maturity
experimental
Selection
Opt-in
Policy intent
not required
Release
v0.1.1
Engine facts used
resolved-source-references canonical-generic-specializations resolved-types

Selection and scope#

Not selected by default. Select it with --detectors or the detectors list in nightshade.json. Either one replaces profile selection, so list every rule you want.

Shell
./.nightshade/node_modules/.bin/nightshade ./contracts --detectors generic-witness-maybe-abi
./.nightshade/node_modules/.bin/nightshade detector show generic-witness-maybe-abi

The first command runs only this rule; --detectors takes a comma-separated list. The second prints the rule's metadata from your installed version.

Severity is review priority. It does not express exploitability or impact. Confidence is detector metadata, not a probability. All built-in rules are experimental.

Compiler scope: the engine supports the pinned profiles 0.28.0, 0.29.0, 0.30.0, 0.31.1, 0.33.0-rc.2, 0.34.0, 0.35.0-rc.1 and 0.35.0, with ZKIR2 by default. Support for this rule can be narrower; the rule documentation below states any narrower scope.

Corpus checks#

Synthetic corpus checks for this rule in the 0.1.1 proof run. A check counts only with compiler acceptance and complete analysis.

Positive detectedCorrected quietLookalike quietOther negative quietIncomplete
1/11/11/10/00

No deviations were recorded for this rule.

These are behavior checks on synthetic fixtures, not a precision or recall estimate. See evaluation.

Rule documentation#

From docs/detectors/generic-witness-maybe-abi.md at v0.1.1.

Availability: opt-in ABI compatibility review, no policy required. Severity/confidence: low/high. Select with --detectors generic-witness-maybe-abi.

Under Compact 0.34.0/ZKIR2, concrete specializations of one generic witness dispatch to the same host method without a generic type argument. When its result is the canonical standard-library Maybe<T>, the generated wrapper checks value even when is_some is false. A bigint payload and a byte-array payload cannot use one fixed absent-result placeholder. This rule reports the static signature relationship, with the declaration, conflicting return types and source reference sites grouped into one finding per canonical witness template.

Compact
import CompactStandardLibrary;
witness lookup<T>(key: Bytes<4>): Maybe<T>;
export circuit getNumber(key: Bytes<4>): Maybe<Uint<64>> {
  return disclose(lookup<Uint<64>>(key));
}
export circuit getBytes(key: Bytes<4>): Maybe<Bytes<32>> {
  return disclose(lookup<Bytes<32>>(key));
}

A shared host handler may distinguish keys, private state, call order or other context and return the correct typed payload. This is not evidence that the handler fails. Review absent-result handling and the generated witness signatures. Use distinct host witness names when incompatible result representations should have independent handlers. Uint<64> and Field are a quiet lookalike because their ordinary payload guards both accept 0n.

The rule requires identical concrete parameter types and known disjoint bigint/byte-array result representations. Resolved import/type aliases retain identity; separate concrete module instances and different witness declarations are kept separate. It describes the entry-reachable source/schema graph, including constant-dead references and zero-iteration callbacks whose wrappers the qualified compiler retains. It does not assert a successful invocation or proof feasibility.

The compiler-only distinct-module probe also emits one shared host method spelling. This initial rule groups only one canonical template: a quiet distinct-instance control is a scope negative, not evidence of separate dispatch or ABI safety.

Suppress a match#

If a match is intentional, suppress it on the line before with the exact rule ID and a reason of at least eight characters:

Compact
// nightshade-disable-next-line generic-witness-maybe-abi -- Reason this match is intentional

Diagnostics cannot be suppressed, and an unmatched directive for a selected rule makes analysis incomplete. See configuration for fingerprint suppressions and baselines.

References#