bigint-pedersen
Version:
This library provides an implementation of Pedersen Commitments, a cryptographic technique widely used for creating non-interactive commitments with strong security properties like homomorphic addition, subtraction, and multiplication.
32 lines (31 loc) • 1.2 kB
TypeScript
export type PedersenParameters = {
g: bigint;
h: bigint;
p: bigint;
};
declare function modExp(base: bigint, exponent: bigint, mod: bigint): bigint;
declare function isPrimeMillerRabin(n: bigint, k?: number): boolean;
declare function randomBlinding(bytes?: number): bigint;
declare function generator(bits?: number): Promise<PedersenParameters>;
declare function modInverse(a: bigint, p: bigint): bigint;
declare function commitment(m: bigint, r: bigint, parans: PedersenParameters): bigint;
declare function sum(C1: bigint, C2: bigint, parans: PedersenParameters): bigint;
declare function sub(C1: bigint, C2: bigint, parans: PedersenParameters): bigint;
declare function multiply(C: bigint, scalar: bigint, parans: PedersenParameters): bigint;
declare const pedersen: {
DEFAULT_GENERRATOR: {
p: bigint;
g: bigint;
h: bigint;
};
modExp: typeof modExp;
modInverse: typeof modInverse;
randomBlinding: typeof randomBlinding;
isPrimeMillerRabin: typeof isPrimeMillerRabin;
generator: typeof generator;
commitment: typeof commitment;
sum: typeof sum;
sub: typeof sub;
multiply: typeof multiply;
};
export default pedersen;