Skip to content

Commit

Permalink
Remove old bn254 functions
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbosio committed Mar 11, 2024
1 parent 8925c51 commit 73d2b7a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 93 deletions.
21 changes: 0 additions & 21 deletions src/lib/provable-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ export {
snarkContext,
SnarkContext,
asProver,
asProverBn254,
runAndCheck,
runAndCheckBn254,
runUnchecked,
constraintSystem,
inProver,
Expand Down Expand Up @@ -68,14 +66,6 @@ function asProver(f: () => void) {
}
}

function asProverBn254(f: () => void) {
if (inCheckedComputation()) {
Snarky.run.asProverBn254(f);
} else {
f();
}
}

function runAndCheck(f: () => void) {
let id = snarkContext.enter({ inCheckedComputation: true });
try {
Expand All @@ -87,17 +77,6 @@ function runAndCheck(f: () => void) {
}
}

function runAndCheckBn254(f: () => void) {
let id = snarkContext.enter({ inCheckedComputation: true });
try {
Snarky.run.runAndCheckBn254(f);
} catch (error) {
throw prettifyStacktrace(error);
} finally {
snarkContext.leave(id);
}
}

function runUnchecked(f: () => void) {
let id = snarkContext.enter({ inCheckedComputation: true });
try {
Expand Down
40 changes: 0 additions & 40 deletions src/lib/provable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import {
inProver,
snarkContext,
asProver,
asProverBn254,
runAndCheck,
runAndCheckBn254,
runUnchecked,
constraintSystem,
} from './provable-context.js';
Expand Down Expand Up @@ -140,16 +138,6 @@ const Provable = {
* ```
*/
log,
/**
* Interface to log elements within a circuit using Bn254 backend.
* Similar to `console.log()`.
* @example
* ```ts
* const element = Field(42);
* Provable.log(element);
* ```
*/
logBn254,
/**
* Runs code as a prover using Pasta backend.
* @example
Expand All @@ -160,16 +148,6 @@ const Provable = {
* ```
*/
asProver,
/**
* Runs code as a prover using Bn254 backend.
* @example
* ```ts
* Provable.asProverBn254(() => {
* // Your prover code here
* });
* ```
*/
asProverBn254,
/**
* Runs provable code quickly, without creating a proof, but still checking whether constraints are satisfied.
* @example
Expand All @@ -180,7 +158,6 @@ const Provable = {
* ```
*/
runAndCheck,
runAndCheckBn254,
/**
* Runs provable code quickly, without creating a proof, and not checking whether constraints are satisfied.
* @example
Expand Down Expand Up @@ -452,23 +429,6 @@ function log(...args: any) {
});
}

function logBn254(...args: any) {
asProverBn254(() => {
let prettyArgs = [];
for (let arg of args) {
if (arg?.toPretty !== undefined) prettyArgs.push(arg.toPretty());
else {
try {
prettyArgs.push(JSON.parse(JSON.stringify(arg)));
} catch {
prettyArgs.push(arg);
}
}
}
console.log(...prettyArgs);
});
}

// helpers

function checkLength(name: string, xs: Field[], ys: Field[]) {
Expand Down
34 changes: 2 additions & 32 deletions src/snarky.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,26 +192,17 @@ declare const Snarky: {
*/
run: {
/**
* Runs code as a prover with Pasta backend.
* Runs code as a prover.
*/
asProver(f: () => void): void;
/**
* Runs code as a prover with Bn254 backend.
*/
asProverBn254(f: () => void): void;
/**
* Check whether we are inside an asProver or exists block with Pasta backend
* Check whether we are inside an asProver or exists block.
*/
inProverBlock(): boolean;
/**
* Check whether we are inside an asProver or exists block with Bn254 backend
*/
inProverBlockBn254(): boolean;
/**
* Runs code and checks its correctness.
*/
runAndCheck(f: () => void): void;
runAndCheckBn254(f: () => void): void;
/**
* Runs code in prover mode, without checking correctness.
*/
Expand Down Expand Up @@ -549,12 +540,6 @@ declare const Snarky: {
absorb(sponge: unknown, x: FieldVar): void;
squeeze(sponge: unknown): FieldVar;
};

foreignSponge: {
create(isChecked: boolean): unknown;
absorb(sponge: unknown, x: MlTuple<FieldVar, 3>): void;
squeeze(sponge: unknown): MlTuple<FieldVar, 3>;
};
};
};

Expand Down Expand Up @@ -594,23 +579,14 @@ declare const SnarkyBn254: {
* Runs code as a prover with Pasta backend.
*/
asProver(f: () => void): void;
/**
* Runs code as a prover with Bn254 backend.
*/
asProverBn254(f: () => void): void;
/**
* Check whether we are inside an asProver or exists block with Pasta backend
*/
inProverBlock(): boolean;
/**
* Check whether we are inside an asProver or exists block with Bn254 backend
*/
inProverBlockBn254(): boolean;
/**
* Runs code and checks its correctness.
*/
runAndCheck(f: () => void): void;
runAndCheckBn254(f: () => void): void;
/**
* Runs code in prover mode, without checking correctness.
*/
Expand Down Expand Up @@ -948,12 +924,6 @@ declare const SnarkyBn254: {
absorb(sponge: unknown, x: FieldVar): void;
squeeze(sponge: unknown): FieldVar;
};

foreignSponge: {
create(isChecked: boolean): unknown;
absorb(sponge: unknown, x: MlTuple<FieldVar, 3>): void;
squeeze(sponge: unknown): MlTuple<FieldVar, 3>;
};
};
};

Expand Down

0 comments on commit 73d2b7a

Please sign in to comment.