Skip to content

Commit

Permalink
remove duplicate toConstant method
Browse files Browse the repository at this point in the history
  • Loading branch information
mitschabaude committed Mar 25, 2024
1 parent 0f23f82 commit 6e62425
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
7 changes: 3 additions & 4 deletions src/lib/proof-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
Struct,
provable,
provablePure,
toConstant,
} from './provable-types/struct.js';
import { Provable } from './provable.js';
import { assert, prettifyStacktracePromise } from './errors.js';
Expand Down Expand Up @@ -847,12 +846,12 @@ function methodArgumentsToConstant(
let arg = args[i];
let { type, index } = allArgs[i];
if (type === 'witness') {
constArgs.push(toConstant(witnessArgs[index], arg));
constArgs.push(Provable.toConstant(witnessArgs[index], arg));
} else if (type === 'proof') {
let Proof = proofArgs[index];
let type = getStatementType(Proof);
let publicInput = toConstant(type.input, arg.publicInput);
let publicOutput = toConstant(type.output, arg.publicOutput);
let publicInput = Provable.toConstant(type.input, arg.publicInput);
let publicOutput = Provable.toConstant(type.output, arg.publicOutput);
constArgs.push(
new Proof({ publicInput, publicOutput, proof: arg.proof })
);
Expand Down
9 changes: 0 additions & 9 deletions src/lib/provable-types/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export {
AnyConstructor,
cloneCircuitValue,
circuitValueEquals,
toConstant,
InferProvable,
HashInput,
InferJson,
Expand Down Expand Up @@ -372,11 +371,3 @@ function circuitValueEquals<T>(a: T, b: T): boolean {
([key, value]) => key in b && circuitValueEquals((b as any)[key], value)
);
}

function toConstant<T>(type: FlexibleProvable<T>, value: T): T;
function toConstant<T>(type: Provable<T>, value: T): T {
return type.fromFields(
type.toFields(value).map((x) => x.toConstant()),
type.toAuxiliary(value)
);
}
3 changes: 1 addition & 2 deletions src/lib/zkapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
FlexibleProvablePure,
InferProvable,
provable,
toConstant,
} from './provable-types/struct.js';
import { Provable, getBlindingValue, memoizationContext } from './provable.js';
import * as Encoding from '../bindings/lib/encoding.js';
Expand Down Expand Up @@ -408,7 +407,7 @@ function wrapMethod(
returnType !== undefined,
"Bug: returnType is undefined but the method result isn't."
);
result = toConstant(returnType, result);
result = Provable.toConstant(returnType, result);
}

// store inputs + result in callData
Expand Down

0 comments on commit 6e62425

Please sign in to comment.