further benchmarking stuff

This commit is contained in:
Zoe
2025-11-28 14:53:06 -06:00
parent e16383e9b9
commit d0f4936b84
25 changed files with 441 additions and 739 deletions

View File

@@ -1,35 +1,43 @@
import { defineEventHandler } from 'h3'
import { ChallengeStrategy } from '@impost/lib';
import { ChallengeStrategy, ChallengeAlgorithm } from '@impost/lib';
export default defineEventHandler(async (event) => {
const body = await readBody(event)
let difficulty = body.difficulty;
switch (config.strategy) {
case ChallengeStrategy.LeadingZeroes:
if (!difficulty || difficulty < 1 || difficulty > 64) {
throw createError({
statusCode: 400,
statusMessage: 'Invalid request',
});
}
switch (config.algorithm) {
case ChallengeAlgorithm.SHA256:
case ChallengeAlgorithm.Argon2:
switch (config.strategy) {
case ChallengeStrategy.LeadingZeroes:
if (!difficulty || difficulty < 1 || difficulty > 64) {
throw createError({
statusCode: 400,
statusMessage: 'Invalid request',
});
}
config.leading_zeroes.difficulty = difficulty;
config.leading_zeroes.difficulty = difficulty;
break;
case ChallengeStrategy.TargetNumber:
if (!difficulty || difficulty < 1 || difficulty > 100_000_000) {
throw createError({
statusCode: 400,
statusMessage: 'Invalid request',
});
}
config.target_number.max_number = difficulty;
break;
}
break;
case ChallengeStrategy.TargetNumber:
if (!difficulty || difficulty < 1 || difficulty > 100_000_000) {
throw createError({
statusCode: 400,
statusMessage: 'Invalid request',
});
}
config.target_number.max_number = difficulty;
case ChallengeAlgorithm.kCTF:
config.kctf.difficulty = difficulty;
break;
}
return {
message: 'Challenge difficulty set'
message: `Challenge difficulty set to ${difficulty}`
};
});