A curious issue with account_seckey encoding was detected:
enacl secret keys can be either 32-byte or 64-byte, depending on whether they include the pubkey as an optimization
gmser_api_encoder:encode(account_seckey, Sec64Byte) would work, but the subsequent decode would fail.
Generally, encode/2 never bothered to check the payload size, but decode() did, which is backwards.
There was even an EUnit test that relied on this, using encode() to generate an illegal encoding, and then verifying that it couldn't be decoded.
This PR introduces size checks in encode(), which technically might be a compatibility break. For testing, encode_/2 works like the old encode/2, without checking size.
Also encode/decode of account_seckey now supports both 32-byte and 64-byte payload.
The new functions encode_keypair/1 and safe_decode_keypair/1 convert between an enacl keypair and one that the gajumaru config schema can handle. The decode verifies that the public and secret keys in fact match.
The usual caveats still apply that secret keys should remain secret (thus strictly not being good candidates for serialization) - but for testing, it is quite useful, and since we've gone down that road already, it would be nice to have the support be consistent and reasonably safe.
A curious issue with `account_seckey` encoding was detected:
* enacl secret keys can be either 32-byte or 64-byte, depending on whether they include the pubkey as an optimization
* `gmser_api_encoder:encode(account_seckey, Sec64Byte)` would work, but the subsequent decode would fail.
* Generally, `encode/2` never bothered to check the payload size, but `decode()` did, which is backwards.
* There was even an EUnit test that relied on this, using `encode()` to generate an illegal encoding, and then verifying that it couldn't be decoded.
This PR introduces size checks in `encode()`, which technically might be a compatibility break. For testing, `encode_/2` works like the old `encode/2`, without checking size.
Also encode/decode of `account_seckey` now supports both 32-byte and 64-byte payload.
The new functions `encode_keypair/1` and `safe_decode_keypair/1` convert between an `enacl` keypair and one that the gajumaru config schema can handle. The decode verifies that the public and secret keys in fact match.
The usual caveats still apply that secret keys should remain secret (thus strictly not being good candidates for serialization) - but for testing, it *is* quite useful, and since we've gone down that road already, it would be nice to have the support be consistent and reasonably safe.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
A curious issue with
account_seckeyencoding was detected:gmser_api_encoder:encode(account_seckey, Sec64Byte)would work, but the subsequent decode would fail.encode/2never bothered to check the payload size, butdecode()did, which is backwards.encode()to generate an illegal encoding, and then verifying that it couldn't be decoded.This PR introduces size checks in
encode(), which technically might be a compatibility break. For testing,encode_/2works like the oldencode/2, without checking size.Also encode/decode of
account_seckeynow supports both 32-byte and 64-byte payload.The new functions
encode_keypair/1andsafe_decode_keypair/1convert between anenaclkeypair and one that the gajumaru config schema can handle. The decode verifies that the public and secret keys in fact match.The usual caveats still apply that secret keys should remain secret (thus strictly not being good candidates for serialization) - but for testing, it is quite useful, and since we've gone down that road already, it would be nice to have the support be consistent and reasonably safe.