$ docker run --rm --name validator-libsodium-usage-ruby-rbnacl-r10-private-key-derive-public-2732 -t --mount type=bind,src=/tmp/validator-status-libsodium-usage-ruby-rbnacl-r10-private-key-derive-public,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-r10-private-key-derive-public -- bash -c 'PS4=$1; shift; set -x; source "$@"' validator-xtrace '__VALIDATOR_XTRACE__ ' /validator/tests/libsodium/tests/cases/usage/usage-ruby-rbnacl-r10-private-key-derive-public.sh no override packages found; continuing with apt originals alice_sk = RbNaCl::PrivateKey.generate bob_sk = RbNaCl::PrivateKey.generate alice_pk_bytes = alice_sk.public_key.to_bytes abort "wrong public key length" unless alice_pk_bytes.bytesize == 32 reconstructed = RbNaCl::PublicKey.new(alice_pk_bytes) abort "public key bytes mismatch" unless reconstructed.to_bytes == alice_pk_bytes # Bob encrypts to Alice using the reconstructed public key. sender_box = RbNaCl::Box.new(reconstructed, bob_sk) nonce = RbNaCl::Random.random_bytes(RbNaCl::Box.nonce_bytes) msg = "rbnacl r10 derive public payload" ct = sender_box.encrypt(nonce, msg) # Alice decrypts using her real secret key. receiver_box = RbNaCl::Box.new(bob_sk.public_key, alice_sk) pt = receiver_box.decrypt(nonce, ct) abort "roundtrip failed" unless pt == msg puts "ok" ' ok