mirror of
https://github.com/selfxyz/self.git
synced 2026-01-07 22:04:03 -05:00
SELF-1394: Fix/aadhaar registry (#1449)
* fix: remove timestamp while cal qrhash * chore: pad the timestamp with 0 instead of skipping it --------- Co-authored-by: ayman <aymanshaik1015@gmail.com>
This commit is contained in:
@@ -113,7 +113,16 @@ template REGISTER_AADHAAR(n, k, maxDataLength){
|
||||
signal output nullifier <== nullifierHasher.out;
|
||||
|
||||
|
||||
signal qrDataHash <== PackBytesAndPoseidon(maxDataLength)(qrDataPadded);
|
||||
component qrDataHasher = PackBytesAndPoseidon(maxDataLength);
|
||||
for (var i = 0; i < 9; i++){
|
||||
qrDataHasher.in[i] <== qrDataPadded[i];
|
||||
}
|
||||
for (var i = 9; i < 26; i++) {
|
||||
qrDataHasher.in[i] <== 0;
|
||||
}
|
||||
for (var i = 26; i < maxDataLength; i++){
|
||||
qrDataHasher.in[i] <== qrDataPadded[i];
|
||||
}
|
||||
|
||||
// Generate commitment
|
||||
component packedCommitment = PackBytesAndPoseidon(42 + 62);
|
||||
@@ -138,7 +147,7 @@ template REGISTER_AADHAAR(n, k, maxDataLength){
|
||||
component commitmentHasher = Poseidon(5);
|
||||
|
||||
commitmentHasher.inputs[0] <== secret;
|
||||
commitmentHasher.inputs[1] <== qrDataHash;
|
||||
commitmentHasher.inputs[1] <== qrDataHasher.out;
|
||||
commitmentHasher.inputs[2] <== nullifierHasher.out;
|
||||
commitmentHasher.inputs[3] <== packedCommitment.out;
|
||||
commitmentHasher.inputs[4] <== qrDataExtractor.photoHash;
|
||||
|
||||
@@ -208,8 +208,6 @@ export function prepareAadhaarDiscloseData(
|
||||
secret,
|
||||
qrDataHash: formatInput(BigInt(sharedData.qrHash)),
|
||||
gender: formatInput(genderAscii),
|
||||
// qrDataHash: BigInt(sharedData.qrHash).toString(),
|
||||
// gender: genderAscii.toString(),
|
||||
yob: stringToAsciiArray(sharedData.extractedFields.yob),
|
||||
mob: stringToAsciiArray(sharedData.extractedFields.mob),
|
||||
dob: stringToAsciiArray(sharedData.extractedFields.dob),
|
||||
@@ -551,7 +549,6 @@ export function processQRData(
|
||||
QRData = newTestData.testQRData;
|
||||
} else {
|
||||
QRData = testQRData.testQRData;
|
||||
// console.log('testQRData:', testQRData);
|
||||
}
|
||||
|
||||
return processQRDataSimple(QRData);
|
||||
@@ -576,7 +573,13 @@ export function processQRDataSimple(qrData: string) {
|
||||
// Extract actual fields from QR data instead of using hardcoded values
|
||||
const extractedFields = extractQRDataFields(qrDataBytes);
|
||||
|
||||
const qrHash = packBytesAndPoseidon(Array.from(qrDataPadded));
|
||||
// Calculate qrHash exclude timestamp (positions 9-25, 17 bytes)
|
||||
const qrDataWithoutTimestamp = [
|
||||
...Array.from(qrDataPadded.slice(0, 9)),
|
||||
...Array.from(qrDataPadded.slice(9, 26)).map((x) => 0),
|
||||
...Array.from(qrDataPadded.slice(26)),
|
||||
];
|
||||
const qrHash = packBytesAndPoseidon(qrDataWithoutTimestamp);
|
||||
const photo = extractPhoto(Array.from(qrDataPadded), photoEOI + 1);
|
||||
|
||||
const photoHash = packBytesAndPoseidon(photo.bytes.map(Number));
|
||||
|
||||
Reference in New Issue
Block a user