$ docker run --rm --name validator-libsodium-usage-ruby-rbnacl-r14-box-precompute-roundtrip-2732 -t --mount type=bind,src=/tmp/validator-status-libsodium-usage-ruby-rbnacl-r14-box-precompute-roundtrip,dst=/validator/status validator-libsodium-shared bash -lc 'set -euo pipefail /validator/tests/_shared/install_override_debs.sh exec /validator/tests/_shared/run_library_tests.sh "$@"' validator-testcase libsodium usage-ruby-rbnacl-r14-box-precompute-roundtrip -- bash -c 'PS4=$1; shift; set -x; source "$@"' validator-xtrace '__VALIDATOR_XTRACE__ ' /validator/tests/libsodium/tests/cases/usage/usage-ruby-rbnacl-r14-box-precompute-roundtrip.sh no override packages found; continuing with apt originals sk_a = RbNaCl::PrivateKey.generate sk_b = RbNaCl::PrivateKey.generate box_ab = RbNaCl::Box.new(sk_b.public_key, sk_a) box_ba = RbNaCl::Box.new(sk_a.public_key, sk_b) nonce = ("\x14".b * 24) msg = "rbnacl r14 box payload".b ct = box_ab.encrypt(nonce, msg) abort "ciphertext == plaintext" if ct == msg pt = box_ba.decrypt(nonce, ct) abort "round-trip mismatch" unless pt == msg # Wrong nonce on decrypt must fail. bad_nonce = ("\x15".b * 24) rejected = false begin box_ba.decrypt(bad_nonce, ct) rescue RbNaCl::CryptoError rejected = true end abort "wrong-nonce decrypt accepted" unless rejected puts "ok" ' ok