Manuscript Offprint

arXiv:2610.32017

SynMark: Semantic-Coordinate Multi-Bit Watermarking during LLM Code Generation

Rui Xu, Weizhi Liu, Zhaoxia Yin

ABSTRACT

LLM-generated code is increasingly reused across downstream applications and often undergoes identifier renaming or structural refactoring, making robustness to functionality-preserving edits essential for generative multi-bit code watermarking. Existing methods commonly derive message routes from surface-token prefixes, so such edits can desynchronize routing and degrade watermark recovery. We propose SynMark, which replaces surface-dependent routing with learned semantic coordinates and further calibrates residual recovery errors after transformation. For watermark embedding, Scope learns semantic coordinates from aligned prefixes of functionally equivalent variants for keyed routing and applies a syntax-aware adaptive bias during generation. For watermark extraction, Traced recomputes semantic routes from transformed code and uses reliability-weighted aggregation to suppress unreliable token contributions. Under 100% identifier renaming, SynMark retains 82.27% and 83.77% BitAcc on CodeLlama and DeepSeek-Coder, respectively. Across three code LMs, it also improves clean BitAcc and Pass@1 by up to 4.53 and 11.18 percentage points over the strongest watermarked baselines.

Index Terms— code generation, multi-bit watermarking, semantic synchronization, syntax-aware embedding

1. INTRODUCTION

Large language models increasingly generate code that is reused across downstream projects, where identifier renaming, reformatting, and structural refactoring are common [1]. However, external records such as generation logs and platform metadata do not travel with reused code, making provenance difficult to maintain after such edits. Generative watermarking addresses this problem by embedding provenance information directly into token selection, allowing the signal to remain with the generated code when external records are unavailable [2, 3].

However, existing generative watermarking methods struggle to trace code fragments after semantics-preserving transformations. They commonly derive keyed message routes and candidate sets directly from surface-token prefixes [4, 5, 6]. Transformations can then impair recovery at

Figure

Fig. 1. Token-based and semantic-coordinate routing under identifier renaming. Binary strings are two-bit message symbols; token-based routing uses nearby tokens, while SynMark routes from a semantic coordinate of the full prefix.

two coupled levels: (i) modified prefixes may cause the detector to reconstruct routes or candidate sets different from those used during generation, as illustrated in Fig. 1; and (ii) even under a correct route, renamed, inserted, or rewritten tokens may produce unreliable recovery signals. The former changes message-block assignment, while the latter degrades token-level recovery after routing. Increasing the watermark bias cannot correct either failure and may alter syntax-sensitive token choices, reducing functional correctness. Robust recovery therefore requires both stable semantic routing references and calibration of the residual transformation-induced variation in token-level recovery signals.

We propose SynMark, a generative multi-bit watermarking framework that embeds watermark messages during LLM code generation. Unlike existing methods that directly couple keyed routing to surface-token prefixes, Scope first maps each prefix to a discrete semantic coordinate learned from aligned, functionally equivalent code variants and performs keyed block assignment on this intermediate reference. During generation, Scope also applies a syntax-aware adaptive bias to limit watermark-induced changes at syntax-sensitive positions. Since semantic routing reduces but does not eliminate transformation-induced variation, Traced recomputes semantic routes during extraction and calibrates the remaining token-level recovery signals through candidate-score correction and reliability-weighted aggregation.

We evaluate SynMark on HumanEval with OpenCoder, CodeLlama, and DeepSeek-Coder against MPAC, CredID, XMark, and CodeIP. SynMark improves 8-bit message re-covery across all three generators, retains higher Pass@1 than competing watermarked methods, and achieves stronger recovery under identifier renaming and random code transformations.

Our main contributions are summarized as follows:

• Semantic-coordinate routing. We introduce a causal routing mechanism that learns discrete semantic coordinates from aligned prefixes of functionally equivalent code, reducing dependence on surface-token references during both embedding and extraction.

• Syntax-aware watermark embedding. We develop an adaptive logit bias that limits watermark-induced changes at syntax-sensitive positions while retaining the default embedding strength elsewhere.

• Reliability-weighted extraction. We design Traced to compensate for residual transformation-induced drift in token-level recovery signals through candidate-score correction and reliability-weighted aggregation.

References (16)