Skip to content

Latest commit

 

History

History
100 lines (76 loc) · 3.43 KB

File metadata and controls

100 lines (76 loc) · 3.43 KB

Embedding and verification

Input graph

The graph input is an NPZ file containing x with shape [N,F] and a binary, symmetric adj with shape [N,N] and a zero diagonal. Features must use the same preprocessing and dimensionality as the trained model. An optional boolean mask of length N identifies valid nodes in a padded graph.

Export a preprocessed test example:

python -m gsmark sample --config configs/computers.yaml \
  --split test --seed 0 --output results/example.npz

The CLI uses dense adjacency for individual input graphs; choose a graph size that fits memory. Dataset processing retains the complete source graph as CSR and creates dense batches only after subgraph sampling.

Private key and watermark

Training creates an owner key under the run directory. To generate a key before training and select it explicitly:

python -m gsmark keygen --key-output results/owner-key.npy
python -m gsmark train --config configs/computers.yaml \
  --key results/owner-key.npy --seed 0 --device cuda:0

Generate 64 public watermark bits independently:

python -m gsmark keygen --watermark-output results/watermark.npy

Key and watermark files are separate NPY vectors. Keys use file mode 0600; new key, watermark and graph outputs refuse to overwrite existing files. Preserve the owner key used to train the embedding checkpoint.

Embed a watermark

python -m gsmark embed \
  --checkpoint results/computers/seed-0/checkpoint.pt \
  --graph results/example.npz --watermark results/watermark.npy \
  --key results/computers/seed-0/owner-key.npy \
  --output results/watermarked.npz --device cuda:0

This updates the node signal and preserves adjacency. Embedding uses the latent posterior mean for deterministic inference.

Export the public detector

python -m gsmark export \
  --checkpoint results/computers/seed-0/checkpoint.pt \
  --output results/extractor.pt

The exported file contains the extractor, public watermark projection and architecture settings. The embedding network, key projection, task model and private key are excluded.

Verify

python -m gsmark verify --checkpoint results/extractor.pt \
  --graph results/watermarked.npz --watermark results/watermark.npy \
  --device cuda:0

This returns a raw cosine score using the candidate graph and watermark. Calibrate the same detector and watermark on held-out unwatermarked signals:

python -m gsmark calibrate --config configs/computers.yaml \
  --checkpoint results/extractor.pt --watermark results/watermark.npy \
  --output results/calibration.npy --trials 256 --device cuda:0

The command uses the reserved calibration partition and saves null scores plus a JSON manifest identifying the detector, watermark, data and sampling seed. Then obtain a p-value and decision:

python -m gsmark verify --checkpoint results/extractor.pt \
  --graph results/watermarked.npz --watermark results/watermark.npy \
  --null-scores results/calibration.npy --alpha 0.01 --device cuda:0

The evaluation command saves evaluation/null-scores.npy calibrated to its own evaluation/watermark.npy. Use those files together; a newly generated watermark needs its own calibration. The verifier checks a calibration manifest when one is present; a standalone NPY null-score array is also accepted. The protocol defines the null construction and significance rule. Device options also accept cpu.