identity-based-encryption-bn254
Version:

31 lines (30 loc) • 1.22 kB
TypeScript
import { Fp } from "@noble/curves/abstract/tower";
import { ProjPointType } from "@noble/curves/abstract/weierstrass";
import { Ciphertext, G2, IbeOpts } from "./crypto";
export declare class IBE {
private opts;
constructor(opts?: IbeOpts);
createIdentity(bytes: Uint8Array): Identity;
createDecryptionKey(secretKey: SecretKey | Uint8Array, identity: Identity): DecryptionKey;
isValidDecryptionKey(publicKey: PublicKey | Uint8Array, decryptionKey: DecryptionKey | Uint8Array, identity: Identity | Uint8Array): boolean;
encrypt(message: Uint8Array, identity: Identity, publicKey: PublicKey): Ciphertext;
decrypt(ciphertext: Ciphertext, decryptionKey: DecryptionKey | Uint8Array): Uint8Array;
static parsePublicKey(bytes: Uint8Array): PublicKey;
static parseDecryptionKey(bytes: Uint8Array): DecryptionKey;
static parseSecretKey(sk: Uint8Array | bigint): SecretKey;
static createSecretKey(): SecretKey;
static createPublicKey(secretKey: SecretKey): PublicKey;
}
export type SecretKey = {
sk: bigint;
};
export type Identity = {
m: Uint8Array;
i: ProjPointType<Fp>;
};
export type PublicKey = {
p: G2;
};
export type DecryptionKey = {
bytes: Uint8Array;
};