chore: validate idcommitment against Q

This commit is contained in:
Danish Arora 2025-05-29 01:36:43 +05:30
parent f911bf8cfa
commit 10590dad85
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E

View File

@ -268,7 +268,14 @@ export class RLNCredentialsManager {
const idCommitment = sha256(idSecretHash);
// Convert IDCommitment to BigInt
const idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment);
let idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment);
const Q = BigInt(
"21888242871839275222246405745257275088548364400416034343698204186575808495617"
);
if (idCommitmentBigInt >= Q) {
log.warn("IDCommitment is greater than Q, truncating");
idCommitmentBigInt = idCommitmentBigInt % Q;
}
log.info("Successfully generated identity credential");
return new IdentityCredential(