ed448.d.ts 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { AffinePoint, Group } from './abstract/curve.js';
  2. import { ExtPointType } from './abstract/edwards.js';
  3. import { htfBasicOpts } from './abstract/hash-to-curve.js';
  4. import { Hex } from './abstract/utils.js';
  5. export declare const ed448: import("./abstract/edwards.js").CurveFn;
  6. export declare const ed448ph: import("./abstract/edwards.js").CurveFn;
  7. export declare const x448: import("./abstract/montgomery.js").CurveFn;
  8. /**
  9. * Converts edwards448 public key to x448 public key. Uses formula:
  10. * * `(u, v) = ((y-1)/(y+1), sqrt(156324)*u/x)`
  11. * * `(x, y) = (sqrt(156324)*u/v, (1+u)/(1-u))`
  12. * @example
  13. * const aPub = ed448.getPublicKey(utils.randomPrivateKey());
  14. * x448.getSharedSecret(edwardsToMontgomery(aPub), edwardsToMontgomery(someonesPub))
  15. */
  16. export declare function edwardsToMontgomeryPub(edwardsPub: string | Uint8Array): Uint8Array;
  17. export declare const edwardsToMontgomery: typeof edwardsToMontgomeryPub;
  18. export declare const hashToCurve: (msg: Uint8Array, options?: htfBasicOpts) => import("./abstract/hash-to-curve.js").H2CPoint<bigint>;
  19. export declare const encodeToCurve: (msg: Uint8Array, options?: htfBasicOpts) => import("./abstract/hash-to-curve.js").H2CPoint<bigint>;
  20. type ExtendedPoint = ExtPointType;
  21. /**
  22. * Each ed448/ExtendedPoint has 4 different equivalent points. This can be
  23. * a source of bugs for protocols like ring signatures. Decaf was created to solve this.
  24. * Decaf point operates in X:Y:Z:T extended coordinates like ExtendedPoint,
  25. * but it should work in its own namespace: do not combine those two.
  26. * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-ristretto255-decaf448
  27. */
  28. declare class DcfPoint implements Group<DcfPoint> {
  29. private readonly ep;
  30. static BASE: DcfPoint;
  31. static ZERO: DcfPoint;
  32. constructor(ep: ExtendedPoint);
  33. static fromAffine(ap: AffinePoint<bigint>): DcfPoint;
  34. /**
  35. * Takes uniform output of 112-byte hash function like shake256 and converts it to `DecafPoint`.
  36. * The hash-to-group operation applies Elligator twice and adds the results.
  37. * **Note:** this is one-way map, there is no conversion from point to hash.
  38. * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-ristretto255-decaf448-07#name-element-derivation-2
  39. * @param hex 112-byte output of a hash function
  40. */
  41. static hashToCurve(hex: Hex): DcfPoint;
  42. /**
  43. * Converts decaf-encoded string to decaf point.
  44. * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-ristretto255-decaf448-07#name-decode-2
  45. * @param hex Decaf-encoded 56 bytes. Not every 56-byte string is valid decaf encoding
  46. */
  47. static fromHex(hex: Hex): DcfPoint;
  48. /**
  49. * Encodes decaf point to Uint8Array.
  50. * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-ristretto255-decaf448-07#name-encode-2
  51. */
  52. toRawBytes(): Uint8Array;
  53. toHex(): string;
  54. toString(): string;
  55. equals(other: DcfPoint): boolean;
  56. add(other: DcfPoint): DcfPoint;
  57. subtract(other: DcfPoint): DcfPoint;
  58. multiply(scalar: bigint): DcfPoint;
  59. multiplyUnsafe(scalar: bigint): DcfPoint;
  60. double(): DcfPoint;
  61. negate(): DcfPoint;
  62. }
  63. export declare const DecafPoint: typeof DcfPoint;
  64. export declare const hashToDecaf448: (msg: Uint8Array, options: htfBasicOpts) => DcfPoint;
  65. export declare const hash_to_decaf448: (msg: Uint8Array, options: htfBasicOpts) => DcfPoint;
  66. export {};
  67. //# sourceMappingURL=ed448.d.ts.map