From efbe84e599a8f07409136649c1f8ee8dc500af6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Seshanth=2ES=F0=9F=90=BA?= <35675963+seshanthS@users.noreply.github.com> Date: Thu, 13 Feb 2025 18:53:15 +0530 Subject: [PATCH] update rsapss tests (#70) --- circuits/tests/utils/rsapss.test.ts | 11 +++++++++-- common/src/utils/passports/genMockPassportData.ts | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/circuits/tests/utils/rsapss.test.ts b/circuits/tests/utils/rsapss.test.ts index fcbe7bbb4..5f05d9179 100644 --- a/circuits/tests/utils/rsapss.test.ts +++ b/circuits/tests/utils/rsapss.test.ts @@ -67,7 +67,10 @@ describe('VerifyRsapss Circuit Test', function () { algorithm.saltLength ); - const invalidSignature = signature.map((byte: string) => String((parseInt(byte) + 1) % 256)); + const invalidSignature = [...signature]; + const randomIndex = Math.floor(Math.random() * signature.length); + invalidSignature[randomIndex] = String((BigInt(signature[randomIndex]) + 1n).toString()); + const circuit = await wasmTester( path.join( __dirname, @@ -95,7 +98,11 @@ describe('VerifyRsapss Circuit Test', function () { algorithm.saltLength ); - const invalidMessage = message.map((byte: number) => String((byte + 1) % 256)); + // Flip one bit in the message + const invalidMessage = [...message]; + const randomIndex = Math.floor(Math.random() * message.length); + invalidMessage[randomIndex] = invalidMessage[randomIndex] === 0 ? 1 : 0; + const circuit = await wasmTester( path.join( __dirname, diff --git a/common/src/utils/passports/genMockPassportData.ts b/common/src/utils/passports/genMockPassportData.ts index aed2345d4..4f497fe5e 100644 --- a/common/src/utils/passports/genMockPassportData.ts +++ b/common/src/utils/passports/genMockPassportData.ts @@ -174,8 +174,8 @@ export function genMockPassportData( dsc = mockCertificates.mock_dsc_sha256_rsapss_32_65537_3072; break; case 'rsapss_sha256_65537_4096': - privateKeyPem = mockCertificates.mock_dsc_sha256_rsapss_32_65537_2048_key; - dsc = mockCertificates.mock_dsc_sha256_rsapss_32_65537_2048; + privateKeyPem = mockCertificates.mock_dsc_sha256_rsapss_32_65537_4096_key; + dsc = mockCertificates.mock_dsc_sha256_rsapss_32_65537_4096; break; case 'ecdsa_sha256_brainpoolP384r1_384': privateKeyPem = mockCertificates.mock_dsc_sha256_ecdsa_brainpoolP384r1_key;