26 lines
1.0 KiB
JavaScript
26 lines
1.0 KiB
JavaScript
import { Scalar } from "ffjavascript";
|
|
import {load as loadR1cs} from "r1csfile";
|
|
|
|
const bls12381r = Scalar.e("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001", 16);
|
|
const bn128r = Scalar.e("21888242871839275222246405745257275088548364400416034343698204186575808495617");
|
|
|
|
export default async function r1csInfo(r1csName, logger) {
|
|
|
|
const cir = await loadR1cs(r1csName);
|
|
|
|
if (Scalar.eq(cir.prime, bn128r)) {
|
|
if (logger) logger.info("Curve: bn-128");
|
|
} else if (Scalar.eq(cir.prime, bls12381r)) {
|
|
if (logger) logger.info("Curve: bls12-381");
|
|
} else {
|
|
if (logger) logger.info(`Unknown Curve. Prime: ${Scalar.toString(cir.prime)}`);
|
|
}
|
|
if (logger) logger.info(`# of Wires: ${cir.nVars}`);
|
|
if (logger) logger.info(`# of Constraints: ${cir.nConstraints}`);
|
|
if (logger) logger.info(`# of Private Inputs: ${cir.nPrvInputs}`);
|
|
if (logger) logger.info(`# of Public Inputs: ${cir.nPubInputs}`);
|
|
if (logger) logger.info(`# of Outputs: ${cir.nOutputs}`);
|
|
|
|
return cir;
|
|
}
|