mina-attestations
Version:
Private Attestations on Mina
156 lines (155 loc) • 8.43 kB
TypeScript
import { VerificationKey, DynamicProof, type InferProvable, FeatureFlags, Proof, Cache, Provable, PublicKey, type From, type InferValue, Field } from 'o1js';
import { ProvableType } from './o1js-missing.ts';
import { type InferNestedProvable, NestedProvable, type NestedProvableFor } from './nested.ts';
import { type CredentialSpec, type Credential, type StoredCredential, type WitnessSpec } from './credential.ts';
import type { ImportedWitnessSpecJSON } from './validation.ts';
export { Imported, type ImportedWitness, ImportedWitnessSpec };
type ImportedWitness<Input = unknown> = {
type: 'imported';
vk: VerificationKey;
proof: DynamicProof<Input, Credential>;
};
type ImportedWitnessSpec = {
type: 'imported';
publicInputType: ProvableType;
publicOutputType: ProvableType<Credential<any>>;
maxProofsVerified: 0 | 1 | 2;
featureFlags: FeatureFlags;
};
type Imported<Data, Input> = StoredCredential<Data, ImportedWitness<Input>>;
declare const Imported: {
create: typeof createImported;
fromProgram: typeof importedFromProgram;
fromMethod: typeof importedFromMethod;
publicInputType: typeof publicInputType;
Generic: {
witnessType<Input>(witnessSpec: WitnessSpec): NestedProvableFor<ImportedWitness<Input>>;
verify({ vk, proof }: ImportedWitness, credHash: Field): void;
validate({ vk, proof }: ImportedWitness, credHash: Field): Promise<void>;
matchesSpec(witness: ImportedWitness): boolean;
};
};
declare function createImported<DataType extends NestedProvable, InputType extends ProvableType, Data extends InferNestedProvable<DataType>, Input extends InferProvable<InputType>>(spec: {
data: DataType;
witness: ImportedWitnessSpec;
}): CredentialSpec<ImportedWitness<Input>, Data>;
declare function witnessSpecToJSON(spec: ImportedWitnessSpec): {
type: "imported";
publicInputType: import("./serialize-provable.ts").SerializedType;
publicOutputType: import("./serialize-provable.ts").SerializedType;
maxProofsVerified: 0 | 2 | 1;
featureFlags: {
rangeCheck0: boolean | null;
rangeCheck1: boolean | null;
foreignFieldAdd: boolean | null;
foreignFieldMul: boolean | null;
xor: boolean | null;
rot: boolean | null;
lookup: boolean | null;
runtimeTables: boolean | null;
};
};
declare function witnessSpecFromJSON(json: ImportedWitnessSpecJSON): ImportedWitnessSpec;
declare const ImportedWitnessSpec: {
toJSON: typeof witnessSpecToJSON;
fromJSON: typeof witnessSpecFromJSON;
};
declare function publicInputType<Spec extends CredentialSpec>(credentialSpec: Spec): ProvableType;
declare function importedFromProgram<DataType extends ProvableType, InputType extends ProvableType, Data extends InferProvable<DataType>, Input extends InferProvable<InputType>, AllInputs extends any[]>(program: {
publicInputType: InputType;
publicOutputType: ProvableType<Credential<Data>>;
analyzeMethods(): Promise<Record<string, any>>;
maxProofsVerified(): Promise<0 | 1 | 2>;
compile: (options?: {
cache?: Cache;
forceRecompile?: boolean;
proofsEnabled?: boolean;
}) => Promise<{
verificationKey: VerificationKey;
}>;
run(...inputs: AllInputs): Promise<{
proof: Proof<Input, Credential<Data>>;
auxiliaryOutput: undefined;
}>;
}): Promise<{
spec: CredentialSpec<ImportedWitness<Input>, Data>;
program: {
publicInputType: InputType;
publicOutputType: ProvableType<Credential<Data>>;
analyzeMethods(): Promise<Record<string, any>>;
maxProofsVerified(): Promise<0 | 1 | 2>;
compile: (options?: {
cache?: Cache;
forceRecompile?: boolean;
proofsEnabled?: boolean;
}) => Promise<{
verificationKey: VerificationKey;
}>;
run(...inputs: AllInputs): Promise<{
proof: Proof<Input, Credential<Data>>;
auxiliaryOutput: undefined;
}>;
};
isCompiled: boolean;
verificationKey: VerificationKey | undefined;
create(...inputs: AllInputs): Promise<Imported<Data, Input>>;
fromProof(proof: Proof<Input, Credential<Data>>, vk: VerificationKey): Promise<Imported<Data, Input>>;
compile(options?: {
cache?: Cache;
forceRecompile?: boolean;
proofsEnabled?: boolean;
}): Promise<VerificationKey>;
dummy({ owner, data, }: Credential<From<DataType>>): Promise<Imported<Data, Input>>;
}>;
type PublicInput<Config> = InferProvableOrUndefined<Get<Config, 'publicInput'>>;
type PrivateInput<Config> = InferProvable<Get<Config, 'privateInput'>>;
type Data<Config> = InferProvable<Get<Config, 'data'>>;
declare function importedFromMethod<Config extends {
name: string;
publicInput?: NestedProvable;
privateInput?: NestedProvable;
data: NestedProvable;
}>(spec: Config, method: (inputs: {
publicInput: PublicInput<Config>;
privateInput: PrivateInput<Config>;
owner: PublicKey;
}) => Promise<Data<Config>>): Promise<Omit<{
spec: CredentialSpec<ImportedWitness<InferProvableOrUndefined<Get<Config, "publicInput">>>, import("node_modules/o1js/dist/node/bindings/lib/provable-generic.js").InferProvable<Get<Config, "data">, import("node_modules/o1js/dist/node/lib/provable/field.js").Field>>;
program: {
publicInputType: Provable<InferProvableOrUndefined<Get<Config, "publicInput">>, InferValue<Get<Config, "publicInput">>>;
publicOutputType: ProvableType<Credential<import("node_modules/o1js/dist/node/bindings/lib/provable-generic.js").InferProvable<Get<Config, "data">, import("node_modules/o1js/dist/node/lib/provable/field.js").Field>>>;
analyzeMethods(): Promise<Record<string, any>>;
maxProofsVerified(): Promise<0 | 1 | 2>;
compile: (options?: {
cache?: Cache;
forceRecompile?: boolean;
proofsEnabled?: boolean;
}) => Promise<{
verificationKey: VerificationKey;
}>;
run(...inputs: any): Promise<{
proof: Proof<InferProvableOrUndefined<Get<Config, "publicInput">>, Credential<import("node_modules/o1js/dist/node/bindings/lib/provable-generic.js").InferProvable<Get<Config, "data">, import("node_modules/o1js/dist/node/lib/provable/field.js").Field>>>;
auxiliaryOutput: undefined;
}>;
};
isCompiled: boolean;
verificationKey: VerificationKey | undefined;
create(...inputs: any): Promise<Imported<import("node_modules/o1js/dist/node/bindings/lib/provable-generic.js").InferProvable<Get<Config, "data">, import("node_modules/o1js/dist/node/lib/provable/field.js").Field>, InferProvableOrUndefined<Get<Config, "publicInput">>>>;
fromProof(proof: Proof<InferProvableOrUndefined<Get<Config, "publicInput">>, Credential<import("node_modules/o1js/dist/node/bindings/lib/provable-generic.js").InferProvable<Get<Config, "data">, import("node_modules/o1js/dist/node/lib/provable/field.js").Field>>>, vk: VerificationKey): Promise<Imported<import("node_modules/o1js/dist/node/bindings/lib/provable-generic.js").InferProvable<Get<Config, "data">, import("node_modules/o1js/dist/node/lib/provable/field.js").Field>, InferProvableOrUndefined<Get<Config, "publicInput">>>>;
compile(options?: {
cache?: Cache;
forceRecompile?: boolean;
proofsEnabled?: boolean;
} | undefined): Promise<VerificationKey>;
dummy({ owner, data, }: Credential<import("node_modules/o1js/dist/node/bindings/lib/provable-generic.js").InferProvable<Get<Config, "data">, import("node_modules/o1js/dist/node/lib/provable/field.js").Field> | InferValue<Get<Config, "data">>>): Promise<Imported<import("node_modules/o1js/dist/node/bindings/lib/provable-generic.js").InferProvable<Get<Config, "data">, import("node_modules/o1js/dist/node/lib/provable/field.js").Field>, InferProvableOrUndefined<Get<Config, "publicInput">>>>;
}, "create"> & {
create(inputs: {
publicInput: From<Get<Config, "publicInput">>;
privateInput: From<Get<Config, "privateInput">>;
owner: PublicKey;
}): Promise<Imported<InferProvable<Get<Config, "data">>, InferProvableOrUndefined<Get<Config, "publicInput">>>>;
}>;
type Get<T, Key extends string> = T extends {
[K in Key]: infer Value;
} ? Value : undefined;
type InferProvableOrUndefined<A> = A extends undefined ? undefined : InferProvable<A>;