ts-forensic-watermark 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,208 @@
1
+ # ts-forensic-watermark
2
+
3
+ A forensic watermarking (steganography) library in TypeScript.
4
+
5
+ While the core mathematical logic is pure TypeScript and environment-agnostic, **this library includes convenient Node.js helpers powered by `jimp` and `fluent-ffmpeg`**. This "batteries-included" approach allows you to process image buffers and video files directly with a single function call.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install ts-forensic-watermark
11
+ ```
12
+ *(Note: `jimp`, `fluent-ffmpeg`, and `ffmpeg-static` are installed automatically. Because static FFmpeg binaries are included, **you do NOT need to install FFmpeg on your OS**—video processing works out of the box).*
13
+
14
+ ## Usage (Node.js Helpers)
15
+
16
+ ### 1. Image Watermarking (Powered by Jimp)
17
+
18
+ Simply pass a raw image `Buffer`. The library handles decoding, embedding, and re-encoding automatically.
19
+
20
+ ```typescript
21
+ import { embedForensicImage, extractForensicImage } from 'ts-forensic-watermark';
22
+ import fs from 'fs';
23
+
24
+ async function processImage() {
25
+ // --- Embed ---
26
+ const inputBuffer = fs.readFileSync('input.jpg');
27
+ const payload = "SECURE123";
28
+
29
+ // Returns a new PNG buffer with the watermark embedded
30
+ const watermarkedBuffer = await embedForensicImage(inputBuffer, payload);
31
+ fs.writeFileSync('output.png', watermarkedBuffer);
32
+
33
+ // --- Extract ---
34
+ const result = await extractForensicImage(watermarkedBuffer);
35
+ if (result && result.payload !== 'RECOVERY_FAILED') {
36
+ console.log('Extracted Payload:', result.payload); // "SECURE123"
37
+ console.log('Confidence Score:', result.confidence);
38
+ }
39
+ }
40
+ ```
41
+
42
+ ### 2. Video Watermarking (Powered by FFmpeg)
43
+
44
+ Injects both **H.264 SEI** metadata and an **MP4 UUID Box** into a video file in one go. It uses stream copying (`-c:v copy`), so it is extremely fast and does not degrade video quality.
45
+
46
+ ```typescript
47
+ import { embedVideoWatermark } from 'ts-forensic-watermark';
48
+
49
+ async function processVideo() {
50
+ const inputPath = 'input.mp4';
51
+ const outputPath = 'output_watermarked.mp4';
52
+ const payload = JSON.stringify({ userId: "user_001", orderId: "ord_999" });
53
+
54
+ // Pass file paths, and it handles the FFmpeg process automatically
55
+ await embedVideoWatermark(inputPath, outputPath, payload);
56
+ console.log('Video watermarking complete!');
57
+ }
58
+ ```
59
+
60
+ ### 3. HMAC-SHA256 Signatures (Tamper Detection)
61
+
62
+ The library includes utilities to cryptographically sign your payloads, ensuring they haven't been tampered with. It uses the native Web Crypto API, so it works in Node.js, browsers, and edge environments without relying on Node's `crypto` module.
63
+
64
+ ```typescript
65
+ import {
66
+ generateSecurePayload, verifySecurePayload,
67
+ signJsonMetadata, verifyJsonSignature
68
+ } from 'ts-forensic-watermark';
69
+
70
+ const SECRET_KEY = "my-super-secret-key";
71
+
72
+ async function testSignatures() {
73
+ // 1. Generate a 22-byte secure payload for forensic watermarking (6-char ID + 16-char HMAC)
74
+ const securePayload = await generateSecurePayload("ORD123", SECRET_KEY);
75
+
76
+ const isValid = await verifySecurePayload(securePayload, SECRET_KEY);
77
+ console.log("Payload Valid:", isValid); // true
78
+
79
+ // 2. Sign JSON metadata for EOE or UUID Boxes
80
+ const metadata = { userId: "user_01", sessionId: "sess_99", timestamp: "2023-10-01T12:00:00Z" };
81
+
82
+ // Generates a signature over specific fields and appends it to the object
83
+ const signedMetadata = await signJsonMetadata(metadata, SECRET_KEY, ['userId', 'sessionId']);
84
+
85
+ const isJsonValid = await verifyJsonSignature(signedMetadata, SECRET_KEY, ['userId', 'sessionId']);
86
+ console.log("JSON Signature Valid:", isJsonValid); // true
87
+ }
88
+ ```
89
+
90
+ ### 4. Tuning Options & Custom ID Length
91
+
92
+ You can fine-tune the robustness and visual impact of the watermark using `ForensicOptions`.
93
+
94
+ ```typescript
95
+ import { embedForensicImage, extractForensicImage } from 'ts-forensic-watermark';
96
+
97
+ const options = {
98
+ delta: 120, // Embedding depth (default: 120). Higher = more robust to compression, but more noise.
99
+ varianceThreshold: 25, // Embedding area (default: 25). Lower = embeds in flatter areas, but noise becomes more visible.
100
+ arnoldIterations: 7 // Spatial scrambling strength (default: 7). Must match during extraction.
101
+ };
102
+
103
+ // Embed
104
+ const watermarkedBuffer = await embedForensicImage(imageBuffer, 'MyPayload', options);
105
+
106
+ // Extract
107
+ const result = await extractForensicImage(watermarkedBuffer, options);
108
+ ```
109
+
110
+ You can also customize the ID length of the secure payload (default is 22 bytes total).
111
+
112
+ ```typescript
113
+ import { generateSecurePayload, verifySecurePayload } from 'ts-forensic-watermark';
114
+
115
+ // 10-char ID + 12-char HMAC signature (Total: 22 bytes)
116
+ const payload = await generateSecurePayload('USER123456', 'my-secret', 10);
117
+ const isValid = await verifySecurePayload(payload, 'my-secret', 10);
118
+ ```
119
+
120
+ ### 5. Web UI Demo
121
+
122
+ The root directory of this project includes a **Web UI Demo (React + Vite)** that demonstrates how to use this library entirely in the browser. It is a complete implementation that performs watermark generation, embedding, extraction, and signature verification using only local browser APIs (Web Crypto API and Canvas API) without any backend server.
123
+
124
+ **How to run:**
125
+ ```bash
126
+ # Run in the project root directory
127
+ npm install
128
+ npm run dev
129
+ ```
130
+
131
+ **Features:**
132
+ 1. **Sign & Embed Tab**:
133
+ Enter metadata (like User ID and Session ID), select an image, and the app will embed both a "Forensic Watermark" (invisible) and "EOF Metadata" (signed JSON) into the image, ready for download.
134
+ 2. **Analyze Tab**:
135
+ Drag and drop a watermarked image to automatically extract the watermark data and verify its authenticity (tamper detection) using HMAC signatures.
136
+
137
+ ---
138
+
139
+ ## Core API (Browser / Edge Environments)
140
+
141
+ If you are running in a browser or Edge environment (like Cloudflare Workers), you can bypass the Node.js helpers and use the pure core functions directly on pixel data.
142
+
143
+ ```typescript
144
+ import { embedForensic, extractForensic } from 'ts-forensic-watermark';
145
+
146
+ // Use Canvas API or any other decoder to get raw RGBA pixels
147
+ const imageData = {
148
+ data: new Uint8ClampedArray([...]), // RGBA array
149
+ width: 1920,
150
+ height: 1080
151
+ };
152
+
153
+ embedForensic(imageData, "SECURE123");
154
+ ```
155
+
156
+ ---
157
+
158
+ ## Watermarking Techniques: Background, Pros, and Cons
159
+
160
+ This library provides multiple watermarking techniques tailored for different use cases.
161
+
162
+ ### 1. Advanced Forensic Watermarking (DWT + DCT + SVD)
163
+ * **Technical Background**: A sophisticated steganography technique that embeds data into the frequency domain of an image. It uses Discrete Wavelet Transform (DWT) to separate frequency bands, Discrete Cosine Transform (DCT), and Singular Value Decomposition (SVD) to embed data into the singular values. It also utilizes Arnold Transform for spatial scrambling and Reed-Solomon Error Correction Codes (ECC) to ensure data integrity.
164
+ * **Pros**:
165
+ * **Extreme Robustness**: Highly resilient against JPEG compression, resizing, cropping, and noise addition.
166
+ * **Invisibility**: The watermark is perceptually invisible to the human eye.
167
+ * **Cons**:
168
+ * **High Computation Cost**: The complex mathematical transformations require significant CPU resources and processing time.
169
+ * **Limited Payload**: Can only store a very small amount of data (e.g., ~22 bytes), making it suitable only for short IDs or hashes.
170
+
171
+ ### 2. EOE (End Of File) Watermarking
172
+ * **Technical Background**: Appends raw text or binary data directly to the end of a file buffer (after the official EOF marker). Most media decoders (for PNG, JPEG, MP3) ignore any trailing data after the EOF marker, allowing the file to be read normally.
173
+ * **Pros**:
174
+ * **Zero Degradation & High Speed**: Does not affect media quality at all and executes almost instantly.
175
+ * **Large Payload**: Can easily store large amounts of data, such as JSON metadata or full cryptographic signatures.
176
+ * **Cons**:
177
+ * **Fragility**: Easily destroyed. Any re-encoding, resizing, or saving via an image editor will strip the appended data.
178
+ * **Low Secrecy**: The appended data can be easily discovered and removed using a simple hex editor.
179
+
180
+ ### 3. MP4 UUID Box
181
+ * **Technical Background**: Injects a custom `uuid` extension box into the ISO Base Media File Format (ISOBMFF / MP4) container structure, which is the standard way to add custom metadata to MP4 files.
182
+ * **Pros**:
183
+ * **Standard Compliant**: Safely adds metadata without degrading video or audio quality, adhering to MP4 specifications.
184
+ * **Cons**:
185
+ * **Vulnerable to Transcoding**: Like EOE, custom UUID boxes are typically stripped when the video is uploaded to social media platforms or processed by transcoders.
186
+
187
+ ### 4. H.264 SEI (Supplemental Enhancement Information)
188
+ * **Technical Background**: Embeds metadata directly into the H.264/H.265 video bitstream via NAL units. This library generates the `user_data_unregistered` payload string.
189
+ * **Pros**:
190
+ * **Stream-level Binding**: Because it's embedded in the video stream rather than the container, it survives container format changes (e.g., MP4 to MKV) and stream copying.
191
+ * **Cons**:
192
+ * **Vulnerable to Transcoding**: Usually stripped when platforms re-encode the video.
193
+ * **Requires External Tools**: Injecting the payload into the actual video file requires a multiplexer like FFmpeg.
194
+
195
+ ---
196
+
197
+ ## Future Roadmap
198
+
199
+ ### FSK Watermarking for Audio and Video
200
+ As a future update, we plan to implement **Audio Watermarking using FSK (Frequency-Shift Keying)** for standalone audio files and video audio tracks.
201
+
202
+ This upcoming feature will allow for extremely robust forensic tracking in audio. FSK watermarks are designed to survive analog "analog hole" conversions, meaning the watermark can still be extracted even if the audio is played through a speaker and re-recorded with a microphone.
203
+
204
+ ---
205
+
206
+ ## Integrating with Node.js (Jimp)
207
+
208
+ Since this library is dependency-free, you can easily plug it into your existing Node.js stack. See the `examples/` folder for an Express.js + Jimp integration example.
package/README_ja.md ADDED
@@ -0,0 +1,195 @@
1
+ # ts-forensic-watermark
2
+
3
+ フォレンジック電子透かし(ステガノグラフィ)ライブラリです。
4
+ 知的財産権の保護を目的として作成されています。HMAC-SHA256署名により透かしが改ざんされていないことを証明し、法的に有効であるように配慮しています。
5
+
6
+ コアロジックはピュアTypeScriptで実装されておりブラウザ等でも動作しますが、**利便性を考慮し Node.js 環境向けに `jimp` と `fluent-ffmpeg` を内包した便利なヘルパー関数**を提供しています。これにより、画像のバッファや動画のファイルパスを渡すだけで、一発で透かしの処理が完了します。
7
+
8
+ ## インストール
9
+
10
+ ```bash
11
+ npm install ts-forensic-watermark
12
+ ```
13
+ *(※ `jimp`、`fluent-ffmpeg`、および `ffmpeg-static` が自動的にインストールされます。FFmpegのバイナリも内包されているため、**OSへのFFmpegの事前インストールは一切不要**ですぐに動画処理が可能です)*
14
+
15
+ ## 使い方 (Node.js 向け便利関数)
16
+
17
+ ### 1. 画像への透かし埋め込み・抽出 (Jimp内蔵)
18
+
19
+ 生のバッファ(`Buffer`)を渡すだけで、内部で自動的に画像をデコード・エンコードします。
20
+
21
+ ```typescript
22
+ import { embedForensicImage, extractForensicImage } from 'ts-forensic-watermark';
23
+ import fs from 'fs';
24
+
25
+ async function processImage() {
26
+ // --- 埋め込み ---
27
+ const inputBuffer = fs.readFileSync('input.jpg');
28
+ const payload = "SECURE123";
29
+
30
+ // バッファを渡すだけで透かし入りのPNGバッファが返ってきます
31
+ const watermarkedBuffer = await embedForensicImage(inputBuffer, payload);
32
+ fs.writeFileSync('output.png', watermarkedBuffer);
33
+
34
+ // --- 抽出 ---
35
+ const result = await extractForensicImage(watermarkedBuffer);
36
+ if (result && result.payload !== 'RECOVERY_FAILED') {
37
+ console.log('抽出されたデータ:', result.payload); // "SECURE123"
38
+ console.log('信頼度:', result.confidence);
39
+ }
40
+ }
41
+ ```
42
+
43
+ ### 2. 動画への透かし埋め込み (FFmpeg内蔵)
44
+
45
+ 動画ファイルに対して、**H.264 SEI** と **MP4 UUID Box** の両方を一度に注入します。再エンコードなし(`copy`)で処理されるため非常に高速です。
46
+
47
+ ```typescript
48
+ import { embedVideoWatermark } from 'ts-forensic-watermark';
49
+
50
+ async function processVideo() {
51
+ const inputPath = 'input.mp4';
52
+ const outputPath = 'output_watermarked.mp4';
53
+ const payload = JSON.stringify({ userId: "user_001", orderId: "ord_999" });
54
+
55
+ // ファイルパスを渡すだけで、SEIとUUID Boxの両方が注入されます
56
+ await embedVideoWatermark(inputPath, outputPath, payload);
57
+ console.log('動画への透かし埋め込みが完了しました');
58
+ }
59
+ ```
60
+
61
+ ### 3. HMAC-SHA256 署名の生成と検証 (改ざん検知)
62
+
63
+ 透かしデータが第三者によって書き換えられていないことを数学的に証明するための、HMAC署名ユーティリティも内包しています。Node.jsの `crypto` モジュールに依存せず、標準の Web Crypto API を使用しているため環境を問わず動作します。
64
+
65
+ ```typescript
66
+ import {
67
+ generateSecurePayload, verifySecurePayload,
68
+ signJsonMetadata, verifyJsonSignature
69
+ } from 'ts-forensic-watermark';
70
+
71
+ const SECRET_KEY = "my-super-secret-key";
72
+
73
+ async function testSignatures() {
74
+ // 1. 高度フォレンジック透かし用の22バイトペイロード (6文字ID + 16文字HMAC)
75
+ const securePayload = await generateSecurePayload("ORD123", SECRET_KEY);
76
+ console.log(securePayload); // 例: "ORD123a1b2c3d4e5f6g7h8"
77
+
78
+ const isValid = await verifySecurePayload(securePayload, SECRET_KEY);
79
+ console.log("ペイロード検証:", isValid); // true
80
+
81
+ // 2. EOE追記やUUID Box用のJSONメタデータ署名
82
+ const metadata = { userId: "user_01", sessionId: "sess_99", timestamp: "2023-10-01T12:00:00Z" };
83
+
84
+ // 指定したフィールドを結合して署名を生成し、オブジェクトに 'signature' を追加
85
+ const signedMetadata = await signJsonMetadata(metadata, SECRET_KEY, ['userId', 'sessionId']);
86
+
87
+ const isJsonValid = await verifyJsonSignature(signedMetadata, SECRET_KEY, ['userId', 'sessionId']);
88
+ console.log("JSON署名検証:", isJsonValid); // true
89
+ }
90
+ ```
91
+
92
+ ### 4. オプションによるチューニングとID長変更
93
+
94
+ 透かしの堅牢性や画質への影響を調整するためのオプション(`ForensicOptions`)を指定できます。
95
+
96
+ ```typescript
97
+ import { embedForensicImage, extractForensicImage } from 'ts-forensic-watermark';
98
+
99
+ const options = {
100
+ delta: 120, // 彫りの深さ (デフォルト: 120)。高くすると圧縮に強くなりますがノイズが増えます。
101
+ varianceThreshold: 25, // 埋め込む面積の広さ (デフォルト: 25)。低くすると平坦な部分にも埋め込みますがノイズが目立ちます。
102
+ arnoldIterations: 7 // 空間スクランブルの強度 (デフォルト: 7)。抽出時も同じ値が必要です。
103
+ };
104
+
105
+ // 埋め込み
106
+ const watermarkedBuffer = await embedForensicImage(imageBuffer, 'MyPayload', options);
107
+
108
+ // 抽出
109
+ const result = await extractForensicImage(watermarkedBuffer, options);
110
+ ```
111
+
112
+ また、セキュアペイロード(デフォルト22バイト)のID長を変更することも可能です。
113
+
114
+ ```typescript
115
+ import { generateSecurePayload, verifySecurePayload } from 'ts-forensic-watermark';
116
+
117
+ // 10文字のID + 12文字のHMAC署名 (合計22バイト)
118
+ const payload = await generateSecurePayload('USER123456', 'my-secret', 10);
119
+ const isValid = await verifySecurePayload(payload, 'my-secret', 10);
120
+ ```
121
+
122
+ ### 5. Web UI デモの使い方
123
+
124
+ 本プロジェクトのルートディレクトリには、このライブラリをブラウザ上で動かすための **Web UI デモ (React + Vite)** が含まれています。サーバーサイドを一切使わず、ブラウザのローカル環境(Web Crypto API と Canvas API)だけで透かしの生成・埋め込み・抽出・署名検証を行う完全な実装例です。
125
+
126
+ **起動方法:**
127
+ ```bash
128
+ # プロジェクトのルートディレクトリで実行
129
+ npm install
130
+ npm run dev
131
+ ```
132
+
133
+ **機能:**
134
+ 1. **署名・埋め込み (Sign & Embed) タブ**:
135
+ User ID や Session ID などのメタデータを入力し、画像ファイルを選択すると、「高度フォレンジック透かし(不可視)」と「EOFメタデータ(署名付きJSON)」の両方を画像に埋め込んでダウンロードできます。
136
+ 2. **透かし解析 (Analyze) タブ**:
137
+ 透かしが埋め込まれた画像をドラッグ&ドロップすると、画像から透かしデータを自動抽出し、HMAC署名を用いてデータが改ざんされていないか(真正性)を検証・表示します。
138
+
139
+ ---
140
+
141
+ ## 各透かし技術の背景とメリット・デメリット
142
+
143
+ 本ライブラリでは、用途に応じて複数の透かし技術を使い分けることができます。
144
+
145
+ ### 1. 高度フォレンジック透かし (DWT + DCT + SVD)
146
+ * **技術的背景**: 画像の周波数領域に対して透かしを埋め込む高度なステガノグラフィ技術です。離散ウェーブレット変換 (DWT) で画像を帯域分割し、離散コサイン変換 (DCT) と特異値分解 (SVD) を用いて特異値にデータを埋め込みます。さらに、Arnold変換による空間スクランブルと、Reed-Solomon誤り訂正符号 (ECC) を組み合わせることで、データの欠落を防ぎます。
147
+ * **メリット**:
148
+ * **極めて高い堅牢性**: JPEG圧縮、リサイズ、切り抜き、ノイズ追加などの画像加工や劣化に対して非常に強い耐性を持ちます。
149
+ * **不可視性**: 人間の目には透かしが入っていることがほとんど認識できません。
150
+ * **デメリット**:
151
+ * **計算コスト**: 複雑な数学的変換を伴うため、CPU負荷が高く処理に時間がかかります。
152
+ * **ペイロード制限**: 埋め込めるデータ量が非常に少ない(数十バイト程度)ため、IDや短いハッシュの保存に限られます。
153
+
154
+ ### 2. EOE (End Of File) メタデータ追記
155
+ * **技術的背景**: 画像(PNG/JPEG)や音声ファイルの終端(EOFマーカーの後)に、直接テキストやバイナリデータを追記する手法です。多くのメディアデコーダは、ファイル終端以降の余剰データを無視して正常に再生・表示する特性を利用しています。
156
+ * **メリット**:
157
+ * **無劣化かつ高速**: メディアの品質(画質・音質)に一切影響を与えず、処理も一瞬で完了します。
158
+ * **大容量**: JSONなどの比較的大きなデータ(メタデータや署名など)をそのまま埋め込むことができます。
159
+ * **デメリット**:
160
+ * **脆弱性**: 画像編集ソフトでの上書き保存や、SNS等へのアップロードに伴う再エンコードによって、終端データは簡単に切り捨てられ消失します。
161
+ * **秘匿性の低さ**: バイナリエディタ等でファイルを開くと、追記されたデータが容易に発見されてしまいます。
162
+
163
+ ### 3. MP4 UUID ボックス
164
+ * **技術的背景**: MP4(ISOBMFF)コンテナフォーマットの標準規格である拡張ボックス(`uuid` box)を利用して、独自のメタデータを格納する手法です。
165
+ * **メリット**:
166
+ * **規格準拠**: 動画の画質・音質に影響を与えず、フォーマットの規格に則った安全なメタデータ付与が可能です。
167
+ * **デメリット**:
168
+ * **再エンコードに弱い**: EOEと同様に、動画共有プラットフォームへのアップロード時やトランスコード処理が行われると、カスタムボックスは削除される可能性が高いです。
169
+
170
+ ### 4. H.264 SEI (Supplemental Enhancement Information)
171
+ * **技術的背景**: H.264/H.265ビデオストリームの内部(NALユニット)に直接メタデータを埋め込む手法です。本ライブラリでは、`user_data_unregistered` 形式のペイロード文字列を生成します。
172
+ * **メリット**:
173
+ * **ストリームへの密結合**: コンテナ(MP4等)ではなくビデオストリーム自体に埋め込まれるため、コンテナの変換(MP4 -> MKV等)や単純なストリームコピーではデータが保持されます。
174
+ * **デメリット**:
175
+ * **再エンコードに弱い**: 動画プラットフォームによる再圧縮(トランスコード)が行われると、通常はSEIメッセージも破棄されます。
176
+ * **外部ツールの必要性**: ビデオストリームのNALユニットを直接操作するため、実際のファイルへの書き込みにはFFmpegなどのマルチプレクサが必要です。
177
+
178
+ ---
179
+
180
+ ## 将来の展望 (Roadmap)
181
+
182
+ ### 音声・動画に対するFSK透かしの実装予定
183
+ 将来的なアップデートとして、音声データおよび動画のオーディオトラックに対して、**FSK(周波数偏移変調: Frequency-Shift Keying)を用いた音響透かし(Audio Watermarking)機能**の追加を予定しています。
184
+
185
+ これにより、スピーカーからの再生音をマイクで録音(アナログ変換・再デジタル化)した場合でも透かしデータが残存する、極めて堅牢な音声フォレンジックトラッキングが本ライブラリ単体で可能になる予定です。
186
+
187
+ ---
188
+
189
+ ## アーキテクチャの設計思想
190
+
191
+ このライブラリは「計算ロジック」と「ファイルI/O」を完全に分離しています。
192
+ - **本ライブラリが担当するもの**: ピクセル配列の数学的変換(DWT/DCT/SVD)、誤り訂正符号の計算、バイナリデータの構築。
193
+ - **利用側(アプリ側)が担当するもの**: ファイルの読み書き、画像のデコード(Jimp/Canvas)、動画のエンコード(FFmpeg)。
194
+
195
+ これにより、特定のバックエンド環境に縛られない、極めてポータブルなライブラリとなっています。
@@ -0,0 +1,51 @@
1
+ export interface ForensicOptions {
2
+ /** 彫りの深さ (デフォルト: 120)。高くすると圧縮に強くなりますがノイズが増えます。 */
3
+ delta?: number;
4
+ /** 埋め込む面積の広さ (デフォルト: 25)。低くすると平坦な部分にも埋め込みますがノイズが目立ちます。 */
5
+ varianceThreshold?: number;
6
+ /** Arnold変換の反復回数 (デフォルト: 7)。空間スクランブルの強度。抽出時も同じ値が必要です。 */
7
+ arnoldIterations?: number;
8
+ /** 強制埋め込み/抽出フラグ (分散やSVDの閾値を無視します) */
9
+ force?: boolean;
10
+ }
11
+ export declare class ReedSolomon {
12
+ private eccLen;
13
+ private exp;
14
+ private log;
15
+ private genPoly;
16
+ constructor(eccLen: number);
17
+ private mul;
18
+ private div;
19
+ private polyAdd;
20
+ private polyMul;
21
+ private polyEval;
22
+ encode(msg: Uint8Array): Uint8Array;
23
+ decode(msg: Uint8Array): Uint8Array | null;
24
+ private polyScale;
25
+ }
26
+ export interface ImageDataLike {
27
+ data: Uint8ClampedArray | Uint8Array;
28
+ width: number;
29
+ height: number;
30
+ }
31
+ export declare function embedForensic(imageData: ImageDataLike, payload: string, options?: ForensicOptions): void;
32
+ export declare function generateVideoPattern(width: number, height: number, payload: string, strength?: number, options?: ForensicOptions): {
33
+ data: Uint8ClampedArray;
34
+ width: number;
35
+ height: number;
36
+ };
37
+ export declare function extractVideoForensic(imageData: ImageDataLike, options?: ForensicOptions): {
38
+ payload: string;
39
+ confidence: number;
40
+ debug?: any;
41
+ } | null;
42
+ export declare function generateSpreadSpectrumPattern(width: number, height: number, payload: string, strength?: number, options?: ForensicOptions): {
43
+ data: Uint8ClampedArray;
44
+ width: number;
45
+ height: number;
46
+ };
47
+ export declare function extractForensic(imageData: ImageDataLike, options?: ForensicOptions): {
48
+ payload: string;
49
+ confidence: number;
50
+ debug?: any;
51
+ } | null;