UNPKG

@okxweb3/crypto-lib

Version:

A base package for @okxweb3/coin-*

55 lines (54 loc) 2.36 kB
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ export declare function mod(a: bigint, b: bigint): bigint; export declare function pow(num: bigint, power: bigint, modulo: bigint): bigint; export declare function pow2(x: bigint, power: bigint, modulo: bigint): bigint; export declare function invert(number: bigint, modulo: bigint): bigint; export declare function tonelliShanks(P: bigint): <T>(Fp: IField<T>, n: T) => T; export declare function FpSqrt(P: bigint): <T>(Fp: IField<T>, n: T) => T; export declare const isNegativeLE: (num: bigint, modulo: bigint) => boolean; export interface IField<T> { ORDER: bigint; BYTES: number; BITS: number; MASK: bigint; ZERO: T; ONE: T; create: (num: T) => T; isValid: (num: T) => boolean; is0: (num: T) => boolean; neg(num: T): T; inv(num: T): T; sqrt(num: T): T; sqr(num: T): T; eql(lhs: T, rhs: T): boolean; add(lhs: T, rhs: T): T; sub(lhs: T, rhs: T): T; mul(lhs: T, rhs: T | bigint): T; pow(lhs: T, power: bigint): T; div(lhs: T, rhs: T | bigint): T; addN(lhs: T, rhs: T): T; subN(lhs: T, rhs: T): T; mulN(lhs: T, rhs: T | bigint): T; sqrN(num: T): T; isOdd?(num: T): boolean; pow(lhs: T, power: bigint): T; invertBatch: (lst: T[]) => T[]; toBytes(num: T): Uint8Array; fromBytes(bytes: Uint8Array): T; cmov(a: T, b: T, c: boolean): T; } export declare function validateField<T>(field: IField<T>): IField<T>; export declare function FpPow<T>(f: IField<T>, num: T, power: bigint): T; export declare function FpInvertBatch<T>(f: IField<T>, nums: T[]): T[]; export declare function FpDiv<T>(f: IField<T>, lhs: T, rhs: T | bigint): T; export declare function FpIsSquare<T>(f: IField<T>): (x: T) => boolean; export declare function nLength(n: bigint, nBitLength?: number): { nBitLength: number; nByteLength: number; }; type FpField = IField<bigint> & Required<Pick<IField<bigint>, 'isOdd'>>; export declare function Field(ORDER: bigint, bitLen?: number, isLE?: boolean, redef?: Partial<IField<bigint>>): Readonly<FpField>; export declare function FpSqrtOdd<T>(Fp: IField<T>, elm: T): T; export declare function FpSqrtEven<T>(Fp: IField<T>, elm: T): T; export declare function hashToPrivateScalar(hash: string | Uint8Array, groupOrder: bigint, isLE?: boolean): bigint; export {};