identity-based-encryption-bn254
Version:

42 lines (41 loc) • 1.74 kB
TypeScript
import { Fp, Fp12, Fp2 } from "@noble/curves/abstract/tower";
import { AffinePoint, ProjPointType } from "@noble/curves/abstract/weierstrass";
import { CHash } from "@noble/curves/abstract/utils";
export type G1 = AffinePoint<Fp>;
export type G2 = AffinePoint<Fp2>;
export type GT = Fp12;
export interface Ciphertext {
U: G2;
V: Uint8Array;
W: Uint8Array;
}
export type IbeOpts = {
hash: CHash;
k: number;
expand_fn: "xmd" | "xof";
dsts: DstOpts;
};
export type DstOpts = {
H1_G1: Uint8Array;
H2: Uint8Array;
H3: Uint8Array;
H4: Uint8Array;
};
export declare const DEFAULT_OPTS: IbeOpts;
export declare function createIdentity(identity: Uint8Array, opts: IbeOpts): ProjPointType<Fp>;
export declare function encrypt(m: Uint8Array, identity: ProjPointType<Fp>, publicKey: G2, opts: IbeOpts): Ciphertext;
export declare function decrypt(ciphertext: Ciphertext, decryptionKey: G1, opts?: IbeOpts): Uint8Array;
/**
* Decryption function for IBE based on https://www.iacr.org/archive/crypto2001/21390212.pdf Section 6 / https://eprint.iacr.org/2023/189.pdf, Algorithm 1
* with the identity on G1, and the master public key on G2.
*/
export declare function decryptWithPreprocess(ciphertext: Ciphertext, preprocessedDecryptionKey: Uint8Array, opts?: IbeOpts): Uint8Array;
/**
* Preprocess a signature by computing the hash of the pairing, i.e.,
* H_2(e(\pi_\rho, U)).
* @param ciphertext ciphertext to preprocess the decryption key for
* @param decryptionKey decryption key on g1 for the ciphertext
* @param opts IBE scheme options
* @returns preprocessed decryption key
*/
export declare function preprocessDecryptionKey(ciphertext: Ciphertext, decryptionKey: G1, opts?: IbeOpts): Uint8Array;