@navigators-exploration-team/mina-mastermind
Version:
[](https://github.com/navigators-exploration-team/recursive-mastermind-zkApp/actions/workflows/ci.yml)
238 lines (237 loc) • 9.28 kB
TypeScript
import { Field, UInt64, UInt32, UInt8 } from 'o1js';
export { Combination, Clue, GameState };
declare const Combination_base: (new (value: {
digits: import("o1js/dist/node/lib/provable/field.js").Field[];
}) => {
digits: import("o1js/dist/node/lib/provable/field.js").Field[];
}) & {
_isStruct: true;
} & Omit<import("o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
digits: import("o1js/dist/node/lib/provable/field.js").Field[];
}, {
digits: bigint[];
}>, "fromFields"> & {
fromFields: (fields: import("o1js/dist/node/lib/provable/field.js").Field[]) => {
digits: import("o1js/dist/node/lib/provable/field.js").Field[];
};
} & {
fromValue: (value: {
digits: import("o1js/dist/node/lib/provable/field.js").Field[] | bigint[];
}) => {
digits: import("o1js/dist/node/lib/provable/field.js").Field[];
};
toInput: (x: {
digits: import("o1js/dist/node/lib/provable/field.js").Field[];
}) => {
fields?: Field[] | undefined;
packed?: [Field, number][] | undefined;
};
toJSON: (x: {
digits: import("o1js/dist/node/lib/provable/field.js").Field[];
}) => {
digits: string[];
};
fromJSON: (x: {
digits: string[];
}) => {
digits: import("o1js/dist/node/lib/provable/field.js").Field[];
};
empty: () => {
digits: import("o1js/dist/node/lib/provable/field.js").Field[];
};
};
/**
* `Combination` is a class that represents a combination of digits for both the secret combination and the guesses.
* @param digits - An array of 4 unique digits between 1 and 7.
*
* @method `from` - Creates a new Combination instance from an array of numbers.
* @method `toBits` - Converts the combination to a bit array.
* @method `compress` - Compresses the combination into a single field element.
* @method `decompress` - Decompresses the combination from a single field element.
* @method `validate` - Validates the combination to ensure all digits are unique and within the range [1, 7].
* @method `updateHistory` - Updates the history of combinations with the new combination.
* @method `getElementFromHistory` - Retrieves an element from the history based on the index.
*/
declare class Combination extends Combination_base {
static from(numbers: number[]): Combination;
toBits(): import("o1js/dist/node/lib/provable/bool.js").Bool[];
compress(): import("o1js/dist/node/lib/provable/field.js").Field;
static decompress(compressedCombination: Field): Combination;
validate(): void;
private static decompressHistory;
static updateHistory(newCombination: Combination, compressedHistory: Field, index: Field): import("o1js/dist/node/lib/provable/field.js").Field;
static getElementFromHistory(compressedHistory: Field, index: Field): Combination;
}
declare const Clue_base: (new (value: {
hits: import("o1js/dist/node/lib/provable/field.js").Field;
blows: import("o1js/dist/node/lib/provable/field.js").Field;
}) => {
hits: import("o1js/dist/node/lib/provable/field.js").Field;
blows: import("o1js/dist/node/lib/provable/field.js").Field;
}) & {
_isStruct: true;
} & Omit<import("o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
hits: import("o1js/dist/node/lib/provable/field.js").Field;
blows: import("o1js/dist/node/lib/provable/field.js").Field;
}, {
hits: bigint;
blows: bigint;
}>, "fromFields"> & {
fromFields: (fields: import("o1js/dist/node/lib/provable/field.js").Field[]) => {
hits: import("o1js/dist/node/lib/provable/field.js").Field;
blows: import("o1js/dist/node/lib/provable/field.js").Field;
};
} & {
fromValue: (value: {
hits: string | number | bigint | import("o1js/dist/node/lib/provable/field.js").Field;
blows: string | number | bigint | import("o1js/dist/node/lib/provable/field.js").Field;
}) => {
hits: import("o1js/dist/node/lib/provable/field.js").Field;
blows: import("o1js/dist/node/lib/provable/field.js").Field;
};
toInput: (x: {
hits: import("o1js/dist/node/lib/provable/field.js").Field;
blows: import("o1js/dist/node/lib/provable/field.js").Field;
}) => {
fields?: Field[] | undefined;
packed?: [Field, number][] | undefined;
};
toJSON: (x: {
hits: import("o1js/dist/node/lib/provable/field.js").Field;
blows: import("o1js/dist/node/lib/provable/field.js").Field;
}) => {
hits: string;
blows: string;
};
fromJSON: (x: {
hits: string;
blows: string;
}) => {
hits: import("o1js/dist/node/lib/provable/field.js").Field;
blows: import("o1js/dist/node/lib/provable/field.js").Field;
};
empty: () => {
hits: import("o1js/dist/node/lib/provable/field.js").Field;
blows: import("o1js/dist/node/lib/provable/field.js").Field;
};
};
/**
* `Clue` is a class that represents the clue given by the codeMaster after each guess.
* @param hits - The number of correct digits in the correct position.
* @param blows - The number of correct digits in the wrong position.
*
* @method `compress` - Compresses the clue into a single field element.
* @method `decompress` - Decompresses the clue from a single field element.
* @method `giveClue` - Generates a clue based on the guess and solution.
* @method `isSolved` - Checks if the game is solved based on the clue.
* @method `updateHistory` - Updates the history of clues with the new clue.
*/
declare class Clue extends Clue_base {
compress(): import("o1js/dist/node/lib/provable/field.js").Field;
static decompress(compressedClue: Field): Clue;
static giveClue(guess: Field[], solution: Field[]): Clue;
isSolved(): import("o1js/dist/node/lib/provable/bool.js").Bool;
static updateHistory(newClue: Clue, compressedHistory: Field, index: Field): import("o1js/dist/node/lib/provable/field.js").Field;
}
declare const GameState_base: (new (value: {
rewardAmount: UInt64;
finalizeSlot: UInt32;
turnCount: UInt8;
isSolved: import("o1js/dist/node/lib/provable/bool.js").Bool;
}) => {
rewardAmount: UInt64;
finalizeSlot: UInt32;
turnCount: UInt8;
isSolved: import("o1js/dist/node/lib/provable/bool.js").Bool;
}) & {
_isStruct: true;
} & Omit<import("o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
rewardAmount: UInt64;
finalizeSlot: UInt32;
turnCount: UInt8;
isSolved: import("o1js/dist/node/lib/provable/bool.js").Bool;
}, {
rewardAmount: bigint;
finalizeSlot: bigint;
turnCount: {
value: bigint;
};
isSolved: boolean;
}>, "fromFields"> & {
fromFields: (fields: import("o1js/dist/node/lib/provable/field.js").Field[]) => {
rewardAmount: UInt64;
finalizeSlot: UInt32;
turnCount: UInt8;
isSolved: import("o1js/dist/node/lib/provable/bool.js").Bool;
};
} & {
fromValue: (value: {
rewardAmount: number | bigint | UInt64;
finalizeSlot: number | bigint | UInt32;
turnCount: number | UInt8 | {
value: string | number | bigint | Field;
};
isSolved: boolean | import("o1js/dist/node/lib/provable/bool.js").Bool;
}) => {
rewardAmount: UInt64;
finalizeSlot: UInt32;
turnCount: UInt8;
isSolved: import("o1js/dist/node/lib/provable/bool.js").Bool;
};
toInput: (x: {
rewardAmount: UInt64;
finalizeSlot: UInt32;
turnCount: UInt8;
isSolved: import("o1js/dist/node/lib/provable/bool.js").Bool;
}) => {
fields?: Field[] | undefined;
packed?: [Field, number][] | undefined;
};
toJSON: (x: {
rewardAmount: UInt64;
finalizeSlot: UInt32;
turnCount: UInt8;
isSolved: import("o1js/dist/node/lib/provable/bool.js").Bool;
}) => {
rewardAmount: string;
finalizeSlot: string;
turnCount: {
value: string;
};
isSolved: boolean;
};
fromJSON: (x: {
rewardAmount: string;
finalizeSlot: string;
turnCount: {
value: string;
};
isSolved: boolean;
}) => {
rewardAmount: UInt64;
finalizeSlot: UInt32;
turnCount: UInt8;
isSolved: import("o1js/dist/node/lib/provable/bool.js").Bool;
};
empty: () => {
rewardAmount: UInt64;
finalizeSlot: UInt32;
turnCount: UInt8;
isSolved: import("o1js/dist/node/lib/provable/bool.js").Bool;
};
};
/**
* `GameState` is a class that represents the state of the game.
* @param rewardAmount - The total reward amount for the game.
* @param finalizeSlot - The slot at which the game is finalized.
* @param turnCount - The number of turns taken in the game.
* @param isSolved - A flag indicating whether the game is solved or not.
*
* @method `pack` - Packs the game state into a single field element.
* @method `unpack` - Unpacks the game state from a single field element.
*/
declare class GameState extends GameState_base {
static default: GameState;
pack(): import("o1js/dist/node/lib/provable/field.js").Field;
static unpack(serializedState: Field): GameState;
}