diff --git a/src/lib/proof-system.ts b/src/lib/proof-system.ts index a2fece2e89..2df2431edf 100644 --- a/src/lib/proof-system.ts +++ b/src/lib/proof-system.ts @@ -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'; @@ -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 }) ); diff --git a/src/lib/provable-types/struct.ts b/src/lib/provable-types/struct.ts index 88942b2fa4..7d41286db3 100644 --- a/src/lib/provable-types/struct.ts +++ b/src/lib/provable-types/struct.ts @@ -33,7 +33,6 @@ export { AnyConstructor, cloneCircuitValue, circuitValueEquals, - toConstant, InferProvable, HashInput, InferJson, @@ -372,11 +371,3 @@ function circuitValueEquals(a: T, b: T): boolean { ([key, value]) => key in b && circuitValueEquals((b as any)[key], value) ); } - -function toConstant(type: FlexibleProvable, value: T): T; -function toConstant(type: Provable, value: T): T { - return type.fromFields( - type.toFields(value).map((x) => x.toConstant()), - type.toAuxiliary(value) - ); -} diff --git a/src/lib/zkapp.ts b/src/lib/zkapp.ts index 9469a5e2d5..eea39b9448 100644 --- a/src/lib/zkapp.ts +++ b/src/lib/zkapp.ts @@ -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'; @@ -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