mirror of
https://github.com/selfxyz/self.git
synced 2026-01-09 22:58:20 -05:00
fix disclose test
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
import { assert, expect } from 'chai';
|
||||
import path from 'path';
|
||||
import { wasm as wasm_tester } from 'circom_tester';
|
||||
import { mockPassportData_sha256_rsa_65537 } from '../../../common/src/constants/mockPassportData';
|
||||
import { formatMrz, packBytes } from '../../../common/src/utils/utils';
|
||||
import {
|
||||
attributeToPosition,
|
||||
COMMITMENT_TREE_DEPTH,
|
||||
PASSPORT_ATTESTATION_ID,
|
||||
} from '../../../common/src/constants/constants';
|
||||
import { poseidon1, poseidon2, poseidon6 } from 'poseidon-lite';
|
||||
@@ -14,13 +12,14 @@ import { getLeaf } from '../../../common/src/utils/pubkeyTree';
|
||||
import { generateCircuitInputsDisclose } from '../../../common/src/utils/generateInputs';
|
||||
import { formatAndUnpackReveal } from '../../../common/src/utils/revealBitmap';
|
||||
import crypto from 'crypto';
|
||||
import { genMockPassportData } from '../../../common/src/utils/genMockPassportData';
|
||||
|
||||
describe('Disclose', function () {
|
||||
this.timeout(0);
|
||||
let inputs: any;
|
||||
let circuit: any;
|
||||
let w: any;
|
||||
let passportData = mockPassportData_sha256_rsa_65537;
|
||||
const passportData = genMockPassportData('rsa_sha256', 'FRA', '000101', '300101');
|
||||
let tree: any;
|
||||
|
||||
before(async () => {
|
||||
|
||||
@@ -132,7 +132,7 @@ export function generateCircuitInputsRegister(
|
||||
|
||||
dscModulusComponents = {
|
||||
dsc_modulus: splitToWords(
|
||||
BigInt(hexToDecimal(modulus as string)),
|
||||
BigInt(hexToDecimal(modulus)),
|
||||
n_dsc,
|
||||
k_dsc
|
||||
)
|
||||
|
||||
@@ -7,8 +7,9 @@ import { PassportData } from "./types";
|
||||
import { getSignatureAlgorithm } from "./handleCertificate";
|
||||
|
||||
export function getLeaf(passportData: PassportData): bigint {
|
||||
const { signatureAlgorithm, modulus, x, y } = getSignatureAlgorithm(passportData.dsc);
|
||||
|
||||
const { signatureAlgorithm, hashFunction, modulus, x, y } = getSignatureAlgorithm(passportData.dsc);
|
||||
const sigAlgIndex = SignatureAlgorithmIndex[`${signatureAlgorithm}_${hashFunction}`]
|
||||
|
||||
if (signatureAlgorithm === 'ecdsa') {
|
||||
let qx = splitToWords(BigInt(hexToDecimal(x)), 43, 6);
|
||||
let qy = splitToWords(BigInt(hexToDecimal(y)), 43, 6);
|
||||
@@ -17,15 +18,17 @@ export function getLeaf(passportData: PassportData): bigint {
|
||||
let y_hash = poseidon6(qy);
|
||||
|
||||
return poseidon3([
|
||||
SignatureAlgorithmIndex[signatureAlgorithm],
|
||||
sigAlgIndex,
|
||||
x_hash,
|
||||
y_hash,
|
||||
]);
|
||||
} else {
|
||||
const pubkeyChunked = splitToWords(BigInt(modulus), 230, 9);
|
||||
return poseidon10(
|
||||
[SignatureAlgorithmIndex[signatureAlgorithm], ...pubkeyChunked]
|
||||
);
|
||||
const pubkeyChunked = splitToWords(BigInt(hexToDecimal(modulus)), 230, 9);
|
||||
|
||||
return poseidon10([
|
||||
sigAlgIndex,
|
||||
...pubkeyChunked
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user