Skip to content

Commit

Permalink
reuse transformQueryValueToBigInts function
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Feb 7, 2024
1 parent 22d0543 commit 0ffd6df
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/circuits/verifiers/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Path
} from '@iden3/js-jsonld-merklization';
import { Proof } from '@iden3/js-merkletree';
import { transformQueryValueToBigInts } from '../../proof';
import { createSchemaHash, Parser } from '../../schema-processor';
import { byteDecoder, byteEncoder } from '../../utils';
import { ProofQuery, VerifiableConstants } from '../../verifiable';
Expand Down Expand Up @@ -338,20 +339,9 @@ async function parsePredicate(
throw new Error(`operator '${key}' is not supported for '${datatype}' datatype`);
}

values = await getValuesAsArray(value, datatype);
values = await transformQueryValueToBigInts(value, datatype);
break;
}
return [operator, values];
}

async function getValuesAsArray(v: unknown, datatype: string): Promise<bigint[]> {
const values: Array<bigint> = [];
if (Array.isArray(v)) {
for (let index = 0; index < v.length; index++) {
values[index] = await Merklizer.hashValue(datatype, v[index]);
}
return values;
}
values[0] = await Merklizer.hashValue(datatype, v);
return values;
}

0 comments on commit 0ffd6df

Please sign in to comment.