mirror of
https://github.com/selfxyz/self.git
synced 2026-01-09 14:48:06 -05:00
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { wasm as wasmTester } from 'circom_tester';
|
|
import { describe, it } from 'mocha';
|
|
import path from 'path';
|
|
import { generateMockRsaPkcs1v1_5Inputs } from './generateMockInputsInCircuits';
|
|
import { SignatureAlgorithm } from '../../../common/src/utils/types';
|
|
|
|
describe('VerifyRsaPkcs1v1_5 Circuit Test', function () {
|
|
this.timeout(0);
|
|
|
|
const rsaAlgorithms: SignatureAlgorithm[] = [
|
|
'rsa_sha1_65537_2048',
|
|
'rsa_sha256_65537_2048',
|
|
'rsa_sha256_3_2048',
|
|
'rsa_sha256_65537_3072',
|
|
'rsa_sha256_65537_4096',
|
|
'rsa_sha512_65537_4096',
|
|
];
|
|
|
|
rsaAlgorithms.forEach((algorithm) => {
|
|
it(`should verify RSA signature using the circuit for ${algorithm}`, async function () {
|
|
// Generate inputs using the utility function
|
|
const { signature, modulus, message } = generateMockRsaPkcs1v1_5Inputs(algorithm);
|
|
let dummy = 0;
|
|
// console.log('signature', signature);
|
|
|
|
// Run circuit with inputs
|
|
const circuit = await wasmTester(
|
|
path.join(__dirname, `../../circuits/tests/utils/rsa/test_${algorithm}.circom`),
|
|
{
|
|
include: ['node_modules', './node_modules/@zk-kit/binary-merkle-root.circom/src'],
|
|
}
|
|
);
|
|
|
|
// Log the inputs for debugging
|
|
console.log(`Testing algorithm: ${algorithm}`);
|
|
|
|
const witness = await circuit.calculateWitness({
|
|
signature,
|
|
modulus,
|
|
message,
|
|
dummy,
|
|
});
|
|
|
|
// Check constraints
|
|
await circuit.checkConstraints(witness);
|
|
});
|
|
});
|
|
});
|