_shortw_utils.js 663 B

1234567891011121314151617
  1. /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
  2. import { hmac } from '@noble/hashes/hmac';
  3. import { concatBytes, randomBytes } from '@noble/hashes/utils';
  4. import { weierstrass } from './abstract/weierstrass.js';
  5. // connects noble-curves to noble-hashes
  6. export function getHash(hash) {
  7. return {
  8. hash,
  9. hmac: (key, ...msgs) => hmac(hash, key, concatBytes(...msgs)),
  10. randomBytes,
  11. };
  12. }
  13. export function createCurve(curveDef, defHash) {
  14. const create = (hash) => weierstrass({ ...curveDef, ...getHash(hash) });
  15. return Object.freeze({ ...create(defHash), create });
  16. }
  17. //# sourceMappingURL=_shortw_utils.js.map