mirror of
https://github.com/selfxyz/self.git
synced 2026-01-09 22:58:20 -05:00
63 lines
2.2 KiB
TypeScript
63 lines
2.2 KiB
TypeScript
import { assert, expect } from 'chai'
|
|
import fs from 'fs'
|
|
const forge = require('node-forge');
|
|
import path from 'path';
|
|
const wasm_tester = require("circom_tester").wasm;
|
|
import { splitToWords } from '../../common/src/utils/utils';
|
|
import { sha256Pad } from '../../common/src/utils/shaPad';
|
|
import { findStartIndex, getCSCAInputs } from '../../common/src/utils/csca';
|
|
|
|
describe('DSC chain certificate', function () {
|
|
this.timeout(0); // Disable timeout
|
|
let circuit;
|
|
const n_dsc = 64;
|
|
const k_dsc = 32;
|
|
const n_csca = 64;
|
|
const k_csca = 32;
|
|
const max_cert_bytes = 1664;
|
|
const dsc = fs.readFileSync('../common/src/mock_certificates/sha256_rsa_2048/mock_dsc.crt', 'utf8');
|
|
const csca = fs.readFileSync('../common/src/mock_certificates/sha256_rsa_2048/mock_csca.crt', 'utf8');
|
|
const dscCert = forge.pki.certificateFromPem(dsc);
|
|
const cscaCert = forge.pki.certificateFromPem(csca);
|
|
|
|
|
|
const inputs = getCSCAInputs(BigInt(0).toString(), dscCert, cscaCert, n_dsc, k_dsc, n_csca, k_csca, max_cert_bytes, true);
|
|
console.log("inputs:", inputs);
|
|
|
|
before(async () => {
|
|
circuit = await wasm_tester(
|
|
path.join(__dirname, '../circuits/tests/certificates/dsc_sha256_rsa_2048.circom'),
|
|
{
|
|
include: [
|
|
"node_modules",
|
|
"./node_modules/@zk-kit/binary-merkle-root.circom/src",
|
|
"./node_modules/circomlib/circuits"
|
|
]
|
|
}
|
|
);
|
|
});
|
|
|
|
before(async () => {
|
|
circuit = await wasm_tester(
|
|
path.join(__dirname, '../circuits/tests/certificates/dsc_sha256_rsa_2048.circom'),
|
|
{
|
|
include: [
|
|
"node_modules",
|
|
"./node_modules/@zk-kit/binary-merkle-root.circom/src",
|
|
"./node_modules/circomlib/circuits"
|
|
]
|
|
}
|
|
);
|
|
});
|
|
|
|
it('should compile and load the circuit', () => {
|
|
expect(circuit).to.not.be.undefined;
|
|
})
|
|
|
|
it('should compute the correct output', async () => {
|
|
console.log("Inputs:", inputs);
|
|
const witness = await circuit.calculateWitness(inputs, true);
|
|
console.log(witness);
|
|
})
|
|
|
|
}) |