Skip to content

Commit

Permalink
fix schema-processor & proof folders
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Jul 13, 2023
1 parent 605be1d commit 7363266
Show file tree
Hide file tree
Showing 14 changed files with 176 additions and 164 deletions.
12 changes: 7 additions & 5 deletions src/circuits/atomic-query-mtp-v2-on-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,22 @@ export class AtomicQueryMTPV2OnChainInputs extends BaseConfig {
profileNonce: this.profileNonce?.toString(),
claimSubjectProfileNonce: this.claimSubjectProfileNonce?.toString(),
issuerID: this.claim?.issuerID?.bigInt().toString(),
issuerClaim: this.claim?.claim.marshalJson(),
issuerClaimMtp: this.claim
issuerClaim: this.claim?.claim?.marshalJson(),
issuerClaimMtp: this.claim?.incProof?.proof
? prepareSiblingsStr(this.claim.incProof.proof, this.getMTLevel())
: undefined,
issuerClaimClaimsTreeRoot: this.claim?.incProof?.treeState?.claimsRoot?.string(),
issuerClaimRevTreeRoot: this.claim?.incProof?.treeState?.revocationRoot?.string(),
issuerClaimRootsTreeRoot: this.claim?.incProof?.treeState?.rootOfRoots?.string(),
issuerClaimIdenState: this.claim?.incProof?.treeState?.state?.string(),
issuerClaimNonRevMtp: this.claim
issuerClaimNonRevMtp: this.claim?.nonRevProof?.proof
? prepareSiblingsStr(this.claim.nonRevProof?.proof, this.getMTLevel())
: undefined,
issuerClaimNonRevClaimsTreeRoot: this.claim?.nonRevProof?.treeState?.claimsRoot?.string(),
issuerClaimNonRevRevTreeRoot: this.claim?.nonRevProof?.treeState?.revocationRoot?.string(),
issuerClaimNonRevRootsTreeRoot: this.claim?.nonRevProof?.treeState?.rootOfRoots?.string(),
issuerClaimNonRevState: this.claim?.nonRevProof?.treeState?.state?.string(),
claimSchema: this.claim?.claim.getSchemaHash().bigInt().toString(),
claimSchema: this.claim?.claim?.getSchemaHash().bigInt().toString(),
claimPathMtp: prepareSiblingsStr(valueProof.mtp, this.getMTLevelsClaimMerklization()),
claimPathValue: valueProof.value.toString(),
operator: this.query?.operator,
Expand Down Expand Up @@ -137,7 +137,9 @@ export class AtomicQueryMTPV2OnChainInputs extends BaseConfig {
s.isRevocationChecked = 0;
}

const nodeAuxNonRev = this.claim ? getNodeAuxValue(this.claim.nonRevProof.proof) : undefined;
const nodeAuxNonRev = this.claim?.nonRevProof?.proof ?
getNodeAuxValue(this.claim.nonRevProof.proof)
: undefined;
s.issuerClaimNonRevMtpAuxHi = nodeAuxNonRev?.key.bigInt().toString();
s.issuerClaimNonRevMtpAuxHv = nodeAuxNonRev?.value.bigInt().toString();
s.issuerClaimNonRevMtpNoAux = nodeAuxNonRev?.noAux;
Expand Down
32 changes: 16 additions & 16 deletions src/circuits/atomic-query-mtp-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,36 +65,36 @@ export class AtomicQueryMTPV2Inputs extends BaseConfig {
profileNonce: this.profileNonce?.toString(),
claimSubjectProfileNonce: this.claimSubjectProfileNonce?.toString(),
issuerID: this.claim?.issuerID?.bigInt().toString(),
issuerClaim: this.claim?.claim.marshalJson(),
issuerClaimMtp: this.claim
issuerClaim: this.claim?.claim?.marshalJson(),
issuerClaimMtp: this.claim?.incProof?.proof
? prepareSiblingsStr(this.claim.incProof.proof, this.getMTLevel())
: undefined,
issuerClaimClaimsTreeRoot: this.claim?.incProof.treeState?.claimsRoot.bigInt().toString(),
issuerClaimRevTreeRoot: this.claim?.incProof.treeState?.revocationRoot.bigInt().toString(),
issuerClaimRootsTreeRoot: this.claim?.incProof.treeState?.rootOfRoots.bigInt().toString(),
issuerClaimIdenState: this.claim?.incProof.treeState?.state.bigInt().toString(),
issuerClaimNonRevMtp: this.claim
issuerClaimClaimsTreeRoot: this.claim?.incProof?.treeState?.claimsRoot?.bigInt().toString(),
issuerClaimRevTreeRoot: this.claim?.incProof?.treeState?.revocationRoot?.bigInt().toString(),
issuerClaimRootsTreeRoot: this.claim?.incProof?.treeState?.rootOfRoots?.bigInt().toString(),
issuerClaimIdenState: this.claim?.incProof?.treeState?.state?.bigInt().toString(),
issuerClaimNonRevMtp: this.claim?.nonRevProof?.proof
? prepareSiblingsStr(this.claim.nonRevProof.proof, this.getMTLevel())
: undefined,
issuerClaimNonRevClaimsTreeRoot: this.claim?.nonRevProof.treeState?.claimsRoot
.bigInt()
issuerClaimNonRevClaimsTreeRoot: this.claim?.nonRevProof?.treeState?.claimsRoot
?.bigInt()
.toString(),
issuerClaimNonRevRevTreeRoot: this.claim?.nonRevProof.treeState?.revocationRoot
.bigInt()
issuerClaimNonRevRevTreeRoot: this.claim?.nonRevProof?.treeState?.revocationRoot
?.bigInt()
.toString(),
issuerClaimNonRevRootsTreeRoot: this.claim?.nonRevProof.treeState?.rootOfRoots
.bigInt()
issuerClaimNonRevRootsTreeRoot: this.claim?.nonRevProof?.treeState?.rootOfRoots
?.bigInt()
.toString(),
issuerClaimNonRevState: this.claim?.nonRevProof.treeState?.state.bigInt().toString(),
claimSchema: this.claim?.claim.getSchemaHash().bigInt().toString(),
issuerClaimNonRevState: this.claim?.nonRevProof?.treeState?.state?.bigInt().toString(),
claimSchema: this.claim?.claim?.getSchemaHash().bigInt().toString(),
claimPathMtp: prepareSiblingsStr(valueProof.mtp, this.getMTLevelsClaimMerklization()),
claimPathValue: valueProof.value.toString(),
operator: this.query?.operator,
slotIndex: this.query?.slotIndex,
timestamp: this.currentTimeStamp ?? undefined
};

const nodeAux = this.claim ? getNodeAuxValue(this.claim.nonRevProof.proof) : undefined;
const nodeAux = this.claim ? getNodeAuxValue(this.claim.nonRevProof?.proof) : undefined;
s.issuerClaimNonRevMtpAuxHi = nodeAux?.key.bigInt().toString();
s.issuerClaimNonRevMtpAuxHv = nodeAux?.value.bigInt().toString();
s.issuerClaimNonRevMtpNoAux = nodeAux?.noAux;
Expand Down
62 changes: 31 additions & 31 deletions src/circuits/atomic-query-sig-v2-on-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ export class AtomicQuerySigV2OnChainInputs extends BaseConfig {
if (!this.requestID) {
throw new Error(CircuitError.EmptyRequestID);
}
if (!this.claim?.nonRevProof.proof) {
if (!this.claim?.nonRevProof?.proof) {
throw new Error(CircuitError.EmptyClaimNonRevProof);
}

if (!this.claim.signatureProof.issuerAuthIncProof.proof) {
if (!this.claim.signatureProof?.issuerAuthIncProof.proof) {
throw new Error(CircuitError.EmptyIssuerAuthClaimProof);
}

Expand Down Expand Up @@ -118,48 +118,48 @@ export class AtomicQuerySigV2OnChainInputs extends BaseConfig {
userGenesisID: this.id?.bigInt().toString(),
profileNonce: this.profileNonce?.toString(),
claimSubjectProfileNonce: this.claimSubjectProfileNonce?.toString(),
issuerID: this.claim?.issuerID.bigInt().toString(),
issuerClaim: this.claim?.claim.marshalJson(),
issuerClaimNonRevClaimsTreeRoot: this.claim?.nonRevProof.treeState?.claimsRoot
.bigInt()
issuerID: this.claim?.issuerID?.bigInt().toString(),
issuerClaim: this.claim?.claim?.marshalJson(),
issuerClaimNonRevClaimsTreeRoot: this.claim?.nonRevProof?.treeState?.claimsRoot
?.bigInt()
.toString(),
issuerClaimNonRevRevTreeRoot: this.claim?.nonRevProof.treeState?.revocationRoot
.bigInt()
issuerClaimNonRevRevTreeRoot: this.claim?.nonRevProof?.treeState?.revocationRoot
?.bigInt()
.toString(),
issuerClaimNonRevRootsTreeRoot: this.claim?.nonRevProof.treeState?.rootOfRoots
.bigInt()
issuerClaimNonRevRootsTreeRoot: this.claim?.nonRevProof?.treeState?.rootOfRoots
?.bigInt()
.toString(),
issuerClaimNonRevState: this.claim?.nonRevProof.treeState?.state.bigInt().toString(),
issuerClaimNonRevMtp: this.claim
issuerClaimNonRevState: this.claim?.nonRevProof?.treeState?.state?.bigInt().toString(),
issuerClaimNonRevMtp: this.claim?.nonRevProof?.proof
? prepareSiblingsStr(this.claim.nonRevProof.proof, this.getMTLevel())
: undefined,
issuerClaimSignatureR8x: this.claim
issuerClaimSignatureR8x: this.claim?.signatureProof
? this.claim.signatureProof.signature.R8[0].toString()
: undefined,
issuerClaimSignatureR8y: this.claim?.signatureProof.signature.R8[1].toString(),
issuerClaimSignatureS: this.claim?.signatureProof.signature.S.toString(),
issuerAuthClaim: this.claim?.signatureProof.issuerAuthClaim?.marshalJson(),
issuerAuthClaimMtp: this.claim
issuerClaimSignatureR8y: this.claim?.signatureProof?.signature.R8[1].toString(),
issuerClaimSignatureS: this.claim?.signatureProof?.signature.S.toString(),
issuerAuthClaim: this.claim?.signatureProof?.issuerAuthClaim?.marshalJson(),
issuerAuthClaimMtp: this.claim?.signatureProof?.issuerAuthIncProof?.proof
? prepareSiblingsStr(this.claim.signatureProof.issuerAuthIncProof.proof, this.getMTLevel())
: undefined,
issuerAuthClaimsTreeRoot: this.claim?.signatureProof.issuerAuthIncProof.treeState?.claimsRoot
.bigInt()
issuerAuthClaimsTreeRoot: this.claim?.signatureProof?.issuerAuthIncProof?.treeState?.claimsRoot
?.bigInt()
.toString(),
issuerAuthRevTreeRoot: this.claim?.signatureProof.issuerAuthIncProof.treeState?.revocationRoot
.bigInt()
issuerAuthRevTreeRoot: this.claim?.signatureProof?.issuerAuthIncProof?.treeState?.revocationRoot
?.bigInt()
.toString(),
issuerAuthRootsTreeRoot: this.claim?.signatureProof.issuerAuthIncProof.treeState?.rootOfRoots
.bigInt()
issuerAuthRootsTreeRoot: this.claim?.signatureProof?.issuerAuthIncProof?.treeState?.rootOfRoots
?.bigInt()
.toString(),

issuerAuthClaimNonRevMtp: this.claim
issuerAuthClaimNonRevMtp: this.claim?.signatureProof?.issuerAuthNonRevProof?.proof
? prepareSiblingsStr(
this.claim.signatureProof.issuerAuthNonRevProof.proof,
this.getMTLevel()
)
: undefined,

claimSchema: this.claim?.claim.getSchemaHash().bigInt().toString(),
claimSchema: this.claim?.claim?.getSchemaHash().bigInt().toString(),
claimPathMtp: prepareSiblingsStr(valueProof.mtp, this.getMTLevelsClaimMerklization()),
claimPathValue: valueProof.value.toString(),
operator: this.query?.operator,
Expand All @@ -178,10 +178,10 @@ export class AtomicQuerySigV2OnChainInputs extends BaseConfig {
challengeSignatureR8x: this.signature?.R8[0].toString(),
challengeSignatureR8y: this.signature?.R8[1].toString(),
challengeSignatureS: this.signature?.S.toString(),
userClaimsTreeRoot: this.treeState?.claimsRoot.string(),
userRevTreeRoot: this.treeState?.revocationRoot.string(),
userRootsTreeRoot: this.treeState?.rootOfRoots.string(),
userState: this.treeState?.state.string(),
userClaimsTreeRoot: this.treeState?.claimsRoot?.string(),
userRevTreeRoot: this.treeState?.revocationRoot?.string(),
userRootsTreeRoot: this.treeState?.rootOfRoots?.string(),
userState: this.treeState?.state?.string(),
gistRoot: this.gistProof?.root.string(),
gistMtp: this.gistProof
? prepareSiblingsStr(this.gistProof.proof, this.getMTLevelOnChain())
Expand All @@ -191,13 +191,13 @@ export class AtomicQuerySigV2OnChainInputs extends BaseConfig {
if (this.skipClaimRevocationCheck) {
s.isRevocationChecked = 0;
}
const nodeAuxNonRev = this.claim ? getNodeAuxValue(this.claim.nonRevProof.proof) : undefined;
const nodeAuxNonRev = this.claim ? getNodeAuxValue(this.claim.nonRevProof?.proof) : undefined;
s.issuerClaimNonRevMtpAuxHi = nodeAuxNonRev?.key.bigInt().toString();
s.issuerClaimNonRevMtpAuxHv = nodeAuxNonRev?.value.bigInt().toString();
s.issuerClaimNonRevMtpNoAux = nodeAuxNonRev?.noAux;

const nodeAuxIssuerAuthNonRev = this.claim
? getNodeAuxValue(this.claim.signatureProof.issuerAuthNonRevProof.proof)
? getNodeAuxValue(this.claim.signatureProof?.issuerAuthNonRevProof.proof)
: undefined;
s.issuerAuthClaimNonRevMtpAuxHi = nodeAuxIssuerAuthNonRev?.key.bigInt().toString();
s.issuerAuthClaimNonRevMtpAuxHv = nodeAuxIssuerAuthNonRev?.value.bigInt().toString();
Expand Down
54 changes: 27 additions & 27 deletions src/circuits/atomic-query-sig-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export class AtomicQuerySigV2Inputs extends BaseConfig {
if (!this.requestID) {
throw new Error(CircuitError.EmptyRequestID);
}
if (!this.claim?.nonRevProof.proof) {
if (!this.claim?.nonRevProof?.proof) {
throw new Error(CircuitError.EmptyClaimNonRevProof);
}

if (!this.claim.signatureProof.issuerAuthIncProof.proof) {
if (!this.claim.signatureProof?.issuerAuthIncProof.proof) {
throw new Error(CircuitError.EmptyIssuerAuthClaimProof);
}

Expand Down Expand Up @@ -86,46 +86,46 @@ export class AtomicQuerySigV2Inputs extends BaseConfig {
userGenesisID: this.id?.bigInt().toString(),
profileNonce: this.profileNonce?.toString(),
claimSubjectProfileNonce: this.claimSubjectProfileNonce?.toString(),
issuerID: this.claim?.issuerID.bigInt().toString(),
issuerClaim: this.claim?.claim.marshalJson(),
issuerClaimNonRevClaimsTreeRoot: this.claim?.nonRevProof.treeState?.claimsRoot
.bigInt()
issuerID: this.claim?.issuerID?.bigInt().toString(),
issuerClaim: this.claim?.claim?.marshalJson(),
issuerClaimNonRevClaimsTreeRoot: this.claim?.nonRevProof?.treeState?.claimsRoot
?.bigInt()
.toString(),
issuerClaimNonRevRevTreeRoot: this.claim?.nonRevProof.treeState?.revocationRoot
.bigInt()
issuerClaimNonRevRevTreeRoot: this.claim?.nonRevProof?.treeState?.revocationRoot
?.bigInt()
.toString(),
issuerClaimNonRevRootsTreeRoot: this.claim?.nonRevProof.treeState?.rootOfRoots
.bigInt()
issuerClaimNonRevRootsTreeRoot: this.claim?.nonRevProof?.treeState?.rootOfRoots
?.bigInt()
.toString(),
issuerClaimNonRevState: this.claim?.nonRevProof.treeState?.state.bigInt().toString(),
issuerClaimNonRevMtp: this.claim
issuerClaimNonRevState: this.claim?.nonRevProof?.treeState?.state?.bigInt().toString(),
issuerClaimNonRevMtp: this.claim?.nonRevProof?.proof
? prepareSiblingsStr(this.claim.nonRevProof.proof, this.getMTLevel())
: undefined,
issuerClaimSignatureR8x: this.claim?.signatureProof.signature.R8[0].toString(),
issuerClaimSignatureR8y: this.claim?.signatureProof.signature.R8[1].toString(),
issuerClaimSignatureS: this.claim?.signatureProof.signature.S.toString(),
issuerAuthClaim: this.claim?.signatureProof.issuerAuthClaim?.marshalJson(),
issuerAuthClaimMtp: this.claim
issuerClaimSignatureR8x: this.claim?.signatureProof?.signature.R8[0].toString(),
issuerClaimSignatureR8y: this.claim?.signatureProof?.signature.R8[1].toString(),
issuerClaimSignatureS: this.claim?.signatureProof?.signature.S.toString(),
issuerAuthClaim: this.claim?.signatureProof?.issuerAuthClaim?.marshalJson(),
issuerAuthClaimMtp: this.claim?.signatureProof?.issuerAuthIncProof?.proof
? prepareSiblingsStr(this.claim.signatureProof.issuerAuthIncProof.proof, this.getMTLevel())
: undefined,
issuerAuthClaimsTreeRoot: this.claim?.signatureProof.issuerAuthIncProof.treeState?.claimsRoot
.bigInt()
issuerAuthClaimsTreeRoot: this.claim?.signatureProof?.issuerAuthIncProof.treeState?.claimsRoot
?.bigInt()
.toString(),
issuerAuthRevTreeRoot: this.claim?.signatureProof.issuerAuthIncProof.treeState?.revocationRoot
.bigInt()
issuerAuthRevTreeRoot: this.claim?.signatureProof?.issuerAuthIncProof?.treeState?.revocationRoot
?.bigInt()
.toString(),
issuerAuthRootsTreeRoot: this.claim?.signatureProof.issuerAuthIncProof.treeState?.rootOfRoots
.bigInt()
issuerAuthRootsTreeRoot: this.claim?.signatureProof?.issuerAuthIncProof?.treeState?.rootOfRoots
?.bigInt()
.toString(),

issuerAuthClaimNonRevMtp: this.claim
issuerAuthClaimNonRevMtp: this.claim?.signatureProof?.issuerAuthNonRevProof?.proof
? prepareSiblingsStr(
this.claim.signatureProof.issuerAuthNonRevProof.proof,
this.getMTLevel()
)
: undefined,

claimSchema: this.claim?.claim.getSchemaHash().bigInt().toString(),
claimSchema: this.claim?.claim?.getSchemaHash().bigInt().toString(),

claimPathMtp: prepareSiblingsStr(valueProof.mtp, this.getMTLevelsClaimMerklization()),
claimPathValue: valueProof.value.toString(),
Expand All @@ -141,12 +141,12 @@ export class AtomicQuerySigV2Inputs extends BaseConfig {
} else {
s.isRevocationChecked = 1;
}
const nodeAuxNonRev = this.claim ? getNodeAuxValue(this.claim.nonRevProof.proof) : undefined;
const nodeAuxNonRev = this.claim ? getNodeAuxValue(this.claim.nonRevProof?.proof) : undefined;
s.issuerClaimNonRevMtpAuxHi = nodeAuxNonRev?.key.bigInt().toString();
s.issuerClaimNonRevMtpAuxHv = nodeAuxNonRev?.value.bigInt().toString();
s.issuerClaimNonRevMtpNoAux = nodeAuxNonRev?.noAux;

const nodeAuxIssuerAuthNonRev = this.claim
const nodeAuxIssuerAuthNonRev = this.claim?.signatureProof
? getNodeAuxValue(this.claim.signatureProof.issuerAuthNonRevProof.proof)
: undefined;
s.issuerAuthClaimNonRevMtpAuxHi = nodeAuxIssuerAuthNonRev?.key.bigInt().toString();
Expand Down
8 changes: 4 additions & 4 deletions src/circuits/auth-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ export class AuthV2Inputs extends BaseConfig {
challengeSignatureR8x: this.signature?.R8[0].toString(),
challengeSignatureR8y: this.signature?.R8[1].toString(),
challengeSignatureS: this.signature?.S.toString(),
claimsTreeRoot: this.treeState?.claimsRoot.bigInt().toString(),
revTreeRoot: this.treeState?.revocationRoot.bigInt().toString(),
rootsTreeRoot: this.treeState?.rootOfRoots.bigInt().toString(),
state: this.treeState?.state.bigInt().toString(),
claimsTreeRoot: this.treeState?.claimsRoot?.bigInt().toString(),
revTreeRoot: this.treeState?.revocationRoot?.bigInt().toString(),
rootsTreeRoot: this.treeState?.rootOfRoots?.bigInt().toString(),
state: this.treeState?.state?.bigInt().toString(),
gistRoot: this.gistProof?.root.bigInt().toString(),
gistMtp: this.gistProof ?
prepareSiblingsStr(this.gistProof.proof, this.getMTLevelOnChain()) :
Expand Down
28 changes: 14 additions & 14 deletions src/circuits/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ export enum CircuitId {
* @class CircuitClaim
*/
export class CircuitClaim {
issuerId: Id | null = null;
claim: CoreClaim | null = null;
treeState: TreeState | null = null;
proof: Proof | null = null;
nonRevProof: ClaimNonRevStatus | null = null; // Claim non revocation proof
signatureProof: BJJSignatureProof | null = null;
issuerId?: Id;
claim?: CoreClaim;
treeState?: TreeState;
proof?: Proof;
nonRevProof?: ClaimNonRevStatus; // Claim non revocation proof
signatureProof?: BJJSignatureProof;
}

/**
Expand All @@ -97,10 +97,10 @@ export class CircuitClaim {
* @interface ClaimWithSigProof
*/
export interface ClaimWithSigProof {
issuerID: Id;
claim: Claim;
nonRevProof: MTProof;
signatureProof: BJJSignatureProof;
issuerID?: Id;
claim?: Claim;
nonRevProof?: MTProof;
signatureProof?: BJJSignatureProof;
}

/**
Expand All @@ -112,9 +112,9 @@ export interface ClaimWithSigProof {
*/
export interface ClaimWithMTPProof {
issuerID?: Id;
claim: Claim;
incProof: MTProof;
nonRevProof: MTProof;
claim?: Claim;
incProof?: MTProof;
nonRevProof?: MTProof;
}

/**
Expand All @@ -139,7 +139,7 @@ export interface BJJSignatureProof {
* @interface MTProof
*/
export interface MTProof {
proof: Proof;
proof?: Proof;
treeState?: TreeState;
}
/**
Expand Down
Loading

0 comments on commit 7363266

Please sign in to comment.