/// <reference types="node" />
import { Point } from "@dedis/kyber";
import { Message, Properties } from "protobufjs/light";
import ByzCoinRPC from "../byzcoin/byzcoin-rpc";
import Instance, { InstanceID } from "../byzcoin/instance";
import Signer from "../darc/signer";
export default class CredentialsInstance extends Instance {
    private rpc;
    readonly inst: Instance;
    static readonly contractID = "credential";
    static readonly commandUpdate = "update";
    static readonly argumentCredential = "credential";
    static readonly argumentCredID = "credentialID";
    static readonly argumentDarcID = "darcIDBuf";
    /**
     * Generate the credential instance ID for a given public key
     *
     * @param buf the public key in marshalBinary form
     * @returns the id as a buffer
     */
    static credentialIID(buf: Buffer): InstanceID;
    /**
     * Spawn a new credential instance from a darc
     *
     * @param bc        The RPC to use
     * @param darcID    The darc instance ID
     * @param signers   The list of signers for the transaction
     * @param cred      The credential to store
     * @param credID    the instanceID will be sha256("credential" | pub)
     * @param credDarcID replaces the darc stored in the new credential with credDarcID
     * @param preID     replaces credID for byzcoin-versions >= VersionPreID
     * @returns a promise that resolves with the new instance
     */
    static spawn(bc: ByzCoinRPC, darcID: InstanceID, signers: Signer[], cred: CredentialStruct, credID?: Buffer, credDarcID?: InstanceID, preID?: Buffer): Promise<CredentialsInstance>;
    /**
     * Create a new credential instance from a darc
     *
     * @param bc        The RPC to use
     * @param darcID    The darc instance ID
     * @param cred      The credential to store
     * @param credID    the instanceID will be sha256("credential" | credID)
     * @returns the new instance
     */
    static create(bc: ByzCoinRPC, darcID: InstanceID, cred: CredentialStruct, credID?: Buffer): CredentialsInstance;
    /**
     * Get an existing credential instance using its instance ID by fetching
     * the proof.
     * @param bc    the byzcoin RPC
     * @param iid   the instance ID
     * @param waitMatch how many times to wait for a match - useful if its called just after an addTransactionAndWait.
     * @param interval how long to wait between two attempts in waitMatch.
     */
    static fromByzcoin(bc: ByzCoinRPC, iid: InstanceID, waitMatch?: number, interval?: number): Promise<CredentialsInstance>;
    credential: CredentialStruct;
    constructor(rpc: ByzCoinRPC, inst: Instance);
    /**
     * Update the data of the crendetial instance by fetching the proof
     *
     * @returns a promise resolving with the instance on success
     */
    update(): Promise<CredentialsInstance>;
    /**
     * Get a credential attribute
     *
     * @param credential    The name of the credential
     * @param attribute     The name of the attribute
     * @returns the value of the attribute if it exists, undefined otherwise
     */
    getAttribute(credential: string, attribute: string): Buffer | undefined;
    /**
     * Set or update a credential attribute locally. The new credential is not sent to
     * the blockchain, for this you need to call sendUpdate.
     *
     * @param credential    Name of the credential
     * @param attribute     Name of the attribute
     * @param value         The value to set
     */
    setAttribute(credential: string, attribute: string, value?: Buffer): void;
    /**
     * Creates a transaction to update the credential and sends it to ByzCoin.
     *
     * @param owners a list of signers to fulfill the expression of the `invoke:credential.update` rule.
     * @param newCred the new credentialStruct to store in the instance.
     * @return the updated CredentialInstance
     */
    sendUpdate(owners: Signer[], newCred?: CredentialStruct): Promise<CredentialsInstance>;
    /**
     * Recovers an identity by giving a list of signatures from trusted people.
     *
     * @param pubKey the new public key for the identity. It will be stored as the new expression for the
     * signer-rule.
     * @param signatures a threshold list of signatures on the public key and the instanceID.
     */
    recoverIdentity(pubKey: Point, signatures: RecoverySignature[]): Promise<void>;
}
/**
 * Data of a credential instance. It contains none, one or multiple
 * credentials.
 */
export declare class CredentialStruct extends Message<CredentialStruct> {
    /**
     * @see README#Message classes
     */
    static register(): void;
    readonly credentials: Credential[];
    constructor(properties?: Properties<CredentialStruct>);
    /**
     * Get a credential attribute
     *
     * @param credential    The name of the credential
     * @param attribute     The name of the attribute
     * @returns the value of the attribute if it exists, undefined otherwise
     */
    getAttribute(credential: string, attribute: string): Buffer | undefined;
    /**
     * getCredential returns the credential with the given name, or undefined if
     * nothing found.
     * @param credential name of the credential to return
     */
    getCredential(credential: string): Credential | undefined;
    /**
     * Overwrites the credential with name 'name' with the given credential.
     * If it doesn't exist, it will be appended to the list.
     *
     * @param name the name of the credential
     * @param cred the credential to store
     */
    setCredential(name: string, cred: Credential): void;
    /**
     * Set or update a credential attribute locally. The update is not sent to the blockchain.
     * For this you need to call CredentialInstance.sendUpdate().
     *
     * @param owner         Signer to use for the transaction
     * @param credential    Name of the credential
     * @param attribute     Name of the attribute
     * @param value         The value to set
     */
    setAttribute(credential: string, attribute: string, value?: Buffer | string): void;
    /**
     * Removes the attribute from the given credential. If the credential or the
     * attribute doesn't exist, it returns 'undefined', else it returns the
     * content of the deleted attribute.
     *
     * @param credential the name of the credential
     * @param attribute the attribute to be deleted
     */
    deleteAttribute(credential: string, attribute: string): Buffer | undefined;
    /**
     * Copy returns a new CredentialStruct with copies of all internal data.
     */
    copy(): CredentialStruct;
    /**
     * Helper to encode the struct using protobuf
     * @returns encoded struct as a buffer
     */
    toBytes(): Buffer;
}
/**
 * A credential has a given name used as a key and one or more attributes
 */
export declare class Credential extends Message<Credential> {
    /**
     * @see README#Message classes
     */
    static register(): void;
    /**
     * Returns a credential with only the given name/key = value stored in it.
     *
     * @param name the name of the attribute
     * @param key the key to store
     * @param value the value that will be stored in the key
     */
    static fromNameAttr(name: string, key: string, value: Buffer): Credential;
    readonly name: string;
    readonly attributes: Attribute[];
    constructor(props?: Properties<Credential>);
    toString(): string;
}
/**
 * Attribute of a credential
 */
export declare class Attribute extends Message<Attribute> {
    /**
     * @see README#Message classes
     */
    static register(): void;
    readonly name: string;
    readonly value: Buffer;
    constructor(props?: Properties<Attribute>);
}
export declare class RecoverySignature {
    credentialIID: InstanceID;
    signature: Buffer;
    static readonly sig = 64;
    static readonly pub = 32;
    static readonly credIID = 32;
    static readonly version = 8;
    static readonly pubSig: number;
    static readonly msgBuf: number;
    constructor(credentialIID: InstanceID, signature: Buffer);
}
