mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@selfxyz/core",
|
||||
"version": "1.1.0-beta.7",
|
||||
"version": "1.2.0-beta.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/selfxyz/self"
|
||||
|
||||
@@ -5,6 +5,8 @@ import {
|
||||
AadhaarVerifier__factory,
|
||||
IdentityVerificationHubImpl,
|
||||
IdentityVerificationHubImpl__factory,
|
||||
KycVerifier,
|
||||
KycVerifier__factory,
|
||||
Registry__factory,
|
||||
Verifier,
|
||||
Verifier__factory,
|
||||
@@ -222,7 +224,26 @@ export class SelfBackendVerifier {
|
||||
let circuitTimestampYy: number[];
|
||||
let circuitTimestampMm: number[];
|
||||
let circuitTimestampDd: number[];
|
||||
if (attestationId === 3) {
|
||||
if (attestationId === 4) {
|
||||
circuitTimestampYy = publicSignals
|
||||
.slice(
|
||||
discloseIndices[attestationId].currentDateIndex,
|
||||
discloseIndices[attestationId].currentDateIndex + 4
|
||||
)
|
||||
.map(Number);
|
||||
circuitTimestampMm = publicSignals
|
||||
.slice(
|
||||
discloseIndices[attestationId].currentDateIndex + 4,
|
||||
discloseIndices[attestationId].currentDateIndex + 6
|
||||
)
|
||||
.map(Number);
|
||||
circuitTimestampDd = publicSignals
|
||||
.slice(
|
||||
discloseIndices[attestationId].currentDateIndex + 6,
|
||||
discloseIndices[attestationId].currentDateIndex + 8
|
||||
)
|
||||
.map(Number);
|
||||
} else if (attestationId === 3) {
|
||||
circuitTimestampYy = String(publicSignals[discloseIndices[attestationId].currentDateIndex])
|
||||
.split('')
|
||||
.map(Number);
|
||||
@@ -285,7 +306,7 @@ export class SelfBackendVerifier {
|
||||
throw new ConfigMismatchError(issues);
|
||||
}
|
||||
|
||||
let verifierContract: Verifier | AadhaarVerifier;
|
||||
let verifierContract: Verifier | AadhaarVerifier | KycVerifier;
|
||||
try {
|
||||
const verifierAddress = await this.identityVerificationHubContract.discloseVerifier(
|
||||
'0x' + attestationId.toString(16).padStart(64, '0')
|
||||
@@ -293,7 +314,9 @@ export class SelfBackendVerifier {
|
||||
if (verifierAddress === '0x0000000000000000000000000000000000000000') {
|
||||
throw new VerifierContractError('Verifier contract not found');
|
||||
}
|
||||
if (attestationId === 3) {
|
||||
if (attestationId === 4) {
|
||||
verifierContract = KycVerifier__factory.connect(verifierAddress, this.provider);
|
||||
} else if (attestationId === 3) {
|
||||
verifierContract = AadhaarVerifier__factory.connect(verifierAddress, this.provider);
|
||||
} else {
|
||||
verifierContract = Verifier__factory.connect(verifierAddress, this.provider);
|
||||
|
||||
36
sdk/core/src/abi/KycVerifier.json
Normal file
36
sdk/core/src/abi/KycVerifier.json
Normal file
@@ -0,0 +1,36 @@
|
||||
[
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "a",
|
||||
"type": "uint256[2]"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256[2][2]",
|
||||
"name": "b",
|
||||
"type": "uint256[2][2]"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "c",
|
||||
"type": "uint256[2]"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256[29]",
|
||||
"name": "pubSignals",
|
||||
"type": "uint256[29]"
|
||||
}
|
||||
],
|
||||
"name": "verifyProof",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
||||
@@ -50,9 +50,9 @@ export const discloseIndices = {
|
||||
// Selfrica ID Card - see CircuitConstantsV2.sol for layout documentation
|
||||
4: {
|
||||
revealedDataPackedIndex: 0,
|
||||
forbiddenCountriesListPackedIndex: 9,
|
||||
nullifierIndex: 13,
|
||||
attestationIdIndex: 29,
|
||||
forbiddenCountriesListPackedIndex: 10,
|
||||
nullifierIndex: 14,
|
||||
attestationIdIndex: 15,
|
||||
merkleRootIndex: 17,
|
||||
currentDateIndex: 21,
|
||||
namedobSmtRootIndex: 18,
|
||||
@@ -139,25 +139,24 @@ export const revealedDataIndices: Record<
|
||||
ofacEnd: 117,
|
||||
},
|
||||
4: {
|
||||
//put everything as 99
|
||||
issuingStateStart: 99,
|
||||
issuingStateEnd: 99,
|
||||
nameStart: 99,
|
||||
nameEnd: 99,
|
||||
idNumberStart: 99,
|
||||
idNumberEnd: 99,
|
||||
nationalityStart: 99,
|
||||
nationalityEnd: 99,
|
||||
dateOfBirthStart: 99,
|
||||
dateOfBirthEnd: 99,
|
||||
genderStart: 99,
|
||||
genderEnd: 99,
|
||||
expiryDateStart: 99,
|
||||
expiryDateEnd: 99,
|
||||
olderThanStart: 99,
|
||||
olderThanEnd: 99,
|
||||
ofacStart: 99,
|
||||
ofacEnd: 99,
|
||||
nameStart: 78,
|
||||
nameEnd: 141,
|
||||
idNumberStart: 30,
|
||||
idNumberEnd: 61,
|
||||
nationalityStart: 0,
|
||||
nationalityEnd: 2,
|
||||
dateOfBirthStart: 142,
|
||||
dateOfBirthEnd: 149,
|
||||
genderStart: 194,
|
||||
genderEnd: 194,
|
||||
expiryDateStart: 70,
|
||||
expiryDateEnd: 77,
|
||||
olderThanStart: 297,
|
||||
olderThanEnd: 297,
|
||||
ofacStart: 295,
|
||||
ofacEnd: 296,
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
||||
@@ -23,12 +23,19 @@ export const formatRevealedDataPacked = (
|
||||
discloseIndices[attestationId].forbiddenCountriesListPackedIndex,
|
||||
discloseIndices[attestationId].forbiddenCountriesListPackedIndex + 4
|
||||
);
|
||||
const issuingState = revealedDataPackedString
|
||||
.subarray(
|
||||
revealedDataIndices[attestationId].issuingStateStart,
|
||||
revealedDataIndices[attestationId].issuingStateEnd + 1
|
||||
)
|
||||
.toString('utf-8');
|
||||
let issuingState = '';
|
||||
|
||||
if (attestationId === 4) {
|
||||
issuingState = 'UNAVAILABLE';
|
||||
} else {
|
||||
issuingState = revealedDataPackedString
|
||||
.subarray(
|
||||
revealedDataIndices[attestationId].issuingStateStart,
|
||||
revealedDataIndices[attestationId].issuingStateEnd + 1
|
||||
)
|
||||
.toString('utf-8');
|
||||
}
|
||||
|
||||
const name = revealedDataPackedString
|
||||
.subarray(
|
||||
revealedDataIndices[attestationId].nameStart,
|
||||
@@ -93,7 +100,7 @@ export const formatRevealedDataPacked = (
|
||||
.toString('utf-8');
|
||||
}
|
||||
let olderThan: string;
|
||||
if (attestationId === 3) {
|
||||
if (attestationId === 3 || attestationId === 4) {
|
||||
olderThan = revealedDataPackedString
|
||||
.subarray(
|
||||
revealedDataIndices[attestationId].olderThanStart,
|
||||
|
||||
@@ -20,7 +20,7 @@ export function getRevealedDataPublicSignalsLength(attestationId: AttestationId)
|
||||
case 3:
|
||||
return Math.ceil(119 / 31);
|
||||
case 4:
|
||||
return Math.ceil(30 / 31);
|
||||
return Math.ceil(298 / 31);
|
||||
default:
|
||||
throw new ProofError(`Invalid attestation ID: ${attestationId}`);
|
||||
}
|
||||
@@ -30,7 +30,7 @@ export const bytesCount: Record<AttestationId, number[]> = {
|
||||
1: [31, 31, 31],
|
||||
2: [31, 31, 31, 1],
|
||||
3: [31, 31, 31, 26],
|
||||
4: [31, 31, 31, 26],
|
||||
4: [31, 31, 31, 31, 31, 31, 31, 31, 31, 19],
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user