mina-attestations
Version:
Private Attestations on Mina
90 lines (89 loc) • 4.42 kB
TypeScript
/**
* This file exports types and functions that actually should be exported from o1js
*/
import { Field, type InferProvable, type InferValue, Provable, type ProvableHashable, type ProvablePure } from 'o1js';
import type { NestedProvable } from './nested.ts';
import type { Json } from './types.ts';
export { ProvableType, assertPure, type ProvablePureType, type ProvableHashableType, type ProvableHashablePure, type ProvableHashableWide, array, toFieldsPacked, hashPacked, empty, toInput, HashInput, };
declare const ProvableType: {
get<A extends unknown>(type: A): ToProvable<A>;
fromValue<T>(value: T): ProvableHashableType<T>;
synthesize<T>(type_: ProvableType<T>): T;
isProvableType(type: unknown): type is ProvableType;
isProvableHashableType(type: unknown): type is ProvableHashableType;
constant<const T extends Json>(value: T): ProvablePure<T, T> & {
serialize(): any;
};
};
declare function assertPure<T>(type_: Provable<T>): asserts type_ is ProvablePure<T>;
declare function assertPure<T>(type: ProvableType<T>): asserts type is ProvablePureType<T>;
type WithProvable<A> = {
provable: A;
} | A;
type ProvableType<T = any, V = any> = WithProvable<Provable<T, V>>;
type ProvablePureType<T = any, V = any> = WithProvable<ProvablePure<T, V>>;
type ProvableHashableType<T = any, V = any> = WithProvable<ProvableHashable<T, V>>;
type ProvableHashableWide<T = any, V = any, W = any> = Omit<ProvableHashable<T, V>, 'fromValue'> & {
fromValue: (value: T | W) => T;
};
type ToProvable<A extends WithProvable<any>> = A extends {
provable: infer P;
} ? P : A;
type HashInput = {
fields?: Field[];
packed?: [Field, number][];
};
type MaybeHashable<T> = {
toInput?: (x: T) => HashInput;
empty?: () => T;
};
type ProvableMaybeHashable<T = any, V = any> = Provable<T, V> & MaybeHashable<T>;
type ProvableHashablePure<T = any, V = any> = ProvablePure<T, V> & ProvableHashable<T, V>;
/**
* Pack a value to as few field elements as possible using `toInput()`, falling back to `toFields()` if that's not available.
*
* Note: Different than `Packed` in o1js, this uses little-endian packing.
*/
declare function toFieldsPacked<T>(type_: WithProvable<ProvableMaybeHashable<T>>, value: T): Field[];
/**
* Hash a provable value efficiently, by first packing it into as few field elements as possible.
*
* Note: Different than `Poseidon.hashPacked()` and `Hashed` (by default) in o1js, this uses little-endian packing.
*/
declare function hashPacked<T>(type: WithProvable<ProvableMaybeHashable<T>>, value: T): Field;
declare function array<A extends NestedProvable>(elementType: A, length: number): {
_isArray: true;
innerType: A;
size: number;
/**
* Returns the size of this structure in {@link Field} elements.
* @returns size of this structure
*/
sizeInFields(): number;
/**
* Serializes this structure into {@link Field} elements.
* @returns an array of {@link Field} elements
*/
toFields(array: InferProvable<A>[]): import("node_modules/o1js/dist/node/lib/provable/field.js").Field[];
/**
* Serializes this structure's auxiliary data.
* @returns auxiliary data
*/
toAuxiliary(array?: InferProvable<A>[] | undefined): any[][];
/**
* Deserializes an array of {@link Field} elements into this structure.
*/
fromFields(fields: Field[], aux?: any[]): InferProvable<A>[];
check(array: InferProvable<A>[]): void;
toCanonical(x: InferProvable<A>[]): import("node_modules/o1js/dist/node/bindings/lib/provable-generic.js").InferProvable<A, import("node_modules/o1js/dist/node/lib/provable/field.js").Field>[];
toValue(x: InferProvable<A>[]): InferValue<A>[];
fromValue(x: InferProvable<A>[] | InferValue<A>[]): import("node_modules/o1js/dist/node/bindings/lib/provable-generic.js").InferProvable<A, import("node_modules/o1js/dist/node/lib/provable/field.js").Field>[];
toInput(array: InferProvable<A>[]): {};
empty(): import("node_modules/o1js/dist/node/bindings/lib/provable-generic.js").InferProvable<A, import("node_modules/o1js/dist/node/lib/provable/field.js").Field>[];
};
declare const HashInput: {
readonly empty: {};
append(input1: HashInput, input2: HashInput): HashInput;
};
declare function toInput<T>(type: ProvableMaybeHashable<T>, value: T): HashInput;
declare function empty<T>(type: ProvableMaybeHashable<T>): T;