mirror of
https://github.com/selfxyz/self.git
synced 2026-04-27 03:01:15 -04:00
call validateProof with the sig alg index from the app
This commit is contained in:
@@ -12,7 +12,7 @@ import useNavigationStore from './navigationStore';
|
||||
import { Steps } from '../utils/utils';
|
||||
import { downloadZkey } from '../utils/zkeyDownload';
|
||||
import { generateCircuitInputsRegister } from '../../../common/src/utils/generateInputs';
|
||||
import { PASSPORT_ATTESTATION_ID, RPC_URL } from '../../../common/src/constants/constants';
|
||||
import { PASSPORT_ATTESTATION_ID, RPC_URL, SignatureAlgorithm } from '../../../common/src/constants/constants';
|
||||
import { generateProof } from '../utils/prover';
|
||||
import { formatSigAlg } from '../../../common/src/utils/utils';
|
||||
import { sendRegisterTransaction } from '../utils/transactions';
|
||||
@@ -125,6 +125,7 @@ const useUserStore = create<UserState>((set, get) => ({
|
||||
const start = Date.now();
|
||||
|
||||
const sigAlgFormatted = formatSigAlg(passportData.signatureAlgorithm, passportData.pubKey.exponent);
|
||||
const sigAlgIndex = SignatureAlgorithm[sigAlgFormatted as keyof typeof SignatureAlgorithm]
|
||||
|
||||
const proof = await generateProof(
|
||||
`register_${sigAlgFormatted}`,
|
||||
@@ -139,7 +140,7 @@ const useUserStore = create<UserState>((set, get) => ({
|
||||
|
||||
const provider = new ethers.JsonRpcProvider(RPC_URL);
|
||||
|
||||
const serverResponse = await sendRegisterTransaction(proof)
|
||||
const serverResponse = await sendRegisterTransaction(proof, sigAlgIndex)
|
||||
const txHash = serverResponse?.data.hash;
|
||||
|
||||
const receipt = await provider.waitForTransaction(txHash);
|
||||
|
||||
@@ -4,12 +4,13 @@ import groth16ExportSolidityCallData from '../../utils/snarkjs';
|
||||
import contractAddresses from "../../deployments/deployed_addresses.json";
|
||||
import registerArtefacts from "../../deployments/artifacts/Deploy_Registry#ProofOfPassportRegister.json";
|
||||
import sbtArtefacts from "../../deployments/artifacts/Deploy_Registry#SBT.json";
|
||||
import { CHAIN_NAME, RELAYER_URL, RPC_URL } from '../../../common/src/constants/constants';
|
||||
import { CHAIN_NAME, RELAYER_URL, RPC_URL, SignatureAlgorithm } from '../../../common/src/constants/constants';
|
||||
import { Proof } from "../../../common/src/utils/types";
|
||||
import { formatCallData_disclose, formatCallData_register } from "../../../common/src/utils/formatCallData";
|
||||
|
||||
export const sendRegisterTransaction = async (
|
||||
proof: Proof,
|
||||
sigAlgIndex: SignatureAlgorithm
|
||||
) => {
|
||||
const provider = new ethers.JsonRpcProvider(RPC_URL);
|
||||
|
||||
@@ -35,7 +36,7 @@ export const sendRegisterTransaction = async (
|
||||
);
|
||||
|
||||
const transactionRequest = await registerContract
|
||||
.validateProof.populateTransaction(formattedCallData_register, 1);
|
||||
.validateProof.populateTransaction(formattedCallData_register, sigAlgIndex);
|
||||
console.log('transactionRequest', transactionRequest);
|
||||
|
||||
const response = await axios.post(RELAYER_URL, {
|
||||
|
||||
@@ -82,9 +82,6 @@ export function generateCircuitInputsRegister(
|
||||
MAX_DATAHASHES_LEN
|
||||
);
|
||||
|
||||
const sigAlgFormatted = formatSigAlg(passportData.signatureAlgorithm, passportData.pubKey.exponent);
|
||||
const sigAlgIndex = SignatureAlgorithm[sigAlgFormatted]
|
||||
|
||||
return {
|
||||
secret: [secret],
|
||||
mrz: formattedMrz.map(byte => String(byte)),
|
||||
|
||||
Reference in New Issue
Block a user