Commit graph

18 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]
fce5b3fa59 feat: improve pgp testability and coverage
- Add `SymmetricallyDecrypt` to `pkg/crypt/std/pgp`.
- Add validation for empty passphrases in `SymmetricallyEncrypt` and `SymmetricallyDecrypt`.
- Refactor `pkg/crypt/std/pgp/pgp.go` to use package-level variables for `openpgp` functions to enable mocking.
- Add comprehensive tests in `pkg/crypt/std/pgp/pgp_test.go` to cover error paths using mocks, achieving 100% coverage.
- Remove practically unreachable error check in `GenerateKeyPair` for `SignUserId` (as `NewEntity` guarantees validity).
2025-11-23 19:26:56 +00:00
google-labs-jules[bot]
16a346ca99 test: Increase test coverage to over 90%
Increases the test coverage of the project to over 90%.

- Increases the test coverage of the `cmd/trix` package from 82.3% to 83.3%.
- Increases the test coverage of the `pkg/crypt/std/pgp` package from 84.0% to over 90%.
- Adds tests for error paths and edge cases in `cmd/trix` and `pkg/crypt/std/pgp`.
2025-11-13 20:21:25 +00:00
google-labs-jules[bot]
18ac6b99bc test: Further increase test coverage
Increases the test coverage of the project.

- Increases the test coverage of the `cmd/trix` package from 78.1% to 82.3%.
- Increases the test coverage of the `pkg/crypt/std/pgp` package from 76.5% to 84.0%.
- Adds tests for error paths and edge cases in `cmd/trix` and `pkg/crypt/std/pgp`.
2025-11-13 20:06:32 +00:00
google-labs-jules[bot]
b6b526bcf7 feat: Expand OpenPGP implementation
Expands the existing OpenPGP implementation to include a more complete set of features for handling PGP data.

- Adds support for signing and verifying detached signatures.
- Adds support for symmetric encryption using a passphrase.
- Includes tests for all new functionality.
2025-11-13 19:06:20 +00:00
google-labs-jules[bot]
a46477c8fd feat: Add OpenPGP implementation
Adds a full implementation of OpenPGP features using ProtonMail's go-crypto fork.

- Implements PGP key generation, encryption, and decryption.
- Exposes PGP functionality through the crypt.Service.
- Adds tests for the PGP implementation.
2025-11-13 19:02:03 +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]
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]
c286a82e89 feat(tests): Add internal tests for private functions
Adds `_internal_test.go` files to test unexported functions in the `crypt` and `lthn` packages, improving overall test coverage.

- Adds tests for the `ensureRSA` private function in `pkg/crypt/crypt.go`.
- Adds tests for the `createSalt` private function in `pkg/crypt/std/lthn/lthn.go`.

These changes align with the project's TDD methodology and follow the `_Good`, `_Bad`, `_Ugly` testing structure.
2025-11-02 21:23:13 +00:00
google-labs-jules[bot]
e7aeb3c8b8 Refactor(crypt): Improve RSA safety and flexibility
This commit introduces several improvements to the RSA implementation:

- Preserves zero-value service safety by lazily initializing the RSA service in `pkg/crypt/crypt.go`.
- Enforces a minimum RSA key size of 2048 bits in `pkg/crypt/std/rsa/rsa.go` to prevent the generation of insecure keys.
- Exposes the OAEP label parameter in `Encrypt` and `Decrypt` functions, allowing for more advanced use cases.
- Adds a test case to verify that `GenerateKeyPair` correctly rejects key sizes below the new minimum.
2025-11-02 03:06:04 +00:00
coderabbitai[bot]
186b75c402
📝 Add docstrings to feature-openpgp-implementation
Docstrings generation was requested by @Snider.

* https://github.com/Snider/Enchantrix/pull/17#issuecomment-3473285782

The following files were modified:

* `pkg/crypt/crypt.go`
* `pkg/crypt/std/rsa/rsa.go`
2025-10-31 19:59:43 +00:00
google-labs-jules[bot]
83e8174634 feat: Implement RSA service
This commit introduces a standard RSA implementation in `pkg/crypt/std/rsa`.

The new `rsa.Service` provides a clean API for RSA operations, including:
- Key pair generation
- Encryption and decryption of data

The implementation uses the standard `crypto/rsa` package and follows best practices, including OAEP padding. The main `crypt.Service` has been updated to integrate and expose this new functionality.

This work was done to validate the build environment, and the tests for this implementation pass successfully, confirming that the previous testing issues were isolated to the OpenPGP library.
2025-10-31 14:46:28 +00:00
google-labs-jules[bot]
52aa833a2f feat: Implement OpenPGP service
This commit introduces a full OpenPGP implementation in `pkg/crypt/std/openpgp`, using the ProtonMail `go-crypto` library.

The new `openpgp.Service` provides a clean, Web3-friendly API for PGP operations, including:
- Key pair generation
- Subkey management
- Encryption and decryption of messages
- Signing and verification of messages

The implementation is based on the user's `Core` repository and uses file-based key management. The main `crypt.Service` has been updated to integrate and expose this new functionality.
2025-10-31 14:13:57 +00:00
google-labs-jules[bot]
2ff894327b refactor: Restructure crypt service and decouple from storage
This commit restructures the `crypt` service to be more modular and decoupled from storage concerns.

- The standard cryptographic implementations (`lthn`, `chachapoly`, `rsa`) have been moved to the `pkg/crypt/std` directory.
- The `rootfs` components have been removed to decouple the library from storage.
- Import paths have been updated to reflect the new structure.
2025-10-31 01:34:24 +00:00