import { ContractLoader, Description, Executor, DfsInterface, KeyProvider, NameResolver, Logger, LoggerOptions } from '@evan.network/dbcp';
import { CryptoProvider } from '../encryption/crypto-provider';
export interface SharingOptions extends LoggerOptions {
    contractLoader: ContractLoader;
    cryptoProvider: CryptoProvider;
    description: Description;
    executor: Executor;
    dfs: DfsInterface;
    keyProvider: KeyProvider;
    nameResolver: NameResolver;
    defaultCryptoAlgo?: string;
}
/**
 * Sharing helper. Can add Sharings to contract addresses and ENS endpoints
 *
 * @class      Sharing (name)
 */
export declare class Sharing extends Logger {
    options: SharingOptions;
    private readonly encodingUnencrypted;
    private readonly encodingEncrypted;
    private sharingCache;
    private hashCache;
    constructor(options: SharingOptions);
    /**
     * add a sharing to a contract or an ENS address
     *
     * @param      {string}         address     contract address or ENS address
     * @param      {string}         originator  Ethereum account id of the sharing user
     * @param      {string}         partner     Ethereum account id for which key shall be added
     * @param      {string}         section     data section the key is intended for or '*'
     * @param      {number|string}  block       starting with this block, the key is valid
     * @param      {string}         sharingKey  key to share
     * @param      {string}         context     context to share key in
     * @param      {boolean}        isHashKey   indicates if given key already is a hash key
     * @param      {string}         sharingId   id of a sharing (when multi-sharings is used)
     * @return     {Promise<void>}  resolved when done
     */
    addSharing(address: string, originator: string, partner: string, section: string, block: number | string, sharingKey: string, context?: string, isHashKey?: boolean, sharingId?: string): Promise<void>;
    /**
     * add a hash to to cache, can be used to speed up sharing key retrieval, when
     * sharings hash is already known
     *
     * @param      {string}  address    contract address
     * @param      {any}     sharings   encrypted sharings object
     * @param      {string}  sharingId  id of a multisharing
     */
    addHashToCache(address: string, sharings: any, sharingId?: string): void;
    /**
     * clear caches and fetch new hashes and sharing on next request
     *
     * @return     {void}  resolved when done
     */
    clearCache(): void;
    /**
     * give hash key "hashKey" to account "partner", if this account does not have a hash key already
     *
     * @param      {string}         address     contract adress
     * @param      {string}         originator  executing users account id
     * @param      {string}         partner     account id of a contract participant
     * @param      {string}         hashKey     key for DFS hashes
     * @param      {string}         context     (optional) context for encryption
     * @param      {string}         sharingId   id of a sharing (when multi-sharings is used)
     * @return     {Promise<void>}  resolved when done
     */
    ensureHashKey(address: string, originator: string, partner: string, hashKey: string, context?: string, sharingId?: string): Promise<void>;
    /**
     * extend an existing sharing info with given key; this is done on a sharings object and does not
     * perform a transaction on its own
     *
     * @param      {any}            sharings    a sharings info
     * @param      {string}         originator  Ethereum account id of the sharing user
     * @param      {string}         partner     Ethereum account id for which key shall be added
     * @param      {string}         section     data section the key is intended for or '*'
     * @param      {number|string}  block       starting with this block, the key is valid
     * @param      {string}         sharingKey  key to share
     * @param      {string}         context     context to share key in
     * @return     {Promise<any>}   updated sharings info
     */
    extendSharings(sharings: any, originator: string, partner: string, section: string, block: number | string, sharingKey: string, context?: string): Promise<string>;
    /**
     * returns an accounts key for file hashes
     *
     * @param      {string}           address    contract address or ENS address
     * @param      {string}           partner    Ethereum account id for which key shall be retrieved
     * @param      {string}           sharingId  id of a sharing (when multi-sharings is used)
     * @return     {Promise<string>}  matching key
     */
    getHashKey(address: string, partner: string, sharingId?: string): Promise<any>;
    /**
     * get sharing from a contract, if _partner, _section, _block matches
     *
     * @param      {string}        address   address of a contract or an ENS address
     * @param      {string}        _partner  Ethereum account id for which key shall be retrieved
     * @param      {string}        _section  data section the key is intended for or '*'
     * @param      {number}        _block    starting with this block, the key is valid
     * @return     {Promise<any>}  sharings as an object.
     */
    getSharings(address: string, _partner?: string, _section?: string, _block?: number, sharingId?: string): Promise<any>;
    /**
     * get encrypted sharings from smart contract
     *
     * @param      {any}           contract   contract with sharing info
     * @param      {string}        sharingId  id of a sharing in mutlisharings
     * @return     {Promise<any>}  sharings object
     */
    getSharingsFromContract(contract: any, sharingId?: string): Promise<any>;
    /**
     * get a content key from the sharing of a contract
     *
     * @param      {string}           address    contract address or ENS address
     * @param      {string}           partner    Ethereum account id for which key shall be retrieved
     * @param      {string}           section    data section the key is intended for or '*'
     * @param      {number|string}    block      starting with this block, the key is valid
     * @param      {string}           sharingId  id of a sharing (when multi-sharings is used)
     * @return     {Promise<string>}  matching key
     */
    getKey(address: string, partner: string, section: string, block?: number | string, sharingId?: string): Promise<string>;
    /**
     * remove a sharing key from a contract with sharing info
     *
     * @param      {string}         address     contract address or ENS address
     * @param      {string}         originator  Ethereum account id of the sharing user
     * @param      {string}         partner     Ethereum account id for which key shall be removed
     * @param      {string}         section     data section of the key
     * @param      {string}         sharingId   id of a sharing (when multi-sharings is used)
     * @return     {Promise<void>}  resolved when done
     */
    removeSharing(address: string, originator: string, partner: string, section: string, sharingId?: string): Promise<void>;
    /**
     * save sharings object with encrypted keys to contract
     *
     * @param      {string|any}     contract    contract address or instance
     * @param      {any}            sharings    sharings object with encrypted keys
     * @param      {string}         originator  Ethereum account id of the sharing user
     * @param      {string}         sharingId   id of a sharing (when multi-sharings is used)
     * @return     {Promise<void>}  resolved when done
     */
    saveSharingsToContract(contract: string, sharings: any, originator: string, sharingId?: string): Promise<void>;
    private decryptSharings(sharings, _partner?, _section?, _block?);
}
