Skip to content

Commit 4879434

Browse files
committed
feat: Release STC v0.2.1 with performance optimizations, varint encoding, and decoy vector support
1 parent 73f2d99 commit 4879434

11 files changed

Lines changed: 283 additions & 38 deletions

File tree

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ build/
1111
*.pyc
1212
*.pyo
1313

14+
# Test outputs
15+
*.enc
16+
*.enc.meta
17+
password_vault.json
18+
config.enc
19+
config.enc.meta
20+
1421
# Internal documentation
1522
IMPLEMENTATION.md
1623
blueprint.md
17-
DISTRIBUTION_GUIDE.md
24+
DISTRIBUTION_GUIDE.md
25+
RELEASE_v*.md

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,36 @@ All notable changes to Seigr Toolset Crypto will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.2.1] - 2025-10-30
9+
10+
### Added
11+
12+
- **Variable-length integer encoding (varint)**: Implemented LEB128-style varint with zigzag encoding for signed integers
13+
- Run-length encoding for consecutive zeros (marker: 0xFF)
14+
- Reduces metadata size by 65% (786KB → 276KB without decoys)
15+
- **Decoy vector TLV serialization**: Full support for obfuscated vectors in binary format
16+
- New TLV type: `TLV_TYPE_VECTOR` (0x10) for serializing encrypted metadata blobs
17+
- Recursive TLV serialization/deserialization for nested vector structures
18+
- **Decoy vectors now enabled by default**: `use_decoys=True` in encrypt() API
19+
20+
### Changed
21+
22+
- **Performance optimizations**:
23+
- Reduced CEL audit frequency: every 100th operation (was every 50th)
24+
- Reduced chained timing entropy: every 200th operation (was every 100th)
25+
- Total speedup: 1.95x faster than v0.2.0 (2.27s → 1.17s avg)
26+
- **Metadata compression**:
27+
- Without decoys: 786KB → 276KB (65% reduction)
28+
- With 3 decoys: 786KB → 414KB (47% reduction)
29+
- **API**: `use_decoys` parameter now defaults to `True` (was `False`)
30+
31+
### Performance
32+
33+
- **Encryption**: 0.63s average (was 1.33s in v0.2.0)
34+
- **Decryption**: 0.54s average (was 0.94s in v0.2.0)
35+
- **Total**: 1.17s average (was 2.27s in v0.2.0)
36+
- **Speedup**: 1.95x faster than v0.2.0, 148x faster than v0.1.0
37+
838
## [0.2.0] - 2025-10-30
939

1040
### Added

README.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# Seigr Toolset Crypto (STC)
22

33
[![Sponsor Seigr-lab](https://img.shields.io/badge/Sponsor-Seigr--lab-forestgreen?style=flat&logo=github)](https://github.com/sponsors/Seigr-lab)
4-
[![Version](https://img.shields.io/badge/version-0.2.0-blue)](https://github.com/Seigr-lab/SeigrToolsetCrypto/releases)
4+
[![Version](https://img.shields.io/badge/version-0.2.1-blue)](https://github.com/Seigr-lab/SeigrToolsetCrypto/releases)
55
[![License](https://img.shields.io/badge/license-ANTI--CAPITALIST-red)](LICENSE)
66

77
**Post-classical cryptographic engine with entropy-regenerative architecture**
88

99
## Overview
1010

11-
STC v0.2.0 is a research-grade cryptographic system that rejects traditional symmetric/asymmetric paradigms. Instead of XOR-based mixing, static keys, and classical block ciphers, it implements:
11+
STC v0.2.1 is a research-grade cryptographic system that rejects traditional symmetric/asymmetric paradigms. Instead of XOR-based mixing, static keys, and classical block ciphers, it implements:
1212

1313
- **Continuous Entropy Lattice (CEL)** - Self-evolving entropy field regenerated from computational deltas
1414
- **Probabilistic Hashing Engine (PHE)** - Multi-path hashing with CEL-driven path selection
1515
- **Contextual Key Emergence (CKE)** - Ephemeral keys reconstructed from context intersections
1616
- **Data-State Folding (DSF)** - Encryption via multidimensional tensor folding
1717
- **Polymorphic Cryptographic Flow (PCF)** - Dynamic algorithmic morphing
18-
- **State Management** - Deterministic reconstruction from compact persistence vectors
18+
- **State Management** - Deterministic reconstruction with varint compression
1919

2020
## Architecture
2121

@@ -33,31 +33,41 @@ interfaces/
3333
├── cli/ # Command-line tools
3434
└── bindings/ # Future cross-language bindings
3535
36-
utils/ # Mathematical primitives
36+
utils/ # Mathematical primitives + TLV varint encoding
3737
tests/ # Validation and integrity checks
3838
```
3939

40-
## ⚡ Performance (v0.2.0)
40+
## ⚡ Performance (v0.2.1)
4141

42-
- **Encryption**: ~1.3s for small messages (76x faster than v0.2.0-alpha)
43-
- **Decryption**: ~0.9s for small messages
44-
- **Metadata Size**: ~786 KB (constant, independent of data size)
45-
- **Total Throughput**: ~2.3s for encrypt+decrypt cycle
42+
- **Encryption**: ~0.6s for small messages (2x faster than v0.2.0)
43+
- **Decryption**: ~0.5s for small messages
44+
- **Metadata Size**: ~276 KB without decoys, ~414 KB with 3 decoys (65% smaller than v0.2.0)
45+
- **Total Throughput**: ~1.2s for encrypt+decrypt cycle
4646

47+
> **Version History**:
48+
> - v0.2.1: 1.95x faster than v0.2.0, 65% smaller metadata via varint encoding
49+
> - v0.2.0: 76x faster than v0.1.0 via systematic optimizations
50+
>
4751
> See [PERFORMANCE_OPTIMIZATIONS.md](PERFORMANCE_OPTIMIZATIONS.md) for optimization details and [CHANGELOG.md](CHANGELOG.md) for version history.
4852
4953
## Installation
5054

51-
### From GitHub Release (Recommended)
55+
### From PyPI (Recommended)
56+
57+
```bash
58+
pip install seigr-toolset-crypto==0.2.1
59+
```
60+
61+
### From GitHub Release
5262

5363
Download the latest release from [Releases](https://github.com/Seigr-lab/SeigrToolsetCrypto/releases):
5464

5565
```bash
5666
# Install from wheel (recommended)
57-
pip install seigr_toolset_crypto-0.2.0-py3-none-any.whl
67+
pip install seigr_toolset_crypto-0.2.1-py3-none-any.whl
5868

5969
# Or install from source tarball
60-
pip install seigr_toolset_crypto-0.2.0.tar.gz
70+
pip install seigr_toolset_crypto-0.2.1.tar.gz
6171
```
6272

6373
### From Source (Development)

core/cel/cel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def update(self, context: Optional[Dict[str, Any]] = None) -> None:
182182
self.entropy_history.pop(0)
183183

184184
# Perform entropy quality audit (reduced frequency for performance)
185-
if self.operation_count % 50 == 0: # Was every 10th, now every 50th
185+
if self.operation_count % 100 == 0: # Was every 50th, now every 100th (v0.2.1)
186186
self._audit_entropy_quality(entropy_sources)
187187

188188
def _gather_entropy_sources(self, context: Optional[Dict[str, Any]]) -> Dict[str, int]:
@@ -200,7 +200,7 @@ def _gather_entropy_sources(self, context: Optional[Dict[str, Any]]) -> Dict[str
200200

201201
# Time-based entropy (chained computational loads for higher variance)
202202
# Reduced frequency for performance
203-
if self.operation_count % 100 == 0: # Was every 10th, now every 100th
203+
if self.operation_count % 200 == 0: # Was every 100th, now every 200th (v0.2.1)
204204
# Use expensive chained entropy rarely
205205
sources['time_delta'] = compute_chained_timing_entropy(self.seed_fingerprint or 0)
206206
else:

examples/config_encryption/config_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def encrypt_config_file(config_data: dict, password: str, output_file: str):
3030
# Encrypt with password-based encryption
3131
encrypted, metadata = context.encrypt(
3232
config_json,
33-
password=password,
34-
use_decoys=False
33+
password=password
34+
# use_decoys=True by default in v0.2.1
3535
)
3636

3737
# Save encrypted data (binary)

examples/password_manager/password_manager.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ def add_credential(self, service: str, username: str, password: str):
5353
credential_json = json.dumps(credential)
5454

5555
# Encrypt with password-based encryption (v0.2.0)
56+
# Encrypt password
5657
encrypted, metadata = self.context.encrypt(
57-
credential_json,
58-
password=self.master_password,
59-
use_decoys=False # Decoys not yet supported in v0.2.0
58+
password,
59+
password=self.master_password
60+
# use_decoys=True by default in v0.2.1 (decoys now supported!)
6061
)
6162

6263
# Store in vault (both encrypted and metadata are bytes)

interfaces/api/stc_api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ def encrypt(
8686
data: Union[str, bytes],
8787
context_data: Optional[Dict[str, Any]] = None,
8888
password: Optional[str] = None,
89-
use_decoys: bool = False, # Disabled by default (TLV serialization not yet implemented)
89+
use_decoys: bool = True, # Now enabled by default in v0.2.1!
9090
num_decoys: int = 3
9191
) -> Tuple[bytes, Union[bytes, Dict[str, Any]]]:
9292
"""
93-
Encrypt data using complete STC pipeline (v0.2.0)
94-
Enhanced with metadata encryption and differential encoding
93+
Encrypt data using complete STC pipeline (v0.2.1)
94+
Enhanced with varint compression and decoy vector support
9595
9696
Args:
9797
data: Data to encrypt
9898
context_data: Optional additional context
9999
password: Password for metadata encryption (if None, uses seed)
100-
use_decoys: Whether to inject decoy vectors (NOT YET WORKING - TLV serialization needed)
100+
use_decoys: Whether to inject decoy vectors (NOW WORKING in v0.2.1!)
101101
num_decoys: Number of decoy snapshots (3-5)
102102
103103
Returns:

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
"""
23
Seigr Toolset Crypto (STC) - Setup Configuration
34
Post-classical cryptographic engine with entropy-regenerative architecture
@@ -10,7 +11,7 @@
1011

1112
setup(
1213
name="seigr-toolset-crypto",
13-
version="0.2.0",
14+
version="0.2.1",
1415
author="Sergi Saldaña-Massó - Seigr Lab",
1516
author_email="sergism@gmail.com",
1617
description="Post-classical cryptographic engine with entropy amplification and multi-path hashing",

tests/benchmark_v021.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Quick performance benchmark for v0.2.1
4+
"""
5+
import sys
6+
from pathlib import Path
7+
8+
# Add parent directory to path for imports
9+
sys.path.insert(0, str(Path(__file__).parent.parent))
10+
11+
import time
12+
from interfaces.api.stc_api import STCContext
13+
14+
ctx = STCContext('test-seed')
15+
16+
# Warmup
17+
e, m = ctx.encrypt('Warmup', password='pw')
18+
d = ctx.decrypt(e, m, password='pw')
19+
20+
# Benchmark
21+
times = []
22+
for i in range(5):
23+
start = time.time()
24+
encrypted, metadata = ctx.encrypt(f'Test message {i}', password='strong_password')
25+
enc_time = time.time() - start
26+
27+
start = time.time()
28+
decrypted = ctx.decrypt(encrypted, metadata, password='strong_password')
29+
dec_time = time.time() - start
30+
31+
total = enc_time + dec_time
32+
times.append((enc_time, dec_time, total))
33+
print(f'Run {i+1}: Enc={enc_time:.3f}s Dec={dec_time:.3f}s Total={total:.3f}s Metadata={len(metadata)//1024}KB')
34+
35+
# Statistics
36+
avg_enc = sum(t[0] for t in times) / len(times)
37+
avg_dec = sum(t[1] for t in times) / len(times)
38+
avg_total = sum(t[2] for t in times) / len(times)
39+
40+
print(f'\n{"="*60}')
41+
print(f'AVERAGE: Enc={avg_enc:.3f}s Dec={avg_dec:.3f}s Total={avg_total:.3f}s')
42+
print(f'{"="*60}')
43+
print(f'\nv0.2.0 baseline: 1.33s enc + 0.94s dec = 2.27s total, 786KB metadata')
44+
print(f'v0.2.1 results: {avg_enc:.2f}s enc + {avg_dec:.2f}s dec = {avg_total:.2f}s total, ~{len(metadata)//1024}KB metadata')
45+
46+
# Calculate improvements
47+
speedup = 2.27 / avg_total
48+
metadata_reduction = (786 - len(metadata)//1024) / 786 * 100
49+
print(f'\nSpeedup: {speedup:.2f}x faster than v0.2.0')
50+
print(f'Metadata reduction: {metadata_reduction:.1f}% smaller')

tests/test_decoys.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Test decoy vector functionality in v0.2.1
4+
"""
5+
import sys
6+
from pathlib import Path
7+
8+
# Add parent directory to path for imports
9+
sys.path.insert(0, str(Path(__file__).parent.parent))
10+
11+
from interfaces.api.stc_api import STCContext
12+
13+
print("Testing decoy vector encryption/decryption...")
14+
15+
ctx = STCContext('test-seed')
16+
17+
# Test with decoys enabled (default in v0.2.1)
18+
print("\n1. Testing WITH decoys (use_decoys=True):")
19+
encrypted, metadata = ctx.encrypt("Secret message", password="strong_pw", use_decoys=True, num_decoys=3)
20+
print(f" - Encrypted: {len(encrypted)} bytes")
21+
print(f" - Metadata: {len(metadata)} bytes ({len(metadata)//1024}KB)")
22+
23+
decrypted = ctx.decrypt(encrypted, metadata, password="strong_pw")
24+
print(f" - Decrypted: {decrypted}")
25+
print(f" - ✓ Success!" if decrypted == "Secret message" else " - ✗ FAILED!")
26+
27+
# Test with wrong password (should fail)
28+
print("\n2. Testing wrong password (should reject):")
29+
try:
30+
bad_decrypt = ctx.decrypt(encrypted, metadata, password="wrong_password")
31+
print(f" - ✗ SECURITY ISSUE: Decrypted with wrong password!")
32+
except ValueError as e:
33+
print(f" - ✓ Correctly rejected: {e}")
34+
35+
# Test without decoys
36+
print("\n3. Testing WITHOUT decoys (use_decoys=False):")
37+
encrypted2, metadata2 = ctx.encrypt("Another secret", password="pw2", use_decoys=False)
38+
print(f" - Encrypted: {len(encrypted2)} bytes")
39+
print(f" - Metadata: {len(metadata2)} bytes ({len(metadata2)//1024}KB)")
40+
41+
decrypted2 = ctx.decrypt(encrypted2, metadata2, password="pw2")
42+
print(f" - Decrypted: {decrypted2}")
43+
print(f" - ✓ Success!" if decrypted2 == "Another secret" else " - ✗ FAILED!")
44+
45+
# Compare metadata sizes
46+
print(f"\n4. Metadata size comparison:")
47+
print(f" - With decoys (3): {len(metadata)//1024}KB")
48+
print(f" - Without decoys: {len(metadata2)//1024}KB")
49+
print(f" - Overhead: {(len(metadata) - len(metadata2))//1024}KB (+{((len(metadata)/len(metadata2))-1)*100:.1f}%)")
50+
51+
print("\n✓ All decoy vector tests passed!")

0 commit comments

Comments
 (0)