Sprint: SPRINT_4100_0006_0001 Status: COMPLETED Implemented plugin-based crypto command architecture for regional compliance with build-time distribution selection (GOST/eIDAS/SM) and runtime validation. ## New Commands - `stella crypto sign` - Sign artifacts with regional crypto providers - `stella crypto verify` - Verify signatures with trust policy support - `stella crypto profiles` - List available crypto providers & capabilities ## Build-Time Distribution Selection ```bash # International (default - BouncyCastle) dotnet build src/Cli/StellaOps.Cli/StellaOps.Cli.csproj # Russia distribution (GOST R 34.10-2012) dotnet build -p:StellaOpsEnableGOST=true # EU distribution (eIDAS Regulation 910/2014) dotnet build -p:StellaOpsEnableEIDAS=true # China distribution (SM2/SM3/SM4) dotnet build -p:StellaOpsEnableSM=true ``` ## Key Features - Build-time conditional compilation prevents export control violations - Runtime crypto profile validation on CLI startup - 8 predefined profiles (international, russia-prod/dev, eu-prod/dev, china-prod/dev) - Comprehensive configuration with environment variable substitution - Integration tests with distribution-specific assertions - Full migration path from deprecated `cryptoru` CLI ## Files Added - src/Cli/StellaOps.Cli/Commands/CryptoCommandGroup.cs - src/Cli/StellaOps.Cli/Commands/CommandHandlers.Crypto.cs - src/Cli/StellaOps.Cli/Services/CryptoProfileValidator.cs - src/Cli/StellaOps.Cli/appsettings.crypto.yaml.example - src/Cli/__Tests/StellaOps.Cli.Tests/CryptoCommandTests.cs - docs/cli/crypto-commands.md - docs/implplan/SPRINT_4100_0006_0001_COMPLETION_SUMMARY.md ## Files Modified - src/Cli/StellaOps.Cli/StellaOps.Cli.csproj (conditional plugin refs) - src/Cli/StellaOps.Cli/Program.cs (plugin registration + validation) - src/Cli/StellaOps.Cli/Commands/CommandFactory.cs (command wiring) - src/Scanner/__Libraries/StellaOps.Scanner.Core/Configuration/PoEConfiguration.cs (fix) ## Compliance - GOST (Russia): GOST R 34.10-2012, FSB certified - eIDAS (EU): Regulation (EU) No 910/2014, QES/AES/AdES - SM (China): GM/T 0003-2012 (SM2), OSCCA certified ## Migration `cryptoru` CLI deprecated → sunset date: 2025-07-01 - `cryptoru providers` → `stella crypto profiles` - `cryptoru sign` → `stella crypto sign` ## Testing ✅ All crypto code compiles successfully ✅ Integration tests pass ✅ Build verification for all distributions (international/GOST/eIDAS/SM) Next: SPRINT_4100_0006_0002 (eIDAS plugin implementation) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
StellaOps.Canonical.Json
Canonical JSON serialization with deterministic hashing for StellaOps proofs.
Overview
This library provides canonical JSON serialization that produces bit-identical output across different environments, enabling deterministic replay and cryptographic verification of score proofs.
Key Features
- Deterministic Output: Object keys are recursively sorted using Ordinal comparison
- No Whitespace: Compact output with no formatting variations
- Consistent Hashing: SHA-256 hashes are always lowercase hex
- Cross-Platform: Same output across Windows, Linux, containers
Usage
Basic Canonicalization
using StellaOps.Canonical.Json;
var obj = new { z = 3, a = 1, nested = new { b = 2, x = 1 } };
// Get canonical bytes
byte[] canonical = CanonJson.Canonicalize(obj);
// Result: {"a":1,"nested":{"b":2,"x":1},"z":3}
// Compute hash
string hash = CanonJson.Sha256Hex(canonical);
// Result: lowercase 64-char hex string
One-Step Hash
// Hash object directly
string hash = CanonJson.Hash(obj);
// With sha256: prefix
string prefixed = CanonJson.HashPrefixed(obj);
// Result: "sha256:a1b2c3..."
Canonicalizing Existing JSON
// Re-sort keys in existing JSON
byte[] rawJson = Encoding.UTF8.GetBytes(@"{""z"":1,""a"":2}");
byte[] canonical = CanonJson.CanonicalizeParsedJson(rawJson);
// Result: {"a":2,"z":1}
Custom Serialization Options
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower
};
byte[] canonical = CanonJson.Canonicalize(obj, options);
API Reference
| Method | Description |
|---|---|
Canonicalize<T>(obj) |
Serialize and canonicalize an object |
Canonicalize<T>(obj, options) |
Serialize with custom options and canonicalize |
CanonicalizeParsedJson(bytes) |
Canonicalize existing JSON bytes |
Sha256Hex(bytes) |
Compute SHA-256, return lowercase hex |
Sha256Prefixed(bytes) |
Compute SHA-256 with "sha256:" prefix |
Hash<T>(obj) |
Canonicalize and hash in one step |
HashPrefixed<T>(obj) |
Canonicalize and hash with prefix |
Guarantees
- Key Ordering: Object keys are always sorted alphabetically (Ordinal)
- No Environment Dependencies: No timestamps, random values, or environment variables
- UTF-8 Without BOM: Output is always UTF-8 encoded without byte order mark
- Array Order Preserved: Arrays maintain element order (only object keys are sorted)
Use Cases
- Scan Manifests: Hash all inputs affecting scan results
- DSSE Payloads: Sign canonical JSON for attestations
- Proof Replay: Verify scores are deterministic
- Content Addressing: Store proofs by their hash
Related Components
StellaOps.Scanner.Core.Models.ScanManifest- Uses CanonJson for manifest hashingStellaOps.Attestor- Signs canonical JSON payloadsStellaOps.Evidence.Bundle- Content-addressed proof storage