import { Bool, Field, Signature, PublicKey, type InferProvable, Provable, type From } from 'o1js'; import type { ExcludeFromRecord } from './types.ts'; import { ProvableType } from './o1js-missing.ts'; import { type InferNestedProvable, NestedProvable, type NestedProvableFor } from './nested.ts'; import { type CredentialSpec, type Credential, type CredentialInputs, type CredentialOutputs } from './credential.ts'; import { type InputToNode, Node } from './operation.ts'; export type { PublicInputs, PrivateInputs, UserInputs, RootValue, Input, Claims, RootType, }; export { Spec, Claim, Constant, publicInputTypes, publicOutputType, privateInputTypes, splitUserInputs, extractCredentialInputs, rootValue, isCredentialSpec, }; type Spec = Record> = { inputs: Inputs; assert: Node; outputClaim: Node; }; /** * Specify a ZkProgram that verifies and selectively discloses data */ declare function Spec>(inputs: Inputs, spec: (inputs: { [K in keyof Inputs]: InputToNode; }) => { assert?: Node | Node[]; outputClaim: Node; }): Spec; declare function Spec>(inputs: Inputs, spec: (inputs: { [K in keyof Inputs]: InputToNode; }) => { assert?: Node | Node[]; }): Spec; type Constant = { type: 'constant'; data: ProvableType; value: Data; }; type Claim = { type: 'claim'; data: NestedProvableFor; }; type Input = (CredentialSpec & { type?: undefined; }) | Constant | Claim; declare function isCredentialSpec(input: Input | undefined): input is CredentialSpec; declare function Constant(data: DataType, value: From): Constant>; declare function Claim(data: DataType): Claim>; declare function publicInputTypes({ inputs }: Spec): { context: typeof Field; claims: NestedProvable; }; type CredentialInputType = { credential: { owner: PublicKey; data: unknown; }; witness: unknown; }; declare function privateInputTypes({ inputs }: Spec): NestedProvableFor<{ ownerSignature: Signature; credentials: Record; }>; declare function publicOutputType(spec: Spec): Provable; type RootType = Record; declare function splitUserInputs(userInputs: UserInputs): { publicInput: PublicInputs; privateInput: PrivateInputs; }; declare function extractCredentialInputs(spec: Spec, { context }: PublicInputs, { ownerSignature, credentials }: PrivateInputs): CredentialInputs; declare function rootValue(spec: S, publicInputs: PublicInputs, privateInputs: PrivateInputs, credentialOutputs: CredentialOutputs): RootValue; type Claims> = ExcludeFromRecord, never>; type PublicInputs> = { context: Field; claims: Claims; }; type Credentials> = ExcludeFromRecord, never>; type PrivateInputs> = { ownerSignature: Signature; credentials: Credentials; }; type UserInputs> = { context: Field; ownerSignature: Signature; claims: ExcludeFromRecord, never>; credentials: ExcludeFromRecord, never>; }; type RootValue = Record> = ExcludeFromRecord, never> & { owner: PublicKey; }; type MapToClaims> = { [K in keyof T]: ToClaim; }; type MapToCredentials> = { [K in keyof T]: ToCredential; }; type MapToDataInput> = { [K in keyof T]: ToDataInput; }; type ToClaim = T extends Claim ? Data : never; type ToCredential = T extends CredentialSpec ? { credential: Credential; witness: Witness; } : never; type ToDataInput = T extends CredentialSpec ? { data: Data; witness: Witness; issuer: Field; } : T extends Input ? Data : never;