Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup deserialization of proof-systems JSON format #975

Merged
merged 3 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ on:
branches:
- main
- berkeley
- develop
pull_request:
branches:
- main
- berkeley
- develop
workflow_dispatch: {}

jobs:
Expand Down
2 changes: 1 addition & 1 deletion src/bindings
10 changes: 3 additions & 7 deletions src/lib/provable-context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Context } from './global-context.js';
import { Gate, JsonGate, Snarky } from '../snarky.js';
import { bytesToBigInt } from '../bindings/crypto/bigint-helpers.js';
import { parseHexString } from '../bindings/crypto/bigint-helpers.js';
import { prettifyStacktrace } from './errors.js';

// internal API
Expand Down Expand Up @@ -105,12 +105,8 @@ function constraintSystem<T>(f: () => T) {
// helpers

function gatesFromJson(cs: { gates: JsonGate[]; public_input_size: number }) {
let gates: Gate[] = cs.gates.map(({ typ, wires, coeffs: byteCoeffs }) => {
let coeffs = [];
for (let coefficient of byteCoeffs) {
let arr = new Uint8Array(coefficient);
coeffs.push(bytesToBigInt(arr).toString());
}
let gates: Gate[] = cs.gates.map(({ typ, wires, coeffs: hexCoeffs }) => {
let coeffs = hexCoeffs.map(hex => parseHexString(hex).toString());
return { type: typ, wires, coeffs };
});
return { publicInputSize: cs.public_input_size, gates };
Expand Down
2 changes: 1 addition & 1 deletion src/snarky.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ declare const Snarky: {
type JsonGate = {
typ: string;
wires: { row: number; col: number }[];
coeffs: number[][];
coeffs: string[];
};
type JsonConstraintSystem = { gates: JsonGate[]; public_input_size: number };

Expand Down