panurus

ZK-ATDLOG Testing Architecture

This document explains the testing architecture for the Zero-Knowledge Anonymous Token Discrete Logarithm (ZK-ATDLOG) implementation in Panurus.

Related Documentation:

Overview

The ZK-ATDLOG tests are organized in a layered architecture that mirrors the code abstraction levels. Each layer represents a different level of the software stack - from low-level cryptographic primitives to high-level service APIs.

Architecture Layers

Each layer represents a different code abstraction level.

┌─────────────────────────────────────────────────────────────────┐
│ Layer 3: Service Layer (Highest Abstraction)                    │
├─────────────────────────────────────────────────────────────────┤
│ Transfer Generation Service                                     │
│ Location: token/core/zkatdlog/nogh/v1/                          │
│ Tests: - BenchmarkTransferServiceTransfer                       │
│        - TestParallelBenchmarkTransferServiceTransfer           │
│ Purpose: End-to-end transfer operation generation with vault,   │
│          audit, and metadata handling                           │
├─────────────────────────────────────────────────────────────────┤
│ Issue Generation Service                                        │
│ Location: token/core/zkatdlog/nogh/v1/                          │
│ Tests: - BenchmarkIssueServiceIssue                             │
│        - TestParallelBenchmarkIssueServiceIssue                 │
│ Purpose: End-to-end issue operation: wallet lookup, signer      │
│          resolution, ZK proof, audit-info encoding, serialize   │
├─────────────────────────────────────────────────────────────────┤
│ Auditor Check Service                                           │
│ Location: token/core/zkatdlog/nogh/v1/                          │
│ Tests: - BenchmarkAuditorServiceCheck                           │
│        - TestParallelBenchmarkAuditorServiceCheck               │
│ Purpose: Audit verification: action deserialization and         │
│          Pedersen commitment arithmetic                         │
├─────────────────────────────────────────────────────────────────┤
│ Transfer Validator Service                                      │
│ Location: token/core/zkatdlog/nogh/v1/validator/                │
│ Tests: - BenchmarkValidatorTransfer                             │
│        - TestParallelBenchmarkValidatorTransfer                 │
│ Purpose: Transfer validation with signatures, business logic,   │
│          and cryptographic verification                         │
└─────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────┐
│ Layer 2: Action Operations                                      │
├─────────────────────────────────────────────────────────────────┤
│ Transfer Generation (token/core/zkatdlog/nogh/v1/transfer/)     │
│ Tests: - BenchmarkSender                                        │
│        - BenchmarkParallelSender                                │
│        - TestParallelBenchmarkSender                            │
│ Purpose: Transfer action generation and serialization           │
├─────────────────────────────────────────────────────────────────┤
│ Transfer Verification (token/core/zkatdlog/nogh/v1/transfer/)   │
│ Tests: - BenchmarkVerificationSenderProof                       │
│        - BenchmarkVerificationParallelSenderProof               │
│        - TestParallelBenchmarkVerificationSenderProof           │
│ Purpose: Deserialization and cryptographic format validation    │
│          and verification of transfer actions                   │
├─────────────────────────────────────────────────────────────────┤
│ Issue Generation (token/core/zkatdlog/nogh/v1/issue/)           │
│ Tests: - BenchmarkIssuer                                        │
│ Purpose: Issue action generation and serialization              │
├─────────────────────────────────────────────────────────────────┤
│ Issue Verification (token/core/zkatdlog/nogh/v1/issue/)         │
│ Tests: - BenchmarkProofVerificationIssuer                       │
│ Purpose: Deserialization and cryptographic verification of      │
│          issue actions                                          │
└─────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────┐
│ Layer 1: Core Cryptographic Operations (Lowest Abstraction)     │
│ Location: token/core/zkatdlog/nogh/v1/transfer/                 │
│          token/core/zkatdlog/nogh/v1/crypto/rp/                 │
│ Tests: - BenchmarkTransferProofGeneration                       │
│        - TestParallelBenchmarkTransferProofGeneration           │
│ Purpose: Pure transfer ZK proof generation and serialization    │
│                                                                  │
│ Range Proof Systems (as of commit 586d4f58):                    │
│ • Bulletproofs: crypto/rp/bulletproof/ (IPA-based)              │
│ • CSP: crypto/rp/csp/ (Compressed Sigma Protocols)              │
└─────────────────────────────────────────────────────────────────┘

Layer 1: Core Cryptographic Operations

Location: token/core/zkatdlog/nogh/v1/transfer/ and token/core/zkatdlog/nogh/v1/crypto/rp/

