UNPKG

micro-zk-proofs

Version:

Create & verify zero-knowledge SNARK proofs in parallel, using noble cryptography

39 lines 1.33 kB
/** * Pedersen Hash over babyjubjub elliptic curve, defined in * {@link https://eips.ethereum.org/EIPS/eip-2494 | EIP-2494}. * jubjub - edwards over bls12-381 scalar * babyjubjub - edwards over bn254 scalar * Using scalar as field allows to be used inside of zk-circuits. * @module */ import { type EdwardsPoint as ExtPointType } from '@noble/curves/abstract/edwards.js'; import type { TArg, TRet } from '@noble/hashes/utils.js'; type PointCodec = { encode: (p: any) => Uint8Array; decode: (bytes: Uint8Array) => ExtPointType; }; /** * Pedersen point encoder/decoder for babyjubjub points. * @example * Encode a babyjubjub point to bytes and decode it back. * ```ts * const { babyjubjub } = await import('@noble/curves/misc.js'); * const point = babyjubjub.Point.BASE; * const encoded = Point.encode(point); * Point.decode(encoded); * ``` */ export declare const Point: TRet<PointCodec>; /** * Computes the Pedersen hash for the input bytes. * @param msg - Message bytes to hash. * @returns Encoded babyjubjub point bytes. * @example * Hash message bytes into an encoded babyjubjub point. * ```ts * const digest = pedersenHash(new Uint8Array([1, 2, 3])); * ``` */ export declare function pedersenHash(msg: TArg<Uint8Array>): TRet<Uint8Array>; export {}; //# sourceMappingURL=pedersen.d.ts.map