_shortw_utils.js 849 B

123456789101112131415161718192021
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.getHash = getHash;
  4. exports.createCurve = createCurve;
  5. /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
  6. const hmac_1 = require("@noble/hashes/hmac");
  7. const utils_1 = require("@noble/hashes/utils");
  8. const weierstrass_js_1 = require("./abstract/weierstrass.js");
  9. // connects noble-curves to noble-hashes
  10. function getHash(hash) {
  11. return {
  12. hash,
  13. hmac: (key, ...msgs) => (0, hmac_1.hmac)(hash, key, (0, utils_1.concatBytes)(...msgs)),
  14. randomBytes: utils_1.randomBytes,
  15. };
  16. }
  17. function createCurve(curveDef, defHash) {
  18. const create = (hash) => (0, weierstrass_js_1.weierstrass)({ ...curveDef, ...getHash(hash) });
  19. return Object.freeze({ ...create(defHash), create });
  20. }
  21. //# sourceMappingURL=_shortw_utils.js.map