@reclaimprotocol/attestor-core
Version:
<div> <div> <img src="https://raw.githubusercontent.com/reclaimprotocol/.github/main/assets/banners/Attestor-Core.png" /> </div> </div>
74 lines (73 loc) • 3.08 kB
TypeScript
import type { ArraySlice, OPRFRawMarker, RedactedOrHashedArraySlice, TOPRFProofParams } from '../types/index.ts';
export declare const REDACTION_CHAR = "*";
export declare const REDACTION_CHAR_CODE: number;
type SliceWithReveal<T> = {
block: T;
redactedPlaintext: Uint8Array;
/**
* If the block has some TOPRF claims -- they'll be set here
*/
toprfs?: TOPRFProofParams[];
/**
* If the block has oprf-raw markers for server-side OPRF computation
*/
oprfRawMarkers?: OPRFRawMarker[];
/**
* If text was replaced in the previous block w TOPRF but
* it overshot into this block. The "length" specifies how much
* of it got overshot into this block
*/
overshotToprfFromPrevBlock?: {
length: number;
};
/**
* If an oprf-raw marker from the previous block overshot into this block.
* The server will collect plaintext from this block to complete the OPRF.
*/
overshotOprfRawFromPrevBlock?: {
length: number;
};
};
export type RevealedSlices<T> = 'all' | SliceWithReveal<T>[];
/**
* Check if a redacted string is congruent with the original string.
* @param redacted the redacted content, redacted content is replaced by '*'
* @param original the original content
*/
export declare function isRedactionCongruent<T extends string | Uint8Array>(redacted: T, original: T): boolean;
/**
* Is the string fully redacted?
*/
export declare function isFullyRedacted<T extends string | Uint8Array>(redacted: T): boolean;
/**
* Given some plaintext blocks and a redaction function, return the blocks that
* need to be revealed to the other party
*
* Use case: we get the response for a request in several blocks, and want to redact
* pieces that go through multiple blocks. We can use this function to get the
* blocks that need to be revealed to the other party
*
* @example if we received ["secret is 12","345","678. Thanks"]. We'd want
* to redact the "12345678" and reveal the rest. We'd pass in the blocks and
* the redact function will return the redactions, namely [10,19].
* The function will return the blocks ["secret is **","***. Thanks"].
* The middle block is fully redacted, so it's not returned
*
* @param blocks blocks to reveal
* @param redact function that returns the redactions
* @returns blocks to reveal
*/
export declare function getBlocksToReveal<T extends {
plaintext: Uint8Array;
}>(blocks: T[], redact: (total: Uint8Array) => RedactedOrHashedArraySlice[], performOprf: (plaintext: Uint8Array) => Promise<TOPRFProofParams>): Promise<"all" | SliceWithReveal<T>[]>;
/**
* Redact the following slices from the total
*/
export declare function redactSlices(total: Uint8Array, slices: ArraySlice[]): Uint8Array<ArrayBuffer>;
/**
* Converts the binary hash to an ASCII string of the expected length.
* If the hash is shorter than the expected length, it will be padded with
* '0' characters. If it's longer, it will be truncated.
*/
export declare function binaryHashToStr(hash: Uint8Array, expLength: number): string;
export {};