Commit graph

17 commits

Author SHA1 Message Date
snider
bdef246a87 docs: add examples for checksum algorithms, hashing, PGP operations, and .trix container format 2026-01-13 16:10:30 +00:00
Claude
afb11667e6
feat: add encryption sigil with pre-obfuscation layer
Implements ChaChaPolySigil that applies pre-obfuscation before sending
data to CPU encryption routines. This ensures raw plaintext is never
passed directly to encryption functions.

Key improvements:
- XORObfuscator and ShuffleMaskObfuscator for pre-encryption transforms
- Nonce is now properly embedded in ciphertext, not stored separately
  in headers (production-ready, not demo-style)
- Trix crypto integration with EncryptPayload/DecryptPayload methods
- Comprehensive test coverage following Good/Bad/Ugly pattern
2025-12-25 12:36:32 +00:00
google-labs-jules[bot]
fca2880355 feat: add 100% docstring coverage
Adds comprehensive docstrings and runnable examples to all public APIs in the `crypt`, `enchantrix`, and `trix` packages. This change is intended to bring the project's documentation to a production-ready standard and to provide high-quality, verifiable examples for the official Go documentation website.
2025-11-14 14:39:45 +00:00
b03ba0cd99
Merge branch 'main' into test-sigil-coverage 2025-11-03 01:05:16 +00:00
google-labs-jules[bot]
ac706983ed test: increase test coverage to 100%
- Refactors `trix.Encode` and `trix.Decode` to allow for dependency injection, enabling the testing of I/O error paths.
- Adds comprehensive tests for the `trix` package to cover all error paths.
- Adds tests for the `Fletcher` checksums and `ensureRSA` function in the `crypt` package.
- Adds tests for the `lthn` package to cover the `SetKeyMap` and `GetKeyMap` functions.
- Adds tests for the `chachapoly` package to cover error paths.
- Adds tests for the `rsa` package to cover error paths.
- Fixes the example in `examples/main.go` to work with the refactored `trix` package.
- Refactors the `lthn` keymap test to be thread-safe by using a mutex and `t.Cleanup` to ensure state is properly restored.
- Corrects the `mockReader` implementation in the `trix` tests to adhere to the `io.Reader` interface contract.
- Removes dead code from `pkg/trix/trix.go`.
2025-11-03 01:02:41 +00:00
3ab55c98fc
Merge pull request #29 from Snider/test-sigil-coverage
test: increase test coverage to 100%
2025-11-03 00:43:45 +00:00
google-labs-jules[bot]
47db6efff9 test: increase test coverage to 100%
- Refactors `trix.Encode` and `trix.Decode` to allow for dependency injection, enabling the testing of I/O error paths.
- Adds comprehensive tests for the `trix` package to cover all error paths.
- Adds tests for the `Fletcher` checksums and `ensureRSA` function in the `crypt` package.
- Adds tests for the `lthn` package to cover the `SetKeyMap` and `GetKeyMap` functions.
- Adds tests for the `chachapoly` package to cover error paths.
- Adds tests for the `rsa` package to cover error paths.
- Fixes the example in `examples/main.go` to work with the refactored `trix` package.
- Refactors the `lthn` keymap test to be thread-safe by using a mutex and `t.Cleanup` to ensure state is properly restored.
- Corrects the `mockReader` implementation in the `trix` tests to adhere to the `io.Reader` interface contract.
2025-11-03 00:42:39 +00:00
google-labs-jules[bot]
edb8b8f98e fix(tests): address race conditions and incorrect mocks
- Refactors the `lthn` keymap test to be thread-safe by using a mutex and `t.Cleanup` to ensure state is properly restored.
- Corrects the `mockReader` implementation in the `trix` tests to adhere to the `io.Reader` interface contract.
2025-11-03 00:29:26 +00:00
google-labs-jules[bot]
1a4b2923bf test: increase test coverage to 100%
- Refactors `trix.Encode` and `trix.Decode` to allow for dependency injection, enabling the testing of I/O error paths.
- Adds comprehensive tests for the `trix` package to cover all error paths.
- Adds tests for the `Fletcher` checksums and `ensureRSA` function in the `crypt` package.
- Adds tests for the `lthn` package to cover the `SetKeyMap` and `GetKeyMap` functions.
- Adds tests for the `chachapoly` package to cover error paths.
- Adds tests for the `rsa` package to cover error paths.
2025-11-03 00:17:27 +00:00
Snider
0ca908f434 style: format code for consistency and readability 2025-11-03 00:13:13 +00:00
google-labs-jules[bot]
d7c738bbd3 refactor(tests): Co-locate tests with source code
Moves all test files from the `tdd/` directory to their corresponding `pkg/` subdirectories. This aligns with standard Go project structure and simplifies the test coverage workflow.

