forked from keep-starknet-strange/garaga
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,678 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
presets: [ | ||
'@babel/preset-env', | ||
'@babel/preset-typescript', | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
export default { | ||
module.exports= { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testMatch: ['**/tests/**/*.test.ts'], | ||
moduleFileExtensions: ['ts', 'js'], | ||
transform: { | ||
'^.+\\.ts$': 'ts-jest' | ||
}, | ||
// transform: { | ||
// '^.+\\.ts$': 'ts-jest' | ||
// }, | ||
collectCoverage: true, | ||
collectCoverageFrom: ['src/**/*.ts'], | ||
transform: { | ||
'^.+\\.(ts|tsx|js|jsx)$': 'babel-jest', | ||
}, | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
export * from './api'; // exports "ts" interface | ||
export * from '../wasm/pkg/garaga_rs'; // export "raw" interface | ||
|
||
export { CurveId } from './definitions'; | ||
|
||
import pkg_init from '../wasm/pkg/garaga_rs'; | ||
import module_or_path from '../wasm/pkg/garaga_rs_bg.wasm'; | ||
|
||
|
||
export function init(): ReturnType<typeof pkg_init> { | ||
return pkg_init({ module_or_path }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
tools/npm/garaga_ts/tests/starknet/groth16Calldata.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Groth16Proof, parseGroth16ProofFromJson, parseGroth16VerifyingKeyFromJson } from "../../src/node/starknet/groth16ContractGenerator/parsingUtils"; | ||
import * as garaga from "../../src/node/index"; | ||
|
||
|
||
const PATH = '../../../hydra/garaga/starknet/groth16_contract_generator/examples'; | ||
|
||
describe('Groth16 Getting calldata', () => { | ||
|
||
const proofAndVkWithPublicInputs = [ | ||
[`${PATH}/proof_bn254.json`, `${PATH}/vk_bn254.json`, null], | ||
[`${PATH}/proof_bls.json`, `${PATH}/vk_bls.json`, null], | ||
|
||
[`${PATH}/gnark_proof_bn254.json`, `${PATH}/gnark_vk_bn254.json`, `${PATH}/gnark_public_bn254.json`], | ||
[`${PATH}/snarkjs_proof_bn254.json`, `${PATH}/snarkjs_vk_bn254.json`, `${PATH}/snarkjs_public_bn254.json`], | ||
|
||
[`${PATH}/proof_risc0.json`, `${PATH}/vk_risc0.json`, null], | ||
|
||
] | ||
|
||
test.each(proofAndVkWithPublicInputs)("should get groth16 calldata from proof %s, vk %s and pub inputs %s", async (proofPath, vkPath, pubInputsPath) => { | ||
|
||
await garaga.init(); | ||
|
||
const vk = parseGroth16VerifyingKeyFromJson(vkPath as string); | ||
|
||
let proof: Groth16Proof; | ||
if(pubInputsPath == null){ | ||
proof = parseGroth16ProofFromJson(proofPath as string); | ||
} else{ | ||
proof = parseGroth16ProofFromJson(proofPath as string, pubInputsPath); | ||
} | ||
|
||
const curveId: garaga.CurveId = proof.a.curveId; | ||
|
||
console.log("proof", proof); | ||
|
||
console.log("vk", vk); | ||
console.log("curveId", curveId); | ||
const groth16Calldata = garaga.getGroth16CallData(proof, vk, curveId); | ||
|
||
console.log("groth16Calldata", groth16Calldata); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters