Commit graph

12 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
google-labs-jules[bot]
33e7fa1e17 test: Improve test coverage and add examples
Improves the test coverage of the project and adds examples for coverage reports.

- Increases the test coverage of the `cmd/trix` package from 67.7% to 78.1%.
- Increases the test coverage of the `pkg/crypt` package from 96.2% to 98.7%.
- Adds tests for the `examples` to ensure they run without errors.
- Adds a new example that demonstrates how to generate and interpret a coverage report.
2025-11-13 19:51:11 +00:00
google-labs-jules[bot]
8082074054 docs: Add feature examples
Adds a comprehensive set of examples to demonstrate the library's features.

- Breaks out the existing `examples/main.go` into separate, well-named files.
- Adds new examples for hashing, checksums, RSA, and PGP.
- The PGP examples cover key generation, encryption/decryption, signing/verification, and symmetric encryption.
- Removes the old `examples/main.go` file and formats the new example files.
2025-11-13 19:37:35 +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]
b4ef069ee6 fix: Correct test logic and revert breaking API changes
This commit addresses feedback from the code review:

- Updates the `TestChecksum_Bad` test in `tdd/trix/trix_test.go` to use `assert.ErrorIs` for consistent error handling.
- Reverts the breaking API change to `EncryptRSA` and `DecryptRSA` in `pkg/crypt/crypt.go` by re-introducing the `label` parameter to the public-facing functions.
- Updates the tests and examples to match the reverted API.
- Fixes a build error in `tdd/crypt/crypt_test.go` by re-introducing a necessary variable.
2025-11-02 18:46:36 +00:00
google-labs-jules[bot]
aca835874a fix: Correct test logic and revert breaking API changes
This commit addresses feedback from the code review:

- Updates the `HeaderTooLarge` test in `tdd/trix/trix_test.go` to correctly verify that `trix.Decode` returns `trix.ErrHeaderTooLarge`.
- Removes local `service` variable shadowing in `tdd/crypt/crypt_test.go` to use the package-level variable.
- Reverts the breaking API change to `EncryptRSA` and `DecryptRSA` in `pkg/crypt/crypt.go` by removing the `label` parameter from the public-facing functions.
- Updates the tests and examples to match the reverted API.
2025-11-02 18:19:58 +00:00
google-labs-jules[bot]
8cf1df9495 feat: Add comprehensive TDD tests for crypt package
This commit introduces a new `tdd/` directory and adds a comprehensive test suite for the `crypt` package, covering hashing, checksums, and RSA functions.

- Adds a new `tdd/crypt_test.go` file with tests for all functions in the `crypt` package, following the "Good, Bad, Ugly" methodology.
- Deletes the old `pkg/crypt/crypt_test.go` to avoid redundancy.
- Fixes a build error in `examples/main.go` related to an updated function signature.
2025-11-02 17:23:36 +00:00
Snider
e9f0e9f43f
Remove newline from success message 2025-11-02 13:44:29 +00:00
google-labs-jules[bot]
af9a6076c4 feat: Expand examples to demonstrate all features
Expanded `examples/main.go` to fully demonstrate the functionality of the `crypt`, `enchantrix`, and `trix` packages.

- Restructured the main example file into distinct functions for each feature set (`demoTrix`, `demoHashing`, `demoChecksums`, `demoRSA`, `demoSigils`).
- Implemented a comprehensive `demoTrix` that showcases a chain of multiple sigils (`json-indent`, `gzip`, `base64`, `reverse`), checksum functionality, and the full Pack/Unpack workflow.
- Added a `demoHashing` function that iterates through all supported hashing algorithms.
- Added a `demoChecksums` function that demonstrates the Luhn and Fletcher algorithms.
- Added a `demoRSA` function that shows the complete RSA workflow from key generation to decryption.
- Added a `demoSigils` function to demonstrate sigil transformations independently.
- Fixed a bug in the Trix demo verification logic related to JSON indentation.
2025-11-02 12:22:44 +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
google-labs-jules[bot]
36884ecb53 feat: Implement generic .trix file format
This commit introduces a new, generic `.trix` file format, which is decoupled from any specific encryption algorithm.

The format is defined in `docs/trix_format.md` and consists of a magic number, version, a flexible JSON header, and a raw data payload.

A new `trix` Go package is implemented to handle the encoding and decoding of this format. Unit tests are included to verify the implementation.

An example file, `examples/main.go`, is also added to demonstrate how to use the `.trix` container to store data encrypted with the `chachapoly` package, showcasing the intended decoupled design.
2025-10-31 01:06:23 +00:00