thirdparty.d.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. declare module "bn.js" {
  2. export class BN {
  3. constructor(value: string | number, radix?: number);
  4. add(other: BN): BN;
  5. sub(other: BN): BN;
  6. div(other: BN): BN;
  7. mod(other: BN): BN;
  8. mul(other: BN): BN;
  9. pow(other: BN): BN;
  10. maskn(other: number): BN;
  11. eq(other: BN): boolean;
  12. lt(other: BN): boolean;
  13. lte(other: BN): boolean;
  14. gt(other: BN): boolean;
  15. gte(other: BN): boolean;
  16. isZero(): boolean;
  17. toTwos(other: number): BN;
  18. fromTwos(other: number): BN;
  19. toString(radix: number): string;
  20. toNumber(): number;
  21. toArray(endian: string, width: number): Uint8Array;
  22. encode(encoding: string, compact: boolean): Uint8Array;
  23. }
  24. }
  25. declare module "elliptic" {
  26. import { BN } from "bn.js";
  27. export type BasicSignature = {
  28. r: Uint8Array;
  29. s: Uint8Array;
  30. };
  31. export type Signature = {
  32. r: BN,
  33. s: BN,
  34. recoveryParam: number
  35. }
  36. interface Point {
  37. add(point: Point): Point;
  38. encodeCompressed(enc: string): string
  39. }
  40. interface KeyPair {
  41. sign(message: Uint8Array, options: { canonical?: boolean }): Signature;
  42. getPublic(compressed: boolean, encoding?: string): string;
  43. getPublic(): BN;
  44. getPrivate(encoding?: string): string;
  45. encode(encoding: string, compressed: boolean): string;
  46. derive(publicKey: BN): BN;
  47. pub: Point;
  48. priv: BN;
  49. }
  50. export class ec {
  51. constructor(curveName: string);
  52. n: BN;
  53. keyFromPublic(publicKey: Uint8Array): KeyPair;
  54. keyFromPrivate(privateKey: Uint8Array): KeyPair;
  55. recoverPubKey(data: Uint8Array, signature: BasicSignature, recoveryParam: number): KeyPair;
  56. }
  57. }