refactor test sheet

This commit is contained in:
turnoffthiscomputer
2024-09-12 12:48:27 +02:00
parent 3ebf159b4a
commit f233542b2d
3 changed files with 159 additions and 249 deletions

View File

@@ -0,0 +1,48 @@
import { PassportData } from '../../../common/src/utils/types';
import { CircuitName } from '../../../common/src/utils/appType';
import {
k_dsc,
n_dsc,
PASSPORT_ATTESTATION_ID,
} from '../../../common/src/constants/constants';
import {
generateCircuitInputsProve,
generateCircuitInputsRegister,
} from '../../../common/src/utils/generateInputs';
import { majority, scope } from './testCases';
export const generateCircuitInputsInSdk = (
passportData: PassportData,
circuit: CircuitName
): any => {
switch (circuit) {
case 'register': {
const secret = BigInt(0).toString();
const dscSecret = BigInt(0).toString();
const attestationId = PASSPORT_ATTESTATION_ID;
return generateCircuitInputsRegister(
secret,
dscSecret as string,
attestationId,
passportData,
n_dsc,
k_dsc
);
}
case 'prove': {
const bitmap = Array(90).fill('1');
const user_identifier = crypto.randomUUID();
return generateCircuitInputsProve(
passportData,
n_dsc,
k_dsc,
scope,
bitmap,
majority,
user_identifier
);
}
default:
throw new Error('Invalid circuit');
}
};

View File

@@ -0,0 +1,63 @@
import { countryCodes, DEFAULT_MAJORITY } from "../../../common/src/constants/constants";
type CircuitType = 'register' | 'prove';
type AlgorithmType = 'rsa_sha256' | 'rsa_sha1' | 'rsapss_sha256';
export const scope = '@spaceShips';
export const majority = DEFAULT_MAJORITY;
export const alphaCode = 'FRA';
export const dateOfBirth = '000101';
export const dateOfExpiry = '300101';
export const getCountryName = () => {
const countryName = countryCodes[alphaCode as keyof typeof countryCodes];
if (!countryName) {
throw new Error(`Country name not found for alpha code: ${alphaCode}`);
}
return countryName;
};
export interface TestCase {
circuitType: CircuitType;
algorithm: AlgorithmType;
wasmPath: string;
zkeyPath: string;
}
export const testCases: TestCase[] = [
{
circuitType: 'register',
algorithm: 'rsa_sha256',
wasmPath: '../circuits/build/fromAWS/register_rsa_65537_sha256.wasm',
zkeyPath: '../circuits/build/fromAWS/register_rsa_65537_sha256.zkey',
},
{
circuitType: 'register',
algorithm: 'rsa_sha1',
wasmPath: '../circuits/build/fromAWS/register_rsa_65537_sha1.wasm',
zkeyPath: '../circuits/build/fromAWS/register_rsa_65537_sha1.zkey',
},
{
circuitType: 'register',
algorithm: 'rsapss_sha256',
wasmPath: '../circuits/build/fromAWS/register_rsapss_65537_sha256.wasm',
zkeyPath: '../circuits/build/fromAWS/register_rsapss_65537_sha256.zkey',
},
{
circuitType: 'prove',
algorithm: 'rsa_sha256',
wasmPath: '../circuits/build/fromAWS/prove_rsa_65537_sha256.wasm',
zkeyPath: '../circuits/build/fromAWS/prove_rsa_65537_sha256.zkey',
},
{
circuitType: 'prove',
algorithm: 'rsa_sha1',
wasmPath: '../circuits/build/fromAWS/prove_rsa_65537_sha1.wasm',
zkeyPath: '../circuits/build/fromAWS/prove_rsa_65537_sha1.zkey',
},
{
circuitType: 'prove',
algorithm: 'rsapss_sha256',
wasmPath: '../circuits/build/fromAWS/prove_rsapss_65537_sha256.wasm',
zkeyPath: '../circuits/build/fromAWS/prove_rsapss_65537_sha256.zkey',
},
];