/// <reference types="node" />
import Long from "long";
import { Message, Properties } from "protobufjs/light";
import { ForwardLink, SkipBlock } from "../skipchain/skipblock";
import Instance, { InstanceID } from "./instance";
/**
 * The proof class represents a proof that a given instance with its data is either present or absent in the global
 * state. It does this by proving three different things:
 *
 * 1. that there is a valid chain of blocks from the genesis to the latest block
 * 2. a copy of the latest block to get the root hash of the global state trie
 * 3. an inclusion proof against the root hash that can be positive (element is there) or negative (absence of element)
 *
 * As the element that is proven is always an instance, this class also has convenience methods to access the
 * instance data in case it is a proof of existence. For absence proofs, these methods will throw an error.
 */
export default class Proof extends Message<Proof> {
    /**
     * Get the state change stored in the inclusion proof
     *
     * @returns the state change body
     */
    readonly stateChangeBody: StateChangeBody;
    /**
     * Returns the contractID this proof represents. Throws an error if it
     * is a proof of absence.
     *
     * @returns the contract ID as a buffer
     */
    readonly contractID: string;
    /**
     * Get the darc ID of the instance
     *
     * @returns the darcID responsible for the instanceID this proof represents.
     */
    readonly darcID: Buffer;
    /**
     * The value of the instance is different from the value stored in the global state.
     *
     * @returns the value of the instance this proof represents.
     */
    readonly value: Buffer;
    /**
     * Get the instance ID for the proof
     *
     * @returns the instance ID as a buffer
     */
    readonly key: Buffer;
    /**
     * @see README#Message classes
     */
    static register(): void;
    private static latestID;
    readonly inclusionproof: InclusionProof;
    readonly latest: SkipBlock;
    readonly links: ForwardLink[];
    constructor(props: Properties<Proof>);
    /**
     * Verifies that the proof is of the given type and starts at the given byzcoin-id.
     * @param genesisID the hash of the first block, the byzcoin-id
     * @param contractID what contract the instance is supposed to be of
     * @throws an error if the proof is not based on genesisID, if it is a proof of absence,
     * or if the instance is not of type contractID.
     * @deprecated this function is unsecure
     */
    getVerifiedInstance(genesisID: InstanceID, contractID: string): Promise<Instance>;
    /**
     * Verify that the proof contains a correct chain from the given block.
     *
     * @param block the first block of the proof
     * @returns an error if something is wrong, null otherwise
     */
    verifyFrom(block: SkipBlock): Error;
    /**
     * Verify that the proof contains a correct chain from the given genesis. Note that
     * this function doesn't verify the first roster of the chain.
     *
     * @param latestID ID of the latest known and trusted block the proof is based upon
     * @returns an error if something is wrong, null otherwise
     * @deprecated use verifyFrom for a complete verification
     */
    verify(latestID: InstanceID): Error | undefined;
    /**
     * Check if the key exists in the proof
     *
     * @returns true when it exists, false otherwise
     * @throws for corrupted proofs
     */
    exists(key: Buffer): boolean;
    /**
     * @param cid contractID to check
     * @returns true if it is a proof of existence and the given type of contract matches.
     */
    matchContract(cid: string): boolean;
    /**
     * @returns a nicely formatted representation of the proof.
     */
    toString(): string;
}
/**
 * Interior node of an inclusion proof
 */
declare class InteriorNode extends Message<InteriorNode> {
    /**
     * @see README#Message classes
     */
    static register(): void;
    readonly left: Buffer;
    readonly right: Buffer;
}
/**
 * Empty node of an inclusion proof
 */
declare class EmptyNode extends Message<EmptyNode> {
    /**
     * @see README#Message classes
     */
    static register(): void;
    readonly prefix: boolean[];
    constructor(props?: Properties<EmptyNode>);
}
/**
 * Leaf node of an inclusion proof
 */
declare class LeafNode extends Message<LeafNode> {
    /**
     * @see README#Message classes
     */
    static register(): void;
    readonly prefix: boolean[];
    readonly key: Buffer;
    readonly value: Buffer;
    constructor(props?: Properties<LeafNode>);
}
/**
 * InclusionProof represents the proof that an instance is present or not in the global state trie.
 */
export declare class InclusionProof extends Message<InclusionProof> {
    /**
     * @return {Buffer} the key in the leaf for this inclusionProof. This is not the same as the key this proof has
     * been created for!
     */
    readonly key: Buffer;
    /**
     * @return {Buffer} the value stored in the instance. The value of an instance holds the contractID, darcID,
     * version and the data of the instance.
     */
    readonly value: Buffer;
    /**
     * Returns the stateChangeBody of this InclusionProof.
     */
    readonly stateChangeBody: StateChangeBody;
    /**
     * @see README#Message classes
     */
    static register(): void;
    interiors: InteriorNode[];
    leaf: LeafNode;
    empty: EmptyNode;
    nonce: Buffer;
    private _state;
    constructor(props?: Properties<InclusionProof>);
    /**
     * Get the hash of the interior node at the given index
     *
     * @param index the index of the interior node
     * @returns the hash as a buffer
     */
    hashInterior(index: number): Buffer;
    /**
     * Get the hash of the leaf of the inclusion proof
     *
     * @returns the hash as a buffer
     */
    hashLeaf(): Buffer;
    /**
     * Get the hash of the empty node of the inclusion proof
     *
     * @returns the hash of the empty node
     */
    hashEmpty(): Buffer;
    /**
     * Check if the key exists in the proof
     *
     * @returns true when it exists, false otherwise
     * @throws for corrupted proofs
     */
    exists(key: Buffer): boolean;
}
export declare class StateChangeBody extends Message<StateChangeBody> {
    readonly contractID: string;
    readonly darcID: Buffer;
    /**
     * @see README#Message classes
     */
    static register(): void;
    static fromBytes(b: Buffer): StateChangeBody;
    readonly stateaction: number;
    readonly contractid: string;
    readonly value: Buffer;
    readonly version: Long;
    readonly darcid: Buffer;
    constructor(props?: Properties<StateChangeBody>);
    /**
     * Helper to encode the StateChangeBody using protobuf
     * @returns the bytes
     */
    toBytes(): Buffer;
}
export {};
