mina-attestations
Version:
Private Attestations on Mina
155 lines (154 loc) • 6.82 kB
TypeScript
import { Bool, Field, type ProvableHashable, UInt32, UInt8 } from 'o1js';
import { DynamicArray, DynamicArrayBase } from './dynamic-array.ts';
import { StaticArray } from './static-array.ts';
export { DynamicString };
type DynamicString = DynamicStringBase;
/**
* Specialization of `DynamicArray` to string (represented as array of bytes),
* with added helper methods to create instances.
*
* ```ts
* const String = DynamicString({ maxLength: 120 });
*
* let string = String.from('hello');
* ```
*/
declare function DynamicString({ maxLength }: {
maxLength: number;
}): {
new (array: UInt8[], length: Field): {
readonly innerType: ProvableHashable<UInt8, {
value: bigint;
}>;
/**
* Hash the string using variants of SHA2 and SHA3.
*/
hashToBytes(algorithm: "sha2-256" | "sha2-384" | "sha2-512" | "keccak256"): import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes;
/**
* Convert DynamicString to a string.
*/
toString(): string;
/**
* Concatenate two strings.
*
* The resulting (max)length is the sum of the two individual (max)lengths.
*
* Note: This overrides the naive `concat()` implementation in `DynamicArray`.
* It's much more efficient than the base method and than both `concatTransposed()` and `concatByHashing()`.
*/
concat(other: DynamicArray<UInt8> | string): DynamicString;
/**
* Assert that this string is equal to another.
*
* Note: This only requires the length and the actual elements to be equal, not the padding or the maxLength.
* To check for exact equality, use `assertEqualsStrict()`.
*/
assertEquals(other: DynamicString | DynamicArray<UInt8, UInt8V> | StaticArray<UInt8, UInt8V> | (UInt8 | UInt8V)[] | string): void;
splitAt(index: number): [DynamicString, DynamicString];
slice(start: number | UInt32): DynamicString;
reverse(): DynamicString;
assertContains(substring: StaticArray<UInt8, UInt8V> | DynamicArray<UInt8, UInt8V> | string, message?: string): Field;
growMaxLengthTo(maxLength: number): DynamicString;
array: UInt8[];
length: Field;
readonly maxLength: number;
assertIndexInRange(i: UInt32): void;
get(i: UInt32): UInt8;
getOption(i: UInt32): import("o1js").Option<UInt8>;
getOrUnconstrained(i: Field): UInt8;
set(i: UInt32, value: UInt8): void;
setOrDoNothing(i: Field, value: UInt8): void;
map<S extends import("../o1js-missing.ts").ProvableHashableType>(type: S, f: (t: UInt8, i: number) => import("o1js").From<S>): DynamicArray<import("node_modules/o1js/dist/node/bindings/lib/provable-generic.js").InferProvable<S, import("node_modules/o1js/dist/node/lib/provable/field.js").Field>, import("o1js").InferValue<S>>;
forEach(f: (t: UInt8, isDummy: Bool, i: number) => void): void;
forEachReverse(f: (t: UInt8, isDummy: Bool, i: number) => void): void;
reduce<S>(stateType: import("../nested.ts").NestedProvableFor<S>, state: S, f: (state: S, t: UInt8, isDummy: Bool) => S): S;
hash(): import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
merkelize(listHash?: ((hash: Field, t: UInt8) => Field) | undefined): import("o1js").MerkleList<UInt8>;
chunk(chunkSize: number): [DynamicArray<StaticArray<UInt8, {
value: bigint;
}>, {
value: bigint;
}[]>, DynamicArray<UInt8, {
value: bigint;
}>];
assertEqualsStrict(other: DynamicArray<UInt8, {
value: bigint;
}>): void;
concatTransposed(other: StaticArray<UInt8, {
value: bigint;
}> | DynamicArray<UInt8, {
value: bigint;
}>): DynamicArray<UInt8, {
value: bigint;
}>;
concatByHashing(other: DynamicArray<UInt8, {
value: bigint;
}>): DynamicArray<UInt8, {
value: bigint;
}>;
push(value: UInt8): void;
growMaxLengthBy(maxLength: number): DynamicArray<UInt8, {
value: bigint;
}>;
normalize(): void;
assertNormalized(): void;
_indexMasks: Map<Field, Bool[]>;
_indicesInRange: Set<Field>;
__dummyMask?: Bool[];
_indexMask(i: Field): import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool[];
_dummyMask(): import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool[];
isDummyIndex(i: number): import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool | undefined;
toValue(): {
value: bigint;
}[];
};
readonly maxLength: number;
readonly provable: import("../o1js-missing.ts").ProvableHashablePure<DynamicStringBase, string>;
/**
* Create DynamicBytes from a string.
*/
from(s: string | DynamicStringBase): DynamicStringBase;
};
declare namespace DynamicString {
var from: (s: string | DynamicStringBase | DynamicArray<UInt8>) => DynamicStringBase;
var Base: typeof DynamicStringBase;
}
declare class DynamicStringBase extends DynamicArrayBase<UInt8, {
value: bigint;
}> {
get innerType(): ProvableHashable<UInt8, {
value: bigint;
}>;
/**
* Hash the string using variants of SHA2 and SHA3.
*/
hashToBytes(algorithm: 'sha2-256' | 'sha2-384' | 'sha2-512' | 'keccak256'): import("node_modules/o1js/dist/node/lib/provable/bytes.js").Bytes;
/**
* Convert DynamicString to a string.
*/
toString(): string;
/**
* Concatenate two strings.
*
* The resulting (max)length is the sum of the two individual (max)lengths.
*
* Note: This overrides the naive `concat()` implementation in `DynamicArray`.
* It's much more efficient than the base method and than both `concatTransposed()` and `concatByHashing()`.
*/
concat(other: DynamicArray<UInt8> | string): DynamicString;
/**
* Assert that this string is equal to another.
*
* Note: This only requires the length and the actual elements to be equal, not the padding or the maxLength.
* To check for exact equality, use `assertEqualsStrict()`.
*/
assertEquals(other: DynamicString | DynamicArray<UInt8, UInt8V> | StaticArray<UInt8, UInt8V> | (UInt8 | UInt8V)[] | string): void;
splitAt(index: number): [DynamicString, DynamicString];
slice(start: number | UInt32): DynamicString;
reverse(): DynamicString;
assertContains(substring: StaticArray<UInt8, UInt8V> | DynamicArray<UInt8, UInt8V> | string, message?: string): Field;
growMaxLengthTo(maxLength: number): DynamicString;
}
type UInt8V = {
value: bigint;
};