- Moves `tdd/crypt/crypt_test.go` to `pkg/crypt/`
- Moves `tdd/enchantrix/enchantrix_test.go` to `pkg/enchantrix/`
- Moves `tdd/trix/trix_test.go` to `pkg/trix/`
- Simplifies the `Taskfile.yml` to use a standard `go test` command.
- Removes the now-obsolete `tdd/` directory.
- Adds generated coverage files to `.gitignore`.
2025-11-02 23:09:24 +00:00
google-labs-jules[bot]
0e50aee481 feat: Consolidate and enhance tests for enchantrix and trix packages
This commit consolidates and enhances the tests for the `enchantrix` and `trix` packages, moving them into the `tdd/` directory to improve test coverage and organization.

- Consolidates existing tests from `pkg/enchantrix/` and `pkg/trix/` into new, more comprehensive test suites in `tdd/enchantrix/` and `tdd/trix/` respectively.
- Expands the test suites to include more "Bad" and "Ugly" scenarios.
- Deletes the original test files from `pkg/enchantrix/` and `pkg/trix/` to avoid redundancy.
- Organizes the `tdd/` directory with subdirectories for each package to prevent Go package conflicts.
2025-11-02 17:41:44 +00:00
google-labs-jules[bot]
f51ef1b52e feat: Add fuzz test and fix OOM vulnerability
This commit introduces a fuzz test for the `Decode` function in the `trix` package. This test immediately uncovered a critical out-of-memory (OOM) vulnerability.

-   Adds a new fuzz test, `FuzzDecode`, to `pkg/trix/fuzz_test.go` to continuously test the `Decode` function with a wide range of malformed inputs.
-   Fixes a denial-of-service vulnerability where a malicious input could specify an extremely large header length, causing the application to crash due to an out-of-memory error.
-   Introduces a `MaxHeaderSize` constant (16MB) and a check in the `Decode` function to ensure that the header length does not exceed this limit.
-   Adds a new error, `ErrHeaderTooLarge`, to provide clear feedback when the header size limit is exceeded.
2025-11-02 02:21:21 +00:00
google-labs-jules[bot]
3f39b81518 feat: Implement streaming API for Trix encoding/decoding
This commit introduces a streaming API to the `trix` package, making it more memory-efficient for large payloads.

-   Adds `EncodeTo(io.Writer)` and `DecodeFrom(io.Reader)` functions to handle streaming data.
-   Refactors the existing `Encode` and `Decode` functions to be wrappers around the new streaming API, ensuring backward compatibility.
-   Adds a specific `ErrInvalidHeaderLength` error to the `Decode` function to provide better error feedback.
-   Includes a comprehensive set of "Good, Bad, Ugly" tests for the new streaming functionality, including tests for failing readers and writers.
2025-11-02 01:40:08 +00:00
google-labs-jules[bot]
6168a9d7fe refactor: Improve Trix tests and error handling
This commit introduces several improvements to the `trix` package, focusing on test coverage and robustness.

-   Adds a specific `ErrInvalidHeaderLength` error to the `Decode` function, providing clearer feedback when the header length is invalid.
-   Introduces a `TestPackUnpack_Ugly` test to ensure that calling `Pack` with a `nil` payload is handled gracefully.
-   Simplifies the `TestChecksum_Ugly` test by manually constructing a corrupted byte slice, making the test more direct and easier to understand.
-   Adds a new "Bad" test case to verify that the `Decode` function correctly handles invalid version numbers.
2025-11-02 01:11:20 +00:00
google-labs-jules[bot]
9dcb399988 feat: Implement Go encoding types as Sigils
This commit introduces a new `enchantrix` package that provides a flexible and powerful way to transform data using a "Sigil" interface. The package includes implementations for various encoding types (hex, base64, gzip, json) and a comprehensive set of cryptographic hash functions.

The `trix` package has been refactored to use the new `enchantrix` package, and its API has been simplified to use string identifiers for Sigils, making it easier to use and decoupling it from the implementation details of the `enchantrix` package.

All new functionality is fully tested, and the existing tests have been updated to reflect the API changes.
2025-10-31 15:19:30 +00:00
google-labs-jules[bot]
d66acec498 feat: Add checksums and asymmetrical sigils to Trix container
This commit enhances the Trix container with two new features for improved data integrity and flexibility:

1.  **Configurable Checksums:**
    - The `Trix` struct now has a `ChecksumAlgo` field to specify a hash algorithm.
    - If set, `Encode` computes a checksum of the payload and adds it to the header.
    - `Decode` verifies this checksum, returning an error if it doesn't match, ensuring data integrity during transit.

2.  **Asymmetrical Sigils:**
    - The `Sigils` field has been replaced with `InSigils` and `OutSigils` to support different transformation chains for packing and unpacking.
    - If `OutSigils` is not set, `Unpack` defaults to using the `InSigils` chain to maintain the previous symmetrical behavior.

These features make the `Trix` container a more robust and self-verifying format for internal data transfer.
2025-10-31 02:55:58 +00:00