Skip to content

Commit

Permalink
Merge pull request #975 from o1-labs/feature/update-proof-systems
Browse files Browse the repository at this point in the history
Fixup deserialization of proof-systems JSON format
  • Loading branch information
mitschabaude authored Jun 8, 2023
2 parents 406f3ff + fe33005 commit 796c55f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
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

0 comments on commit 796c55f

Please sign in to comment.