Range Proof Systems: As of commit 586d4f58, two range proof implementations are available:

Tests

Purpose

Pure zero-knowledge proof generation and serialization for transfer operations. The parallel version runs the same benchmark in multiple goroutines.

Includes

Example Commands

cd token/core/zkatdlog/nogh/v1/transfer
go test -bench=BenchmarkTransferProofGeneration -benchtime=10s
go test -run=TestParallelBenchmarkTransferProofGeneration -v

Layer 2: Action Operations

Transfer Action Generation

Location: token/core/zkatdlog/nogh/v1/transfer/

Tests

Purpose

Complete transfer action creation from inputs to serialized output.

Note: BenchmarkParallelSender is a Go benchmark (uses *testing.B), while TestParallelBenchmarkSender is a test (uses *testing.T) that runs custom benchmarking. Same functionality, different frameworks.

Includes

Example Commands

cd token/core/zkatdlog/nogh/v1/transfer
go test -bench=BenchmarkSender -benchtime=10s
go test -bench=BenchmarkParallelSender -benchtime=10s
go test -run=TestParallelBenchmarkSender -v

Transfer Action Verification

Location: token/core/zkatdlog/nogh/v1/transfer/

Tests

Purpose

Deserialization and cryptographic format validation and verification of transfer actions.

Includes

Example Commands

cd token/core/zkatdlog/nogh/v1/transfer
go test -bench=BenchmarkVerificationSenderProof -benchtime=10s
go test -bench=BenchmarkVerificationParallelSenderProof -benchtime=10s
go test -run=TestParallelBenchmarkVerificationSenderProof -v

Issue Action Generation

Location: token/core/zkatdlog/nogh/v1/issue/

Tests

Purpose

Complete issue action creation from inputs to serialized output.

Includes

Example Commands

cd token/core/zkatdlog/nogh/v1/issue
go test -bench=BenchmarkIssuer -benchtime=10s
go test -bench=BenchmarkIssuer -benchmem
go test -bench=BenchmarkIssuer -cpuprofile=cpu.prof

Issue Action Verification

Location: token/core/zkatdlog/nogh/v1/issue/

Tests

Purpose

Deserialization and cryptographic verification of issue actions.

Includes

Example Commands

cd token/core/zkatdlog/nogh/v1/issue
go test -bench=BenchmarkProofVerificationIssuer -benchtime=10s

Layer 3: Service Layer

The Service Layer provides the highest level of abstraction, covering end-to-end operation generation and validation through the high-level service APIs.

Transfer Generation Service

Location: token/core/zkatdlog/nogh/v1/

Tests

Purpose

Complete end-to-end transfer operation generation through the high-level Transfer Service API.

Includes

Example Commands

cd token/core/zkatdlog/nogh/v1
go test -bench=BenchmarkTransferServiceTransfer -benchtime=10s
go test -run=TestParallelBenchmarkTransferServiceTransfer -v

Issue Generation Service

Location: token/core/zkatdlog/nogh/v1/

Tests

Purpose

End-to-end issue operation generation through the high-level Issue Service API.

Includes

Example Commands

cd token/core/zkatdlog/nogh/v1
go test -bench=BenchmarkIssueServiceIssue -benchtime=10s
go test -run=TestParallelBenchmarkIssueServiceIssue -v

Auditor Check Service

Location: token/core/zkatdlog/nogh/v1/

Tests

Purpose

End-to-end audit verification through the high-level Auditor Service API.

Includes

Example Commands

cd token/core/zkatdlog/nogh/v1
go test -bench=BenchmarkAuditorServiceCheck -benchtime=10s
go test -run=TestParallelBenchmarkAuditorServiceCheck -v

Transfer Validator Service

Location: token/core/zkatdlog/nogh/v1/validator/

Tests

Compatibility Tests

Purpose

Complete validation pipeline performance, including all cryptographic and business logic checks.

Includes

Example Commands

cd token/core/zkatdlog/nogh/v1/validator
go test -bench=BenchmarkValidatorTransfer -benchtime=10s
go test -run=TestParallelBenchmarkValidatorTransfer -v

Testing Strategy

Understanding the Layers

Each layer tests a different code abstraction level independently:

The layers do NOT build on each other - they test different parts of the codebase at different abstraction levels.


Parallel Testing Variants

Most layers include parallel test variants that run benchmarks concurrently:

These help identify concurrency issues and measure performance under load.


Benchmark Parameters

All benchmarks support various configurations:

Example with specific parameters: ```bash go test -bench=BenchmarkSender/bits_32-curve_BN254-in_2-out_2 -benchtime=10s