mirror of
https://github.com/selfxyz/self.git
synced 2026-04-27 03:01:15 -04:00
refactor test sheet
This commit is contained in:
48
sdk/tests/utils/generateInputsInSdk.ts
Normal file
48
sdk/tests/utils/generateInputsInSdk.ts
Normal 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');
|
||||
}
|
||||
};
|
||||
63
sdk/tests/utils/testCases.ts
Normal file
63
sdk/tests/utils/testCases.ts
Normal 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',
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user