RSA Digital Signature Tool (javascript, written by Gemini Code Assist)
envgap__gemini__javascript-t1-12
Written by a coding agent; not on GitHubWritten 2026-03-02
01 / FAILURE SIGNATURE
As the study recorded it
No identifying execution failure has been captured.
Not a benchmark task.
- The project already builds and runs before the fix, so there is nothing to repair.
02 / ENVIRONMENT RECIPE
- Base commit
Not freshly verified- Manifest
package.json- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / TASK AND FAILURE
gemini/javascript-t1 #12 · read the task the agent was given
Gemini Code Assist wrote this javascript project from the task below. It installed and ran on a clean Ubuntu 22.04 machine as written. Task given to the agent: TASK: RSA Digital Signature Tool Write a program that generates RSA key pairs and uses them to create and verify digital signatures on files, ensuring document authenticity and integrity. FUNCTIONAL REQUIREMENTS: - Support three subcommands: keygen, sign, and verify - keygen: Generate an RSA key pair (2048 or 4096 bit, selectable via --bits flag, default 2048) and save the private key and public key as separate PEM files - sign: Accept a file path and private key path, compute a SHA-256 hash of the file, sign it with RSA-PSS padding, and save the signature as a separate .sig file - verify: Accept a file path, signature file path, and public key path, then verify the signature and print whether it is valid or invalid with details - Support signing multiple files at once by accepting a directory path via --batch flag - Support a --output flag to specify where to save generated keys or signatures - Display key information: key size, fingerprint (SHA-256 hash of public key), and creation timestamp - Support exporting the public key in both PEM and DER formats via --format flag - Print detailed results to console: for signing show the file hash and signature size, for verification show match/mismatch status and key details - If no arguments are given, generate a sample key pair, create a sample text file, sign it, verify the signature, then tamper with the file and show that verification fails - Handle errors gracefully: invalid key format, mismatched key/signature, corrupted files, unsupported key sizes Create a complete JavaScript project for a clean Ubuntu 22.04 machine with only Node.js 20+ (LTS) installed. Include: - Source code - package.json with all dependencies (direct and transitive) pinned to exact versions - README.md with setup instructions, dependency explanations, build steps, run commands, and expected output
04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]
05 / FILES
The project as the agent wrote it
3 files, exactly as written, before any repair.
package.json
{
"name": "rsa-signature-tool",
"version": "1.0.0",
"description": "RSA keygen, signing, and verification",
"main": "rsa_tool.js",
"engines": {
"node": ">=20.0.0"
},
"dependencies": {
"yargs": "17.7.2"
},
"scripts": {
"start": "node rsa_tool.js"
}
}
README.md
# RSA Digital Signature Tool (JavaScript) A tool for RSA key generation, signing, and verification. ## Setup Instructions 1. Ensure Node.js 20+ (LTS) is installed. 2. Install dependencies: ```bash npm install ``` ## Run Commands - Generate keys: ```bash node rsa_tool.js keygen ``` - Sign a file: ```bash node rsa_tool.js sign data.txt key_private.pem ``` - Verify a file: ```bash node rsa_tool.js verify data.txt data.txt.sig key_public.pem ```
rsa_tool.js
const crypto = require('crypto');
const fs = require('fs');
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const argv = yargs(hideBin(process.argv))
.command('keygen', 'Generate RSA keys')
.command('sign <file> <key>', 'Sign a file')
.command('verify <file> <sig> <key>', 'Verify a signature')
.argv;
function keygen() {
const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', {
modulusLength: 2048,
publicKeyEncoding: { type: 'spki', format: 'pem' },
privateKeyEncoding: { type: 'pkcs8', format: 'pem' }
});
fs.writeFileSync('key_private.pem', privateKey);
fs.writeFileSync('key_public.pem', publicKey);
console.log('Keys generated: key_private.pem, key_public.pem');
}
function sign(file, keyPath) {
const privateKey = fs.readFileSync(keyPath);
const data = fs.readFileSync(file);
const signature = crypto.sign('sha256', data, privateKey);
fs.writeFileSync(file + '.sig', signature);
console.log(`Signed: ${file}.sig`);
}
function verify(file, sigPath, keyPath) {
const publicKey = fs.readFileSync(keyPath);
const data = fs.readFileSync(file);
const signature = fs.readFileSync(sigPath);
const isValid = crypto.verify('sha256', data, publicKey, signature);
console.log(`Verification: ${isValid ? 'SUCCESSFUL' : 'FAILED'}`);
}
const cmd = argv._[0];
if (cmd === 'keygen') keygen();
if (cmd === 'sign') sign(argv.file, argv.key);
if (cmd === 'verify') verify(argv.file, argv.sig, argv.key);