@blamejs/blamejs-shop 0.5.12 → 0.5.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (522) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/lib/asset-manifest.json +1 -1
  3. package/lib/sales-tax-filings.js +143 -0
  4. package/lib/vendor/MANIFEST.json +632 -416
  5. package/lib/vendor/blamejs/.clusterfuzzlite/Dockerfile +21 -10
  6. package/lib/vendor/blamejs/.clusterfuzzlite/build.sh +30 -9
  7. package/lib/vendor/blamejs/.github/dependabot.yml +8 -0
  8. package/lib/vendor/blamejs/.github/workflows/actions-lint.yml +3 -3
  9. package/lib/vendor/blamejs/.github/workflows/cflite_batch.yml +7 -2
  10. package/lib/vendor/blamejs/.github/workflows/cflite_pr.yml +7 -2
  11. package/lib/vendor/blamejs/.github/workflows/ci.yml +21 -21
  12. package/lib/vendor/blamejs/.github/workflows/codeql.yml +3 -3
  13. package/lib/vendor/blamejs/.github/workflows/npm-publish.yml +4 -4
  14. package/lib/vendor/blamejs/.github/workflows/release-container.yml +7 -7
  15. package/lib/vendor/blamejs/.github/workflows/scorecard.yml +3 -3
  16. package/lib/vendor/blamejs/.github/workflows/sha-to-tag-verify.yml +1 -1
  17. package/lib/vendor/blamejs/.gitignore +2 -0
  18. package/lib/vendor/blamejs/CHANGELOG.md +122 -0
  19. package/lib/vendor/blamejs/NOTICE +26 -1
  20. package/lib/vendor/blamejs/SECURITY.md +1 -1
  21. package/lib/vendor/blamejs/api-snapshot.json +207 -5
  22. package/lib/vendor/blamejs/docker/keycloak/realm-blamejs-test.json +29 -0
  23. package/lib/vendor/blamejs/examples/wiki/DEPLOY.md +1 -0
  24. package/lib/vendor/blamejs/examples/wiki/lib/build-app.js +31 -0
  25. package/lib/vendor/blamejs/examples/wiki/lib/source-comment-block-validator.js +109 -0
  26. package/lib/vendor/blamejs/examples/wiki/nginx.conf +106 -0
  27. package/lib/vendor/blamejs/examples/wiki/package-lock.json +1 -1
  28. package/lib/vendor/blamejs/examples/wiki/test/e2e.js +92 -0
  29. package/lib/vendor/blamejs/fuzz/asn1-der.fuzz.js +28 -0
  30. package/lib/vendor/blamejs/fuzz/cms-codec.fuzz.js +17 -0
  31. package/lib/vendor/blamejs/fuzz/link-header.fuzz.js +18 -0
  32. package/lib/vendor/blamejs/index.js +6 -0
  33. package/lib/vendor/blamejs/lib/a2a.js +4 -4
  34. package/lib/vendor/blamejs/lib/agent-idempotency.js +18 -2
  35. package/lib/vendor/blamejs/lib/agent-saga.js +36 -8
  36. package/lib/vendor/blamejs/lib/agent-snapshot.js +63 -6
  37. package/lib/vendor/blamejs/lib/app-shutdown.js +23 -20
  38. package/lib/vendor/blamejs/lib/archive-read.js +8 -0
  39. package/lib/vendor/blamejs/lib/archive-tar.js +12 -2
  40. package/lib/vendor/blamejs/lib/arg-parser.js +49 -5
  41. package/lib/vendor/blamejs/lib/asn1-der.js +12 -0
  42. package/lib/vendor/blamejs/lib/audit-sign.js +47 -1
  43. package/lib/vendor/blamejs/lib/audit.js +71 -8
  44. package/lib/vendor/blamejs/lib/auth/ciba.js +14 -2
  45. package/lib/vendor/blamejs/lib/auth/fido-mds3.js +58 -47
  46. package/lib/vendor/blamejs/lib/auth/jwt.js +34 -0
  47. package/lib/vendor/blamejs/lib/auth/oauth.js +90 -13
  48. package/lib/vendor/blamejs/lib/auth/oid4vci.js +20 -17
  49. package/lib/vendor/blamejs/lib/auth/openid-federation.js +214 -23
  50. package/lib/vendor/blamejs/lib/auth/saml.js +38 -20
  51. package/lib/vendor/blamejs/lib/auth/sd-jwt-vc.js +10 -4
  52. package/lib/vendor/blamejs/lib/backup/bundle.js +13 -3
  53. package/lib/vendor/blamejs/lib/backup/index.js +16 -5
  54. package/lib/vendor/blamejs/lib/backup/manifest.js +18 -5
  55. package/lib/vendor/blamejs/lib/base32.js +21 -0
  56. package/lib/vendor/blamejs/lib/break-glass.js +19 -10
  57. package/lib/vendor/blamejs/lib/bundler.js +5 -1
  58. package/lib/vendor/blamejs/lib/cache-status.js +3 -7
  59. package/lib/vendor/blamejs/lib/calendar.js +21 -1
  60. package/lib/vendor/blamejs/lib/cbor.js +12 -1
  61. package/lib/vendor/blamejs/lib/cert.js +29 -11
  62. package/lib/vendor/blamejs/lib/cli.js +94 -24
  63. package/lib/vendor/blamejs/lib/cloud-events.js +2 -2
  64. package/lib/vendor/blamejs/lib/cluster-provider-db.js +13 -3
  65. package/lib/vendor/blamejs/lib/codepoint-class.js +85 -0
  66. package/lib/vendor/blamejs/lib/compliance-ai-act-prohibited.js +8 -4
  67. package/lib/vendor/blamejs/lib/compliance-ai-act-transparency.js +19 -4
  68. package/lib/vendor/blamejs/lib/compliance-ai-act.js +6 -8
  69. package/lib/vendor/blamejs/lib/content-credentials.js +1 -1
  70. package/lib/vendor/blamejs/lib/content-digest.js +2 -1
  71. package/lib/vendor/blamejs/lib/cookies.js +13 -3
  72. package/lib/vendor/blamejs/lib/cose.js +31 -16
  73. package/lib/vendor/blamejs/lib/crypto-field.js +32 -0
  74. package/lib/vendor/blamejs/lib/crypto-oprf.js +11 -2
  75. package/lib/vendor/blamejs/lib/crypto-xwing.js +22 -4
  76. package/lib/vendor/blamejs/lib/crypto.js +314 -19
  77. package/lib/vendor/blamejs/lib/csp.js +11 -3
  78. package/lib/vendor/blamejs/lib/daemon.js +270 -24
  79. package/lib/vendor/blamejs/lib/dark-patterns.js +5 -2
  80. package/lib/vendor/blamejs/lib/db-declare-view.js +2 -2
  81. package/lib/vendor/blamejs/lib/db-query.js +34 -7
  82. package/lib/vendor/blamejs/lib/db.js +18 -6
  83. package/lib/vendor/blamejs/lib/dbsc.js +17 -0
  84. package/lib/vendor/blamejs/lib/dev.js +21 -2
  85. package/lib/vendor/blamejs/lib/dsr.js +157 -102
  86. package/lib/vendor/blamejs/lib/external-db.js +41 -2
  87. package/lib/vendor/blamejs/lib/file-upload.js +25 -7
  88. package/lib/vendor/blamejs/lib/flag-providers.js +27 -15
  89. package/lib/vendor/blamejs/lib/forms.js +113 -27
  90. package/lib/vendor/blamejs/lib/gate-contract.js +23 -10
  91. package/lib/vendor/blamejs/lib/gdpr-ropa.js +8 -1
  92. package/lib/vendor/blamejs/lib/guard-agent-registry.js +1 -1
  93. package/lib/vendor/blamejs/lib/guard-archive.js +2 -2
  94. package/lib/vendor/blamejs/lib/guard-cidr.js +27 -1
  95. package/lib/vendor/blamejs/lib/guard-graphql.js +30 -11
  96. package/lib/vendor/blamejs/lib/guard-html.js +26 -53
  97. package/lib/vendor/blamejs/lib/guard-image.js +24 -5
  98. package/lib/vendor/blamejs/lib/guard-imap-command.js +10 -2
  99. package/lib/vendor/blamejs/lib/guard-jmap.js +19 -3
  100. package/lib/vendor/blamejs/lib/guard-jwt.js +18 -2
  101. package/lib/vendor/blamejs/lib/guard-list-unsubscribe.js +2 -2
  102. package/lib/vendor/blamejs/lib/guard-managesieve-command.js +10 -2
  103. package/lib/vendor/blamejs/lib/guard-markdown.js +11 -24
  104. package/lib/vendor/blamejs/lib/guard-pdf.js +18 -2
  105. package/lib/vendor/blamejs/lib/guard-pop3-command.js +10 -2
  106. package/lib/vendor/blamejs/lib/guard-regex.js +8 -5
  107. package/lib/vendor/blamejs/lib/guard-svg.js +31 -32
  108. package/lib/vendor/blamejs/lib/guard-time.js +1 -1
  109. package/lib/vendor/blamejs/lib/guard-uuid.js +2 -2
  110. package/lib/vendor/blamejs/lib/html-balance.js +3 -3
  111. package/lib/vendor/blamejs/lib/http-client-cache.js +82 -4
  112. package/lib/vendor/blamejs/lib/http-client-cookie-jar.js +16 -1
  113. package/lib/vendor/blamejs/lib/http-client.js +39 -7
  114. package/lib/vendor/blamejs/lib/http-message-signature.js +35 -1
  115. package/lib/vendor/blamejs/lib/i18n-messageformat.js +31 -6
  116. package/lib/vendor/blamejs/lib/i18n.js +35 -21
  117. package/lib/vendor/blamejs/lib/incident-report.js +8 -1
  118. package/lib/vendor/blamejs/lib/ip-utils.js +11 -1
  119. package/lib/vendor/blamejs/lib/json-path.js +23 -1
  120. package/lib/vendor/blamejs/lib/jwk.js +20 -3
  121. package/lib/vendor/blamejs/lib/link-header.js +2 -1
  122. package/lib/vendor/blamejs/lib/log-stream-otlp-grpc.js +5 -1
  123. package/lib/vendor/blamejs/lib/log-stream-otlp.js +5 -1
  124. package/lib/vendor/blamejs/lib/log-stream.js +8 -3
  125. package/lib/vendor/blamejs/lib/mail-auth.js +123 -22
  126. package/lib/vendor/blamejs/lib/mail-bimi.js +1 -1
  127. package/lib/vendor/blamejs/lib/mail-bounce.js +8 -0
  128. package/lib/vendor/blamejs/lib/mail-crypto-pgp.js +46 -10
  129. package/lib/vendor/blamejs/lib/mail-dav.js +22 -3
  130. package/lib/vendor/blamejs/lib/mail-dkim.js +96 -30
  131. package/lib/vendor/blamejs/lib/mail-helo.js +6 -1
  132. package/lib/vendor/blamejs/lib/mail-scan.js +23 -16
  133. package/lib/vendor/blamejs/lib/mail-send-deliver.js +34 -8
  134. package/lib/vendor/blamejs/lib/mail-server-imap.js +3 -4
  135. package/lib/vendor/blamejs/lib/mail-server-managesieve.js +7 -11
  136. package/lib/vendor/blamejs/lib/mail-server-mx.js +93 -7
  137. package/lib/vendor/blamejs/lib/mail-server-registry.js +8 -2
  138. package/lib/vendor/blamejs/lib/mail.js +15 -5
  139. package/lib/vendor/blamejs/lib/metrics.js +268 -63
  140. package/lib/vendor/blamejs/lib/middleware/age-gate.js +7 -1
  141. package/lib/vendor/blamejs/lib/middleware/asyncapi-serve.js +1 -1
  142. package/lib/vendor/blamejs/lib/middleware/body-parser.js +19 -4
  143. package/lib/vendor/blamejs/lib/middleware/bot-guard.js +5 -9
  144. package/lib/vendor/blamejs/lib/middleware/csp-report.js +40 -8
  145. package/lib/vendor/blamejs/lib/middleware/csrf-protect.js +24 -10
  146. package/lib/vendor/blamejs/lib/middleware/dpop.js +10 -5
  147. package/lib/vendor/blamejs/lib/middleware/index.js +6 -1
  148. package/lib/vendor/blamejs/lib/middleware/nel.js +1 -1
  149. package/lib/vendor/blamejs/lib/middleware/openapi-serve.js +1 -1
  150. package/lib/vendor/blamejs/lib/middleware/rate-limit.js +12 -1
  151. package/lib/vendor/blamejs/lib/middleware/require-bound-key.js +1 -1
  152. package/lib/vendor/blamejs/lib/middleware/scim-server.js +1 -1
  153. package/lib/vendor/blamejs/lib/middleware/tus-upload.js +6 -2
  154. package/lib/vendor/blamejs/lib/mtls-ca.js +18 -2
  155. package/lib/vendor/blamejs/lib/network-dns-resolver.js +11 -1
  156. package/lib/vendor/blamejs/lib/network-dns.js +21 -2
  157. package/lib/vendor/blamejs/lib/network-tls.js +69 -7
  158. package/lib/vendor/blamejs/lib/nonce-store.js +9 -1
  159. package/lib/vendor/blamejs/lib/object-store/gcs.js +7 -0
  160. package/lib/vendor/blamejs/lib/object-store/sigv4.js +31 -0
  161. package/lib/vendor/blamejs/lib/observability-otlp-exporter.js +1 -1
  162. package/lib/vendor/blamejs/lib/outbox.js +1 -1
  163. package/lib/vendor/blamejs/lib/parsers/safe-ini.js +9 -1
  164. package/lib/vendor/blamejs/lib/parsers/safe-toml.js +10 -1
  165. package/lib/vendor/blamejs/lib/permissions.js +6 -3
  166. package/lib/vendor/blamejs/lib/pid-probe.js +55 -0
  167. package/lib/vendor/blamejs/lib/pqc-agent.js +8 -1
  168. package/lib/vendor/blamejs/lib/pqc-software.js +3 -3
  169. package/lib/vendor/blamejs/lib/pubsub.js +20 -9
  170. package/lib/vendor/blamejs/lib/queue-local.js +8 -1
  171. package/lib/vendor/blamejs/lib/queue-redis.js +5 -0
  172. package/lib/vendor/blamejs/lib/redact.js +54 -0
  173. package/lib/vendor/blamejs/lib/restore-bundle.js +10 -2
  174. package/lib/vendor/blamejs/lib/restore.js +19 -0
  175. package/lib/vendor/blamejs/lib/retention.js +12 -4
  176. package/lib/vendor/blamejs/lib/router.js +60 -6
  177. package/lib/vendor/blamejs/lib/safe-buffer.js +69 -0
  178. package/lib/vendor/blamejs/lib/safe-decompress.js +8 -2
  179. package/lib/vendor/blamejs/lib/safe-dns.js +25 -20
  180. package/lib/vendor/blamejs/lib/safe-ical.js +7 -3
  181. package/lib/vendor/blamejs/lib/safe-mime.js +12 -1
  182. package/lib/vendor/blamejs/lib/safe-object.js +80 -0
  183. package/lib/vendor/blamejs/lib/safe-path.js +52 -4
  184. package/lib/vendor/blamejs/lib/safe-redirect.js +10 -2
  185. package/lib/vendor/blamejs/lib/safe-schema.js +4 -1
  186. package/lib/vendor/blamejs/lib/safe-sieve.js +33 -1
  187. package/lib/vendor/blamejs/lib/safe-sql.js +88 -0
  188. package/lib/vendor/blamejs/lib/safe-vcard.js +7 -3
  189. package/lib/vendor/blamejs/lib/scheduler.js +8 -1
  190. package/lib/vendor/blamejs/lib/security-assert.js +6 -6
  191. package/lib/vendor/blamejs/lib/self-update-standalone-verifier.js +74 -27
  192. package/lib/vendor/blamejs/lib/self-update.js +517 -87
  193. package/lib/vendor/blamejs/lib/server-timing.js +2 -4
  194. package/lib/vendor/blamejs/lib/session.js +34 -12
  195. package/lib/vendor/blamejs/lib/sql.js +15 -1
  196. package/lib/vendor/blamejs/lib/ssrf-guard.js +52 -0
  197. package/lib/vendor/blamejs/lib/static.js +55 -13
  198. package/lib/vendor/blamejs/lib/storage.js +8 -2
  199. package/lib/vendor/blamejs/lib/subject.js +6 -1
  200. package/lib/vendor/blamejs/lib/tenant-quota.js +52 -13
  201. package/lib/vendor/blamejs/lib/tls-exporter.js +3 -3
  202. package/lib/vendor/blamejs/lib/tsa.js +34 -13
  203. package/lib/vendor/blamejs/lib/uri-template.js +8 -1
  204. package/lib/vendor/blamejs/lib/vault/index.js +13 -0
  205. package/lib/vendor/blamejs/lib/vc.js +44 -5
  206. package/lib/vendor/blamejs/lib/vendor/MANIFEST.json +26 -26
  207. package/lib/vendor/blamejs/lib/vendor/noble-ciphers.cjs +792 -1
  208. package/lib/vendor/blamejs/lib/vendor/noble-curves.cjs +3443 -1
  209. package/lib/vendor/blamejs/lib/vendor/noble-post-quantum.cjs +2737 -1
  210. package/lib/vendor/blamejs/lib/vendor/pki.cjs +39550 -13
  211. package/lib/vendor/blamejs/lib/vendor/public-suffix-list.dat +55 -53
  212. package/lib/vendor/blamejs/lib/vendor/public-suffix-list.data.js +5551 -5554
  213. package/lib/vendor/blamejs/lib/vendor/simplewebauthn-server.cjs +22459 -32
  214. package/lib/vendor/blamejs/lib/watcher.js +89 -17
  215. package/lib/vendor/blamejs/lib/webhook-dispatcher.js +25 -3
  216. package/lib/vendor/blamejs/lib/webhook.js +12 -2
  217. package/lib/vendor/blamejs/lib/ws-client.js +32 -1
  218. package/lib/vendor/blamejs/lib/xml-c14n.js +29 -1
  219. package/lib/vendor/blamejs/oss-fuzz/projects/blamejs/Dockerfile +1 -1
  220. package/lib/vendor/blamejs/package-lock.json +2 -2
  221. package/lib/vendor/blamejs/package.json +1 -1
  222. package/lib/vendor/blamejs/release-notes/v0.16.x.json +1462 -0
  223. package/lib/vendor/blamejs/release-notes/v0.17.0.json +31 -0
  224. package/lib/vendor/blamejs/release-notes/v0.17.1.json +31 -0
  225. package/lib/vendor/blamejs/release-notes/v0.17.10.json +30 -0
  226. package/lib/vendor/blamejs/release-notes/v0.17.11.json +22 -0
  227. package/lib/vendor/blamejs/release-notes/v0.17.12.json +18 -0
  228. package/lib/vendor/blamejs/release-notes/v0.17.13.json +77 -0
  229. package/lib/vendor/blamejs/release-notes/v0.17.14.json +40 -0
  230. package/lib/vendor/blamejs/release-notes/v0.17.15.json +18 -0
  231. package/lib/vendor/blamejs/release-notes/v0.17.16.json +27 -0
  232. package/lib/vendor/blamejs/release-notes/v0.17.17.json +31 -0
  233. package/lib/vendor/blamejs/release-notes/v0.17.18.json +18 -0
  234. package/lib/vendor/blamejs/release-notes/v0.17.19.json +18 -0
  235. package/lib/vendor/blamejs/release-notes/v0.17.2.json +26 -0
  236. package/lib/vendor/blamejs/release-notes/v0.17.20.json +43 -0
  237. package/lib/vendor/blamejs/release-notes/v0.17.21.json +26 -0
  238. package/lib/vendor/blamejs/release-notes/v0.17.22.json +18 -0
  239. package/lib/vendor/blamejs/release-notes/v0.17.3.json +43 -0
  240. package/lib/vendor/blamejs/release-notes/v0.17.4.json +35 -0
  241. package/lib/vendor/blamejs/release-notes/v0.17.5.json +26 -0
  242. package/lib/vendor/blamejs/release-notes/v0.17.6.json +26 -0
  243. package/lib/vendor/blamejs/release-notes/v0.17.7.json +35 -0
  244. package/lib/vendor/blamejs/release-notes/v0.17.8.json +22 -0
  245. package/lib/vendor/blamejs/release-notes/v0.17.9.json +26 -0
  246. package/lib/vendor/blamejs/scripts/validate-source-comment-blocks.js +4 -0
  247. package/lib/vendor/blamejs/scripts/vendor-update.sh +293 -9
  248. package/lib/vendor/blamejs/socket.yml +94 -0
  249. package/lib/vendor/blamejs/test/00-primitives.js +605 -0
  250. package/lib/vendor/blamejs/test/helpers/drivers.js +12 -9
  251. package/lib/vendor/blamejs/test/integration/audit-stack-mysql.test.js +90 -1
  252. package/lib/vendor/blamejs/test/integration/audit-stack-postgres.test.js +122 -1
  253. package/lib/vendor/blamejs/test/integration/data-layer-mysql.test.js +30 -0
  254. package/lib/vendor/blamejs/test/integration/data-layer-pg.test.js +29 -0
  255. package/lib/vendor/blamejs/test/integration/dsr-cluster-mysql.test.js +479 -0
  256. package/lib/vendor/blamejs/test/integration/dsr-cluster-pg.test.js +487 -0
  257. package/lib/vendor/blamejs/test/integration/federation-auth.test.js +313 -5
  258. package/lib/vendor/blamejs/test/integration/mail-dkim.test.js +80 -0
  259. package/lib/vendor/blamejs/test/integration/openid-federation-chain.test.js +275 -0
  260. package/lib/vendor/blamejs/test/integration/webhook-dispatcher-pg.test.js +96 -0
  261. package/lib/vendor/blamejs/test/layer-0-primitives/a2a-tasks.test.js +401 -0
  262. package/lib/vendor/blamejs/test/layer-0-primitives/acme.test.js +1649 -2
  263. package/lib/vendor/blamejs/test/layer-0-primitives/age-gate.test.js +33 -0
  264. package/lib/vendor/blamejs/test/layer-0-primitives/agent-idempotency.test.js +0 -0
  265. package/lib/vendor/blamejs/test/layer-0-primitives/agent-saga.test.js +60 -0
  266. package/lib/vendor/blamejs/test/layer-0-primitives/agent-snapshot.test.js +524 -0
  267. package/lib/vendor/blamejs/test/layer-0-primitives/api-encrypt.test.js +891 -0
  268. package/lib/vendor/blamejs/test/layer-0-primitives/app-shutdown.test.js +128 -1
  269. package/lib/vendor/blamejs/test/layer-0-primitives/archive-adapters.test.js +271 -0
  270. package/lib/vendor/blamejs/test/layer-0-primitives/archive-read.test.js +628 -1
  271. package/lib/vendor/blamejs/test/layer-0-primitives/archive-tar-read.test.js +0 -0
  272. package/lib/vendor/blamejs/test/layer-0-primitives/archive-wrap.test.js +227 -0
  273. package/lib/vendor/blamejs/test/layer-0-primitives/arg-parser.test.js +15 -0
  274. package/lib/vendor/blamejs/test/layer-0-primitives/asn1-der.test.js +73 -0
  275. package/lib/vendor/blamejs/test/layer-0-primitives/atomic-file.test.js +114 -0
  276. package/lib/vendor/blamejs/test/layer-0-primitives/audit-sign-anchor.test.js +141 -0
  277. package/lib/vendor/blamejs/test/layer-0-primitives/audit-tools.test.js +624 -0
  278. package/lib/vendor/blamejs/test/layer-0-primitives/audit.test.js +769 -0
  279. package/lib/vendor/blamejs/test/layer-0-primitives/auth-jwt-defenses.test.js +436 -0
  280. package/lib/vendor/blamejs/test/layer-0-primitives/auth-oauth.test.js +1697 -0
  281. package/lib/vendor/blamejs/test/layer-0-primitives/auth-oid4vp.test.js +495 -0
  282. package/lib/vendor/blamejs/test/layer-0-primitives/auth-password.test.js +500 -0
  283. package/lib/vendor/blamejs/test/layer-0-primitives/auth-saml.test.js +1809 -0
  284. package/lib/vendor/blamejs/test/layer-0-primitives/auth-status-list.test.js +243 -1
  285. package/lib/vendor/blamejs/test/layer-0-primitives/backup-index.test.js +2226 -0
  286. package/lib/vendor/blamejs/test/layer-0-primitives/backup-manifest-signature.test.js +183 -0
  287. package/lib/vendor/blamejs/test/layer-0-primitives/base32.test.js +105 -0
  288. package/lib/vendor/blamejs/test/layer-0-primitives/break-glass.test.js +693 -0
  289. package/lib/vendor/blamejs/test/layer-0-primitives/cache.test.js +603 -0
  290. package/lib/vendor/blamejs/test/layer-0-primitives/calendar.test.js +557 -0
  291. package/lib/vendor/blamejs/test/layer-0-primitives/case-insensitive-security-token-guard.test.js +214 -0
  292. package/lib/vendor/blamejs/test/layer-0-primitives/cbor.test.js +25 -0
  293. package/lib/vendor/blamejs/test/layer-0-primitives/cert.test.js +843 -6
  294. package/lib/vendor/blamejs/test/layer-0-primitives/ciba-authreqid-binding.test.js +77 -2
  295. package/lib/vendor/blamejs/test/layer-0-primitives/ciba.test.js +866 -0
  296. package/lib/vendor/blamejs/test/layer-0-primitives/clear-site-data.test.js +18 -0
  297. package/lib/vendor/blamejs/test/layer-0-primitives/cli-erase.test.js +19 -0
  298. package/lib/vendor/blamejs/test/layer-0-primitives/cli.test.js +2790 -0
  299. package/lib/vendor/blamejs/test/layer-0-primitives/cluster-lease-renewal-ttl.test.js +114 -0
  300. package/lib/vendor/blamejs/test/layer-0-primitives/cluster.test.js +1032 -0
  301. package/lib/vendor/blamejs/test/layer-0-primitives/cms-codec.test.js +575 -0
  302. package/lib/vendor/blamejs/test/layer-0-primitives/codebase-patterns.test.js +739 -1
  303. package/lib/vendor/blamejs/test/layer-0-primitives/codepoint-class.test.js +8 -0
  304. package/lib/vendor/blamejs/test/layer-0-primitives/compliance-ai-act.test.js +194 -0
  305. package/lib/vendor/blamejs/test/layer-0-primitives/compliance-lifecycle-proto-key.test.js +104 -0
  306. package/lib/vendor/blamejs/test/layer-0-primitives/compliance-sanctions.test.js +254 -0
  307. package/lib/vendor/blamejs/test/layer-0-primitives/content-credentials.test.js +613 -3
  308. package/lib/vendor/blamejs/test/layer-0-primitives/cookies.test.js +140 -0
  309. package/lib/vendor/blamejs/test/layer-0-primitives/cose.test.js +407 -0
  310. package/lib/vendor/blamejs/test/layer-0-primitives/crypto-adversarial.test.js +352 -0
  311. package/lib/vendor/blamejs/test/layer-0-primitives/crypto-field-derived-hash.test.js +32 -0
  312. package/lib/vendor/blamejs/test/layer-0-primitives/crypto-field.test.js +575 -0
  313. package/lib/vendor/blamejs/test/layer-0-primitives/crypto-hash-files-parallel.test.js +10 -0
  314. package/lib/vendor/blamejs/test/layer-0-primitives/crypto-hash-stream.test.js +24 -0
  315. package/lib/vendor/blamejs/test/layer-0-primitives/crypto-oprf.test.js +17 -0
  316. package/lib/vendor/blamejs/test/layer-0-primitives/crypto-spki-pin.test.js +183 -0
  317. package/lib/vendor/blamejs/test/layer-0-primitives/crypto-xwing.test.js +48 -0
  318. package/lib/vendor/blamejs/test/layer-0-primitives/crypto.test.js +345 -0
  319. package/lib/vendor/blamejs/test/layer-0-primitives/csp-report.test.js +58 -0
  320. package/lib/vendor/blamejs/test/layer-0-primitives/csv.test.js +48 -0
  321. package/lib/vendor/blamejs/test/layer-0-primitives/daemon.test.js +459 -1
  322. package/lib/vendor/blamejs/test/layer-0-primitives/dark-patterns.test.js +19 -0
  323. package/lib/vendor/blamejs/test/layer-0-primitives/db-query.test.js +1019 -0
  324. package/lib/vendor/blamejs/test/layer-0-primitives/db-raw-residency-gate.test.js +77 -0
  325. package/lib/vendor/blamejs/test/layer-0-primitives/db.test.js +1621 -0
  326. package/lib/vendor/blamejs/test/layer-0-primitives/ddl-change-control.test.js +462 -3
  327. package/lib/vendor/blamejs/test/layer-0-primitives/dnssec.test.js +323 -0
  328. package/lib/vendor/blamejs/test/layer-0-primitives/dpop-middleware-verify.test.js +562 -0
  329. package/lib/vendor/blamejs/test/layer-0-primitives/dsr.test.js +901 -1
  330. package/lib/vendor/blamejs/test/layer-0-primitives/dual-control.test.js +249 -0
  331. package/lib/vendor/blamejs/test/layer-0-primitives/external-db-migrate.test.js +561 -0
  332. package/lib/vendor/blamejs/test/layer-0-primitives/external-db.test.js +1214 -0
  333. package/lib/vendor/blamejs/test/layer-0-primitives/fal.test.js +21 -0
  334. package/lib/vendor/blamejs/test/layer-0-primitives/fedcm-dbsc.test.js +46 -20
  335. package/lib/vendor/blamejs/test/layer-0-primitives/federation-vc-suite.test.js +147 -3
  336. package/lib/vendor/blamejs/test/layer-0-primitives/fido-mds3.test.js +907 -38
  337. package/lib/vendor/blamejs/test/layer-0-primitives/file-upload-content-safety-skip-audit.test.js +29 -0
  338. package/lib/vendor/blamejs/test/layer-0-primitives/file-upload.test.js +1135 -0
  339. package/lib/vendor/blamejs/test/layer-0-primitives/flag.test.js +30 -0
  340. package/lib/vendor/blamejs/test/layer-0-primitives/forms.test.js +747 -0
  341. package/lib/vendor/blamejs/test/layer-0-primitives/gate-contract.test.js +1855 -0
  342. package/lib/vendor/blamejs/test/layer-0-primitives/gdpr-ropa.test.js +30 -0
  343. package/lib/vendor/blamejs/test/layer-0-primitives/guard-archive.test.js +86 -0
  344. package/lib/vendor/blamejs/test/layer-0-primitives/guard-auth.test.js +117 -0
  345. package/lib/vendor/blamejs/test/layer-0-primitives/guard-cidr.test.js +151 -0
  346. package/lib/vendor/blamejs/test/layer-0-primitives/guard-domain.test.js +422 -0
  347. package/lib/vendor/blamejs/test/layer-0-primitives/guard-filename.test.js +424 -0
  348. package/lib/vendor/blamejs/test/layer-0-primitives/{guard-gate-disposition-coverage.test.js → guard-gate-disposition.test.js} +1 -1
  349. package/lib/vendor/blamejs/test/layer-0-primitives/guard-graphql.test.js +340 -0
  350. package/lib/vendor/blamejs/test/layer-0-primitives/guard-html.test.js +29 -0
  351. package/lib/vendor/blamejs/test/layer-0-primitives/guard-idempotency-key.test.js +28 -0
  352. package/lib/vendor/blamejs/test/layer-0-primitives/guard-image.test.js +519 -45
  353. package/lib/vendor/blamejs/test/layer-0-primitives/guard-imap-command.test.js +0 -0
  354. package/lib/vendor/blamejs/test/layer-0-primitives/guard-jmap.test.js +51 -0
  355. package/lib/vendor/blamejs/test/layer-0-primitives/guard-jsonpath.test.js +66 -0
  356. package/lib/vendor/blamejs/test/layer-0-primitives/guard-jwt.test.js +436 -0
  357. package/lib/vendor/blamejs/test/layer-0-primitives/guard-managesieve-command.test.js +25 -0
  358. package/lib/vendor/blamejs/test/layer-0-primitives/guard-markdown.test.js +16 -0
  359. package/lib/vendor/blamejs/test/layer-0-primitives/guard-mime.test.js +86 -0
  360. package/lib/vendor/blamejs/test/layer-0-primitives/guard-oauth.test.js +140 -0
  361. package/lib/vendor/blamejs/test/layer-0-primitives/guard-pdf.test.js +80 -0
  362. package/lib/vendor/blamejs/test/layer-0-primitives/guard-pop3-command.test.js +27 -0
  363. package/lib/vendor/blamejs/test/layer-0-primitives/guard-regex.test.js +99 -0
  364. package/lib/vendor/blamejs/test/layer-0-primitives/guard-shell.test.js +76 -0
  365. package/lib/vendor/blamejs/test/layer-0-primitives/{guard-sql-coverage.test.js → guard-sql.test.js} +3 -3
  366. package/lib/vendor/blamejs/test/layer-0-primitives/guard-svg.test.js +524 -0
  367. package/lib/vendor/blamejs/test/layer-0-primitives/guard-template.test.js +71 -0
  368. package/lib/vendor/blamejs/test/layer-0-primitives/guard-time.test.js +92 -0
  369. package/lib/vendor/blamejs/test/layer-0-primitives/guard-uuid.test.js +86 -0
  370. package/lib/vendor/blamejs/test/layer-0-primitives/html-balance.test.js +38 -0
  371. package/lib/vendor/blamejs/test/layer-0-primitives/http-client-cache-authorization.test.js +347 -0
  372. package/lib/vendor/blamejs/test/layer-0-primitives/http-client-cache.test.js +908 -0
  373. package/lib/vendor/blamejs/test/layer-0-primitives/http-client.test.js +2874 -0
  374. package/lib/vendor/blamejs/test/layer-0-primitives/http-message-signature.test.js +643 -0
  375. package/lib/vendor/blamejs/test/layer-0-primitives/i18n-messageformat.test.js +38 -0
  376. package/lib/vendor/blamejs/test/layer-0-primitives/i18n.test.js +1153 -1
  377. package/lib/vendor/blamejs/test/layer-0-primitives/idempotency-key.test.js +494 -0
  378. package/lib/vendor/blamejs/test/layer-0-primitives/ip-utils.test.js +30 -0
  379. package/lib/vendor/blamejs/test/layer-0-primitives/jsdoc-example-execution.test.js +177 -0
  380. package/lib/vendor/blamejs/test/layer-0-primitives/json-path.test.js +103 -0
  381. package/lib/vendor/blamejs/test/layer-0-primitives/json-schema.test.js +214 -0
  382. package/lib/vendor/blamejs/test/layer-0-primitives/jwk.test.js +41 -0
  383. package/lib/vendor/blamejs/test/layer-0-primitives/jwt-external.test.js +276 -0
  384. package/lib/vendor/blamejs/test/layer-0-primitives/keychain.test.js +0 -0
  385. package/lib/vendor/blamejs/test/layer-0-primitives/log-stream.test.js +241 -0
  386. package/lib/vendor/blamejs/test/layer-0-primitives/log.test.js +106 -0
  387. package/lib/vendor/blamejs/test/layer-0-primitives/mail-agent.test.js +441 -0
  388. package/lib/vendor/blamejs/test/layer-0-primitives/mail-auth.test.js +2136 -4
  389. package/lib/vendor/blamejs/test/layer-0-primitives/mail-bimi.test.js +759 -12
  390. package/lib/vendor/blamejs/test/layer-0-primitives/mail-bounce.test.js +811 -1
  391. package/lib/vendor/blamejs/test/layer-0-primitives/mail-crypto-pgp-experimental.test.js +401 -3
  392. package/lib/vendor/blamejs/test/layer-0-primitives/mail-crypto-pgp.test.js +751 -8
  393. package/lib/vendor/blamejs/test/layer-0-primitives/mail-crypto-smime.test.js +864 -0
  394. package/lib/vendor/blamejs/test/layer-0-primitives/mail-crypto.test.js +110 -0
  395. package/lib/vendor/blamejs/test/layer-0-primitives/mail-dav.test.js +830 -1
  396. package/lib/vendor/blamejs/test/layer-0-primitives/mail-deploy.test.js +635 -86
  397. package/lib/vendor/blamejs/test/layer-0-primitives/mail-dkim.test.js +818 -0
  398. package/lib/vendor/blamejs/test/layer-0-primitives/mail-helo.test.js +27 -0
  399. package/lib/vendor/blamejs/test/layer-0-primitives/mail-scan.test.js +199 -0
  400. package/lib/vendor/blamejs/test/layer-0-primitives/mail-send-deliver.test.js +686 -2
  401. package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-imap.test.js +778 -0
  402. package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-jmap.test.js +1438 -0
  403. package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-managesieve.test.js +449 -6
  404. package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-mx.test.js +773 -2
  405. package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-pop3.test.js +623 -3
  406. package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-rate-limit.test.js +55 -0
  407. package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-registry.test.js +13 -0
  408. package/lib/vendor/blamejs/test/layer-0-primitives/mail-server-submission.test.js +877 -1
  409. package/lib/vendor/blamejs/test/layer-0-primitives/mail-sieve.test.js +326 -0
  410. package/lib/vendor/blamejs/test/layer-0-primitives/mail-store-fts.test.js +55 -0
  411. package/lib/vendor/blamejs/test/layer-0-primitives/mail-store.test.js +242 -0
  412. package/lib/vendor/blamejs/test/layer-0-primitives/mail.test.js +1596 -2
  413. package/lib/vendor/blamejs/test/layer-0-primitives/mcp.test.js +440 -4
  414. package/lib/vendor/blamejs/test/layer-0-primitives/metrics-snapshot.test.js +89 -0
  415. package/lib/vendor/blamejs/test/layer-0-primitives/metrics.test.js +1230 -0
  416. package/lib/vendor/blamejs/test/layer-0-primitives/middleware-assetlinks.test.js +113 -0
  417. package/lib/vendor/blamejs/test/layer-0-primitives/middleware-body-parser.test.js +1169 -0
  418. package/lib/vendor/blamejs/test/layer-0-primitives/middleware-bot-disclose.test.js +123 -0
  419. package/lib/vendor/blamejs/test/layer-0-primitives/middleware-cookies.test.js +108 -0
  420. package/lib/vendor/blamejs/test/layer-0-primitives/middleware-gpc.test.js +121 -0
  421. package/lib/vendor/blamejs/test/layer-0-primitives/middleware-headers.test.js +163 -0
  422. package/lib/vendor/blamejs/test/layer-0-primitives/middleware-host-allowlist.test.js +154 -0
  423. package/lib/vendor/blamejs/test/layer-0-primitives/middleware-require-content-type.test.js +127 -0
  424. package/lib/vendor/blamejs/test/layer-0-primitives/{middleware-tus-upload-coverage.test.js → middleware-tus-upload.test.js} +45 -0
  425. package/lib/vendor/blamejs/test/layer-0-primitives/middleware-web-app-manifest.test.js +132 -0
  426. package/lib/vendor/blamejs/test/layer-0-primitives/mtls-ca-crl-fingerprint-only.test.js +92 -0
  427. package/lib/vendor/blamejs/test/layer-0-primitives/network-dns-resolver.test.js +65 -0
  428. package/lib/vendor/blamejs/test/layer-0-primitives/network-dns.test.js +1727 -1
  429. package/lib/vendor/blamejs/test/layer-0-primitives/network-nts.test.js +699 -0
  430. package/lib/vendor/blamejs/test/layer-0-primitives/network-smtp-policy.test.js +1181 -0
  431. package/lib/vendor/blamejs/test/layer-0-primitives/network-tls.test.js +1876 -3
  432. package/lib/vendor/blamejs/test/layer-0-primitives/network.test.js +32 -0
  433. package/lib/vendor/blamejs/test/layer-0-primitives/nonce-store-enforce-replay-nonboolean.test.js +81 -0
  434. package/lib/vendor/blamejs/test/layer-0-primitives/ntp-check.test.js +122 -0
  435. package/lib/vendor/blamejs/test/layer-0-primitives/observability-tracing.test.js +378 -0
  436. package/lib/vendor/blamejs/test/layer-0-primitives/observability.test.js +77 -0
  437. package/lib/vendor/blamejs/test/layer-0-primitives/oid4vci.test.js +1016 -0
  438. package/lib/vendor/blamejs/test/layer-0-primitives/openid-federation.test.js +946 -0
  439. package/lib/vendor/blamejs/test/layer-0-primitives/outbox.test.js +818 -0
  440. package/lib/vendor/blamejs/test/layer-0-primitives/own-property-membership-guards.test.js +109 -0
  441. package/lib/vendor/blamejs/test/layer-0-primitives/parsers-safe-toml.test.js +543 -0
  442. package/lib/vendor/blamejs/test/layer-0-primitives/{parsers-safe-yaml-coverage.test.js → parsers-safe-yaml.test.js} +2 -2
  443. package/lib/vendor/blamejs/test/layer-0-primitives/parsers-standalone.test.js +73 -0
  444. package/lib/vendor/blamejs/test/layer-0-primitives/passkey.test.js +649 -0
  445. package/lib/vendor/blamejs/test/layer-0-primitives/permissions.test.js +524 -0
  446. package/lib/vendor/blamejs/test/layer-0-primitives/pqc-agent-curve.test.js +22 -0
  447. package/lib/vendor/blamejs/test/layer-0-primitives/pubsub.test.js +295 -0
  448. package/lib/vendor/blamejs/test/layer-0-primitives/queue-flow-repeat.test.js +36 -0
  449. package/lib/vendor/blamejs/test/layer-0-primitives/queue.test.js +83 -0
  450. package/lib/vendor/blamejs/test/layer-0-primitives/rate-limit-xff-spoofing.test.js +34 -0
  451. package/lib/vendor/blamejs/test/layer-0-primitives/redact.test.js +1031 -0
  452. package/lib/vendor/blamejs/test/layer-0-primitives/request-helpers.test.js +94 -0
  453. package/lib/vendor/blamejs/test/layer-0-primitives/require-bound-key.test.js +401 -0
  454. package/lib/vendor/blamejs/test/layer-0-primitives/restore-empty-manifest-wipe.test.js +154 -0
  455. package/lib/vendor/blamejs/test/layer-0-primitives/retention.test.js +600 -0
  456. package/lib/vendor/blamejs/test/layer-0-primitives/router-host-path-injection.test.js +231 -0
  457. package/lib/vendor/blamejs/test/layer-0-primitives/router-tls0rtt.test.js +21 -0
  458. package/lib/vendor/blamejs/test/layer-0-primitives/router.test.js +1277 -0
  459. package/lib/vendor/blamejs/test/layer-0-primitives/safe-async.test.js +133 -0
  460. package/lib/vendor/blamejs/test/layer-0-primitives/safe-buffer-linear-scans.test.js +14 -0
  461. package/lib/vendor/blamejs/test/layer-0-primitives/safe-buffer.test.js +80 -0
  462. package/lib/vendor/blamejs/test/layer-0-primitives/safe-decompress.test.js +28 -0
  463. package/lib/vendor/blamejs/test/layer-0-primitives/safe-dns.test.js +245 -0
  464. package/lib/vendor/blamejs/test/layer-0-primitives/safe-ical.test.js +32 -0
  465. package/lib/vendor/blamejs/test/layer-0-primitives/safe-ini.test.js +376 -0
  466. package/lib/vendor/blamejs/test/layer-0-primitives/safe-json.test.js +175 -0
  467. package/lib/vendor/blamejs/test/layer-0-primitives/safe-mime.test.js +518 -0
  468. package/lib/vendor/blamejs/test/layer-0-primitives/safe-object.test.js +62 -0
  469. package/lib/vendor/blamejs/test/layer-0-primitives/safe-path.test.js +30 -0
  470. package/lib/vendor/blamejs/test/layer-0-primitives/safe-schema.test.js +104 -0
  471. package/lib/vendor/blamejs/test/layer-0-primitives/safe-sql.test.js +142 -0
  472. package/lib/vendor/blamejs/test/layer-0-primitives/safe-url.test.js +112 -0
  473. package/lib/vendor/blamejs/test/layer-0-primitives/safe-vcard.test.js +26 -0
  474. package/lib/vendor/blamejs/test/layer-0-primitives/scheduler.test.js +157 -0
  475. package/lib/vendor/blamejs/test/layer-0-primitives/scim-server.test.js +396 -0
  476. package/lib/vendor/blamejs/test/layer-0-primitives/sd-jwt-vc.test.js +930 -0
  477. package/lib/vendor/blamejs/test/layer-0-primitives/security-assert.test.js +755 -82
  478. package/lib/vendor/blamejs/test/layer-0-primitives/self-update.test.js +1053 -0
  479. package/lib/vendor/blamejs/test/layer-0-primitives/session-device-binding.test.js +200 -0
  480. package/lib/vendor/blamejs/test/layer-0-primitives/session-strict-binding-missing-failclosed.test.js +110 -0
  481. package/lib/vendor/blamejs/test/layer-0-primitives/sigv4-bucket-ops.test.js +636 -0
  482. package/lib/vendor/blamejs/test/layer-0-primitives/sql-offset-without-limit.test.js +94 -0
  483. package/lib/vendor/blamejs/test/layer-0-primitives/sql.test.js +1190 -0
  484. package/lib/vendor/blamejs/test/layer-0-primitives/ssrf-guard.test.js +21 -0
  485. package/lib/vendor/blamejs/test/layer-0-primitives/static.test.js +850 -0
  486. package/lib/vendor/blamejs/test/layer-0-primitives/storage-presigned-url.test.js +146 -0
  487. package/lib/vendor/blamejs/test/layer-0-primitives/storage.test.js +621 -0
  488. package/lib/vendor/blamejs/test/layer-0-primitives/subject.test.js +47 -0
  489. package/lib/vendor/blamejs/test/layer-0-primitives/template.test.js +582 -0
  490. package/lib/vendor/blamejs/test/layer-0-primitives/tenant-quota.test.js +587 -25
  491. package/lib/vendor/blamejs/test/layer-0-primitives/time.test.js +11 -0
  492. package/lib/vendor/blamejs/test/layer-0-primitives/tsa.test.js +524 -63
  493. package/lib/vendor/blamejs/test/layer-0-primitives/uri-template.test.js +27 -0
  494. package/lib/vendor/blamejs/test/layer-0-primitives/vault-rotate.test.js +866 -0
  495. package/lib/vendor/blamejs/test/layer-0-primitives/vault.test.js +74 -0
  496. package/lib/vendor/blamejs/test/layer-0-primitives/vc.test.js +215 -0
  497. package/lib/vendor/blamejs/test/layer-0-primitives/watcher.test.js +550 -0
  498. package/lib/vendor/blamejs/test/layer-0-primitives/webhook-dispatcher.test.js +388 -0
  499. package/lib/vendor/blamejs/test/layer-0-primitives/webhook.test.js +262 -0
  500. package/lib/vendor/blamejs/test/layer-0-primitives/websocket.test.js +1294 -0
  501. package/lib/vendor/blamejs/test/layer-0-primitives/ws-client.test.js +629 -0
  502. package/lib/vendor/blamejs/test/layer-0-primitives/xml-c14n-attr-normalization.test.js +164 -0
  503. package/lib/vendor/blamejs/test/smoke.js +2 -0
  504. package/package.json +1 -1
  505. package/lib/vendor/blamejs/release-notes/v0.16.0.json +0 -44
  506. package/lib/vendor/blamejs/release-notes/v0.16.1.json +0 -36
  507. package/lib/vendor/blamejs/release-notes/v0.16.2.json +0 -71
  508. package/lib/vendor/blamejs/release-notes/v0.16.3.json +0 -71
  509. package/lib/vendor/blamejs/test/layer-0-primitives/acme-coverage.test.js +0 -441
  510. package/lib/vendor/blamejs/test/layer-0-primitives/auth-oauth-coverage.test.js +0 -482
  511. package/lib/vendor/blamejs/test/layer-0-primitives/auth-saml-coverage.test.js +0 -671
  512. package/lib/vendor/blamejs/test/layer-0-primitives/backup-index-coverage.test.js +0 -690
  513. package/lib/vendor/blamejs/test/layer-0-primitives/cli-coverage.test.js +0 -238
  514. package/lib/vendor/blamejs/test/layer-0-primitives/content-credentials-coverage.test.js +0 -319
  515. package/lib/vendor/blamejs/test/layer-0-primitives/keychain-coverage.test.js +0 -0
  516. package/lib/vendor/blamejs/test/layer-0-primitives/mail-auth-coverage.test.js +0 -437
  517. package/lib/vendor/blamejs/test/layer-0-primitives/mcp-coverage.test.js +0 -443
  518. package/lib/vendor/blamejs/test/layer-0-primitives/metrics-coverage.test.js +0 -395
  519. package/lib/vendor/blamejs/test/layer-0-primitives/network-smtp-policy-coverage.test.js +0 -565
  520. package/lib/vendor/blamejs/test/layer-0-primitives/router-coverage.test.js +0 -592
  521. package/lib/vendor/blamejs/test/layer-0-primitives/sql-coverage.test.js +0 -422
  522. package/lib/vendor/blamejs/test/layer-0-primitives/test-coverage.test.js +0 -573
@@ -4,7 +4,3449 @@
4
4
  // ristretto255_oprf (ristretto255-SHA512), p256_oprf (P-256-SHA256),
5
5
  // p384_oprf (P-384-SHA384), p521_oprf (P-521-SHA512) — each with
6
6
  // oprf / voprf / poprf modes. Backs b.crypto.oprf.
7
- var Re=Object.defineProperty;var rr=Object.getOwnPropertyDescriptor;var or=Object.getOwnPropertyNames;var sr=Object.prototype.hasOwnProperty;var fr=(n,t)=>{for(var e in t)Re(n,e,{get:t[e],enumerable:!0})},ir=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of or(t))!sr.call(n,o)&&o!==e&&Re(n,o,{get:()=>t[o],enumerable:!(r=rr(t,o))||r.enumerable});return n};var cr=n=>ir(Re({},"__esModule",{value:!0}),n);var Xr={};fr(Xr,{p256_oprf:()=>tr,p384_oprf:()=>er,p521_oprf:()=>nr,ristretto255_oprf:()=>Gn});module.exports=cr(Xr);function Oe(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in n&&n.BYTES_PER_ELEMENT===1}function ne(n,t=""){if(typeof n!="number"){let e=t&&`"${t}" `;throw new TypeError(`${e}expected number, got ${typeof n}`)}if(!Number.isSafeInteger(n)||n<0){let e=t&&`"${t}" `;throw new RangeError(`${e}expected integer >= 0, got ${n}`)}}function ot(n,t,e=""){let r=Oe(n),o=n?.length,s=t!==void 0;if(!r||s&&o!==t){let f=e&&`"${e}" `,c=s?` of length ${t}`:"",a=r?`length=${o}`:`type=${typeof n}`,i=f+"expected Uint8Array"+c+", got "+a;throw r?new RangeError(i):new TypeError(i)}return n}function Te(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function cn(n,t){ot(n,void 0,"digestInto() output");let e=t.outputLen;if(n.length<e)throw new RangeError('"digestInto() output" expected to be of length >='+e)}function St(...n){for(let t=0;t<n.length;t++)n[t].fill(0)}function re(n){return new DataView(n.buffer,n.byteOffset,n.byteLength)}function st(n,t){return n<<32-t|n>>>t}var an=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ar=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function oe(n){if(ot(n),an)return n.toHex();let t="";for(let e=0;e<n.length;e++)t+=ar[n[e]];return t}var ut={_0:48,_9:57,A:65,F:70,a:97,f:102};function fn(n){if(n>=ut._0&&n<=ut._9)return n-ut._0;if(n>=ut.A&&n<=ut.F)return n-(ut.A-10);if(n>=ut.a&&n<=ut.f)return n-(ut.a-10)}function kt(n){if(typeof n!="string")throw new TypeError("hex string expected, got "+typeof n);if(an)try{return Uint8Array.fromHex(n)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let t=n.length,e=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let r=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let f=fn(n.charCodeAt(s)),c=fn(n.charCodeAt(s+1));if(f===void 0||c===void 0){let a=n[s]+n[s+1];throw new RangeError('hex string expected, got non-hex character "'+a+'" at index '+s)}r[o]=f*16+c}return r}function Ae(...n){let t=0;for(let r=0;r<n.length;r++){let o=n[r];ot(o),t+=o.length}let e=new Uint8Array(t);for(let r=0,o=0;r<n.length;r++){let s=n[r];e.set(s,o),o+=s.length}return e}function se(n,t={}){let e=(o,s)=>n(s).update(o).digest(),r=n(void 0);return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.canXOF=r.canXOF,e.create=o=>n(o),Object.assign(e,t),Object.freeze(e)}function un(n=32){ne(n,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(n>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${n}`);return t.getRandomValues(new Uint8Array(n))}var fe=n=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,n])});function dn(n,t,e){return n&t^~n&e}function ln(n,t,e){return n&t^n&e^t&e}var Xt=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,e,r,o){this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(t),this.view=re(this.buffer)}update(t){Te(this),ot(t);let{view:e,buffer:r,blockLen:o}=this,s=t.length;for(let f=0;f<s;){let c=Math.min(o-this.pos,s-f);if(c===o){let a=re(t);for(;o<=s-f;f+=o)this.process(a,f);continue}r.set(t.subarray(f,f+c),this.pos),this.pos+=c,f+=c,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Te(this),cn(t,this),this.finished=!0;let{buffer:e,view:r,blockLen:o,isLE:s}=this,{pos:f}=this;e[f++]=128,St(this.buffer.subarray(f)),this.padOffset>o-f&&(this.process(r,0),f=0);for(let d=f;d<o;d++)e[d]=0;r.setBigUint64(o-8,BigInt(this.length*8),s),this.process(r,0);let c=re(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let i=a/4,l=this.get();if(i>l.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<i;d++)c.setUint32(4*d,l[d],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:e,buffer:r,length:o,finished:s,destroyed:f,pos:c}=this;return t.destroyed=f,t.finished=s,t.length=o,t.pos=c,o%e&&t.buffer.set(r),t}clone(){return this._cloneInto()}},dt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var G=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),P=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var ie=BigInt(4294967295),hn=BigInt(32);function ur(n,t=!1){return t?{h:Number(n&ie),l:Number(n>>hn&ie)}:{h:Number(n>>hn&ie)|0,l:Number(n&ie)|0}}function pn(n,t=!1){let e=n.length,r=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:f,l:c}=ur(n[s],t);[r[s],o[s]]=[f,c]}return[r,o]}var Ie=(n,t,e)=>n>>>e,Fe=(n,t,e)=>n<<32-e|t>>>e,_t=(n,t,e)=>n>>>e|t<<32-e,Rt=(n,t,e)=>n<<32-e|t>>>e,Kt=(n,t,e)=>n<<64-e|t>>>e-32,Gt=(n,t,e)=>n>>>e-32|t<<64-e;function ct(n,t,e,r){let o=(t>>>0)+(r>>>0);return{h:n+e+(o/2**32|0)|0,l:o|0}}var bn=(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),xn=(n,t,e,r)=>t+e+r+(n/2**32|0)|0,mn=(n,t,e,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0),yn=(n,t,e,r,o)=>t+e+r+o+(n/2**32|0)|0,wn=(n,t,e,r,o)=>(n>>>0)+(t>>>0)+(e>>>0)+(r>>>0)+(o>>>0),gn=(n,t,e,r,o,s)=>t+e+r+o+s+(n/2**32|0)|0;var lr=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),wt=new Uint32Array(64),Le=class extends Xt{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:e,C:r,D:o,E:s,F:f,G:c,H:a}=this;return[t,e,r,o,s,f,c,a]}set(t,e,r,o,s,f,c,a){this.A=t|0,this.B=e|0,this.C=r|0,this.D=o|0,this.E=s|0,this.F=f|0,this.G=c|0,this.H=a|0}process(t,e){for(let d=0;d<16;d++,e+=4)wt[d]=t.getUint32(e,!1);for(let d=16;d<64;d++){let m=wt[d-15],b=wt[d-2],A=st(m,7)^st(m,18)^m>>>3,B=st(b,17)^st(b,19)^b>>>10;wt[d]=B+wt[d-7]+A+wt[d-16]|0}let{A:r,B:o,C:s,D:f,E:c,F:a,G:i,H:l}=this;for(let d=0;d<64;d++){let m=st(c,6)^st(c,11)^st(c,25),b=l+m+dn(c,a,i)+lr[d]+wt[d]|0,B=(st(r,2)^st(r,13)^st(r,22))+ln(r,o,s)|0;l=i,i=a,a=c,c=f+b|0,f=s,s=o,o=r,r=b+B|0}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,f=f+this.D|0,c=c+this.E|0,a=a+this.F|0,i=i+this.G|0,l=l+this.H|0,this.set(r,o,s,f,c,a,i,l)}roundClean(){St(wt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),St(this.buffer)}},De=class extends Le{A=dt[0]|0;B=dt[1]|0;C=dt[2]|0;D=dt[3]|0;E=dt[4]|0;F=dt[5]|0;G=dt[6]|0;H=dt[7]|0;constructor(){super(32)}};var En=pn(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),hr=En[0],pr=En[1],gt=new Uint32Array(80),Et=new Uint32Array(80),ce=class extends Xt{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:e,Bh:r,Bl:o,Ch:s,Cl:f,Dh:c,Dl:a,Eh:i,El:l,Fh:d,Fl:m,Gh:b,Gl:A,Hh:B,Hl:p}=this;return[t,e,r,o,s,f,c,a,i,l,d,m,b,A,B,p]}set(t,e,r,o,s,f,c,a,i,l,d,m,b,A,B,p){this.Ah=t|0,this.Al=e|0,this.Bh=r|0,this.Bl=o|0,this.Ch=s|0,this.Cl=f|0,this.Dh=c|0,this.Dl=a|0,this.Eh=i|0,this.El=l|0,this.Fh=d|0,this.Fl=m|0,this.Gh=b|0,this.Gl=A|0,this.Hh=B|0,this.Hl=p|0}process(t,e){for(let _=0;_<16;_++,e+=4)gt[_]=t.getUint32(e),Et[_]=t.getUint32(e+=4);for(let _=16;_<80;_++){let D=gt[_-15]|0,L=Et[_-15]|0,C=_t(D,L,1)^_t(D,L,8)^Ie(D,L,7),Z=Rt(D,L,1)^Rt(D,L,8)^Fe(D,L,7),R=gt[_-2]|0,N=Et[_-2]|0,j=_t(R,N,19)^Kt(R,N,61)^Ie(R,N,6),U=Rt(R,N,19)^Gt(R,N,61)^Fe(R,N,6),w=mn(Z,U,Et[_-7],Et[_-16]),T=yn(w,C,j,gt[_-7],gt[_-16]);gt[_]=T|0,Et[_]=w|0}let{Ah:r,Al:o,Bh:s,Bl:f,Ch:c,Cl:a,Dh:i,Dl:l,Eh:d,El:m,Fh:b,Fl:A,Gh:B,Gl:p,Hh:y,Hl:O}=this;for(let _=0;_<80;_++){let D=_t(d,m,14)^_t(d,m,18)^Kt(d,m,41),L=Rt(d,m,14)^Rt(d,m,18)^Gt(d,m,41),C=d&b^~d&B,Z=m&A^~m&p,R=wn(O,L,Z,pr[_],Et[_]),N=gn(R,y,D,C,hr[_],gt[_]),j=R|0,U=_t(r,o,28)^Kt(r,o,34)^Kt(r,o,39),w=Rt(r,o,28)^Gt(r,o,34)^Gt(r,o,39),T=r&s^r&c^s&c,I=o&f^o&a^f&a;y=B|0,O=p|0,B=b|0,p=A|0,b=d|0,A=m|0,{h:d,l:m}=ct(i|0,l|0,N|0,j|0),i=c|0,l=a|0,c=s|0,a=f|0,s=r|0,f=o|0;let u=bn(j,w,I);r=xn(u,N,U,T),o=u|0}({h:r,l:o}=ct(this.Ah|0,this.Al|0,r|0,o|0)),{h:s,l:f}=ct(this.Bh|0,this.Bl|0,s|0,f|0),{h:c,l:a}=ct(this.Ch|0,this.Cl|0,c|0,a|0),{h:i,l}=ct(this.Dh|0,this.Dl|0,i|0,l|0),{h:d,l:m}=ct(this.Eh|0,this.El|0,d|0,m|0),{h:b,l:A}=ct(this.Fh|0,this.Fl|0,b|0,A|0),{h:B,l:p}=ct(this.Gh|0,this.Gl|0,B|0,p|0),{h:y,l:O}=ct(this.Hh|0,this.Hl|0,y|0,O|0),this.set(r,o,s,f,c,a,i,l,d,m,b,A,B,p,y,O)}roundClean(){St(gt,Et)}destroy(){this.destroyed=!0,St(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},He=class extends ce{Ah=P[0]|0;Al=P[1]|0;Bh=P[2]|0;Bl=P[3]|0;Ch=P[4]|0;Cl=P[5]|0;Dh=P[6]|0;Dl=P[7]|0;Eh=P[8]|0;El=P[9]|0;Fh=P[10]|0;Fl=P[11]|0;Gh=P[12]|0;Gl=P[13]|0;Hh=P[14]|0;Hl=P[15]|0;constructor(){super(64)}},qe=class extends ce{Ah=G[0]|0;Al=G[1]|0;Bh=G[2]|0;Bl=G[3]|0;Ch=G[4]|0;Cl=G[5]|0;Dh=G[6]|0;Dl=G[7]|0;Eh=G[8]|0;El=G[9]|0;Fh=G[10]|0;Fl=G[11]|0;Gh=G[12]|0;Gl=G[13]|0;Hh=G[14]|0;Hl=G[15]|0;constructor(){super(48)}};var Ne=se(()=>new De,fe(1));var Ot=se(()=>new He,fe(3)),Ue=se(()=>new qe,fe(2));var k=(n,t,e)=>ot(n,t,e),Ce=ne,Pt=oe,K=(...n)=>Ae(...n),de=n=>kt(n),Ct=Oe,nt=n=>un(n),ue=BigInt(0),Ze=BigInt(1);function Tt(n,t=""){if(typeof n!="boolean"){let e=t&&`"${t}" `;throw new TypeError(e+"expected boolean, got type="+typeof n)}return n}function le(n){if(typeof n=="bigint"){if(!ae(n))throw new RangeError("positive bigint expected, got "+n)}else Ce(n);return n}function J(n,t=""){if(typeof n!="number"){let e=t&&`"${t}" `;throw new TypeError(e+"expected number, got type="+typeof n)}if(!Number.isSafeInteger(n)){let e=t&&`"${t}" `;throw new RangeError(e+"expected safe integer, got "+n)}}function $t(n){let t=le(n).toString(16);return t.length&1?"0"+t:t}function Bn(n){if(typeof n!="string")throw new TypeError("hex string expected, got "+typeof n);return n===""?ue:BigInt("0x"+n)}function lt(n){return Bn(oe(n))}function at(n){return Bn(oe(It(ot(n)).reverse()))}function At(n,t){if(ne(t),t===0)throw new RangeError("zero length");n=le(n);let e=n.toString(16);if(e.length>t*2)throw new RangeError("number too large");return kt(e.padStart(t*2,"0"))}function je(n,t){return At(n,t).reverse()}function vn(n,t){if(n=k(n),t=k(t),n.length!==t.length)return!1;let e=0;for(let r=0;r<n.length;r++)e|=n[r]^t[r];return e===0}function It(n){return Uint8Array.from(k(n))}function tt(n){if(typeof n!="string")throw new TypeError("ascii string expected, got "+typeof n);return Uint8Array.from(n,(t,e)=>{let r=t.charCodeAt(0);if(t.length!==1||r>127)throw new RangeError(`string contains non-ASCII character "${n[e]}" with code ${r} at position ${e}`);return r})}var ae=n=>typeof n=="bigint"&&ue<=n;function br(n,t,e){return ae(n)&&ae(t)&&ae(e)&&t<=n&&n<e}function Wt(n,t,e,r){if(!br(t,e,r))throw new RangeError("expected valid "+n+": "+e+" <= n < "+r+", got "+t)}function Ft(n){if(n<ue)throw new Error("expected non-negative bigint, got "+n);let t;for(t=0;n>ue;n>>=Ze,t+=1);return t}var Qt=n=>(Ze<<BigInt(n))-Ze;function rt(n,t={},e={}){if(Object.prototype.toString.call(n)!=="[object Object]")throw new TypeError("expected valid options object");function r(s,f,c){if(!c&&f!=="function"&&!Object.hasOwn(n,s))throw new TypeError(`param "${s}" is invalid: expected own property`);let a=n[s];if(c&&a===void 0)return;let i=typeof a;if(i!==f||a===null)throw new TypeError(`param "${s}" is invalid: expected ${f}, got ${i}`)}let o=(s,f)=>Object.entries(s).forEach(([c,a])=>r(c,a,f));o(t,!1),o(e,!0)}var Ve=()=>{throw new Error("not implemented")};var $=BigInt(0),X=BigInt(1),Lt=BigInt(2),Rn=BigInt(3),On=BigInt(4),Tn=BigInt(5),xr=BigInt(7),An=BigInt(8),mr=BigInt(9),In=BigInt(16);function z(n,t){if(t<=$)throw new Error("mod: expected positive modulus, got "+t);let e=n%t;return e>=$?e:t+e}function ft(n,t,e){if(t<$)throw new Error("pow2: expected non-negative exponent, got "+t);let r=n;for(;t-- >$;)r*=r,r%=e;return r}function Sn(n,t){if(n===$)throw new Error("invert: expected non-zero number");if(t<=$)throw new Error("invert: expected positive modulus, got "+t);let e=z(n,t),r=t,o=$,s=X,f=X,c=$;for(;e!==$;){let i=r/e,l=r-e*i,d=o-f*i,m=s-c*i;r=e,e=l,o=f,s=c,f=d,c=m}if(r!==X)throw new Error("invert: does not exist");return z(o,t)}function ze(n,t,e){let r=n;if(!r.eql(r.sqr(t),e))throw new Error("Cannot find square root")}function Fn(n,t){let e=n,r=(e.ORDER+X)/On,o=e.pow(t,r);return ze(e,o,t),o}function yr(n,t){let e=n,r=(e.ORDER-Tn)/An,o=e.mul(t,Lt),s=e.pow(o,r),f=e.mul(t,s),c=e.mul(e.mul(f,Lt),s),a=e.mul(f,e.sub(c,e.ONE));return ze(e,a,t),a}function wr(n){let t=pe(n),e=Ln(n),r=e(t,t.neg(t.ONE)),o=e(t,r),s=e(t,t.neg(r)),f=(n+xr)/In;return((c,a)=>{let i=c,l=i.pow(a,f),d=i.mul(l,r),m=i.mul(l,o),b=i.mul(l,s),A=i.eql(i.sqr(d),a),B=i.eql(i.sqr(m),a);l=i.cmov(l,d,A),d=i.cmov(b,m,B);let p=i.eql(i.sqr(d),a),y=i.cmov(l,d,p);return ze(i,y,a),y})}function Ln(n){if(n<Rn)throw new Error("sqrt is not defined for small field");let t=n-X,e=0;for(;t%Lt===$;)t/=Lt,e++;let r=Lt,o=pe(n);for(;Me(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return Fn;let s=o.pow(r,t),f=(t+X)/Lt;return function(a,i){let l=a;if(l.is0(i))return i;if(Me(l,i)!==1)throw new Error("Cannot find square root");let d=e,m=l.mul(l.ONE,s),b=l.pow(i,t),A=l.pow(i,f);for(;!l.eql(b,l.ONE);){if(l.is0(b))return l.ZERO;let B=1,p=l.sqr(b);for(;!l.eql(p,l.ONE);)if(B++,p=l.sqr(p),B===d)throw new Error("Cannot find square root");let y=X<<BigInt(d-B-1),O=l.pow(m,y);d=B,m=l.sqr(O),b=l.mul(b,m),A=l.mul(A,O)}return A}}function gr(n){return n%On===Rn?Fn:n%An===Tn?yr:n%In===mr?wr(n):Ln(n)}var ht=(n,t)=>(z(n,t)&X)===X,Er=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Dt(n){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},e=Er.reduce((r,o)=>(r[o]="function",r),t);if(rt(n,e),J(n.BYTES,"BYTES"),J(n.BITS,"BITS"),n.BYTES<1||n.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(n.ORDER<=X)throw new Error("invalid field: expected ORDER > 1, got "+n.ORDER);return n}function Br(n,t,e){let r=n;if(e<$)throw new Error("invalid exponent, negatives unsupported");if(e===$)return r.ONE;if(e===X)return t;let o=r.ONE,s=t;for(;e>$;)e&X&&(o=r.mul(o,s)),s=r.sqr(s),e>>=X;return o}function Ht(n,t,e=!1){let r=n,o=new Array(t.length).fill(e?r.ZERO:void 0),s=t.reduce((c,a,i)=>r.is0(a)?c:(o[i]=c,r.mul(c,a)),r.ONE),f=r.inv(s);return t.reduceRight((c,a,i)=>r.is0(a)?c:(o[i]=r.mul(c,o[i]),r.mul(c,a)),f),o}function Me(n,t){let e=n,r=(e.ORDER-X)/Lt,o=e.pow(t,r),s=e.eql(o,e.ONE),f=e.eql(o,e.ZERO),c=e.eql(o,e.neg(e.ONE));if(!s&&!f&&!c)throw new Error("invalid Legendre symbol result");return s?1:f?0:-1}function Ye(n,t){return Me(n,t)!==-1}function vr(n,t){if(t!==void 0&&Ce(t),n<=$)throw new Error("invalid n length: expected positive n, got "+n);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let e=Ft(n);if(t!==void 0&&t<e)throw new Error(`invalid n length: expected bit length (${e}) >= n.length (${t})`);let r=t!==void 0?t:e,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}var _n=new WeakMap,he=class{ORDER;BITS;BYTES;isLE;ZERO=$;ONE=X;_lengths;_mod;constructor(t,e={}){if(t<=X)throw new Error("invalid field: expected ORDER > 1, got "+t);let r;this.isLE=!1,e!=null&&typeof e=="object"&&(typeof e.BITS=="number"&&(r=e.BITS),typeof e.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:e.sqrt,enumerable:!0}),typeof e.isLE=="boolean"&&(this.isLE=e.isLE),e.allowedLengths&&(this._lengths=Object.freeze(e.allowedLengths.slice())),typeof e.modFromBytes=="boolean"&&(this._mod=e.modFromBytes));let{nBitLength:o,nByteLength:s}=vr(t,r);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=s,Object.freeze(this)}create(t){return z(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return $<=t&&t<this.ORDER}is0(t){return t===$}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&X)===X}neg(t){return z(-t,this.ORDER)}eql(t,e){return t===e}sqr(t){return z(t*t,this.ORDER)}add(t,e){return z(t+e,this.ORDER)}sub(t,e){return z(t-e,this.ORDER)}mul(t,e){return z(t*e,this.ORDER)}pow(t,e){return Br(this,t,e)}div(t,e){return z(t*Sn(e,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,e){return t+e}subN(t,e){return t-e}mulN(t,e){return t*e}inv(t){return Sn(t,this.ORDER)}sqrt(t){let e=_n.get(this);return e||_n.set(this,e=gr(this.ORDER)),e(this,t)}toBytes(t){return this.isLE?je(t,this.BYTES):At(t,this.BYTES)}fromBytes(t,e=!1){k(t);let{_lengths:r,BYTES:o,isLE:s,ORDER:f,_mod:c}=this;if(r){if(t.length<1||!r.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+t.length);let i=new Uint8Array(o);i.set(t,s?0:i.length-t.length),t=i}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let a=s?at(t):lt(t);if(c&&(a=z(a,f)),!e&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(t){return Ht(this,t)}cmov(t,e,r){return Tt(r,"condition"),r?e:t}};Object.freeze(he.prototype);function pe(n,t={}){return new he(n,t)}function Dn(n){if(typeof n!="bigint")throw new Error("field order must be bigint");if(n<=X)throw new Error("field order must be greater than 1");let t=Ft(n-X);return Math.ceil(t/8)}function be(n){let t=Dn(n);return t+Math.ceil(t/2)}function ke(n,t,e=!1){k(n);let r=n.length,o=Dn(t),s=Math.max(be(t),16);if(r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);let f=e?at(n):lt(n),c=z(f,t-X)+X;return e?je(c,o):At(c,o)}var jt=BigInt(0),qt=BigInt(1);function Un(n){let t=n;if(typeof t!="function")throw new TypeError("Point must be a constructor");rt({Fp:t.Fp,Fn:t.Fn,fromAffine:t.fromAffine,fromBytes:t.fromBytes,fromHex:t.fromHex},{Fp:"object",Fn:"object",fromAffine:"function",fromBytes:"function",fromHex:"function"}),Dt(t.Fp),Dt(t.Fn)}function Jt(n,t){let e=t.negate();return n?e:t}function Nt(n,t){let e=Ht(n.Fp,t.map(r=>r.Z));return t.map((r,o)=>n.fromAffine(r.toAffine(e[o])))}function Zn(n,t){if(!Number.isSafeInteger(n)||n<=0||n>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+n)}function Xe(n,t){Zn(n,t);let e=Math.ceil(t/n)+1,r=2**(n-1),o=2**n,s=Qt(n),f=BigInt(n);return{windows:e,windowSize:r,mask:s,maxNumber:o,shiftBy:f}}function Hn(n,t,e){let{windowSize:r,mask:o,maxNumber:s,shiftBy:f}=e,c=Number(n&o),a=n>>f;c>r&&(c-=s,a+=qt);let i=t*r,l=i+Math.abs(c)-1,d=c===0,m=c<0,b=t%2!==0;return{nextN:a,offset:l,isZero:d,isNeg:m,isNegF:b,offsetF:i}}function Sr(n,t){if(!Array.isArray(n))throw new Error("array expected");n.forEach((e,r)=>{if(!(e instanceof t))throw new Error("invalid point at index "+r)})}function _r(n,t){if(!Array.isArray(n))throw new Error("array of scalars expected");n.forEach((e,r)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+r)})}var Ke=new WeakMap,Cn=new WeakMap;function Ge(n){return Cn.get(n)||1}function qn(n){if(n!==jt)throw new Error("invalid wNAF")}var Vt=class{BASE;ZERO;Fn;bits;constructor(t,e){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,r=this.ZERO){let o=t;for(;e>jt;)e&qt&&(r=r.add(o)),o=o.double(),e>>=qt;return r}precomputeWindow(t,e){let{windows:r,windowSize:o}=Xe(e,this.bits),s=[],f=t,c=f;for(let a=0;a<r;a++){c=f,s.push(c);for(let i=1;i<o;i++)c=c.add(f),s.push(c);f=c.double()}return s}wNAF(t,e,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE,f=Xe(t,this.bits);for(let c=0;c<f.windows;c++){let{nextN:a,offset:i,isZero:l,isNeg:d,isNegF:m,offsetF:b}=Hn(r,c,f);r=a,l?s=s.add(Jt(m,e[b])):o=o.add(Jt(d,e[i]))}return qn(r),{p:o,f:s}}wNAFUnsafe(t,e,r,o=this.ZERO){let s=Xe(t,this.bits);for(let f=0;f<s.windows&&r!==jt;f++){let{nextN:c,offset:a,isZero:i,isNeg:l}=Hn(r,f,s);if(r=c,!i){let d=e[a];o=o.add(l?d.negate():d)}}return qn(r),o}getPrecomputes(t,e,r){let o=Ke.get(e);return o||(o=this.precomputeWindow(e,t),t!==1&&(typeof r=="function"&&(o=r(o)),Ke.set(e,o))),o}cached(t,e,r){let o=Ge(t);return this.wNAF(o,this.getPrecomputes(o,t,r),e)}unsafe(t,e,r,o){let s=Ge(t);return s===1?this._unsafeLadder(t,e,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,r),e,o)}createCache(t,e){Zn(e,this.bits),Cn.set(t,e),Ke.delete(t)}hasCache(t){return Ge(t)!==1}};function jn(n,t,e,r){let o=t,s=n.ZERO,f=n.ZERO;for(;e>jt||r>jt;)e&qt&&(s=s.add(o)),r&qt&&(f=f.add(o)),o=o.double(),e>>=qt,r>>=qt;return{p1:s,p2:f}}function Vn(n,t,e){let r=n.Fn;Sr(t,n),_r(e,r);let o=t.length,s=e.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");let f=n.ZERO,c=Ft(BigInt(o)),a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);let i=Qt(a),l=new Array(Number(i)+1).fill(f),d=Math.floor((r.BITS-1)/a)*a,m=f;for(let b=d;b>=0;b-=a){l.fill(f);for(let B=0;B<s;B++){let p=e[B],y=Number(p>>BigInt(b)&i);l[y]=l[y].add(t[B])}let A=f;for(let B=l.length-1,p=f;B>0;B--)p=p.add(l[B]),A=A.add(p);if(m=m.add(A),b!==0)for(let B=0;B<a;B++)m=m.double()}return m}function Nn(n,t,e){if(t){if(t.ORDER!==n)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Dt(t),t}else return pe(n,{isLE:e})}function xe(n,t,e={},r){if(r===void 0&&(r=n==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${n} CURVE object`);for(let a of["p","n","h"]){let i=t[a];if(!(typeof i=="bigint"&&i>jt))throw new Error(`CURVE.${a} must be positive bigint`)}let o=Nn(t.p,e.Fp,r),s=Nn(t.n,e.Fn,r),c=["Gx","Gy","a",n==="weierstrass"?"b":"d"];for(let a of c)if(!o.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}var Bt=BigInt(0),Q=BigInt(1),Pe=BigInt(2),Or=BigInt(8);function Tr(n,t,e,r){let o=n.sqr(e),s=n.sqr(r),f=n.add(n.mul(t.a,o),s),c=n.add(n.ONE,n.mul(t.d,n.mul(o,s)));return n.eql(f,c)}function Mn(n,t={}){let e=t,r=xe("edwards",n,e,e.FpFnLE),{Fp:o,Fn:s}=r,f=r.CURVE,{h:c}=f;rt(e,{},{uvRatio:"function"});let a=Pe<<BigInt(s.BYTES*8)-Q,i=B=>o.create(B),l=e.uvRatio===void 0?(B,p)=>{try{return{isValid:!0,value:o.sqrt(o.div(B,p))}}catch{return{isValid:!1,value:Bt}}}:e.uvRatio;if(!Tr(o,f,f.Gx,f.Gy))throw new Error("bad curve params: generator point");function d(B,p,y=!1){let O=y?Q:Bt;return Wt("coordinate "+B,p,O,a),p}function m(B){if(!(B instanceof b))throw new Error("EdwardsPoint expected")}class b{static BASE=new b(f.Gx,f.Gy,Q,i(f.Gx*f.Gy));static ZERO=new b(Bt,Q,Q,Bt);static Fp=o;static Fn=s;X;Y;Z;T;constructor(p,y,O,_){this.X=d("x",p),this.Y=d("y",y),this.Z=d("z",O,!0),this.T=d("t",_),Object.freeze(this)}static CURVE(){return f}static fromAffine(p){if(p instanceof b)throw new Error("extended point not allowed");let{x:y,y:O}=p||{};return d("x",y),d("y",O),new b(y,O,Q,i(y*O))}static fromBytes(p,y=!1){let O=o.BYTES,{a:_,d:D}=f;p=It(k(p,O,"point")),Tt(y,"zip215");let L=It(p),C=p[O-1];L[O-1]=C&-129;let Z=at(L),R=y?a:o.ORDER;Wt("point.y",Z,Bt,R);let N=i(Z*Z),j=i(N-Q),U=i(D*N-_),{isValid:w,value:T}=l(j,U);if(!w)throw new Error("bad point: invalid y coordinate");let I=(T&Q)===Q,u=(C&128)!==0;if(!y&&T===Bt&&u)throw new Error("bad point: x=0 and x_0=1");return u!==I&&(T=i(-T)),b.fromAffine({x:T,y:Z})}static fromHex(p,y=!1){return b.fromBytes(de(p),y)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(p=8,y=!0){return A.createCache(this,p),y||this.multiply(Pe),this}assertValidity(){let p=this,{a:y,d:O}=f;if(p.is0())throw new Error("bad point: ZERO");let{X:_,Y:D,Z:L,T:C}=p,Z=i(_*_),R=i(D*D),N=i(L*L),j=i(N*N),U=i(Z*y),w=i(N*i(U+R)),T=i(j+i(O*i(Z*R)));if(w!==T)throw new Error("bad point: equation left != right (1)");let I=i(_*D),u=i(L*C);if(I!==u)throw new Error("bad point: equation left != right (2)")}equals(p){m(p);let{X:y,Y:O,Z:_}=this,{X:D,Y:L,Z:C}=p,Z=i(y*C),R=i(D*_),N=i(O*C),j=i(L*_);return Z===R&&N===j}is0(){return this.equals(b.ZERO)}negate(){return new b(i(-this.X),this.Y,this.Z,i(-this.T))}double(){let{a:p}=f,{X:y,Y:O,Z:_}=this,D=i(y*y),L=i(O*O),C=i(Pe*i(_*_)),Z=i(p*D),R=y+O,N=i(i(R*R)-D-L),j=Z+L,U=j-C,w=Z-L,T=i(N*U),I=i(j*w),u=i(N*w),h=i(U*j);return new b(T,I,h,u)}add(p){m(p);let{a:y,d:O}=f,{X:_,Y:D,Z:L,T:C}=this,{X:Z,Y:R,Z:N,T:j}=p,U=i(_*Z),w=i(D*R),T=i(C*O*j),I=i(L*N),u=i((_+D)*(Z+R)-U-w),h=I-T,g=I+T,E=i(w-y*U),x=i(u*h),S=i(g*E),v=i(u*E),q=i(h*g);return new b(x,S,q,v)}subtract(p){return m(p),this.add(p.negate())}multiply(p){if(!s.isValidNot0(p))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:y,f:O}=A.cached(this,p,_=>Nt(b,_));return Nt(b,[y,O])[0]}multiplyUnsafe(p){if(!s.isValid(p))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return p===Bt?b.ZERO:this.is0()||p===Q?this:A.unsafe(this,p,y=>Nt(b,y))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return A.unsafe(this,f.n).is0()}toAffine(p){let y=this,O=p,{X:_,Y:D,Z:L}=y,C=y.is0();O==null&&(O=C?Or:o.inv(L));let Z=i(_*O),R=i(D*O),N=o.mul(L,O);if(C)return{x:Bt,y:Q};if(N!==Q)throw new Error("invZ was invalid");return{x:Z,y:R}}clearCofactor(){return c===Q?this:this.multiplyUnsafe(c)}toBytes(){let{x:p,y}=this.toAffine(),O=o.toBytes(y);return O[O.length-1]|=p&Q?128:0,O}toHex(){return Pt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let A=new Vt(b,s.BITS);return s.BITS>=8&&b.BASE.precompute(8),Object.freeze(b.prototype),Object.freeze(b),b}var me=class{static BASE;static ZERO;static Fp;static Fn;ep;constructor(t){this.ep=t}static fromBytes(t){Ve()}static fromHex(t){Ve()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return Pt(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,e){return this.ep.precompute(t,e),this}};var Ar=lt;function Ut(n,t){if(J(n),J(t),t<0||t>4)throw new Error("invalid I2OSP length: "+t);if(n<0||n>2**(8*t)-1)throw new Error("invalid I2OSP input: "+n);let e=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)e[r]=n&255,n>>>=8;return new Uint8Array(e)}function Ir(n,t){let e=new Uint8Array(n.length);for(let r=0;r<n.length;r++)e[r]=n[r]^t[r];return e}function zn(n){if(!Ct(n)&&typeof n!="string")throw new Error("DST must be Uint8Array or ascii string");let t=typeof n=="string"?tt(n):n;if(t.length===0)throw new Error("DST must be non-empty");return t}function ye(n,t,e,r){k(n),J(e),t=zn(t),t.length>255&&(t=r(K(tt("H2C-OVERSIZE-DST-"),t)));let{outputLen:o,blockLen:s}=r,f=Math.ceil(e/o);if(e>65535||f>255)throw new Error("expand_message_xmd: invalid lenInBytes");let c=K(t,Ut(t.length,1)),a=new Uint8Array(s),i=Ut(e,2),l=new Array(f),d=r(K(a,n,i,Ut(0,1),c));l[0]=r(K(d,Ut(1,1),c));for(let b=1;b<f;b++){let A=[Ir(d,l[b-1]),Ut(b+1,1),c];l[b]=r(K(...A))}return K(...l).slice(0,e)}function Fr(n,t,e,r,o){if(k(n),J(e),t=zn(t),t.length>255){let s=Math.ceil(2*r/8);t=o.create({dkLen:s}).update(tt("H2C-OVERSIZE-DST-")).update(t).digest()}if(e>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return o.create({dkLen:e}).update(n).update(Ut(e,2)).update(t).update(Ut(t.length,1)).digest()}function $e(n,t,e){rt(e,{p:"bigint",m:"number",k:"number",hash:"function"});let{p:r,k:o,m:s,hash:f,expand:c,DST:a}=e;if(J(f.outputLen,"valid hash"),k(n),J(t),t<1)throw new Error("hash_to_field: expected count >= 1");if(s<1)throw new Error("hash_to_field: expected m >= 1");let i=r.toString(2).length,l=Math.ceil((i+o)/8),d=t*s*l,m;if(c==="xmd")m=ye(n,a,d,f);else if(c==="xof")m=Fr(n,a,d,o,f);else if(c==="_internal_pass")m=n;else throw new Error('expand must be "xmd" or "xof"');let b=new Array(t);for(let A=0;A<t;A++){let B=new Array(s);for(let p=0;p<s;p++){let y=l*(p+A*s),O=m.subarray(y,y+l);B[p]=z(Ar(O),r)}b[A]=B}return b}var te="HashToScalar-";function ee(n,t,e){if(typeof t!="function")throw new Error("mapToCurve() must be defined");let r=c=>Object.freeze({...c,DST:Ct(c.DST)?It(c.DST):c.DST,...c.encodeDST===void 0?{}:{encodeDST:Ct(c.encodeDST)?It(c.encodeDST):c.encodeDST}}),o=r(e);function s(c){return n.fromAffine(t(c))}function f(c){let a=c.clearCofactor();return a.equals(n.ZERO)?n.ZERO:(a.assertValidity(),a)}return Object.freeze({get defaults(){return r(o)},Point:n,hashToCurve(c,a){let i=Object.assign({},o,a),l=$e(c,2,i),d=s(l[0]),m=s(l[1]);return f(d.add(m))},encodeToCurve(c,a){let i=o.encodeDST?{DST:o.encodeDST}:{},l=Object.assign({},o,i,a),d=$e(c,1,l),m=s(d[0]);return f(m)},mapToCurve(c){if(o.m===1){if(typeof c!="bigint")throw new Error("expected bigint (m=1)");return f(s([c]))}if(!Array.isArray(c))throw new Error("expected array of bigints");for(let a of c)if(typeof a!="bigint")throw new Error("expected array of bigints");return f(s(c))},hashToScalar(c,a){let i=n.Fn.ORDER,l=Object.assign({},o,{p:i,m:1,DST:te},a);return $e(c,1,l)[0][0]}})}var Lr=tt(te);function Mt(n){rt(n,{name:"string",hash:"function",hashToScalar:"function",hashToGroup:"function"}),Un(n.Point);let{name:t,Point:e,hash:r}=n,{Fn:o}=e,s=(u,h)=>n.hashToGroup(u,{DST:K(tt("HashToGroup-"),h)}),f=(u,h)=>n.hashToScalar(u,{DST:K(Lr,h)}),c=(u=nt)=>{let h=ke(u(be(o.ORDER)),o.ORDER,o.isLE);return o.isLE?at(h):lt(h)},a=(u,h)=>Vn(e,u,h),i=u=>K(tt("OPRFV1-"),new Uint8Array([u]),tt("-"+t)),l=i(0),d=i(1),m=i(2);function b(...u){let h=[];for(let g of u)typeof g=="number"?h.push(At(g,2)):typeof g=="string"?h.push(tt(g)):(k(g),h.push(At(g.length,2),g));return K(...h)}let A=(u,h)=>{if(k(h,void 0,u),h.length>65535)throw new Error(`"${u}" expected Uint8Array of length <= 65535, got length=${h.length}`);return h},B=(...u)=>r(b(...u,"Finalize"));function p(u,h,g,E){let x=u.toBytes(),S=r(b(x,K(tt("Seed-"),E))),v=[];for(let q=0;q<h.length;q++){let H=h[q].toBytes(),F=g[q].toBytes(),V=f(b(S,q,H,F,"Composite"),E);v.push(V)}return v}function y(u,h,g,E){let x=p(u,h,g,E),S=a(h,x),v=a(g,x);return{M:S,Z:v}}function O(u,h,g,E,x){let S=p(h,g,E,x),v=a(g,S),q=v.multiply(u);return{M:v,Z:q}}function _(u,h,g,E,x,S){let[v,q,H,F,V]=[u,h,g,E,x].map(Y=>Y.toBytes());return f(b(v,q,H,F,V,"Challenge"),S)}function D(u,h,g,E,x,S){let{M:v,Z:q}=O(h,g,E,x,u),H=c(S),F=e.BASE.multiply(H),V=v.multiply(H),Y=_(g,v,q,F,V,u),et=o.sub(H,o.mul(Y,h));return K(...[Y,et].map(M=>o.toBytes(M)))}function L(u,h,g,E,x){k(x,2*o.BYTES);let{M:S,Z:v}=y(h,g,E,u),[q,H]=[x.subarray(0,o.BYTES),x.subarray(o.BYTES)].map(et=>o.fromBytes(et)),F=e.BASE.multiply(H).add(h.multiply(q)),V=S.multiply(H).add(v.multiply(q)),Y=_(h,S,v,F,V,u);if(!o.eql(q,Y))throw new Error("proof verification failed")}function C(){let u=c(),h=e.BASE.multiply(u);return{secretKey:o.toBytes(u),publicKey:h.toBytes()}}function Z(u,h,g){k(h,32,"seed"),g=A("keyInfo",g);let E=K(tt("DeriveKeyPair"),u),x=K(h,b(g),Uint8Array.of(0));for(let S=0;S<=255;S++){x[x.length-1]=S;let v=n.hashToScalar(x,{DST:E});if(!o.is0(v))return{secretKey:o.toBytes(v),publicKey:e.BASE.multiply(v).toBytes()}}throw new Error("Cannot derive key")}let R=(u,h)=>{let g=e.fromBytes(h);if(g.equals(e.ZERO))throw new Error(u+" point at infinity");return g};function N(u,h,g=nt){h=A("input",h);let E=c(g),x=s(h,u);if(x.equals(e.ZERO))throw new Error("Input point at infinity");let S=x.multiply(E);return{blind:o.toBytes(E),blinded:S.toBytes()}}function j(u,h,g){g=A("input",g);let E=o.fromBytes(h),x=s(g,u);if(x.equals(e.ZERO))throw new Error("Input point at infinity");let S=x.multiply(E).toBytes();return B(g,S)}let U=Object.freeze({generateKeyPair:C,deriveKeyPair:(u,h)=>Z(l,u,h),blind:(u,h=nt)=>N(l,u,h),blindEvaluate(u,h){let g=o.fromBytes(u);return R("blinded",h).multiply(g).toBytes()},finalize(u,h,g){u=A("input",u);let E=o.fromBytes(h),S=R("evaluated",g).multiply(o.inv(E)).toBytes();return B(u,S)},evaluate:(u,h)=>j(l,u,h)}),w=Object.freeze({generateKeyPair:C,deriveKeyPair:(u,h)=>Z(d,u,h),blind:(u,h=nt)=>N(d,u,h),blindEvaluateBatch(u,h,g,E=nt){if(!Array.isArray(g))throw new Error("expected array");let x=o.fromBytes(u),S=R("public key",h),v=g.map(F=>R("blinded",F)),q=v.map(F=>F.multiply(x)),H=D(d,x,S,v,q,E);return{evaluated:q.map(F=>F.toBytes()),proof:H}},blindEvaluate(u,h,g,E=nt){let x=this.blindEvaluateBatch(u,h,[g],E);return{evaluated:x.evaluated[0],proof:x.proof}},finalizeBatch(u,h,g){if(!Array.isArray(u))throw new Error("expected array");let E=R("public key",h),x=u.map(v=>R("blinded",v.blinded)),S=u.map(v=>R("evaluated",v.evaluated));return L(d,E,x,S,g),u.map(v=>U.finalize(v.input,v.blind,v.evaluated))},finalize(u,h,g,E,x,S){return this.finalizeBatch([{input:u,blind:h,evaluated:g,blinded:E}],x,S)[0]},evaluate:(u,h)=>j(d,u,h)}),I={name:t,oprf:U,voprf:w,poprf:u=>{u=A("info",u);let h=f(b("Info",u),m),g=e.BASE.multiply(h);return Object.freeze({generateKeyPair:C,deriveKeyPair:(E,x)=>Z(m,E,x),blind(E,x,S=nt){E=A("input",E);let v=R("public key",x),q=g.add(v);if(q.equals(e.ZERO))throw new Error("tweakedKey point at infinity");let H=c(S),F=s(E,m);if(F.equals(e.ZERO))throw new Error("Input point at infinity");let V=F.multiply(H);return{blind:o.toBytes(H),blinded:V.toBytes(),tweakedKey:q.toBytes()}},blindEvaluateBatch(E,x,S=nt){if(!Array.isArray(x))throw new Error("expected array");let v=o.fromBytes(E),q=o.add(v,h),H=o.inv(q),F=x.map(M=>R("blinded",M)),V=F.map(M=>M.multiply(H)),Y=e.BASE.multiply(q),et=D(m,q,Y,V,F,S);return{evaluated:V.map(M=>M.toBytes()),proof:et}},blindEvaluate(E,x,S=nt){let v=this.blindEvaluateBatch(E,[x],S);return{evaluated:v.evaluated[0],proof:v.proof}},finalizeBatch(E,x,S){if(!Array.isArray(E))throw new Error("expected array");let v=E.map(H=>A("input",H.input)),q=E.map(H=>R("evaluated",H.evaluated));return L(m,R("tweakedKey",S),q,E.map(H=>R("blinded",H.blinded)),x),E.map((H,F)=>{let V=o.fromBytes(H.blind),Y=q[F].multiply(o.inv(V)).toBytes();return B(v[F],u,Y)})},finalize(E,x,S,v,q,H){return this.finalizeBatch([{input:E,blind:x,evaluated:S,blinded:v}],q,H)[0]},evaluate(E,x){x=A("input",x);let S=o.fromBytes(E),v=s(x,m);if(v.equals(e.ZERO))throw new Error("Input point at infinity");let q=o.add(S,h),H=o.inv(q),F=v.multiply(H).toBytes();return B(x,u,F)}})},__tests:Object.freeze({Fn:o})};return Object.freeze(I)}var Dr=BigInt(0),pt=BigInt(1),Yn=BigInt(2);var Hr=BigInt(5),qr=BigInt(8),zt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),en={p:zt,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:qr,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Nr(n){let t=BigInt(10),e=BigInt(20),r=BigInt(40),o=BigInt(80),s=zt,c=n*n%s*n%s,a=ft(c,Yn,s)*c%s,i=ft(a,pt,s)*n%s,l=ft(i,Hr,s)*i%s,d=ft(l,t,s)*l%s,m=ft(d,e,s)*d%s,b=ft(m,r,s)*m%s,A=ft(b,o,s)*b%s,B=ft(A,o,s)*b%s,p=ft(B,t,s)*l%s;return{pow_p_5_8:ft(p,Yn,s)*n%s,b2:c}}var We=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function nn(n,t){let e=zt,r=z(t*t*t,e),o=z(r*r*t,e),s=Nr(n*o).pow_p_5_8,f=z(n*r*s,e),c=z(t*f*f,e),a=f,i=z(f*We,e),l=c===n,d=c===z(-n,e),m=c===z(-n*We,e);return l&&(f=a),(d||m)&&(f=i),ht(f,e)&&(f=z(-f,e)),{isValid:l||d,value:f}}var Zt=Mn(en,{uvRatio:nn}),vt=Zt.Fp,Kn=Zt.Fn;var Qe=We,Ur=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Zr=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Cr=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),jr=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),kn=n=>nn(pt,n),Vr=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),Je=n=>vt.create(at(n)&Vr);function Xn(n){let{d:t}=en,e=zt,r=y=>vt.create(y),o=r(Qe*n*n),s=r((o+pt)*Cr),f=BigInt(-1),c=r((f-t*o)*r(o+t)),{isValid:a,value:i}=nn(s,c),l=r(i*n);ht(l,e)||(l=r(-l)),a||(i=l),a||(f=o);let d=r(f*(o-pt)*jr-c),m=i*i,b=r((i+i)*c),A=r(d*Ur),B=r(pt-m),p=r(pt+m);return new Zt(r(b*p),r(B*A),r(A*p),r(b*B))}var bt=class n extends me{static BASE=new n(Zt.BASE);static ZERO=new n(Zt.ZERO);static Fp=vt;static Fn=Kn;constructor(t){super(t)}static fromAffine(t){return new n(Zt.fromAffine(t))}assertSame(t){if(!(t instanceof n))throw new Error("RistrettoPoint expected")}init(t){return new n(t)}static fromBytes(t){ot(t,32);let{a:e,d:r}=en,o=zt,s=D=>vt.create(D),f=Je(t);if(!vn(vt.toBytes(f),t)||ht(f,o))throw new Error("invalid ristretto255 encoding 1");let c=s(f*f),a=s(pt+e*c),i=s(pt-e*c),l=s(a*a),d=s(i*i),m=s(e*r*l-d),{isValid:b,value:A}=kn(s(m*d)),B=s(A*i),p=s(A*B*m),y=s((f+f)*B);ht(y,o)&&(y=s(-y));let O=s(a*p),_=s(y*O);if(!b||ht(_,o)||O===Dr)throw new Error("invalid ristretto255 encoding 2");return new n(new Zt(y,O,pt,_))}static fromHex(t){return n.fromBytes(kt(t))}toBytes(){let{X:t,Y:e,Z:r,T:o}=this.ep,s=zt,f=p=>vt.create(p),c=f(f(r+e)*f(r-e)),a=f(t*e),i=f(a*a),{value:l}=kn(f(c*i)),d=f(l*c),m=f(l*a),b=f(d*m*o),A;if(ht(o*b,s)){let p=f(e*Qe),y=f(t*Qe);t=p,e=y,A=f(d*Zr)}else A=m;ht(t*b,s)&&(e=f(-e));let B=f((r-e)*A);return ht(B,s)&&(B=f(-B)),vt.toBytes(B)}equals(t){this.assertSame(t);let{X:e,Y:r}=this.ep,{X:o,Y:s}=t.ep,f=i=>vt.create(i),c=f(e*s)===f(r*o),a=f(r*s)===f(e*o);return c||a}is0(){return this.equals(n.ZERO)}};Object.freeze(bt.BASE);Object.freeze(bt.ZERO);Object.freeze(bt.prototype);Object.freeze(bt);var tn=Object.freeze({Point:bt,hashToCurve(n,t){let e=t?.DST===void 0?"ristretto255_XMD:SHA-512_R255MAP_RO_":t.DST,r=ye(n,e,64,Ot);return tn.deriveToCurve(r)},hashToScalar(n,t={DST:te}){let e=ye(n,t.DST,64,Ot);return Kn.create(at(e))},deriveToCurve(n){ot(n,64);let t=Je(n.subarray(0,32)),e=Xn(t),r=Je(n.subarray(32,64)),o=Xn(r);return new bt(e.add(o))}}),Gn=Mt({name:"ristretto255-SHA512",Point:bt,hash:Ot,hashToGroup:tn.hashToCurve,hashToScalar:tn.hashToScalar});var Pn=(n,t)=>(n+(n>=0?t:-t)/xt)/t;function Mr(n,t,e){Wt("scalar",n,yt,e);let[[r,o],[s,f]]=t,c=Pn(f*n,e),a=Pn(-o*n,e),i=n-c*r-a*s,l=-c*o-a*f,d=i<yt,m=l<yt;d&&(i=-i),m&&(l=-l);let b=Qt(Math.ceil(Ft(e)/2))+W;if(i<yt||i>=b||l<yt||l>=b)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:i,k2neg:m,k2:l}}var rn=class extends Error{constructor(t=""){super(t)}},mt={Err:rn,_tlv:{encode:(n,t)=>{let{Err:e}=mt;if(J(n,"tag"),n<0||n>255)throw new e("tlv.encode: wrong tag");if(typeof t!="string")throw new TypeError('"data" expected string, got type='+typeof t);if(t.length&1)throw new e("tlv.encode: unpadded data");let r=t.length/2,o=$t(r);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=r>127?$t(o.length/2|128):"";return $t(n)+s+o+t},decode(n,t){let{Err:e}=mt;t=k(t,void 0,"DER data");let r=0;if(n<0||n>255)throw new e("tlv.encode: wrong tag");if(t.length<2||t[r++]!==n)throw new e("tlv.decode: wrong tlv");let o=t[r++],s=!!(o&128),f=0;if(!s)f=o;else{let a=o&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let i=t.subarray(r,r+a);if(i.length!==a)throw new e("tlv.decode: length bytes not complete");if(i[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let l of i)f=f<<8|l;if(r+=a,f<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(r,r+f);if(c.length!==f)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(r+f)}}},_int:{encode(n){let{Err:t}=mt;if(le(n),n<yt)throw new t("integer: negative integers are not allowed");let e=$t(n);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(n){let{Err:t}=mt;if(n.length<1)throw new t("invalid signature integer: empty");if(n[0]&128)throw new t("invalid signature integer: negative");if(n.length>1&&n[0]===0&&!(n[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return lt(n)}},toSig(n){let{Err:t,_int:e,_tlv:r}=mt,o=k(n,void 0,"signature"),{v:s,l:f}=r.decode(48,o);if(f.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=r.decode(2,s),{v:i,l}=r.decode(2,a);if(l.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(i)}},hexFromSig(n){let{_tlv:t,_int:e}=mt,r=t.encode(2,e.encode(n.r)),o=t.encode(2,e.encode(n.s)),s=r+o;return t.encode(48,s)}};Object.freeze(mt._tlv);Object.freeze(mt._int);Object.freeze(mt);var yt=BigInt(0),W=BigInt(1),xt=BigInt(2),Yt=BigInt(3),on=BigInt(4);function we(n,t={}){let e=xe("weierstrass",n,t),r=e.Fp,o=e.Fn,s=e.CURVE,{h:f,n:c}=s;rt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:a,allowInfinityPoint:i}=t;if(a&&(!r.is0(s.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let l=kr(r,o);function d(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function m(U,w,T){if(i&&w.is0())return Uint8Array.of(0);let{x:I,y:u}=w.toAffine(),h=r.toBytes(I);if(Tt(T,"isCompressed"),T){d();let g=!r.isOdd(u);return K(zr(g),h)}else return K(Uint8Array.of(4),h,r.toBytes(u))}function b(U){k(U,void 0,"Point");let{publicKey:w,publicKeyUncompressed:T}=l,I=U.length,u=U[0],h=U.subarray(1);if(i&&I===1&&u===0)return{x:r.ZERO,y:r.ZERO};if(I===w&&(u===2||u===3)){let g=r.fromBytes(h);if(!r.isValid(g))throw new Error("bad point: is not on curve, wrong x");let E=p(g),x;try{x=r.sqrt(E)}catch(q){let H=q instanceof Error?": "+q.message:"";throw new Error("bad point: is not on curve, sqrt error"+H)}d();let S=r.isOdd(x);return(u&1)===1!==S&&(x=r.neg(x)),{x:g,y:x}}else if(I===T&&u===4){let g=r.BYTES,E=r.fromBytes(h.subarray(0,g)),x=r.fromBytes(h.subarray(g,g*2));if(!y(E,x))throw new Error("bad point: is not on curve");return{x:E,y:x}}else throw new Error(`bad point: got length ${I}, expected compressed=${w} or uncompressed=${T}`)}let A=t.toBytes===void 0?m:t.toBytes,B=t.fromBytes===void 0?b:t.fromBytes;function p(U){let w=r.sqr(U),T=r.mul(w,U);return r.add(r.add(T,r.mul(U,s.a)),s.b)}function y(U,w){let T=r.sqr(w),I=p(U);return r.eql(T,I)}if(!y(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let O=r.mul(r.pow(s.a,Yt),on),_=r.mul(r.sqr(s.b),BigInt(27));if(r.is0(r.add(O,_)))throw new Error("bad curve params: a or b");function D(U,w,T=!1){if(!r.isValid(w)||T&&r.is0(w))throw new Error(`bad point coordinate ${U}`);return w}function L(U){if(!(U instanceof R))throw new Error("Weierstrass Point expected")}function C(U){if(!a||!a.basises)throw new Error("no endo");return Mr(U,a.basises,o.ORDER)}function Z(U,w,T,I,u){return T=new R(r.mul(T.X,U),T.Y,T.Z),w=Jt(I,w),T=Jt(u,T),w.add(T)}class R{static BASE=new R(s.Gx,s.Gy,r.ONE);static ZERO=new R(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=o;X;Y;Z;constructor(w,T,I){this.X=D("x",w),this.Y=D("y",T,!0),this.Z=D("z",I),Object.freeze(this)}static CURVE(){return s}static fromAffine(w){let{x:T,y:I}=w||{};if(!w||!r.isValid(T)||!r.isValid(I))throw new Error("invalid affine point");if(w instanceof R)throw new Error("projective point not allowed");return r.is0(T)&&r.is0(I)?R.ZERO:new R(T,I,r.ONE)}static fromBytes(w){let T=R.fromAffine(B(k(w,void 0,"point")));return T.assertValidity(),T}static fromHex(w){return R.fromBytes(de(w))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,T=!0){return j.createCache(this,w),T||this.multiply(Yt),this}assertValidity(){let w=this;if(w.is0()){if(t.allowInfinityPoint&&r.is0(w.X)&&r.eql(w.Y,r.ONE)&&r.is0(w.Z))return;throw new Error("bad point: ZERO")}let{x:T,y:I}=w.toAffine();if(!r.isValid(T)||!r.isValid(I))throw new Error("bad point: x or y not field elements");if(!y(T,I))throw new Error("bad point: equation left != right");if(!w.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:w}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(w)}equals(w){L(w);let{X:T,Y:I,Z:u}=this,{X:h,Y:g,Z:E}=w,x=r.eql(r.mul(T,E),r.mul(h,u)),S=r.eql(r.mul(I,E),r.mul(g,u));return x&&S}negate(){return new R(this.X,r.neg(this.Y),this.Z)}double(){let{a:w,b:T}=s,I=r.mul(T,Yt),{X:u,Y:h,Z:g}=this,E=r.ZERO,x=r.ZERO,S=r.ZERO,v=r.mul(u,u),q=r.mul(h,h),H=r.mul(g,g),F=r.mul(u,h);return F=r.add(F,F),S=r.mul(u,g),S=r.add(S,S),E=r.mul(w,S),x=r.mul(I,H),x=r.add(E,x),E=r.sub(q,x),x=r.add(q,x),x=r.mul(E,x),E=r.mul(F,E),S=r.mul(I,S),H=r.mul(w,H),F=r.sub(v,H),F=r.mul(w,F),F=r.add(F,S),S=r.add(v,v),v=r.add(S,v),v=r.add(v,H),v=r.mul(v,F),x=r.add(x,v),H=r.mul(h,g),H=r.add(H,H),v=r.mul(H,F),E=r.sub(E,v),S=r.mul(H,q),S=r.add(S,S),S=r.add(S,S),new R(E,x,S)}add(w){L(w);let{X:T,Y:I,Z:u}=this,{X:h,Y:g,Z:E}=w,x=r.ZERO,S=r.ZERO,v=r.ZERO,q=s.a,H=r.mul(s.b,Yt),F=r.mul(T,h),V=r.mul(I,g),Y=r.mul(u,E),et=r.add(T,I),M=r.add(h,g);et=r.mul(et,M),M=r.add(F,V),et=r.sub(et,M),M=r.add(T,u);let it=r.add(h,E);return M=r.mul(M,it),it=r.add(F,Y),M=r.sub(M,it),it=r.add(I,u),x=r.add(g,E),it=r.mul(it,x),x=r.add(V,Y),it=r.sub(it,x),v=r.mul(q,M),x=r.mul(H,Y),v=r.add(x,v),x=r.sub(V,v),v=r.add(V,v),S=r.mul(x,v),V=r.add(F,F),V=r.add(V,F),Y=r.mul(q,Y),M=r.mul(H,M),V=r.add(V,Y),Y=r.sub(F,Y),Y=r.mul(q,Y),M=r.add(M,Y),F=r.mul(V,M),S=r.add(S,F),F=r.mul(it,M),x=r.mul(et,x),x=r.sub(x,F),F=r.mul(et,V),v=r.mul(it,v),v=r.add(v,F),new R(x,S,v)}subtract(w){return L(w),this.add(w.negate())}is0(){return this.equals(R.ZERO)}multiply(w){let{endo:T}=t;if(!o.isValidNot0(w))throw new RangeError("invalid scalar: out of range");let I,u,h=g=>j.cached(this,g,E=>Nt(R,E));if(T){let{k1neg:g,k1:E,k2neg:x,k2:S}=C(w),{p:v,f:q}=h(E),{p:H,f:F}=h(S);u=q.add(F),I=Z(T.beta,v,H,g,x)}else{let{p:g,f:E}=h(w);I=g,u=E}return Nt(R,[I,u])[0]}multiplyUnsafe(w){let{endo:T}=t,I=this,u=w;if(!o.isValid(u))throw new RangeError("invalid scalar: out of range");if(u===yt||I.is0())return R.ZERO;if(u===W)return I;if(j.hasCache(this))return this.multiply(u);if(T){let{k1neg:h,k1:g,k2neg:E,k2:x}=C(u),{p1:S,p2:v}=jn(R,I,g,x);return Z(T.beta,S,v,h,E)}else return j.unsafe(I,u)}toAffine(w){let T=this,I=w,{X:u,Y:h,Z:g}=T;if(r.eql(g,r.ONE))return{x:u,y:h};let E=T.is0();I==null&&(I=E?r.ONE:r.inv(g));let x=r.mul(u,I),S=r.mul(h,I),v=r.mul(g,I);if(E)return{x:r.ZERO,y:r.ZERO};if(!r.eql(v,r.ONE))throw new Error("invZ was invalid");return{x,y:S}}isTorsionFree(){let{isTorsionFree:w}=t;return f===W?!0:w?w(R,this):j.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:w}=t;return f===W?this:w?w(R,this):this.multiplyUnsafe(f)}isSmallOrder(){return f===W?this.is0():this.clearCofactor().is0()}toBytes(w=!0){return Tt(w,"isCompressed"),this.assertValidity(),A(R,this,w)}toHex(w=!0){return Pt(this.toBytes(w))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let N=o.BITS,j=new Vt(R,t.endo?Math.ceil(N/2):N);return N>=8&&R.BASE.precompute(8),Object.freeze(R.prototype),Object.freeze(R),R}function zr(n){return Uint8Array.of(n?2:3)}function Yr(n,t){let e=Dt(n),r=e.ORDER,o=yt;for(let B=r-W;B%xt===yt;B/=xt)o+=W;let s=o,f=xt<<s-W-W,c=f*xt,a=(r-W)/c,i=(a-W)/xt,l=c-W,d=f,m=e.pow(t,a),b=e.pow(t,(a+W)/xt),A=(B,p)=>{let y=m,O=e.pow(p,l),_=e.sqr(O);_=e.mul(_,p);let D=e.mul(B,_);D=e.pow(D,i),D=e.mul(D,O),O=e.mul(D,p),_=e.mul(D,B);let L=e.mul(_,O);D=e.pow(L,d);let C=e.eql(D,e.ONE);O=e.mul(_,b),D=e.mul(L,y),_=e.cmov(O,_,C),L=e.cmov(D,L,C);for(let Z=s;Z>W;Z--){let R=Z-xt;R=xt<<R-W;let N=e.pow(L,R),j=e.eql(N,e.ONE);O=e.mul(_,y),y=e.mul(y,y),N=e.mul(L,y),_=e.cmov(O,_,j),L=e.cmov(N,L,j)}return{isValid:!e.is0(p)&&(C||e.is0(B)),value:_}};if(e.ORDER%on===Yt){let B=(e.ORDER-Yt)/on,p=e.sqrt(e.neg(t));A=(y,O)=>{let _=e.sqr(O),D=e.mul(y,O);_=e.mul(_,D);let L=e.pow(_,B);L=e.mul(L,D);let C=e.mul(L,p),Z=e.mul(e.sqr(L),O),R=e.eql(Z,y),N=e.cmov(C,L,R);return{isValid:!e.is0(O)&&R,value:N}}}return A}function $n(n,t){let e=Dt(n),{A:r,B:o,Z:s}=t;if(!e.isValidNot0(r)||!e.isValidNot0(o)||!e.isValid(s))throw new Error("mapToCurveSimpleSWU: invalid opts");if(e.eql(s,e.neg(e.ONE))||Ye(e,s))throw new Error("mapToCurveSimpleSWU: invalid opts");let f=e.mul(o,e.inv(e.mul(s,r))),c=e.add(e.add(e.mul(e.sqr(f),f),e.mul(r,f)),o);if(!Ye(e,c))throw new Error("mapToCurveSimpleSWU: invalid opts");let a=Yr(e,s);if(!e.isOdd)throw new Error("Field does not have .isOdd()");return i=>{let l,d,m,b,A,B,p,y;l=e.sqr(i),l=e.mul(l,s),d=e.sqr(l),d=e.add(d,l),m=e.add(d,e.ONE),m=e.mul(m,o),b=e.cmov(s,e.neg(d),!e.eql(d,e.ZERO)),b=e.mul(b,r),d=e.sqr(m),B=e.sqr(b),A=e.mul(B,r),d=e.add(d,A),d=e.mul(d,m),B=e.mul(B,b),A=e.mul(B,o),d=e.add(d,A),p=e.mul(l,m);let{isValid:O,value:_}=a(d,B);y=e.mul(l,i),y=e.mul(y,_),p=e.cmov(p,m,O),y=e.cmov(y,_,O);let D=e.isOdd(i)===e.isOdd(y);y=e.cmov(e.neg(y),y,D);let L=Ht(e,[b],!0)[0];return p=e.mul(p,L),{x:p,y}}}function kr(n,t){return{secretKey:t.BYTES,publicKey:1+n.BYTES,publicKeyUncompressed:1+2*n.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}var ge={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},Ee={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},Be={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")};function sn(n,t){let e;return r=>(e||(e=$n(n.Fp,t)))(r[0])}var ve=we(ge);var Wn=ee(ve,sn(ve,{A:ge.a,B:ge.b,Z:ve.Fp.create(BigInt("-10"))}),{DST:"P256_XMD:SHA-256_SSWU_RO_",encodeDST:"P256_XMD:SHA-256_SSWU_NU_",p:ge.p,m:1,k:128,expand:"xmd",hash:Ne}),tr=Mt({name:"P256-SHA256",Point:ve,hash:Ne,hashToGroup:Wn.hashToCurve,hashToScalar:Wn.hashToScalar});var Se=we(Ee);var Qn=ee(Se,sn(Se,{A:Ee.a,B:Ee.b,Z:Se.Fp.create(BigInt("-12"))}),{DST:"P384_XMD:SHA-384_SSWU_RO_",encodeDST:"P384_XMD:SHA-384_SSWU_NU_",p:Ee.p,m:1,k:192,expand:"xmd",hash:Ue}),er=Mt({name:"P384-SHA384",Point:Se,hash:Ue,hashToGroup:Qn.hashToCurve,hashToScalar:Qn.hashToScalar}),_e=we(Be);var Jn=ee(_e,sn(_e,{A:Be.a,B:Be.b,Z:_e.Fp.create(BigInt("-4"))}),{DST:"P521_XMD:SHA-512_SSWU_RO_",encodeDST:"P521_XMD:SHA-512_SSWU_NU_",p:Be.p,m:1,k:256,expand:"xmd",hash:Ot}),nr=Mt({name:"P521-SHA512",Point:_e,hash:Ot,hashToGroup:Jn.hashToCurve,hashToScalar:Jn.hashToScalar});0&&(module.exports={p256_oprf,p384_oprf,p521_oprf,ristretto255_oprf});
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
24
+
25
+ // _entry.mjs
26
+ var entry_exports = {};
27
+ __export(entry_exports, {
28
+ p256_oprf: () => p256_oprf,
29
+ p384_oprf: () => p384_oprf,
30
+ p521_oprf: () => p521_oprf,
31
+ ristretto255_oprf: () => ristretto255_oprf
32
+ });
33
+ module.exports = __toCommonJS(entry_exports);
34
+
35
+ // node_modules/@noble/hashes/utils.js
36
+ function isBytes(a) {
37
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
38
+ }
39
+ function anumber(n, title = "") {
40
+ if (typeof n !== "number") {
41
+ const prefix = title && `"${title}" `;
42
+ throw new TypeError(`${prefix}expected number, got ${typeof n}`);
43
+ }
44
+ if (!Number.isSafeInteger(n) || n < 0) {
45
+ const prefix = title && `"${title}" `;
46
+ throw new RangeError(`${prefix}expected integer >= 0, got ${n}`);
47
+ }
48
+ }
49
+ function abytes(value, length, title = "") {
50
+ const bytes = isBytes(value);
51
+ const len = value?.length;
52
+ const needsLen = length !== void 0;
53
+ if (!bytes || needsLen && len !== length) {
54
+ const prefix = title && `"${title}" `;
55
+ const ofLen = needsLen ? ` of length ${length}` : "";
56
+ const got = bytes ? `length=${len}` : `type=${typeof value}`;
57
+ const message = prefix + "expected Uint8Array" + ofLen + ", got " + got;
58
+ if (!bytes)
59
+ throw new TypeError(message);
60
+ throw new RangeError(message);
61
+ }
62
+ return value;
63
+ }
64
+ function aexists(instance, checkFinished = true) {
65
+ if (instance.destroyed)
66
+ throw new Error("Hash instance has been destroyed");
67
+ if (checkFinished && instance.finished)
68
+ throw new Error("Hash#digest() has already been called");
69
+ }
70
+ function aoutput(out, instance) {
71
+ abytes(out, void 0, "digestInto() output");
72
+ const min = instance.outputLen;
73
+ if (out.length < min) {
74
+ throw new RangeError('"digestInto() output" expected to be of length >=' + min);
75
+ }
76
+ }
77
+ function clean(...arrays) {
78
+ for (let i = 0; i < arrays.length; i++) {
79
+ arrays[i].fill(0);
80
+ }
81
+ }
82
+ function createView(arr) {
83
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
84
+ }
85
+ function rotr(word, shift) {
86
+ return word << 32 - shift | word >>> shift;
87
+ }
88
+ var hasHexBuiltin = /* @__PURE__ */ (() => (
89
+ // @ts-ignore
90
+ typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
91
+ ))();
92
+ var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
93
+ function bytesToHex(bytes) {
94
+ abytes(bytes);
95
+ if (hasHexBuiltin)
96
+ return bytes.toHex();
97
+ let hex = "";
98
+ for (let i = 0; i < bytes.length; i++) {
99
+ hex += hexes[bytes[i]];
100
+ }
101
+ return hex;
102
+ }
103
+ var asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
104
+ function asciiToBase16(ch) {
105
+ if (ch >= asciis._0 && ch <= asciis._9)
106
+ return ch - asciis._0;
107
+ if (ch >= asciis.A && ch <= asciis.F)
108
+ return ch - (asciis.A - 10);
109
+ if (ch >= asciis.a && ch <= asciis.f)
110
+ return ch - (asciis.a - 10);
111
+ return;
112
+ }
113
+ function hexToBytes(hex) {
114
+ if (typeof hex !== "string")
115
+ throw new TypeError("hex string expected, got " + typeof hex);
116
+ if (hasHexBuiltin) {
117
+ try {
118
+ return Uint8Array.fromHex(hex);
119
+ } catch (error) {
120
+ if (error instanceof SyntaxError)
121
+ throw new RangeError(error.message);
122
+ throw error;
123
+ }
124
+ }
125
+ const hl = hex.length;
126
+ const al = hl / 2;
127
+ if (hl % 2)
128
+ throw new RangeError("hex string expected, got unpadded hex of length " + hl);
129
+ const array = new Uint8Array(al);
130
+ for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
131
+ const n1 = asciiToBase16(hex.charCodeAt(hi));
132
+ const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
133
+ if (n1 === void 0 || n2 === void 0) {
134
+ const char = hex[hi] + hex[hi + 1];
135
+ throw new RangeError('hex string expected, got non-hex character "' + char + '" at index ' + hi);
136
+ }
137
+ array[ai] = n1 * 16 + n2;
138
+ }
139
+ return array;
140
+ }
141
+ function concatBytes(...arrays) {
142
+ let sum = 0;
143
+ for (let i = 0; i < arrays.length; i++) {
144
+ const a = arrays[i];
145
+ abytes(a);
146
+ sum += a.length;
147
+ }
148
+ const res = new Uint8Array(sum);
149
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
150
+ const a = arrays[i];
151
+ res.set(a, pad);
152
+ pad += a.length;
153
+ }
154
+ return res;
155
+ }
156
+ function createHasher(hashCons, info = {}) {
157
+ const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
158
+ const tmp = hashCons(void 0);
159
+ hashC.outputLen = tmp.outputLen;
160
+ hashC.blockLen = tmp.blockLen;
161
+ hashC.canXOF = tmp.canXOF;
162
+ hashC.create = (opts) => hashCons(opts);
163
+ Object.assign(hashC, info);
164
+ return Object.freeze(hashC);
165
+ }
166
+ function randomBytes(bytesLength = 32) {
167
+ anumber(bytesLength, "bytesLength");
168
+ const cr = typeof globalThis === "object" ? globalThis.crypto : null;
169
+ if (typeof cr?.getRandomValues !== "function")
170
+ throw new Error("crypto.getRandomValues must be defined");
171
+ if (bytesLength > 65536)
172
+ throw new RangeError(`"bytesLength" expected <= 65536, got ${bytesLength}`);
173
+ return cr.getRandomValues(new Uint8Array(bytesLength));
174
+ }
175
+ var oidNist = (suffix) => ({
176
+ // Current NIST hashAlgs suffixes used here fit in one DER subidentifier octet.
177
+ // Larger suffix values would need base-128 OID encoding and a different length byte.
178
+ oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
179
+ });
180
+
181
+ // node_modules/@noble/hashes/_md.js
182
+ function Chi(a, b, c) {
183
+ return a & b ^ ~a & c;
184
+ }
185
+ function Maj(a, b, c) {
186
+ return a & b ^ a & c ^ b & c;
187
+ }
188
+ var HashMD = class {
189
+ blockLen;
190
+ outputLen;
191
+ canXOF = false;
192
+ padOffset;
193
+ isLE;
194
+ // For partial updates less than block size
195
+ buffer;
196
+ view;
197
+ finished = false;
198
+ length = 0;
199
+ pos = 0;
200
+ destroyed = false;
201
+ constructor(blockLen, outputLen, padOffset, isLE) {
202
+ this.blockLen = blockLen;
203
+ this.outputLen = outputLen;
204
+ this.padOffset = padOffset;
205
+ this.isLE = isLE;
206
+ this.buffer = new Uint8Array(blockLen);
207
+ this.view = createView(this.buffer);
208
+ }
209
+ update(data) {
210
+ aexists(this);
211
+ abytes(data);
212
+ const { view, buffer, blockLen } = this;
213
+ const len = data.length;
214
+ for (let pos = 0; pos < len; ) {
215
+ const take = Math.min(blockLen - this.pos, len - pos);
216
+ if (take === blockLen) {
217
+ const dataView = createView(data);
218
+ for (; blockLen <= len - pos; pos += blockLen)
219
+ this.process(dataView, pos);
220
+ continue;
221
+ }
222
+ buffer.set(data.subarray(pos, pos + take), this.pos);
223
+ this.pos += take;
224
+ pos += take;
225
+ if (this.pos === blockLen) {
226
+ this.process(view, 0);
227
+ this.pos = 0;
228
+ }
229
+ }
230
+ this.length += data.length;
231
+ this.roundClean();
232
+ return this;
233
+ }
234
+ digestInto(out) {
235
+ aexists(this);
236
+ aoutput(out, this);
237
+ this.finished = true;
238
+ const { buffer, view, blockLen, isLE } = this;
239
+ let { pos } = this;
240
+ buffer[pos++] = 128;
241
+ clean(this.buffer.subarray(pos));
242
+ if (this.padOffset > blockLen - pos) {
243
+ this.process(view, 0);
244
+ pos = 0;
245
+ }
246
+ for (let i = pos; i < blockLen; i++)
247
+ buffer[i] = 0;
248
+ view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
249
+ this.process(view, 0);
250
+ const oview = createView(out);
251
+ const len = this.outputLen;
252
+ if (len % 4)
253
+ throw new Error("_sha2: outputLen must be aligned to 32bit");
254
+ const outLen = len / 4;
255
+ const state = this.get();
256
+ if (outLen > state.length)
257
+ throw new Error("_sha2: outputLen bigger than state");
258
+ for (let i = 0; i < outLen; i++)
259
+ oview.setUint32(4 * i, state[i], isLE);
260
+ }
261
+ digest() {
262
+ const { buffer, outputLen } = this;
263
+ this.digestInto(buffer);
264
+ const res = buffer.slice(0, outputLen);
265
+ this.destroy();
266
+ return res;
267
+ }
268
+ _cloneInto(to) {
269
+ to ||= new this.constructor();
270
+ to.set(...this.get());
271
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
272
+ to.destroyed = destroyed;
273
+ to.finished = finished;
274
+ to.length = length;
275
+ to.pos = pos;
276
+ if (length % blockLen)
277
+ to.buffer.set(buffer);
278
+ return to;
279
+ }
280
+ clone() {
281
+ return this._cloneInto();
282
+ }
283
+ };
284
+ var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
285
+ 1779033703,
286
+ 3144134277,
287
+ 1013904242,
288
+ 2773480762,
289
+ 1359893119,
290
+ 2600822924,
291
+ 528734635,
292
+ 1541459225
293
+ ]);
294
+ var SHA384_IV = /* @__PURE__ */ Uint32Array.from([
295
+ 3418070365,
296
+ 3238371032,
297
+ 1654270250,
298
+ 914150663,
299
+ 2438529370,
300
+ 812702999,
301
+ 355462360,
302
+ 4144912697,
303
+ 1731405415,
304
+ 4290775857,
305
+ 2394180231,
306
+ 1750603025,
307
+ 3675008525,
308
+ 1694076839,
309
+ 1203062813,
310
+ 3204075428
311
+ ]);
312
+ var SHA512_IV = /* @__PURE__ */ Uint32Array.from([
313
+ 1779033703,
314
+ 4089235720,
315
+ 3144134277,
316
+ 2227873595,
317
+ 1013904242,
318
+ 4271175723,
319
+ 2773480762,
320
+ 1595750129,
321
+ 1359893119,
322
+ 2917565137,
323
+ 2600822924,
324
+ 725511199,
325
+ 528734635,
326
+ 4215389547,
327
+ 1541459225,
328
+ 327033209
329
+ ]);
330
+
331
+ // node_modules/@noble/hashes/_u64.js
332
+ var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
333
+ var _32n = /* @__PURE__ */ BigInt(32);
334
+ function fromBig(n, le = false) {
335
+ if (le)
336
+ return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
337
+ return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
338
+ }
339
+ function split(lst, le = false) {
340
+ const len = lst.length;
341
+ let Ah = new Uint32Array(len);
342
+ let Al = new Uint32Array(len);
343
+ for (let i = 0; i < len; i++) {
344
+ const { h, l } = fromBig(lst[i], le);
345
+ [Ah[i], Al[i]] = [h, l];
346
+ }
347
+ return [Ah, Al];
348
+ }
349
+ var shrSH = (h, _l, s) => h >>> s;
350
+ var shrSL = (h, l, s) => h << 32 - s | l >>> s;
351
+ var rotrSH = (h, l, s) => h >>> s | l << 32 - s;
352
+ var rotrSL = (h, l, s) => h << 32 - s | l >>> s;
353
+ var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
354
+ var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
355
+ function add(Ah, Al, Bh, Bl) {
356
+ const l = (Al >>> 0) + (Bl >>> 0);
357
+ return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
358
+ }
359
+ var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
360
+ var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
361
+ var add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
362
+ var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
363
+ var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
364
+ var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
365
+
366
+ // node_modules/@noble/hashes/sha2.js
367
+ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
368
+ 1116352408,
369
+ 1899447441,
370
+ 3049323471,
371
+ 3921009573,
372
+ 961987163,
373
+ 1508970993,
374
+ 2453635748,
375
+ 2870763221,
376
+ 3624381080,
377
+ 310598401,
378
+ 607225278,
379
+ 1426881987,
380
+ 1925078388,
381
+ 2162078206,
382
+ 2614888103,
383
+ 3248222580,
384
+ 3835390401,
385
+ 4022224774,
386
+ 264347078,
387
+ 604807628,
388
+ 770255983,
389
+ 1249150122,
390
+ 1555081692,
391
+ 1996064986,
392
+ 2554220882,
393
+ 2821834349,
394
+ 2952996808,
395
+ 3210313671,
396
+ 3336571891,
397
+ 3584528711,
398
+ 113926993,
399
+ 338241895,
400
+ 666307205,
401
+ 773529912,
402
+ 1294757372,
403
+ 1396182291,
404
+ 1695183700,
405
+ 1986661051,
406
+ 2177026350,
407
+ 2456956037,
408
+ 2730485921,
409
+ 2820302411,
410
+ 3259730800,
411
+ 3345764771,
412
+ 3516065817,
413
+ 3600352804,
414
+ 4094571909,
415
+ 275423344,
416
+ 430227734,
417
+ 506948616,
418
+ 659060556,
419
+ 883997877,
420
+ 958139571,
421
+ 1322822218,
422
+ 1537002063,
423
+ 1747873779,
424
+ 1955562222,
425
+ 2024104815,
426
+ 2227730452,
427
+ 2361852424,
428
+ 2428436474,
429
+ 2756734187,
430
+ 3204031479,
431
+ 3329325298
432
+ ]);
433
+ var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
434
+ var SHA2_32B = class extends HashMD {
435
+ constructor(outputLen) {
436
+ super(64, outputLen, 8, false);
437
+ }
438
+ get() {
439
+ const { A, B, C, D, E, F, G, H } = this;
440
+ return [A, B, C, D, E, F, G, H];
441
+ }
442
+ // prettier-ignore
443
+ set(A, B, C, D, E, F, G, H) {
444
+ this.A = A | 0;
445
+ this.B = B | 0;
446
+ this.C = C | 0;
447
+ this.D = D | 0;
448
+ this.E = E | 0;
449
+ this.F = F | 0;
450
+ this.G = G | 0;
451
+ this.H = H | 0;
452
+ }
453
+ process(view, offset) {
454
+ for (let i = 0; i < 16; i++, offset += 4)
455
+ SHA256_W[i] = view.getUint32(offset, false);
456
+ for (let i = 16; i < 64; i++) {
457
+ const W15 = SHA256_W[i - 15];
458
+ const W2 = SHA256_W[i - 2];
459
+ const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
460
+ const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
461
+ SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
462
+ }
463
+ let { A, B, C, D, E, F, G, H } = this;
464
+ for (let i = 0; i < 64; i++) {
465
+ const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
466
+ const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
467
+ const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
468
+ const T2 = sigma0 + Maj(A, B, C) | 0;
469
+ H = G;
470
+ G = F;
471
+ F = E;
472
+ E = D + T1 | 0;
473
+ D = C;
474
+ C = B;
475
+ B = A;
476
+ A = T1 + T2 | 0;
477
+ }
478
+ A = A + this.A | 0;
479
+ B = B + this.B | 0;
480
+ C = C + this.C | 0;
481
+ D = D + this.D | 0;
482
+ E = E + this.E | 0;
483
+ F = F + this.F | 0;
484
+ G = G + this.G | 0;
485
+ H = H + this.H | 0;
486
+ this.set(A, B, C, D, E, F, G, H);
487
+ }
488
+ roundClean() {
489
+ clean(SHA256_W);
490
+ }
491
+ destroy() {
492
+ this.destroyed = true;
493
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
494
+ clean(this.buffer);
495
+ }
496
+ };
497
+ var _SHA256 = class extends SHA2_32B {
498
+ // We cannot use array here since array allows indexing by variable
499
+ // which means optimizer/compiler cannot use registers.
500
+ A = SHA256_IV[0] | 0;
501
+ B = SHA256_IV[1] | 0;
502
+ C = SHA256_IV[2] | 0;
503
+ D = SHA256_IV[3] | 0;
504
+ E = SHA256_IV[4] | 0;
505
+ F = SHA256_IV[5] | 0;
506
+ G = SHA256_IV[6] | 0;
507
+ H = SHA256_IV[7] | 0;
508
+ constructor() {
509
+ super(32);
510
+ }
511
+ };
512
+ var K512 = /* @__PURE__ */ (() => split([
513
+ "0x428a2f98d728ae22",
514
+ "0x7137449123ef65cd",
515
+ "0xb5c0fbcfec4d3b2f",
516
+ "0xe9b5dba58189dbbc",
517
+ "0x3956c25bf348b538",
518
+ "0x59f111f1b605d019",
519
+ "0x923f82a4af194f9b",
520
+ "0xab1c5ed5da6d8118",
521
+ "0xd807aa98a3030242",
522
+ "0x12835b0145706fbe",
523
+ "0x243185be4ee4b28c",
524
+ "0x550c7dc3d5ffb4e2",
525
+ "0x72be5d74f27b896f",
526
+ "0x80deb1fe3b1696b1",
527
+ "0x9bdc06a725c71235",
528
+ "0xc19bf174cf692694",
529
+ "0xe49b69c19ef14ad2",
530
+ "0xefbe4786384f25e3",
531
+ "0x0fc19dc68b8cd5b5",
532
+ "0x240ca1cc77ac9c65",
533
+ "0x2de92c6f592b0275",
534
+ "0x4a7484aa6ea6e483",
535
+ "0x5cb0a9dcbd41fbd4",
536
+ "0x76f988da831153b5",
537
+ "0x983e5152ee66dfab",
538
+ "0xa831c66d2db43210",
539
+ "0xb00327c898fb213f",
540
+ "0xbf597fc7beef0ee4",
541
+ "0xc6e00bf33da88fc2",
542
+ "0xd5a79147930aa725",
543
+ "0x06ca6351e003826f",
544
+ "0x142929670a0e6e70",
545
+ "0x27b70a8546d22ffc",
546
+ "0x2e1b21385c26c926",
547
+ "0x4d2c6dfc5ac42aed",
548
+ "0x53380d139d95b3df",
549
+ "0x650a73548baf63de",
550
+ "0x766a0abb3c77b2a8",
551
+ "0x81c2c92e47edaee6",
552
+ "0x92722c851482353b",
553
+ "0xa2bfe8a14cf10364",
554
+ "0xa81a664bbc423001",
555
+ "0xc24b8b70d0f89791",
556
+ "0xc76c51a30654be30",
557
+ "0xd192e819d6ef5218",
558
+ "0xd69906245565a910",
559
+ "0xf40e35855771202a",
560
+ "0x106aa07032bbd1b8",
561
+ "0x19a4c116b8d2d0c8",
562
+ "0x1e376c085141ab53",
563
+ "0x2748774cdf8eeb99",
564
+ "0x34b0bcb5e19b48a8",
565
+ "0x391c0cb3c5c95a63",
566
+ "0x4ed8aa4ae3418acb",
567
+ "0x5b9cca4f7763e373",
568
+ "0x682e6ff3d6b2b8a3",
569
+ "0x748f82ee5defb2fc",
570
+ "0x78a5636f43172f60",
571
+ "0x84c87814a1f0ab72",
572
+ "0x8cc702081a6439ec",
573
+ "0x90befffa23631e28",
574
+ "0xa4506cebde82bde9",
575
+ "0xbef9a3f7b2c67915",
576
+ "0xc67178f2e372532b",
577
+ "0xca273eceea26619c",
578
+ "0xd186b8c721c0c207",
579
+ "0xeada7dd6cde0eb1e",
580
+ "0xf57d4f7fee6ed178",
581
+ "0x06f067aa72176fba",
582
+ "0x0a637dc5a2c898a6",
583
+ "0x113f9804bef90dae",
584
+ "0x1b710b35131c471b",
585
+ "0x28db77f523047d84",
586
+ "0x32caab7b40c72493",
587
+ "0x3c9ebe0a15c9bebc",
588
+ "0x431d67c49c100d4c",
589
+ "0x4cc5d4becb3e42b6",
590
+ "0x597f299cfc657e2a",
591
+ "0x5fcb6fab3ad6faec",
592
+ "0x6c44198c4a475817"
593
+ ].map((n) => BigInt(n))))();
594
+ var SHA512_Kh = /* @__PURE__ */ (() => K512[0])();
595
+ var SHA512_Kl = /* @__PURE__ */ (() => K512[1])();
596
+ var SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
597
+ var SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
598
+ var SHA2_64B = class extends HashMD {
599
+ constructor(outputLen) {
600
+ super(128, outputLen, 16, false);
601
+ }
602
+ // prettier-ignore
603
+ get() {
604
+ const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
605
+ return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];
606
+ }
607
+ // prettier-ignore
608
+ set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
609
+ this.Ah = Ah | 0;
610
+ this.Al = Al | 0;
611
+ this.Bh = Bh | 0;
612
+ this.Bl = Bl | 0;
613
+ this.Ch = Ch | 0;
614
+ this.Cl = Cl | 0;
615
+ this.Dh = Dh | 0;
616
+ this.Dl = Dl | 0;
617
+ this.Eh = Eh | 0;
618
+ this.El = El | 0;
619
+ this.Fh = Fh | 0;
620
+ this.Fl = Fl | 0;
621
+ this.Gh = Gh | 0;
622
+ this.Gl = Gl | 0;
623
+ this.Hh = Hh | 0;
624
+ this.Hl = Hl | 0;
625
+ }
626
+ process(view, offset) {
627
+ for (let i = 0; i < 16; i++, offset += 4) {
628
+ SHA512_W_H[i] = view.getUint32(offset);
629
+ SHA512_W_L[i] = view.getUint32(offset += 4);
630
+ }
631
+ for (let i = 16; i < 80; i++) {
632
+ const W15h = SHA512_W_H[i - 15] | 0;
633
+ const W15l = SHA512_W_L[i - 15] | 0;
634
+ const s0h = rotrSH(W15h, W15l, 1) ^ rotrSH(W15h, W15l, 8) ^ shrSH(W15h, W15l, 7);
635
+ const s0l = rotrSL(W15h, W15l, 1) ^ rotrSL(W15h, W15l, 8) ^ shrSL(W15h, W15l, 7);
636
+ const W2h = SHA512_W_H[i - 2] | 0;
637
+ const W2l = SHA512_W_L[i - 2] | 0;
638
+ const s1h = rotrSH(W2h, W2l, 19) ^ rotrBH(W2h, W2l, 61) ^ shrSH(W2h, W2l, 6);
639
+ const s1l = rotrSL(W2h, W2l, 19) ^ rotrBL(W2h, W2l, 61) ^ shrSL(W2h, W2l, 6);
640
+ const SUMl = add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
641
+ const SUMh = add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
642
+ SHA512_W_H[i] = SUMh | 0;
643
+ SHA512_W_L[i] = SUMl | 0;
644
+ }
645
+ let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
646
+ for (let i = 0; i < 80; i++) {
647
+ const sigma1h = rotrSH(Eh, El, 14) ^ rotrSH(Eh, El, 18) ^ rotrBH(Eh, El, 41);
648
+ const sigma1l = rotrSL(Eh, El, 14) ^ rotrSL(Eh, El, 18) ^ rotrBL(Eh, El, 41);
649
+ const CHIh = Eh & Fh ^ ~Eh & Gh;
650
+ const CHIl = El & Fl ^ ~El & Gl;
651
+ const T1ll = add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
652
+ const T1h = add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
653
+ const T1l = T1ll | 0;
654
+ const sigma0h = rotrSH(Ah, Al, 28) ^ rotrBH(Ah, Al, 34) ^ rotrBH(Ah, Al, 39);
655
+ const sigma0l = rotrSL(Ah, Al, 28) ^ rotrBL(Ah, Al, 34) ^ rotrBL(Ah, Al, 39);
656
+ const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
657
+ const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
658
+ Hh = Gh | 0;
659
+ Hl = Gl | 0;
660
+ Gh = Fh | 0;
661
+ Gl = Fl | 0;
662
+ Fh = Eh | 0;
663
+ Fl = El | 0;
664
+ ({ h: Eh, l: El } = add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
665
+ Dh = Ch | 0;
666
+ Dl = Cl | 0;
667
+ Ch = Bh | 0;
668
+ Cl = Bl | 0;
669
+ Bh = Ah | 0;
670
+ Bl = Al | 0;
671
+ const All = add3L(T1l, sigma0l, MAJl);
672
+ Ah = add3H(All, T1h, sigma0h, MAJh);
673
+ Al = All | 0;
674
+ }
675
+ ({ h: Ah, l: Al } = add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
676
+ ({ h: Bh, l: Bl } = add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
677
+ ({ h: Ch, l: Cl } = add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
678
+ ({ h: Dh, l: Dl } = add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
679
+ ({ h: Eh, l: El } = add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
680
+ ({ h: Fh, l: Fl } = add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
681
+ ({ h: Gh, l: Gl } = add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
682
+ ({ h: Hh, l: Hl } = add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
683
+ this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
684
+ }
685
+ roundClean() {
686
+ clean(SHA512_W_H, SHA512_W_L);
687
+ }
688
+ destroy() {
689
+ this.destroyed = true;
690
+ clean(this.buffer);
691
+ this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
692
+ }
693
+ };
694
+ var _SHA512 = class extends SHA2_64B {
695
+ Ah = SHA512_IV[0] | 0;
696
+ Al = SHA512_IV[1] | 0;
697
+ Bh = SHA512_IV[2] | 0;
698
+ Bl = SHA512_IV[3] | 0;
699
+ Ch = SHA512_IV[4] | 0;
700
+ Cl = SHA512_IV[5] | 0;
701
+ Dh = SHA512_IV[6] | 0;
702
+ Dl = SHA512_IV[7] | 0;
703
+ Eh = SHA512_IV[8] | 0;
704
+ El = SHA512_IV[9] | 0;
705
+ Fh = SHA512_IV[10] | 0;
706
+ Fl = SHA512_IV[11] | 0;
707
+ Gh = SHA512_IV[12] | 0;
708
+ Gl = SHA512_IV[13] | 0;
709
+ Hh = SHA512_IV[14] | 0;
710
+ Hl = SHA512_IV[15] | 0;
711
+ constructor() {
712
+ super(64);
713
+ }
714
+ };
715
+ var _SHA384 = class extends SHA2_64B {
716
+ Ah = SHA384_IV[0] | 0;
717
+ Al = SHA384_IV[1] | 0;
718
+ Bh = SHA384_IV[2] | 0;
719
+ Bl = SHA384_IV[3] | 0;
720
+ Ch = SHA384_IV[4] | 0;
721
+ Cl = SHA384_IV[5] | 0;
722
+ Dh = SHA384_IV[6] | 0;
723
+ Dl = SHA384_IV[7] | 0;
724
+ Eh = SHA384_IV[8] | 0;
725
+ El = SHA384_IV[9] | 0;
726
+ Fh = SHA384_IV[10] | 0;
727
+ Fl = SHA384_IV[11] | 0;
728
+ Gh = SHA384_IV[12] | 0;
729
+ Gl = SHA384_IV[13] | 0;
730
+ Hh = SHA384_IV[14] | 0;
731
+ Hl = SHA384_IV[15] | 0;
732
+ constructor() {
733
+ super(48);
734
+ }
735
+ };
736
+ var sha256 = /* @__PURE__ */ createHasher(
737
+ () => new _SHA256(),
738
+ /* @__PURE__ */ oidNist(1)
739
+ );
740
+ var sha512 = /* @__PURE__ */ createHasher(
741
+ () => new _SHA512(),
742
+ /* @__PURE__ */ oidNist(3)
743
+ );
744
+ var sha384 = /* @__PURE__ */ createHasher(
745
+ () => new _SHA384(),
746
+ /* @__PURE__ */ oidNist(2)
747
+ );
748
+
749
+ // node_modules/@noble/curves/utils.js
750
+ var abytes2 = (value, length, title) => abytes(value, length, title);
751
+ var anumber2 = anumber;
752
+ var bytesToHex2 = bytesToHex;
753
+ var concatBytes2 = (...arrays) => concatBytes(...arrays);
754
+ var hexToBytes2 = (hex) => hexToBytes(hex);
755
+ var isBytes2 = isBytes;
756
+ var randomBytes2 = (bytesLength) => randomBytes(bytesLength);
757
+ var _0n = /* @__PURE__ */ BigInt(0);
758
+ var _1n = /* @__PURE__ */ BigInt(1);
759
+ function abool(value, title = "") {
760
+ if (typeof value !== "boolean") {
761
+ const prefix = title && `"${title}" `;
762
+ throw new TypeError(prefix + "expected boolean, got type=" + typeof value);
763
+ }
764
+ return value;
765
+ }
766
+ function abignumber(n) {
767
+ if (typeof n === "bigint") {
768
+ if (!isPosBig(n))
769
+ throw new RangeError("positive bigint expected, got " + n);
770
+ } else
771
+ anumber2(n);
772
+ return n;
773
+ }
774
+ function asafenumber(value, title = "") {
775
+ if (typeof value !== "number") {
776
+ const prefix = title && `"${title}" `;
777
+ throw new TypeError(prefix + "expected number, got type=" + typeof value);
778
+ }
779
+ if (!Number.isSafeInteger(value)) {
780
+ const prefix = title && `"${title}" `;
781
+ throw new RangeError(prefix + "expected safe integer, got " + value);
782
+ }
783
+ }
784
+ function numberToHexUnpadded(num) {
785
+ const hex = abignumber(num).toString(16);
786
+ return hex.length & 1 ? "0" + hex : hex;
787
+ }
788
+ function hexToNumber(hex) {
789
+ if (typeof hex !== "string")
790
+ throw new TypeError("hex string expected, got " + typeof hex);
791
+ return hex === "" ? _0n : BigInt("0x" + hex);
792
+ }
793
+ function bytesToNumberBE(bytes) {
794
+ return hexToNumber(bytesToHex(bytes));
795
+ }
796
+ function bytesToNumberLE(bytes) {
797
+ return hexToNumber(bytesToHex(copyBytes(abytes(bytes)).reverse()));
798
+ }
799
+ function numberToBytesBE(n, len) {
800
+ anumber(len);
801
+ if (len === 0)
802
+ throw new RangeError("zero length");
803
+ n = abignumber(n);
804
+ const hex = n.toString(16);
805
+ if (hex.length > len * 2)
806
+ throw new RangeError("number too large");
807
+ return hexToBytes(hex.padStart(len * 2, "0"));
808
+ }
809
+ function numberToBytesLE(n, len) {
810
+ return numberToBytesBE(n, len).reverse();
811
+ }
812
+ function equalBytes(a, b) {
813
+ a = abytes2(a);
814
+ b = abytes2(b);
815
+ if (a.length !== b.length)
816
+ return false;
817
+ let diff = 0;
818
+ for (let i = 0; i < a.length; i++)
819
+ diff |= a[i] ^ b[i];
820
+ return diff === 0;
821
+ }
822
+ function copyBytes(bytes) {
823
+ return Uint8Array.from(abytes2(bytes));
824
+ }
825
+ function asciiToBytes(ascii) {
826
+ if (typeof ascii !== "string")
827
+ throw new TypeError("ascii string expected, got " + typeof ascii);
828
+ return Uint8Array.from(ascii, (c, i) => {
829
+ const charCode = c.charCodeAt(0);
830
+ if (c.length !== 1 || charCode > 127) {
831
+ throw new RangeError(`string contains non-ASCII character "${ascii[i]}" with code ${charCode} at position ${i}`);
832
+ }
833
+ return charCode;
834
+ });
835
+ }
836
+ var isPosBig = (n) => typeof n === "bigint" && _0n <= n;
837
+ function inRange(n, min, max) {
838
+ return isPosBig(n) && isPosBig(min) && isPosBig(max) && min <= n && n < max;
839
+ }
840
+ function aInRange(title, n, min, max) {
841
+ if (!inRange(n, min, max))
842
+ throw new RangeError("expected valid " + title + ": " + min + " <= n < " + max + ", got " + n);
843
+ }
844
+ function bitLen(n) {
845
+ if (n < _0n)
846
+ throw new Error("expected non-negative bigint, got " + n);
847
+ let len;
848
+ for (len = 0; n > _0n; n >>= _1n, len += 1)
849
+ ;
850
+ return len;
851
+ }
852
+ var bitMask = (n) => (_1n << BigInt(n)) - _1n;
853
+ function validateObject(object, fields = {}, optFields = {}) {
854
+ if (Object.prototype.toString.call(object) !== "[object Object]")
855
+ throw new TypeError("expected valid options object");
856
+ function checkField(fieldName, expectedType, isOpt) {
857
+ if (!isOpt && expectedType !== "function" && !Object.hasOwn(object, fieldName))
858
+ throw new TypeError(`param "${fieldName}" is invalid: expected own property`);
859
+ const val = object[fieldName];
860
+ if (isOpt && val === void 0)
861
+ return;
862
+ const current = typeof val;
863
+ if (current !== expectedType || val === null)
864
+ throw new TypeError(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
865
+ }
866
+ const iter = (f, isOpt) => Object.entries(f).forEach(([k, v]) => checkField(k, v, isOpt));
867
+ iter(fields, false);
868
+ iter(optFields, true);
869
+ }
870
+ var notImplemented = () => {
871
+ throw new Error("not implemented");
872
+ };
873
+
874
+ // node_modules/@noble/curves/abstract/modular.js
875
+ var _0n2 = /* @__PURE__ */ BigInt(0);
876
+ var _1n2 = /* @__PURE__ */ BigInt(1);
877
+ var _2n = /* @__PURE__ */ BigInt(2);
878
+ var _3n = /* @__PURE__ */ BigInt(3);
879
+ var _4n = /* @__PURE__ */ BigInt(4);
880
+ var _5n = /* @__PURE__ */ BigInt(5);
881
+ var _7n = /* @__PURE__ */ BigInt(7);
882
+ var _8n = /* @__PURE__ */ BigInt(8);
883
+ var _9n = /* @__PURE__ */ BigInt(9);
884
+ var _16n = /* @__PURE__ */ BigInt(16);
885
+ function mod(a, b) {
886
+ if (b <= _0n2)
887
+ throw new Error("mod: expected positive modulus, got " + b);
888
+ const result = a % b;
889
+ return result >= _0n2 ? result : b + result;
890
+ }
891
+ function pow2(x, power, modulo) {
892
+ if (power < _0n2)
893
+ throw new Error("pow2: expected non-negative exponent, got " + power);
894
+ let res = x;
895
+ while (power-- > _0n2) {
896
+ res *= res;
897
+ res %= modulo;
898
+ }
899
+ return res;
900
+ }
901
+ function invert(number, modulo) {
902
+ if (number === _0n2)
903
+ throw new Error("invert: expected non-zero number");
904
+ if (modulo <= _0n2)
905
+ throw new Error("invert: expected positive modulus, got " + modulo);
906
+ let a = mod(number, modulo);
907
+ let b = modulo;
908
+ let x = _0n2, y = _1n2, u = _1n2, v = _0n2;
909
+ while (a !== _0n2) {
910
+ const q = b / a;
911
+ const r = b - a * q;
912
+ const m = x - u * q;
913
+ const n = y - v * q;
914
+ b = a, a = r, x = u, y = v, u = m, v = n;
915
+ }
916
+ const gcd = b;
917
+ if (gcd !== _1n2)
918
+ throw new Error("invert: does not exist");
919
+ return mod(x, modulo);
920
+ }
921
+ function assertIsSquare(Fp2, root, n) {
922
+ const F = Fp2;
923
+ if (!F.eql(F.sqr(root), n))
924
+ throw new Error("Cannot find square root");
925
+ }
926
+ function sqrt3mod4(Fp2, n) {
927
+ const F = Fp2;
928
+ const p1div4 = (F.ORDER + _1n2) / _4n;
929
+ const root = F.pow(n, p1div4);
930
+ assertIsSquare(F, root, n);
931
+ return root;
932
+ }
933
+ function sqrt5mod8(Fp2, n) {
934
+ const F = Fp2;
935
+ const p5div8 = (F.ORDER - _5n) / _8n;
936
+ const n2 = F.mul(n, _2n);
937
+ const v = F.pow(n2, p5div8);
938
+ const nv = F.mul(n, v);
939
+ const i = F.mul(F.mul(nv, _2n), v);
940
+ const root = F.mul(nv, F.sub(i, F.ONE));
941
+ assertIsSquare(F, root, n);
942
+ return root;
943
+ }
944
+ function sqrt9mod16(P) {
945
+ const Fp_ = Field(P);
946
+ const tn = tonelliShanks(P);
947
+ const c1 = tn(Fp_, Fp_.neg(Fp_.ONE));
948
+ const c2 = tn(Fp_, c1);
949
+ const c3 = tn(Fp_, Fp_.neg(c1));
950
+ const c4 = (P + _7n) / _16n;
951
+ return ((Fp2, n) => {
952
+ const F = Fp2;
953
+ let tv1 = F.pow(n, c4);
954
+ let tv2 = F.mul(tv1, c1);
955
+ const tv3 = F.mul(tv1, c2);
956
+ const tv4 = F.mul(tv1, c3);
957
+ const e1 = F.eql(F.sqr(tv2), n);
958
+ const e2 = F.eql(F.sqr(tv3), n);
959
+ tv1 = F.cmov(tv1, tv2, e1);
960
+ tv2 = F.cmov(tv4, tv3, e2);
961
+ const e3 = F.eql(F.sqr(tv2), n);
962
+ const root = F.cmov(tv1, tv2, e3);
963
+ assertIsSquare(F, root, n);
964
+ return root;
965
+ });
966
+ }
967
+ function tonelliShanks(P) {
968
+ if (P < _3n)
969
+ throw new Error("sqrt is not defined for small field");
970
+ let Q = P - _1n2;
971
+ let S = 0;
972
+ while (Q % _2n === _0n2) {
973
+ Q /= _2n;
974
+ S++;
975
+ }
976
+ let Z = _2n;
977
+ const _Fp = Field(P);
978
+ while (FpLegendre(_Fp, Z) === 1) {
979
+ if (Z++ > 1e3)
980
+ throw new Error("Cannot find square root: probably non-prime P");
981
+ }
982
+ if (S === 1)
983
+ return sqrt3mod4;
984
+ let cc = _Fp.pow(Z, Q);
985
+ const Q1div2 = (Q + _1n2) / _2n;
986
+ return function tonelliSlow(Fp2, n) {
987
+ const F = Fp2;
988
+ if (F.is0(n))
989
+ return n;
990
+ if (FpLegendre(F, n) !== 1)
991
+ throw new Error("Cannot find square root");
992
+ let M = S;
993
+ let c = F.mul(F.ONE, cc);
994
+ let t = F.pow(n, Q);
995
+ let R = F.pow(n, Q1div2);
996
+ while (!F.eql(t, F.ONE)) {
997
+ if (F.is0(t))
998
+ return F.ZERO;
999
+ let i = 1;
1000
+ let t_tmp = F.sqr(t);
1001
+ while (!F.eql(t_tmp, F.ONE)) {
1002
+ i++;
1003
+ t_tmp = F.sqr(t_tmp);
1004
+ if (i === M)
1005
+ throw new Error("Cannot find square root");
1006
+ }
1007
+ const exponent = _1n2 << BigInt(M - i - 1);
1008
+ const b = F.pow(c, exponent);
1009
+ M = i;
1010
+ c = F.sqr(b);
1011
+ t = F.mul(t, c);
1012
+ R = F.mul(R, b);
1013
+ }
1014
+ return R;
1015
+ };
1016
+ }
1017
+ function FpSqrt(P) {
1018
+ if (P % _4n === _3n)
1019
+ return sqrt3mod4;
1020
+ if (P % _8n === _5n)
1021
+ return sqrt5mod8;
1022
+ if (P % _16n === _9n)
1023
+ return sqrt9mod16(P);
1024
+ return tonelliShanks(P);
1025
+ }
1026
+ var isNegativeLE = (num, modulo) => (mod(num, modulo) & _1n2) === _1n2;
1027
+ var FIELD_FIELDS = [
1028
+ "create",
1029
+ "isValid",
1030
+ "is0",
1031
+ "neg",
1032
+ "inv",
1033
+ "sqrt",
1034
+ "sqr",
1035
+ "eql",
1036
+ "add",
1037
+ "sub",
1038
+ "mul",
1039
+ "pow",
1040
+ "div",
1041
+ "addN",
1042
+ "subN",
1043
+ "mulN",
1044
+ "sqrN"
1045
+ ];
1046
+ function validateField(field) {
1047
+ const initial = {
1048
+ ORDER: "bigint",
1049
+ BYTES: "number",
1050
+ BITS: "number"
1051
+ };
1052
+ const opts = FIELD_FIELDS.reduce((map, val) => {
1053
+ map[val] = "function";
1054
+ return map;
1055
+ }, initial);
1056
+ validateObject(field, opts);
1057
+ asafenumber(field.BYTES, "BYTES");
1058
+ asafenumber(field.BITS, "BITS");
1059
+ if (field.BYTES < 1 || field.BITS < 1)
1060
+ throw new Error("invalid field: expected BYTES/BITS > 0");
1061
+ if (field.ORDER <= _1n2)
1062
+ throw new Error("invalid field: expected ORDER > 1, got " + field.ORDER);
1063
+ return field;
1064
+ }
1065
+ function FpPow(Fp2, num, power) {
1066
+ const F = Fp2;
1067
+ if (power < _0n2)
1068
+ throw new Error("invalid exponent, negatives unsupported");
1069
+ if (power === _0n2)
1070
+ return F.ONE;
1071
+ if (power === _1n2)
1072
+ return num;
1073
+ let p = F.ONE;
1074
+ let d = num;
1075
+ while (power > _0n2) {
1076
+ if (power & _1n2)
1077
+ p = F.mul(p, d);
1078
+ d = F.sqr(d);
1079
+ power >>= _1n2;
1080
+ }
1081
+ return p;
1082
+ }
1083
+ function FpInvertBatch(Fp2, nums, passZero = false) {
1084
+ const F = Fp2;
1085
+ const inverted = new Array(nums.length).fill(passZero ? F.ZERO : void 0);
1086
+ const multipliedAcc = nums.reduce((acc, num, i) => {
1087
+ if (F.is0(num))
1088
+ return acc;
1089
+ inverted[i] = acc;
1090
+ return F.mul(acc, num);
1091
+ }, F.ONE);
1092
+ const invertedAcc = F.inv(multipliedAcc);
1093
+ nums.reduceRight((acc, num, i) => {
1094
+ if (F.is0(num))
1095
+ return acc;
1096
+ inverted[i] = F.mul(acc, inverted[i]);
1097
+ return F.mul(acc, num);
1098
+ }, invertedAcc);
1099
+ return inverted;
1100
+ }
1101
+ function FpLegendre(Fp2, n) {
1102
+ const F = Fp2;
1103
+ const p1mod2 = (F.ORDER - _1n2) / _2n;
1104
+ const powered = F.pow(n, p1mod2);
1105
+ const yes = F.eql(powered, F.ONE);
1106
+ const zero = F.eql(powered, F.ZERO);
1107
+ const no = F.eql(powered, F.neg(F.ONE));
1108
+ if (!yes && !zero && !no)
1109
+ throw new Error("invalid Legendre symbol result");
1110
+ return yes ? 1 : zero ? 0 : -1;
1111
+ }
1112
+ function FpIsSquare(Fp2, n) {
1113
+ const l = FpLegendre(Fp2, n);
1114
+ return l !== -1;
1115
+ }
1116
+ function nLength(n, nBitLength) {
1117
+ if (nBitLength !== void 0)
1118
+ anumber2(nBitLength);
1119
+ if (n <= _0n2)
1120
+ throw new Error("invalid n length: expected positive n, got " + n);
1121
+ if (nBitLength !== void 0 && nBitLength < 1)
1122
+ throw new Error("invalid n length: expected positive bit length, got " + nBitLength);
1123
+ const bits = bitLen(n);
1124
+ if (nBitLength !== void 0 && nBitLength < bits)
1125
+ throw new Error(`invalid n length: expected bit length (${bits}) >= n.length (${nBitLength})`);
1126
+ const _nBitLength = nBitLength !== void 0 ? nBitLength : bits;
1127
+ const nByteLength = Math.ceil(_nBitLength / 8);
1128
+ return { nBitLength: _nBitLength, nByteLength };
1129
+ }
1130
+ var FIELD_SQRT = /* @__PURE__ */ new WeakMap();
1131
+ var _Field = class {
1132
+ ORDER;
1133
+ BITS;
1134
+ BYTES;
1135
+ isLE;
1136
+ ZERO = _0n2;
1137
+ ONE = _1n2;
1138
+ _lengths;
1139
+ _mod;
1140
+ constructor(ORDER, opts = {}) {
1141
+ if (ORDER <= _1n2)
1142
+ throw new Error("invalid field: expected ORDER > 1, got " + ORDER);
1143
+ let _nbitLength = void 0;
1144
+ this.isLE = false;
1145
+ if (opts != null && typeof opts === "object") {
1146
+ if (typeof opts.BITS === "number")
1147
+ _nbitLength = opts.BITS;
1148
+ if (typeof opts.sqrt === "function")
1149
+ Object.defineProperty(this, "sqrt", { value: opts.sqrt, enumerable: true });
1150
+ if (typeof opts.isLE === "boolean")
1151
+ this.isLE = opts.isLE;
1152
+ if (opts.allowedLengths)
1153
+ this._lengths = Object.freeze(opts.allowedLengths.slice());
1154
+ if (typeof opts.modFromBytes === "boolean")
1155
+ this._mod = opts.modFromBytes;
1156
+ }
1157
+ const { nBitLength, nByteLength } = nLength(ORDER, _nbitLength);
1158
+ if (nByteLength > 2048)
1159
+ throw new Error("invalid field: expected ORDER of <= 2048 bytes");
1160
+ this.ORDER = ORDER;
1161
+ this.BITS = nBitLength;
1162
+ this.BYTES = nByteLength;
1163
+ Object.freeze(this);
1164
+ }
1165
+ create(num) {
1166
+ return mod(num, this.ORDER);
1167
+ }
1168
+ isValid(num) {
1169
+ if (typeof num !== "bigint")
1170
+ throw new TypeError("invalid field element: expected bigint, got " + typeof num);
1171
+ return _0n2 <= num && num < this.ORDER;
1172
+ }
1173
+ is0(num) {
1174
+ return num === _0n2;
1175
+ }
1176
+ // is valid and invertible
1177
+ isValidNot0(num) {
1178
+ return !this.is0(num) && this.isValid(num);
1179
+ }
1180
+ isOdd(num) {
1181
+ return (num & _1n2) === _1n2;
1182
+ }
1183
+ neg(num) {
1184
+ return mod(-num, this.ORDER);
1185
+ }
1186
+ eql(lhs, rhs) {
1187
+ return lhs === rhs;
1188
+ }
1189
+ sqr(num) {
1190
+ return mod(num * num, this.ORDER);
1191
+ }
1192
+ add(lhs, rhs) {
1193
+ return mod(lhs + rhs, this.ORDER);
1194
+ }
1195
+ sub(lhs, rhs) {
1196
+ return mod(lhs - rhs, this.ORDER);
1197
+ }
1198
+ mul(lhs, rhs) {
1199
+ return mod(lhs * rhs, this.ORDER);
1200
+ }
1201
+ pow(num, power) {
1202
+ return FpPow(this, num, power);
1203
+ }
1204
+ div(lhs, rhs) {
1205
+ return mod(lhs * invert(rhs, this.ORDER), this.ORDER);
1206
+ }
1207
+ // Same as above, but doesn't normalize
1208
+ sqrN(num) {
1209
+ return num * num;
1210
+ }
1211
+ addN(lhs, rhs) {
1212
+ return lhs + rhs;
1213
+ }
1214
+ subN(lhs, rhs) {
1215
+ return lhs - rhs;
1216
+ }
1217
+ mulN(lhs, rhs) {
1218
+ return lhs * rhs;
1219
+ }
1220
+ inv(num) {
1221
+ return invert(num, this.ORDER);
1222
+ }
1223
+ sqrt(num) {
1224
+ let sqrt = FIELD_SQRT.get(this);
1225
+ if (!sqrt)
1226
+ FIELD_SQRT.set(this, sqrt = FpSqrt(this.ORDER));
1227
+ return sqrt(this, num);
1228
+ }
1229
+ toBytes(num) {
1230
+ return this.isLE ? numberToBytesLE(num, this.BYTES) : numberToBytesBE(num, this.BYTES);
1231
+ }
1232
+ fromBytes(bytes, skipValidation = false) {
1233
+ abytes2(bytes);
1234
+ const { _lengths: allowedLengths, BYTES, isLE, ORDER, _mod: modFromBytes } = this;
1235
+ if (allowedLengths) {
1236
+ if (bytes.length < 1 || !allowedLengths.includes(bytes.length) || bytes.length > BYTES) {
1237
+ throw new Error("Field.fromBytes: expected " + allowedLengths + " bytes, got " + bytes.length);
1238
+ }
1239
+ const padded = new Uint8Array(BYTES);
1240
+ padded.set(bytes, isLE ? 0 : padded.length - bytes.length);
1241
+ bytes = padded;
1242
+ }
1243
+ if (bytes.length !== BYTES)
1244
+ throw new Error("Field.fromBytes: expected " + BYTES + " bytes, got " + bytes.length);
1245
+ let scalar = isLE ? bytesToNumberLE(bytes) : bytesToNumberBE(bytes);
1246
+ if (modFromBytes)
1247
+ scalar = mod(scalar, ORDER);
1248
+ if (!skipValidation) {
1249
+ if (!this.isValid(scalar))
1250
+ throw new Error("invalid field element: outside of range 0..ORDER");
1251
+ }
1252
+ return scalar;
1253
+ }
1254
+ // TODO: we don't need it here, move out to separate fn
1255
+ invertBatch(lst) {
1256
+ return FpInvertBatch(this, lst);
1257
+ }
1258
+ // We can't move this out because Fp6, Fp12 implement it
1259
+ // and it's unclear what to return in there.
1260
+ cmov(a, b, condition) {
1261
+ abool(condition, "condition");
1262
+ return condition ? b : a;
1263
+ }
1264
+ };
1265
+ Object.freeze(_Field.prototype);
1266
+ function Field(ORDER, opts = {}) {
1267
+ return new _Field(ORDER, opts);
1268
+ }
1269
+ function getFieldBytesLength(fieldOrder) {
1270
+ if (typeof fieldOrder !== "bigint")
1271
+ throw new Error("field order must be bigint");
1272
+ if (fieldOrder <= _1n2)
1273
+ throw new Error("field order must be greater than 1");
1274
+ const bitLength = bitLen(fieldOrder - _1n2);
1275
+ return Math.ceil(bitLength / 8);
1276
+ }
1277
+ function getMinHashLength(fieldOrder) {
1278
+ const length = getFieldBytesLength(fieldOrder);
1279
+ return length + Math.ceil(length / 2);
1280
+ }
1281
+ function mapHashToField(key, fieldOrder, isLE = false) {
1282
+ abytes2(key);
1283
+ const len = key.length;
1284
+ const fieldLen = getFieldBytesLength(fieldOrder);
1285
+ const minLen = Math.max(getMinHashLength(fieldOrder), 16);
1286
+ if (len < minLen || len > 1024)
1287
+ throw new Error("expected " + minLen + "-1024 bytes of input, got " + len);
1288
+ const num = isLE ? bytesToNumberLE(key) : bytesToNumberBE(key);
1289
+ const reduced = mod(num, fieldOrder - _1n2) + _1n2;
1290
+ return isLE ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
1291
+ }
1292
+
1293
+ // node_modules/@noble/curves/abstract/curve.js
1294
+ var _0n3 = /* @__PURE__ */ BigInt(0);
1295
+ var _1n3 = /* @__PURE__ */ BigInt(1);
1296
+ function validatePointCons(Point) {
1297
+ const pc = Point;
1298
+ if (typeof pc !== "function")
1299
+ throw new TypeError("Point must be a constructor");
1300
+ validateObject({
1301
+ Fp: pc.Fp,
1302
+ Fn: pc.Fn,
1303
+ fromAffine: pc.fromAffine,
1304
+ fromBytes: pc.fromBytes,
1305
+ fromHex: pc.fromHex
1306
+ }, {
1307
+ Fp: "object",
1308
+ Fn: "object",
1309
+ fromAffine: "function",
1310
+ fromBytes: "function",
1311
+ fromHex: "function"
1312
+ });
1313
+ validateField(pc.Fp);
1314
+ validateField(pc.Fn);
1315
+ }
1316
+ function negateCt(condition, item) {
1317
+ const neg = item.negate();
1318
+ return condition ? neg : item;
1319
+ }
1320
+ function normalizeZ(c, points) {
1321
+ const invertedZs = FpInvertBatch(c.Fp, points.map((p) => p.Z));
1322
+ return points.map((p, i) => c.fromAffine(p.toAffine(invertedZs[i])));
1323
+ }
1324
+ function validateW(W, bits) {
1325
+ if (!Number.isSafeInteger(W) || W <= 0 || W > bits)
1326
+ throw new Error("invalid window size, expected [1.." + bits + "], got W=" + W);
1327
+ }
1328
+ function calcWOpts(W, scalarBits) {
1329
+ validateW(W, scalarBits);
1330
+ const windows = Math.ceil(scalarBits / W) + 1;
1331
+ const windowSize = 2 ** (W - 1);
1332
+ const maxNumber = 2 ** W;
1333
+ const mask = bitMask(W);
1334
+ const shiftBy = BigInt(W);
1335
+ return { windows, windowSize, mask, maxNumber, shiftBy };
1336
+ }
1337
+ function calcOffsets(n, window, wOpts) {
1338
+ const { windowSize, mask, maxNumber, shiftBy } = wOpts;
1339
+ let wbits = Number(n & mask);
1340
+ let nextN = n >> shiftBy;
1341
+ if (wbits > windowSize) {
1342
+ wbits -= maxNumber;
1343
+ nextN += _1n3;
1344
+ }
1345
+ const offsetStart = window * windowSize;
1346
+ const offset = offsetStart + Math.abs(wbits) - 1;
1347
+ const isZero = wbits === 0;
1348
+ const isNeg = wbits < 0;
1349
+ const isNegF = window % 2 !== 0;
1350
+ const offsetF = offsetStart;
1351
+ return { nextN, offset, isZero, isNeg, isNegF, offsetF };
1352
+ }
1353
+ function validateMSMPoints(points, c) {
1354
+ if (!Array.isArray(points))
1355
+ throw new Error("array expected");
1356
+ points.forEach((p, i) => {
1357
+ if (!(p instanceof c))
1358
+ throw new Error("invalid point at index " + i);
1359
+ });
1360
+ }
1361
+ function validateMSMScalars(scalars, field) {
1362
+ if (!Array.isArray(scalars))
1363
+ throw new Error("array of scalars expected");
1364
+ scalars.forEach((s, i) => {
1365
+ if (!field.isValid(s))
1366
+ throw new Error("invalid scalar at index " + i);
1367
+ });
1368
+ }
1369
+ var pointPrecomputes = /* @__PURE__ */ new WeakMap();
1370
+ var pointWindowSizes = /* @__PURE__ */ new WeakMap();
1371
+ function getW(P) {
1372
+ return pointWindowSizes.get(P) || 1;
1373
+ }
1374
+ function assert0(n) {
1375
+ if (n !== _0n3)
1376
+ throw new Error("invalid wNAF");
1377
+ }
1378
+ var wNAF = class {
1379
+ BASE;
1380
+ ZERO;
1381
+ Fn;
1382
+ bits;
1383
+ // Parametrized with a given Point class (not individual point)
1384
+ constructor(Point, bits) {
1385
+ this.BASE = Point.BASE;
1386
+ this.ZERO = Point.ZERO;
1387
+ this.Fn = Point.Fn;
1388
+ this.bits = bits;
1389
+ }
1390
+ // non-const time multiplication ladder
1391
+ _unsafeLadder(elm, n, p = this.ZERO) {
1392
+ let d = elm;
1393
+ while (n > _0n3) {
1394
+ if (n & _1n3)
1395
+ p = p.add(d);
1396
+ d = d.double();
1397
+ n >>= _1n3;
1398
+ }
1399
+ return p;
1400
+ }
1401
+ /**
1402
+ * Creates a wNAF precomputation window. Used for caching.
1403
+ * Default window size is set by `utils.precompute()` and is equal to 8.
1404
+ * Number of precomputed points depends on the curve size:
1405
+ * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
1406
+ * - 𝑊 is the window size
1407
+ * - 𝑛 is the bitlength of the curve order.
1408
+ * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
1409
+ * @param point - Point instance
1410
+ * @param W - window size
1411
+ * @returns precomputed point tables flattened to a single array
1412
+ */
1413
+ precomputeWindow(point, W) {
1414
+ const { windows, windowSize } = calcWOpts(W, this.bits);
1415
+ const points = [];
1416
+ let p = point;
1417
+ let base = p;
1418
+ for (let window = 0; window < windows; window++) {
1419
+ base = p;
1420
+ points.push(base);
1421
+ for (let i = 1; i < windowSize; i++) {
1422
+ base = base.add(p);
1423
+ points.push(base);
1424
+ }
1425
+ p = base.double();
1426
+ }
1427
+ return points;
1428
+ }
1429
+ /**
1430
+ * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
1431
+ * More compact implementation:
1432
+ * https://github.com/paulmillr/noble-secp256k1/blob/47cb1669b6e506ad66b35fe7d76132ae97465da2/index.ts#L502-L541
1433
+ * @returns real and fake (for const-time) points
1434
+ */
1435
+ wNAF(W, precomputes, n) {
1436
+ if (!this.Fn.isValid(n))
1437
+ throw new Error("invalid scalar");
1438
+ let p = this.ZERO;
1439
+ let f = this.BASE;
1440
+ const wo = calcWOpts(W, this.bits);
1441
+ for (let window = 0; window < wo.windows; window++) {
1442
+ const { nextN, offset, isZero, isNeg, isNegF, offsetF } = calcOffsets(n, window, wo);
1443
+ n = nextN;
1444
+ if (isZero) {
1445
+ f = f.add(negateCt(isNegF, precomputes[offsetF]));
1446
+ } else {
1447
+ p = p.add(negateCt(isNeg, precomputes[offset]));
1448
+ }
1449
+ }
1450
+ assert0(n);
1451
+ return { p, f };
1452
+ }
1453
+ /**
1454
+ * Implements unsafe EC multiplication using precomputed tables
1455
+ * and w-ary non-adjacent form.
1456
+ * @param acc - accumulator point to add result of multiplication
1457
+ * @returns point
1458
+ */
1459
+ wNAFUnsafe(W, precomputes, n, acc = this.ZERO) {
1460
+ const wo = calcWOpts(W, this.bits);
1461
+ for (let window = 0; window < wo.windows; window++) {
1462
+ if (n === _0n3)
1463
+ break;
1464
+ const { nextN, offset, isZero, isNeg } = calcOffsets(n, window, wo);
1465
+ n = nextN;
1466
+ if (isZero) {
1467
+ continue;
1468
+ } else {
1469
+ const item = precomputes[offset];
1470
+ acc = acc.add(isNeg ? item.negate() : item);
1471
+ }
1472
+ }
1473
+ assert0(n);
1474
+ return acc;
1475
+ }
1476
+ getPrecomputes(W, point, transform) {
1477
+ let comp = pointPrecomputes.get(point);
1478
+ if (!comp) {
1479
+ comp = this.precomputeWindow(point, W);
1480
+ if (W !== 1) {
1481
+ if (typeof transform === "function")
1482
+ comp = transform(comp);
1483
+ pointPrecomputes.set(point, comp);
1484
+ }
1485
+ }
1486
+ return comp;
1487
+ }
1488
+ cached(point, scalar, transform) {
1489
+ const W = getW(point);
1490
+ return this.wNAF(W, this.getPrecomputes(W, point, transform), scalar);
1491
+ }
1492
+ unsafe(point, scalar, transform, prev) {
1493
+ const W = getW(point);
1494
+ if (W === 1)
1495
+ return this._unsafeLadder(point, scalar, prev);
1496
+ return this.wNAFUnsafe(W, this.getPrecomputes(W, point, transform), scalar, prev);
1497
+ }
1498
+ // We calculate precomputes for elliptic curve point multiplication
1499
+ // using windowed method. This specifies window size and
1500
+ // stores precomputed values. Usually only base point would be precomputed.
1501
+ createCache(P, W) {
1502
+ validateW(W, this.bits);
1503
+ pointWindowSizes.set(P, W);
1504
+ pointPrecomputes.delete(P);
1505
+ }
1506
+ hasCache(elm) {
1507
+ return getW(elm) !== 1;
1508
+ }
1509
+ };
1510
+ function mulEndoUnsafe(Point, point, k1, k2) {
1511
+ let acc = point;
1512
+ let p1 = Point.ZERO;
1513
+ let p2 = Point.ZERO;
1514
+ while (k1 > _0n3 || k2 > _0n3) {
1515
+ if (k1 & _1n3)
1516
+ p1 = p1.add(acc);
1517
+ if (k2 & _1n3)
1518
+ p2 = p2.add(acc);
1519
+ acc = acc.double();
1520
+ k1 >>= _1n3;
1521
+ k2 >>= _1n3;
1522
+ }
1523
+ return { p1, p2 };
1524
+ }
1525
+ function pippenger(c, points, scalars) {
1526
+ const fieldN = c.Fn;
1527
+ validateMSMPoints(points, c);
1528
+ validateMSMScalars(scalars, fieldN);
1529
+ const plength = points.length;
1530
+ const slength = scalars.length;
1531
+ if (plength !== slength)
1532
+ throw new Error("arrays of points and scalars must have equal length");
1533
+ const zero = c.ZERO;
1534
+ const wbits = bitLen(BigInt(plength));
1535
+ let windowSize = 1;
1536
+ if (wbits > 12)
1537
+ windowSize = wbits - 3;
1538
+ else if (wbits > 4)
1539
+ windowSize = wbits - 2;
1540
+ else if (wbits > 0)
1541
+ windowSize = 2;
1542
+ const MASK = bitMask(windowSize);
1543
+ const buckets = new Array(Number(MASK) + 1).fill(zero);
1544
+ const lastBits = Math.floor((fieldN.BITS - 1) / windowSize) * windowSize;
1545
+ let sum = zero;
1546
+ for (let i = lastBits; i >= 0; i -= windowSize) {
1547
+ buckets.fill(zero);
1548
+ for (let j = 0; j < slength; j++) {
1549
+ const scalar = scalars[j];
1550
+ const wbits2 = Number(scalar >> BigInt(i) & MASK);
1551
+ buckets[wbits2] = buckets[wbits2].add(points[j]);
1552
+ }
1553
+ let resI = zero;
1554
+ for (let j = buckets.length - 1, sumI = zero; j > 0; j--) {
1555
+ sumI = sumI.add(buckets[j]);
1556
+ resI = resI.add(sumI);
1557
+ }
1558
+ sum = sum.add(resI);
1559
+ if (i !== 0)
1560
+ for (let j = 0; j < windowSize; j++)
1561
+ sum = sum.double();
1562
+ }
1563
+ return sum;
1564
+ }
1565
+ function createField(order, field, isLE) {
1566
+ if (field) {
1567
+ if (field.ORDER !== order)
1568
+ throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
1569
+ validateField(field);
1570
+ return field;
1571
+ } else {
1572
+ return Field(order, { isLE });
1573
+ }
1574
+ }
1575
+ function createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) {
1576
+ if (FpFnLE === void 0)
1577
+ FpFnLE = type === "edwards";
1578
+ if (!CURVE || typeof CURVE !== "object")
1579
+ throw new Error(`expected valid ${type} CURVE object`);
1580
+ for (const p of ["p", "n", "h"]) {
1581
+ const val = CURVE[p];
1582
+ if (!(typeof val === "bigint" && val > _0n3))
1583
+ throw new Error(`CURVE.${p} must be positive bigint`);
1584
+ }
1585
+ const Fp2 = createField(CURVE.p, curveOpts.Fp, FpFnLE);
1586
+ const Fn2 = createField(CURVE.n, curveOpts.Fn, FpFnLE);
1587
+ const _b = type === "weierstrass" ? "b" : "d";
1588
+ const params = ["Gx", "Gy", "a", _b];
1589
+ for (const p of params) {
1590
+ if (!Fp2.isValid(CURVE[p]))
1591
+ throw new Error(`CURVE.${p} must be valid field element of CURVE.Fp`);
1592
+ }
1593
+ CURVE = Object.freeze(Object.assign({}, CURVE));
1594
+ return { CURVE, Fp: Fp2, Fn: Fn2 };
1595
+ }
1596
+
1597
+ // node_modules/@noble/curves/abstract/edwards.js
1598
+ var _0n4 = /* @__PURE__ */ BigInt(0);
1599
+ var _1n4 = /* @__PURE__ */ BigInt(1);
1600
+ var _2n2 = /* @__PURE__ */ BigInt(2);
1601
+ var _8n2 = /* @__PURE__ */ BigInt(8);
1602
+ function isEdValidXY(Fp2, CURVE, x, y) {
1603
+ const x2 = Fp2.sqr(x);
1604
+ const y2 = Fp2.sqr(y);
1605
+ const left = Fp2.add(Fp2.mul(CURVE.a, x2), y2);
1606
+ const right = Fp2.add(Fp2.ONE, Fp2.mul(CURVE.d, Fp2.mul(x2, y2)));
1607
+ return Fp2.eql(left, right);
1608
+ }
1609
+ function edwards(params, extraOpts = {}) {
1610
+ const opts = extraOpts;
1611
+ const validated = createCurveFields("edwards", params, opts, opts.FpFnLE);
1612
+ const { Fp: Fp2, Fn: Fn2 } = validated;
1613
+ let CURVE = validated.CURVE;
1614
+ const { h: cofactor } = CURVE;
1615
+ validateObject(opts, {}, { uvRatio: "function" });
1616
+ const MASK = _2n2 << BigInt(Fn2.BYTES * 8) - _1n4;
1617
+ const modP = (n) => Fp2.create(n);
1618
+ const uvRatio2 = opts.uvRatio === void 0 ? (u, v) => {
1619
+ try {
1620
+ return { isValid: true, value: Fp2.sqrt(Fp2.div(u, v)) };
1621
+ } catch (e) {
1622
+ return { isValid: false, value: _0n4 };
1623
+ }
1624
+ } : opts.uvRatio;
1625
+ if (!isEdValidXY(Fp2, CURVE, CURVE.Gx, CURVE.Gy))
1626
+ throw new Error("bad curve params: generator point");
1627
+ function acoord(title, n, banZero = false) {
1628
+ const min = banZero ? _1n4 : _0n4;
1629
+ aInRange("coordinate " + title, n, min, MASK);
1630
+ return n;
1631
+ }
1632
+ function aedpoint(other) {
1633
+ if (!(other instanceof Point))
1634
+ throw new Error("EdwardsPoint expected");
1635
+ }
1636
+ class Point {
1637
+ // base / generator point
1638
+ static BASE = new Point(CURVE.Gx, CURVE.Gy, _1n4, modP(CURVE.Gx * CURVE.Gy));
1639
+ // zero / infinity / identity point
1640
+ static ZERO = new Point(_0n4, _1n4, _1n4, _0n4);
1641
+ // 0, 1, 1, 0
1642
+ // math field
1643
+ static Fp = Fp2;
1644
+ // scalar field
1645
+ static Fn = Fn2;
1646
+ X;
1647
+ Y;
1648
+ Z;
1649
+ T;
1650
+ constructor(X, Y, Z, T) {
1651
+ this.X = acoord("x", X);
1652
+ this.Y = acoord("y", Y);
1653
+ this.Z = acoord("z", Z, true);
1654
+ this.T = acoord("t", T);
1655
+ Object.freeze(this);
1656
+ }
1657
+ static CURVE() {
1658
+ return CURVE;
1659
+ }
1660
+ /**
1661
+ * Create one extended Edwards point from affine coordinates.
1662
+ * Does NOT validate that the point is on-curve or torsion-free.
1663
+ * Use `.assertValidity()` on adversarial inputs.
1664
+ */
1665
+ static fromAffine(p) {
1666
+ if (p instanceof Point)
1667
+ throw new Error("extended point not allowed");
1668
+ const { x, y } = p || {};
1669
+ acoord("x", x);
1670
+ acoord("y", y);
1671
+ return new Point(x, y, _1n4, modP(x * y));
1672
+ }
1673
+ // Uses algo from RFC8032 5.1.3.
1674
+ static fromBytes(bytes, zip215 = false) {
1675
+ const len = Fp2.BYTES;
1676
+ const { a, d } = CURVE;
1677
+ bytes = copyBytes(abytes2(bytes, len, "point"));
1678
+ abool(zip215, "zip215");
1679
+ const normed = copyBytes(bytes);
1680
+ const lastByte = bytes[len - 1];
1681
+ normed[len - 1] = lastByte & ~128;
1682
+ const y = bytesToNumberLE(normed);
1683
+ const max = zip215 ? MASK : Fp2.ORDER;
1684
+ aInRange("point.y", y, _0n4, max);
1685
+ const y2 = modP(y * y);
1686
+ const u = modP(y2 - _1n4);
1687
+ const v = modP(d * y2 - a);
1688
+ let { isValid, value: x } = uvRatio2(u, v);
1689
+ if (!isValid)
1690
+ throw new Error("bad point: invalid y coordinate");
1691
+ const isXOdd = (x & _1n4) === _1n4;
1692
+ const isLastByteOdd = (lastByte & 128) !== 0;
1693
+ if (!zip215 && x === _0n4 && isLastByteOdd)
1694
+ throw new Error("bad point: x=0 and x_0=1");
1695
+ if (isLastByteOdd !== isXOdd)
1696
+ x = modP(-x);
1697
+ return Point.fromAffine({ x, y });
1698
+ }
1699
+ static fromHex(hex, zip215 = false) {
1700
+ return Point.fromBytes(hexToBytes2(hex), zip215);
1701
+ }
1702
+ get x() {
1703
+ return this.toAffine().x;
1704
+ }
1705
+ get y() {
1706
+ return this.toAffine().y;
1707
+ }
1708
+ precompute(windowSize = 8, isLazy = true) {
1709
+ wnaf.createCache(this, windowSize);
1710
+ if (!isLazy)
1711
+ this.multiply(_2n2);
1712
+ return this;
1713
+ }
1714
+ // Useful in fromAffine() - not for fromBytes(), which always created valid points.
1715
+ assertValidity() {
1716
+ const p = this;
1717
+ const { a, d } = CURVE;
1718
+ if (p.is0())
1719
+ throw new Error("bad point: ZERO");
1720
+ const { X, Y, Z, T } = p;
1721
+ const X2 = modP(X * X);
1722
+ const Y2 = modP(Y * Y);
1723
+ const Z2 = modP(Z * Z);
1724
+ const Z4 = modP(Z2 * Z2);
1725
+ const aX2 = modP(X2 * a);
1726
+ const left = modP(Z2 * modP(aX2 + Y2));
1727
+ const right = modP(Z4 + modP(d * modP(X2 * Y2)));
1728
+ if (left !== right)
1729
+ throw new Error("bad point: equation left != right (1)");
1730
+ const XY = modP(X * Y);
1731
+ const ZT = modP(Z * T);
1732
+ if (XY !== ZT)
1733
+ throw new Error("bad point: equation left != right (2)");
1734
+ }
1735
+ // Compare one point to another.
1736
+ equals(other) {
1737
+ aedpoint(other);
1738
+ const { X: X1, Y: Y1, Z: Z1 } = this;
1739
+ const { X: X2, Y: Y2, Z: Z2 } = other;
1740
+ const X1Z2 = modP(X1 * Z2);
1741
+ const X2Z1 = modP(X2 * Z1);
1742
+ const Y1Z2 = modP(Y1 * Z2);
1743
+ const Y2Z1 = modP(Y2 * Z1);
1744
+ return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;
1745
+ }
1746
+ is0() {
1747
+ return this.equals(Point.ZERO);
1748
+ }
1749
+ negate() {
1750
+ return new Point(modP(-this.X), this.Y, this.Z, modP(-this.T));
1751
+ }
1752
+ // Fast algo for doubling Extended Point.
1753
+ // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#doubling-dbl-2008-hwcd
1754
+ // Cost: 4M + 4S + 1*a + 6add + 1*2.
1755
+ double() {
1756
+ const { a } = CURVE;
1757
+ const { X: X1, Y: Y1, Z: Z1 } = this;
1758
+ const A = modP(X1 * X1);
1759
+ const B = modP(Y1 * Y1);
1760
+ const C = modP(_2n2 * modP(Z1 * Z1));
1761
+ const D = modP(a * A);
1762
+ const x1y1 = X1 + Y1;
1763
+ const E = modP(modP(x1y1 * x1y1) - A - B);
1764
+ const G = D + B;
1765
+ const F = G - C;
1766
+ const H = D - B;
1767
+ const X3 = modP(E * F);
1768
+ const Y3 = modP(G * H);
1769
+ const T3 = modP(E * H);
1770
+ const Z3 = modP(F * G);
1771
+ return new Point(X3, Y3, Z3, T3);
1772
+ }
1773
+ // Fast algo for adding 2 Extended Points.
1774
+ // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd
1775
+ // Cost: 9M + 1*a + 1*d + 7add.
1776
+ add(other) {
1777
+ aedpoint(other);
1778
+ const { a, d } = CURVE;
1779
+ const { X: X1, Y: Y1, Z: Z1, T: T1 } = this;
1780
+ const { X: X2, Y: Y2, Z: Z2, T: T2 } = other;
1781
+ const A = modP(X1 * X2);
1782
+ const B = modP(Y1 * Y2);
1783
+ const C = modP(T1 * d * T2);
1784
+ const D = modP(Z1 * Z2);
1785
+ const E = modP((X1 + Y1) * (X2 + Y2) - A - B);
1786
+ const F = D - C;
1787
+ const G = D + C;
1788
+ const H = modP(B - a * A);
1789
+ const X3 = modP(E * F);
1790
+ const Y3 = modP(G * H);
1791
+ const T3 = modP(E * H);
1792
+ const Z3 = modP(F * G);
1793
+ return new Point(X3, Y3, Z3, T3);
1794
+ }
1795
+ subtract(other) {
1796
+ aedpoint(other);
1797
+ return this.add(other.negate());
1798
+ }
1799
+ // Constant-time multiplication.
1800
+ multiply(scalar) {
1801
+ if (!Fn2.isValidNot0(scalar))
1802
+ throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");
1803
+ const { p, f } = wnaf.cached(this, scalar, (p2) => normalizeZ(Point, p2));
1804
+ return normalizeZ(Point, [p, f])[0];
1805
+ }
1806
+ // Non-constant-time multiplication. Uses double-and-add algorithm.
1807
+ // It's faster, but should only be used when you don't care about
1808
+ // an exposed private key e.g. sig verification.
1809
+ // Keeps the same subgroup-scalar contract: 0 is allowed for public-scalar callers, but
1810
+ // n and larger values are rejected instead of being reduced mod n to the identity point.
1811
+ multiplyUnsafe(scalar) {
1812
+ if (!Fn2.isValid(scalar))
1813
+ throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");
1814
+ if (scalar === _0n4)
1815
+ return Point.ZERO;
1816
+ if (this.is0() || scalar === _1n4)
1817
+ return this;
1818
+ return wnaf.unsafe(this, scalar, (p) => normalizeZ(Point, p));
1819
+ }
1820
+ // Checks if point is of small order.
1821
+ // If you add something to small order point, you will have "dirty"
1822
+ // point with torsion component.
1823
+ // Clears cofactor and checks if the result is 0.
1824
+ isSmallOrder() {
1825
+ return this.clearCofactor().is0();
1826
+ }
1827
+ // Multiplies point by curve order and checks if the result is 0.
1828
+ // Returns `false` is the point is dirty.
1829
+ isTorsionFree() {
1830
+ return wnaf.unsafe(this, CURVE.n).is0();
1831
+ }
1832
+ // Converts Extended point to default (x, y) coordinates.
1833
+ // Can accept precomputed Z^-1 - for example, from invertBatch.
1834
+ toAffine(invertedZ) {
1835
+ const p = this;
1836
+ let iz = invertedZ;
1837
+ const { X, Y, Z } = p;
1838
+ const is0 = p.is0();
1839
+ if (iz == null)
1840
+ iz = is0 ? _8n2 : Fp2.inv(Z);
1841
+ const x = modP(X * iz);
1842
+ const y = modP(Y * iz);
1843
+ const zz = Fp2.mul(Z, iz);
1844
+ if (is0)
1845
+ return { x: _0n4, y: _1n4 };
1846
+ if (zz !== _1n4)
1847
+ throw new Error("invZ was invalid");
1848
+ return { x, y };
1849
+ }
1850
+ clearCofactor() {
1851
+ if (cofactor === _1n4)
1852
+ return this;
1853
+ return this.multiplyUnsafe(cofactor);
1854
+ }
1855
+ toBytes() {
1856
+ const { x, y } = this.toAffine();
1857
+ const bytes = Fp2.toBytes(y);
1858
+ bytes[bytes.length - 1] |= x & _1n4 ? 128 : 0;
1859
+ return bytes;
1860
+ }
1861
+ toHex() {
1862
+ return bytesToHex2(this.toBytes());
1863
+ }
1864
+ toString() {
1865
+ return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
1866
+ }
1867
+ }
1868
+ const wnaf = new wNAF(Point, Fn2.BITS);
1869
+ if (Fn2.BITS >= 8)
1870
+ Point.BASE.precompute(8);
1871
+ Object.freeze(Point.prototype);
1872
+ Object.freeze(Point);
1873
+ return Point;
1874
+ }
1875
+ var PrimeEdwardsPoint = class {
1876
+ static BASE;
1877
+ static ZERO;
1878
+ static Fp;
1879
+ static Fn;
1880
+ ep;
1881
+ /**
1882
+ * Wrap one internal Edwards representative directly.
1883
+ * This is not a canonical encoding boundary: alternate Edwards
1884
+ * representatives may still describe the same abstract wrapper element.
1885
+ */
1886
+ constructor(ep) {
1887
+ this.ep = ep;
1888
+ }
1889
+ // Static methods that must be implemented by subclasses
1890
+ static fromBytes(_bytes) {
1891
+ notImplemented();
1892
+ }
1893
+ static fromHex(_hex) {
1894
+ notImplemented();
1895
+ }
1896
+ get x() {
1897
+ return this.toAffine().x;
1898
+ }
1899
+ get y() {
1900
+ return this.toAffine().y;
1901
+ }
1902
+ // Common implementations
1903
+ clearCofactor() {
1904
+ return this;
1905
+ }
1906
+ assertValidity() {
1907
+ this.ep.assertValidity();
1908
+ }
1909
+ /**
1910
+ * Return affine coordinates of the current internal Edwards representative.
1911
+ * This is a convenience helper, not a canonical Ristretto/Decaf encoding.
1912
+ * Equal abstract elements may expose different `x` / `y`; use
1913
+ * `toBytes()` / `fromBytes()` for canonical roundtrips.
1914
+ */
1915
+ toAffine(invertedZ) {
1916
+ return this.ep.toAffine(invertedZ);
1917
+ }
1918
+ toHex() {
1919
+ return bytesToHex2(this.toBytes());
1920
+ }
1921
+ toString() {
1922
+ return this.toHex();
1923
+ }
1924
+ isTorsionFree() {
1925
+ return true;
1926
+ }
1927
+ isSmallOrder() {
1928
+ return false;
1929
+ }
1930
+ add(other) {
1931
+ this.assertSame(other);
1932
+ return this.init(this.ep.add(other.ep));
1933
+ }
1934
+ subtract(other) {
1935
+ this.assertSame(other);
1936
+ return this.init(this.ep.subtract(other.ep));
1937
+ }
1938
+ multiply(scalar) {
1939
+ return this.init(this.ep.multiply(scalar));
1940
+ }
1941
+ multiplyUnsafe(scalar) {
1942
+ return this.init(this.ep.multiplyUnsafe(scalar));
1943
+ }
1944
+ double() {
1945
+ return this.init(this.ep.double());
1946
+ }
1947
+ negate() {
1948
+ return this.init(this.ep.negate());
1949
+ }
1950
+ precompute(windowSize, isLazy) {
1951
+ this.ep.precompute(windowSize, isLazy);
1952
+ return this;
1953
+ }
1954
+ };
1955
+
1956
+ // node_modules/@noble/curves/abstract/hash-to-curve.js
1957
+ var os2ip = bytesToNumberBE;
1958
+ function i2osp(value, length) {
1959
+ asafenumber(value);
1960
+ asafenumber(length);
1961
+ if (length < 0 || length > 4)
1962
+ throw new Error("invalid I2OSP length: " + length);
1963
+ if (value < 0 || value > 2 ** (8 * length) - 1)
1964
+ throw new Error("invalid I2OSP input: " + value);
1965
+ const res = Array.from({ length }).fill(0);
1966
+ for (let i = length - 1; i >= 0; i--) {
1967
+ res[i] = value & 255;
1968
+ value >>>= 8;
1969
+ }
1970
+ return new Uint8Array(res);
1971
+ }
1972
+ function strxor(a, b) {
1973
+ const arr = new Uint8Array(a.length);
1974
+ for (let i = 0; i < a.length; i++) {
1975
+ arr[i] = a[i] ^ b[i];
1976
+ }
1977
+ return arr;
1978
+ }
1979
+ function normDST(DST) {
1980
+ if (!isBytes2(DST) && typeof DST !== "string")
1981
+ throw new Error("DST must be Uint8Array or ascii string");
1982
+ const dst = typeof DST === "string" ? asciiToBytes(DST) : DST;
1983
+ if (dst.length === 0)
1984
+ throw new Error("DST must be non-empty");
1985
+ return dst;
1986
+ }
1987
+ function expand_message_xmd(msg, DST, lenInBytes, H) {
1988
+ abytes2(msg);
1989
+ asafenumber(lenInBytes);
1990
+ DST = normDST(DST);
1991
+ if (DST.length > 255)
1992
+ DST = H(concatBytes2(asciiToBytes("H2C-OVERSIZE-DST-"), DST));
1993
+ const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H;
1994
+ const ell = Math.ceil(lenInBytes / b_in_bytes);
1995
+ if (lenInBytes > 65535 || ell > 255)
1996
+ throw new Error("expand_message_xmd: invalid lenInBytes");
1997
+ const DST_prime = concatBytes2(DST, i2osp(DST.length, 1));
1998
+ const Z_pad = new Uint8Array(r_in_bytes);
1999
+ const l_i_b_str = i2osp(lenInBytes, 2);
2000
+ const b = new Array(ell);
2001
+ const b_0 = H(concatBytes2(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));
2002
+ b[0] = H(concatBytes2(b_0, i2osp(1, 1), DST_prime));
2003
+ for (let i = 1; i < ell; i++) {
2004
+ const args = [strxor(b_0, b[i - 1]), i2osp(i + 1, 1), DST_prime];
2005
+ b[i] = H(concatBytes2(...args));
2006
+ }
2007
+ const pseudo_random_bytes = concatBytes2(...b);
2008
+ return pseudo_random_bytes.slice(0, lenInBytes);
2009
+ }
2010
+ function expand_message_xof(msg, DST, lenInBytes, k, H) {
2011
+ abytes2(msg);
2012
+ asafenumber(lenInBytes);
2013
+ DST = normDST(DST);
2014
+ if (DST.length > 255) {
2015
+ const dkLen = Math.ceil(2 * k / 8);
2016
+ DST = H.create({ dkLen }).update(asciiToBytes("H2C-OVERSIZE-DST-")).update(DST).digest();
2017
+ }
2018
+ if (lenInBytes > 65535 || DST.length > 255)
2019
+ throw new Error("expand_message_xof: invalid lenInBytes");
2020
+ return H.create({ dkLen: lenInBytes }).update(msg).update(i2osp(lenInBytes, 2)).update(DST).update(i2osp(DST.length, 1)).digest();
2021
+ }
2022
+ function hash_to_field(msg, count, options) {
2023
+ validateObject(options, {
2024
+ p: "bigint",
2025
+ m: "number",
2026
+ k: "number",
2027
+ hash: "function"
2028
+ });
2029
+ const { p, k, m, hash, expand, DST } = options;
2030
+ asafenumber(hash.outputLen, "valid hash");
2031
+ abytes2(msg);
2032
+ asafenumber(count);
2033
+ if (count < 1)
2034
+ throw new Error("hash_to_field: expected count >= 1");
2035
+ if (m < 1)
2036
+ throw new Error("hash_to_field: expected m >= 1");
2037
+ const log2p = p.toString(2).length;
2038
+ const L = Math.ceil((log2p + k) / 8);
2039
+ const len_in_bytes = count * m * L;
2040
+ let prb;
2041
+ if (expand === "xmd") {
2042
+ prb = expand_message_xmd(msg, DST, len_in_bytes, hash);
2043
+ } else if (expand === "xof") {
2044
+ prb = expand_message_xof(msg, DST, len_in_bytes, k, hash);
2045
+ } else if (expand === "_internal_pass") {
2046
+ prb = msg;
2047
+ } else {
2048
+ throw new Error('expand must be "xmd" or "xof"');
2049
+ }
2050
+ const u = new Array(count);
2051
+ for (let i = 0; i < count; i++) {
2052
+ const e = new Array(m);
2053
+ for (let j = 0; j < m; j++) {
2054
+ const elm_offset = L * (j + i * m);
2055
+ const tv = prb.subarray(elm_offset, elm_offset + L);
2056
+ e[j] = mod(os2ip(tv), p);
2057
+ }
2058
+ u[i] = e;
2059
+ }
2060
+ return u;
2061
+ }
2062
+ var _DST_scalar = "HashToScalar-";
2063
+ function createHasher2(Point, mapToCurve, defaults) {
2064
+ if (typeof mapToCurve !== "function")
2065
+ throw new Error("mapToCurve() must be defined");
2066
+ const snapshot = (src) => Object.freeze({
2067
+ ...src,
2068
+ DST: isBytes2(src.DST) ? copyBytes(src.DST) : src.DST,
2069
+ ...src.encodeDST === void 0 ? {} : { encodeDST: isBytes2(src.encodeDST) ? copyBytes(src.encodeDST) : src.encodeDST }
2070
+ });
2071
+ const safeDefaults = snapshot(defaults);
2072
+ function map(num) {
2073
+ return Point.fromAffine(mapToCurve(num));
2074
+ }
2075
+ function clear(initial) {
2076
+ const P = initial.clearCofactor();
2077
+ if (P.equals(Point.ZERO))
2078
+ return Point.ZERO;
2079
+ P.assertValidity();
2080
+ return P;
2081
+ }
2082
+ return Object.freeze({
2083
+ get defaults() {
2084
+ return snapshot(safeDefaults);
2085
+ },
2086
+ Point,
2087
+ hashToCurve(msg, options) {
2088
+ const opts = Object.assign({}, safeDefaults, options);
2089
+ const u = hash_to_field(msg, 2, opts);
2090
+ const u0 = map(u[0]);
2091
+ const u1 = map(u[1]);
2092
+ return clear(u0.add(u1));
2093
+ },
2094
+ encodeToCurve(msg, options) {
2095
+ const optsDst = safeDefaults.encodeDST ? { DST: safeDefaults.encodeDST } : {};
2096
+ const opts = Object.assign({}, safeDefaults, optsDst, options);
2097
+ const u = hash_to_field(msg, 1, opts);
2098
+ const u0 = map(u[0]);
2099
+ return clear(u0);
2100
+ },
2101
+ /** See {@link H2CHasher} */
2102
+ mapToCurve(scalars) {
2103
+ if (safeDefaults.m === 1) {
2104
+ if (typeof scalars !== "bigint")
2105
+ throw new Error("expected bigint (m=1)");
2106
+ return clear(map([scalars]));
2107
+ }
2108
+ if (!Array.isArray(scalars))
2109
+ throw new Error("expected array of bigints");
2110
+ for (const i of scalars)
2111
+ if (typeof i !== "bigint")
2112
+ throw new Error("expected array of bigints");
2113
+ return clear(map(scalars));
2114
+ },
2115
+ // hash_to_scalar can produce 0: https://www.rfc-editor.org/errata/eid8393
2116
+ // RFC 9380, draft-irtf-cfrg-bbs-signatures-08. Default scalar DST is the shared generic
2117
+ // `HashToScalar-` prefix above unless the caller overrides it per invocation.
2118
+ hashToScalar(msg, options) {
2119
+ const N = Point.Fn.ORDER;
2120
+ const opts = Object.assign({}, safeDefaults, { p: N, m: 1, DST: _DST_scalar }, options);
2121
+ return hash_to_field(msg, 1, opts)[0][0];
2122
+ }
2123
+ });
2124
+ }
2125
+
2126
+ // node_modules/@noble/curves/abstract/oprf.js
2127
+ var _DST_scalarBytes = /* @__PURE__ */ asciiToBytes(_DST_scalar);
2128
+ function createOPRF(opts) {
2129
+ validateObject(opts, {
2130
+ name: "string",
2131
+ hash: "function",
2132
+ hashToScalar: "function",
2133
+ hashToGroup: "function"
2134
+ });
2135
+ validatePointCons(opts.Point);
2136
+ const { name, Point, hash } = opts;
2137
+ const { Fn: Fn2 } = Point;
2138
+ const hashToGroup = (msg, ctx) => opts.hashToGroup(msg, {
2139
+ DST: concatBytes2(asciiToBytes("HashToGroup-"), ctx)
2140
+ });
2141
+ const hashToScalarPrefixed = (msg, ctx) => opts.hashToScalar(msg, { DST: concatBytes2(_DST_scalarBytes, ctx) });
2142
+ const randomScalar = (rng = randomBytes2) => {
2143
+ const t = mapHashToField(rng(getMinHashLength(Fn2.ORDER)), Fn2.ORDER, Fn2.isLE);
2144
+ return Fn2.isLE ? bytesToNumberLE(t) : bytesToNumberBE(t);
2145
+ };
2146
+ const msm = (points, scalars) => pippenger(Point, points, scalars);
2147
+ const getCtx = (mode) => concatBytes2(asciiToBytes("OPRFV1-"), new Uint8Array([mode]), asciiToBytes("-" + name));
2148
+ const ctxOPRF = getCtx(0);
2149
+ const ctxVOPRF = getCtx(1);
2150
+ const ctxPOPRF = getCtx(2);
2151
+ function encode(...args) {
2152
+ const res2 = [];
2153
+ for (const a of args) {
2154
+ if (typeof a === "number")
2155
+ res2.push(numberToBytesBE(a, 2));
2156
+ else if (typeof a === "string")
2157
+ res2.push(asciiToBytes(a));
2158
+ else {
2159
+ abytes2(a);
2160
+ res2.push(numberToBytesBE(a.length, 2), a);
2161
+ }
2162
+ }
2163
+ return concatBytes2(...res2);
2164
+ }
2165
+ const inputBytes = (title, bytes) => {
2166
+ abytes2(bytes, void 0, title);
2167
+ if (bytes.length > 65535)
2168
+ throw new Error(`"${title}" expected Uint8Array of length <= 65535, got length=${bytes.length}`);
2169
+ return bytes;
2170
+ };
2171
+ const hashInput = (...bytes) => hash(encode(...bytes, "Finalize"));
2172
+ function getTranscripts(B, C, D, ctx) {
2173
+ const Bm = B.toBytes();
2174
+ const seed = hash(encode(Bm, concatBytes2(asciiToBytes("Seed-"), ctx)));
2175
+ const res2 = [];
2176
+ for (let i = 0; i < C.length; i++) {
2177
+ const Ci = C[i].toBytes();
2178
+ const Di = D[i].toBytes();
2179
+ const di = hashToScalarPrefixed(encode(seed, i, Ci, Di, "Composite"), ctx);
2180
+ res2.push(di);
2181
+ }
2182
+ return res2;
2183
+ }
2184
+ function computeComposites(B, C, D, ctx) {
2185
+ const T = getTranscripts(B, C, D, ctx);
2186
+ const M = msm(C, T);
2187
+ const Z = msm(D, T);
2188
+ return { M, Z };
2189
+ }
2190
+ function computeCompositesFast(k, B, C, D, ctx) {
2191
+ const T = getTranscripts(B, C, D, ctx);
2192
+ const M = msm(C, T);
2193
+ const Z = M.multiply(k);
2194
+ return { M, Z };
2195
+ }
2196
+ function challengeTranscript(B, M, Z, t2, t3, ctx) {
2197
+ const [Bm, a0, a1, a2, a3] = [B, M, Z, t2, t3].map((i) => i.toBytes());
2198
+ return hashToScalarPrefixed(encode(Bm, a0, a1, a2, a3, "Challenge"), ctx);
2199
+ }
2200
+ function generateProof(ctx, k, B, C, D, rng) {
2201
+ const { M, Z } = computeCompositesFast(k, B, C, D, ctx);
2202
+ const r = randomScalar(rng);
2203
+ const t2 = Point.BASE.multiply(r);
2204
+ const t3 = M.multiply(r);
2205
+ const c = challengeTranscript(B, M, Z, t2, t3, ctx);
2206
+ const s = Fn2.sub(r, Fn2.mul(c, k));
2207
+ return concatBytes2(...[c, s].map((i) => Fn2.toBytes(i)));
2208
+ }
2209
+ function verifyProof(ctx, B, C, D, proof) {
2210
+ abytes2(proof, 2 * Fn2.BYTES);
2211
+ const { M, Z } = computeComposites(B, C, D, ctx);
2212
+ const [c, s] = [proof.subarray(0, Fn2.BYTES), proof.subarray(Fn2.BYTES)].map((f) => Fn2.fromBytes(f));
2213
+ const t2 = Point.BASE.multiply(s).add(B.multiply(c));
2214
+ const t3 = M.multiply(s).add(Z.multiply(c));
2215
+ const expectedC = challengeTranscript(B, M, Z, t2, t3, ctx);
2216
+ if (!Fn2.eql(c, expectedC))
2217
+ throw new Error("proof verification failed");
2218
+ }
2219
+ function generateKeyPair() {
2220
+ const skS = randomScalar();
2221
+ const pkS = Point.BASE.multiply(skS);
2222
+ return { secretKey: Fn2.toBytes(skS), publicKey: pkS.toBytes() };
2223
+ }
2224
+ function deriveKeyPair(ctx, seed, info) {
2225
+ abytes2(seed, 32, "seed");
2226
+ info = inputBytes("keyInfo", info);
2227
+ const dst = concatBytes2(asciiToBytes("DeriveKeyPair"), ctx);
2228
+ const msg = concatBytes2(seed, encode(info), Uint8Array.of(0));
2229
+ for (let counter = 0; counter <= 255; counter++) {
2230
+ msg[msg.length - 1] = counter;
2231
+ const skS = opts.hashToScalar(msg, { DST: dst });
2232
+ if (Fn2.is0(skS))
2233
+ continue;
2234
+ return {
2235
+ secretKey: Fn2.toBytes(skS),
2236
+ publicKey: Point.BASE.multiply(skS).toBytes()
2237
+ };
2238
+ }
2239
+ throw new Error("Cannot derive key");
2240
+ }
2241
+ const wirePoint = (label, bytes) => {
2242
+ const point = Point.fromBytes(bytes);
2243
+ if (point.equals(Point.ZERO))
2244
+ throw new Error(label + " point at infinity");
2245
+ return point;
2246
+ };
2247
+ function blind(ctx, input, rng = randomBytes2) {
2248
+ input = inputBytes("input", input);
2249
+ const blind2 = randomScalar(rng);
2250
+ const inputPoint = hashToGroup(input, ctx);
2251
+ if (inputPoint.equals(Point.ZERO))
2252
+ throw new Error("Input point at infinity");
2253
+ const blinded = inputPoint.multiply(blind2);
2254
+ return { blind: Fn2.toBytes(blind2), blinded: blinded.toBytes() };
2255
+ }
2256
+ function evaluate(ctx, secretKey, input) {
2257
+ input = inputBytes("input", input);
2258
+ const skS = Fn2.fromBytes(secretKey);
2259
+ const inputPoint = hashToGroup(input, ctx);
2260
+ if (inputPoint.equals(Point.ZERO))
2261
+ throw new Error("Input point at infinity");
2262
+ const unblinded = inputPoint.multiply(skS).toBytes();
2263
+ return hashInput(input, unblinded);
2264
+ }
2265
+ const oprf = Object.freeze({
2266
+ generateKeyPair,
2267
+ deriveKeyPair: (seed, keyInfo) => deriveKeyPair(ctxOPRF, seed, keyInfo),
2268
+ blind: (input, rng = randomBytes2) => blind(ctxOPRF, input, rng),
2269
+ blindEvaluate(secretKey, blindedPoint) {
2270
+ const skS = Fn2.fromBytes(secretKey);
2271
+ const elm = wirePoint("blinded", blindedPoint);
2272
+ return elm.multiply(skS).toBytes();
2273
+ },
2274
+ finalize(input, blindBytes, evaluatedBytes) {
2275
+ input = inputBytes("input", input);
2276
+ const blind2 = Fn2.fromBytes(blindBytes);
2277
+ const evalPoint = wirePoint("evaluated", evaluatedBytes);
2278
+ const unblinded = evalPoint.multiply(Fn2.inv(blind2)).toBytes();
2279
+ return hashInput(input, unblinded);
2280
+ },
2281
+ evaluate: (secretKey, input) => evaluate(ctxOPRF, secretKey, input)
2282
+ });
2283
+ const voprf = Object.freeze({
2284
+ generateKeyPair,
2285
+ deriveKeyPair: (seed, keyInfo) => deriveKeyPair(ctxVOPRF, seed, keyInfo),
2286
+ blind: (input, rng = randomBytes2) => blind(ctxVOPRF, input, rng),
2287
+ blindEvaluateBatch(secretKey, publicKey, blinded, rng = randomBytes2) {
2288
+ if (!Array.isArray(blinded))
2289
+ throw new Error("expected array");
2290
+ const skS = Fn2.fromBytes(secretKey);
2291
+ const pkS = wirePoint("public key", publicKey);
2292
+ const blindedPoints = blinded.map((i) => wirePoint("blinded", i));
2293
+ const evaluated = blindedPoints.map((i) => i.multiply(skS));
2294
+ const proof = generateProof(ctxVOPRF, skS, pkS, blindedPoints, evaluated, rng);
2295
+ return { evaluated: evaluated.map((i) => i.toBytes()), proof };
2296
+ },
2297
+ blindEvaluate(secretKey, publicKey, blinded, rng = randomBytes2) {
2298
+ const res2 = this.blindEvaluateBatch(secretKey, publicKey, [blinded], rng);
2299
+ return { evaluated: res2.evaluated[0], proof: res2.proof };
2300
+ },
2301
+ finalizeBatch(items, publicKey, proof) {
2302
+ if (!Array.isArray(items))
2303
+ throw new Error("expected array");
2304
+ const pkS = wirePoint("public key", publicKey);
2305
+ const blindedPoints = items.map((i) => wirePoint("blinded", i.blinded));
2306
+ const evalPoints = items.map((i) => wirePoint("evaluated", i.evaluated));
2307
+ verifyProof(ctxVOPRF, pkS, blindedPoints, evalPoints, proof);
2308
+ return items.map((i) => oprf.finalize(i.input, i.blind, i.evaluated));
2309
+ },
2310
+ finalize(input, blind2, evaluated, blinded, publicKey, proof) {
2311
+ return this.finalizeBatch([{ input, blind: blind2, evaluated, blinded }], publicKey, proof)[0];
2312
+ },
2313
+ evaluate: (secretKey, input) => evaluate(ctxVOPRF, secretKey, input)
2314
+ });
2315
+ const poprf = (info) => {
2316
+ info = inputBytes("info", info);
2317
+ const m = hashToScalarPrefixed(encode("Info", info), ctxPOPRF);
2318
+ const T = Point.BASE.multiply(m);
2319
+ return Object.freeze({
2320
+ generateKeyPair,
2321
+ deriveKeyPair: (seed, keyInfo) => deriveKeyPair(ctxPOPRF, seed, keyInfo),
2322
+ blind(input, publicKey, rng = randomBytes2) {
2323
+ input = inputBytes("input", input);
2324
+ const pkS = wirePoint("public key", publicKey);
2325
+ const tweakedKey = T.add(pkS);
2326
+ if (tweakedKey.equals(Point.ZERO))
2327
+ throw new Error("tweakedKey point at infinity");
2328
+ const blind2 = randomScalar(rng);
2329
+ const inputPoint = hashToGroup(input, ctxPOPRF);
2330
+ if (inputPoint.equals(Point.ZERO))
2331
+ throw new Error("Input point at infinity");
2332
+ const blindedPoint = inputPoint.multiply(blind2);
2333
+ return {
2334
+ blind: Fn2.toBytes(blind2),
2335
+ blinded: blindedPoint.toBytes(),
2336
+ tweakedKey: tweakedKey.toBytes()
2337
+ };
2338
+ },
2339
+ blindEvaluateBatch(secretKey, blinded, rng = randomBytes2) {
2340
+ if (!Array.isArray(blinded))
2341
+ throw new Error("expected array");
2342
+ const skS = Fn2.fromBytes(secretKey);
2343
+ const t = Fn2.add(skS, m);
2344
+ const invT = Fn2.inv(t);
2345
+ const blindedPoints = blinded.map((i) => wirePoint("blinded", i));
2346
+ const evalPoints = blindedPoints.map((i) => i.multiply(invT));
2347
+ const tweakedKey = Point.BASE.multiply(t);
2348
+ const proof = generateProof(ctxPOPRF, t, tweakedKey, evalPoints, blindedPoints, rng);
2349
+ return { evaluated: evalPoints.map((i) => i.toBytes()), proof };
2350
+ },
2351
+ blindEvaluate(secretKey, blinded, rng = randomBytes2) {
2352
+ const res2 = this.blindEvaluateBatch(secretKey, [blinded], rng);
2353
+ return { evaluated: res2.evaluated[0], proof: res2.proof };
2354
+ },
2355
+ finalizeBatch(items, proof, tweakedKey) {
2356
+ if (!Array.isArray(items))
2357
+ throw new Error("expected array");
2358
+ const inputs = items.map((i) => inputBytes("input", i.input));
2359
+ const evalPoints = items.map((i) => wirePoint("evaluated", i.evaluated));
2360
+ verifyProof(ctxPOPRF, wirePoint("tweakedKey", tweakedKey), evalPoints, items.map((i) => wirePoint("blinded", i.blinded)), proof);
2361
+ return items.map((i, j) => {
2362
+ const blind2 = Fn2.fromBytes(i.blind);
2363
+ const point = evalPoints[j].multiply(Fn2.inv(blind2)).toBytes();
2364
+ return hashInput(inputs[j], info, point);
2365
+ });
2366
+ },
2367
+ finalize(input, blind2, evaluated, blinded, proof, tweakedKey) {
2368
+ return this.finalizeBatch([{ input, blind: blind2, evaluated, blinded }], proof, tweakedKey)[0];
2369
+ },
2370
+ evaluate(secretKey, input) {
2371
+ input = inputBytes("input", input);
2372
+ const skS = Fn2.fromBytes(secretKey);
2373
+ const inputPoint = hashToGroup(input, ctxPOPRF);
2374
+ if (inputPoint.equals(Point.ZERO))
2375
+ throw new Error("Input point at infinity");
2376
+ const t = Fn2.add(skS, m);
2377
+ const invT = Fn2.inv(t);
2378
+ const unblinded = inputPoint.multiply(invT).toBytes();
2379
+ return hashInput(input, info, unblinded);
2380
+ }
2381
+ });
2382
+ };
2383
+ const res = { name, oprf, voprf, poprf, __tests: Object.freeze({ Fn: Fn2 }) };
2384
+ return Object.freeze(res);
2385
+ }
2386
+
2387
+ // node_modules/@noble/curves/ed25519.js
2388
+ var _0n5 = /* @__PURE__ */ BigInt(0);
2389
+ var _1n5 = /* @__PURE__ */ BigInt(1);
2390
+ var _2n3 = /* @__PURE__ */ BigInt(2);
2391
+ var _5n2 = /* @__PURE__ */ BigInt(5);
2392
+ var _8n3 = /* @__PURE__ */ BigInt(8);
2393
+ var ed25519_CURVE_p = /* @__PURE__ */ BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");
2394
+ var ed25519_CURVE = /* @__PURE__ */ (() => ({
2395
+ p: ed25519_CURVE_p,
2396
+ n: BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),
2397
+ h: _8n3,
2398
+ a: BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),
2399
+ d: BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),
2400
+ Gx: BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),
2401
+ Gy: BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")
2402
+ }))();
2403
+ function ed25519_pow_2_252_3(x) {
2404
+ const _10n = BigInt(10), _20n = BigInt(20), _40n = BigInt(40), _80n = BigInt(80);
2405
+ const P = ed25519_CURVE_p;
2406
+ const x2 = x * x % P;
2407
+ const b2 = x2 * x % P;
2408
+ const b4 = pow2(b2, _2n3, P) * b2 % P;
2409
+ const b5 = pow2(b4, _1n5, P) * x % P;
2410
+ const b10 = pow2(b5, _5n2, P) * b5 % P;
2411
+ const b20 = pow2(b10, _10n, P) * b10 % P;
2412
+ const b40 = pow2(b20, _20n, P) * b20 % P;
2413
+ const b80 = pow2(b40, _40n, P) * b40 % P;
2414
+ const b160 = pow2(b80, _80n, P) * b80 % P;
2415
+ const b240 = pow2(b160, _80n, P) * b80 % P;
2416
+ const b250 = pow2(b240, _10n, P) * b10 % P;
2417
+ const pow_p_5_8 = pow2(b250, _2n3, P) * x % P;
2418
+ return { pow_p_5_8, b2 };
2419
+ }
2420
+ var ED25519_SQRT_M1 = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
2421
+ function uvRatio(u, v) {
2422
+ const P = ed25519_CURVE_p;
2423
+ const v3 = mod(v * v * v, P);
2424
+ const v7 = mod(v3 * v3 * v, P);
2425
+ const pow = ed25519_pow_2_252_3(u * v7).pow_p_5_8;
2426
+ let x = mod(u * v3 * pow, P);
2427
+ const vx2 = mod(v * x * x, P);
2428
+ const root1 = x;
2429
+ const root2 = mod(x * ED25519_SQRT_M1, P);
2430
+ const useRoot1 = vx2 === u;
2431
+ const useRoot2 = vx2 === mod(-u, P);
2432
+ const noRoot = vx2 === mod(-u * ED25519_SQRT_M1, P);
2433
+ if (useRoot1)
2434
+ x = root1;
2435
+ if (useRoot2 || noRoot)
2436
+ x = root2;
2437
+ if (isNegativeLE(x, P))
2438
+ x = mod(-x, P);
2439
+ return { isValid: useRoot1 || useRoot2, value: x };
2440
+ }
2441
+ var ed25519_Point = /* @__PURE__ */ edwards(ed25519_CURVE, { uvRatio });
2442
+ var Fp = /* @__PURE__ */ (() => ed25519_Point.Fp)();
2443
+ var Fn = /* @__PURE__ */ (() => ed25519_Point.Fn)();
2444
+ var SQRT_M1 = ED25519_SQRT_M1;
2445
+ var SQRT_AD_MINUS_ONE = /* @__PURE__ */ BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235");
2446
+ var INVSQRT_A_MINUS_D = /* @__PURE__ */ BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578");
2447
+ var ONE_MINUS_D_SQ = /* @__PURE__ */ BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838");
2448
+ var D_MINUS_ONE_SQ = /* @__PURE__ */ BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");
2449
+ var invertSqrt = (number) => uvRatio(_1n5, number);
2450
+ var MAX_255B = /* @__PURE__ */ BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
2451
+ var bytes255ToNumberLE = (bytes) => Fp.create(bytesToNumberLE(bytes) & MAX_255B);
2452
+ function calcElligatorRistrettoMap(r0) {
2453
+ const { d } = ed25519_CURVE;
2454
+ const P = ed25519_CURVE_p;
2455
+ const mod2 = (n) => Fp.create(n);
2456
+ const r = mod2(SQRT_M1 * r0 * r0);
2457
+ const Ns = mod2((r + _1n5) * ONE_MINUS_D_SQ);
2458
+ let c = BigInt(-1);
2459
+ const D = mod2((c - d * r) * mod2(r + d));
2460
+ let { isValid: Ns_D_is_sq, value: s } = uvRatio(Ns, D);
2461
+ let s_ = mod2(s * r0);
2462
+ if (!isNegativeLE(s_, P))
2463
+ s_ = mod2(-s_);
2464
+ if (!Ns_D_is_sq)
2465
+ s = s_;
2466
+ if (!Ns_D_is_sq)
2467
+ c = r;
2468
+ const Nt = mod2(c * (r - _1n5) * D_MINUS_ONE_SQ - D);
2469
+ const s2 = s * s;
2470
+ const W0 = mod2((s + s) * D);
2471
+ const W1 = mod2(Nt * SQRT_AD_MINUS_ONE);
2472
+ const W2 = mod2(_1n5 - s2);
2473
+ const W3 = mod2(_1n5 + s2);
2474
+ return new ed25519_Point(mod2(W0 * W3), mod2(W2 * W1), mod2(W1 * W3), mod2(W0 * W2));
2475
+ }
2476
+ var _RistrettoPoint = class __RistrettoPoint extends PrimeEdwardsPoint {
2477
+ // Do NOT change syntax: the following gymnastics is done,
2478
+ // because typescript strips comments, which makes bundlers disable tree-shaking.
2479
+ // prettier-ignore
2480
+ static BASE = /* @__PURE__ */ (() => new __RistrettoPoint(ed25519_Point.BASE))();
2481
+ // prettier-ignore
2482
+ static ZERO = /* @__PURE__ */ (() => new __RistrettoPoint(ed25519_Point.ZERO))();
2483
+ // prettier-ignore
2484
+ static Fp = /* @__PURE__ */ (() => Fp)();
2485
+ // prettier-ignore
2486
+ static Fn = /* @__PURE__ */ (() => Fn)();
2487
+ constructor(ep) {
2488
+ super(ep);
2489
+ }
2490
+ /**
2491
+ * Create one Ristretto255 point from affine Edwards coordinates.
2492
+ * This wraps the internal Edwards representative directly and is not a
2493
+ * canonical ristretto255 decoding path.
2494
+ * Use `toBytes()` / `fromBytes()` if canonical ristretto255 bytes matter.
2495
+ */
2496
+ static fromAffine(ap) {
2497
+ return new __RistrettoPoint(ed25519_Point.fromAffine(ap));
2498
+ }
2499
+ assertSame(other) {
2500
+ if (!(other instanceof __RistrettoPoint))
2501
+ throw new Error("RistrettoPoint expected");
2502
+ }
2503
+ init(ep) {
2504
+ return new __RistrettoPoint(ep);
2505
+ }
2506
+ static fromBytes(bytes) {
2507
+ abytes(bytes, 32);
2508
+ const { a, d } = ed25519_CURVE;
2509
+ const P = ed25519_CURVE_p;
2510
+ const mod2 = (n) => Fp.create(n);
2511
+ const s = bytes255ToNumberLE(bytes);
2512
+ if (!equalBytes(Fp.toBytes(s), bytes) || isNegativeLE(s, P))
2513
+ throw new Error("invalid ristretto255 encoding 1");
2514
+ const s2 = mod2(s * s);
2515
+ const u1 = mod2(_1n5 + a * s2);
2516
+ const u2 = mod2(_1n5 - a * s2);
2517
+ const u1_2 = mod2(u1 * u1);
2518
+ const u2_2 = mod2(u2 * u2);
2519
+ const v = mod2(a * d * u1_2 - u2_2);
2520
+ const { isValid, value: I } = invertSqrt(mod2(v * u2_2));
2521
+ const Dx = mod2(I * u2);
2522
+ const Dy = mod2(I * Dx * v);
2523
+ let x = mod2((s + s) * Dx);
2524
+ if (isNegativeLE(x, P))
2525
+ x = mod2(-x);
2526
+ const y = mod2(u1 * Dy);
2527
+ const t = mod2(x * y);
2528
+ if (!isValid || isNegativeLE(t, P) || y === _0n5)
2529
+ throw new Error("invalid ristretto255 encoding 2");
2530
+ return new __RistrettoPoint(new ed25519_Point(x, y, _1n5, t));
2531
+ }
2532
+ /**
2533
+ * Converts ristretto-encoded string to ristretto point.
2534
+ * Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-decode).
2535
+ * @param hex - Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding
2536
+ */
2537
+ static fromHex(hex) {
2538
+ return __RistrettoPoint.fromBytes(hexToBytes(hex));
2539
+ }
2540
+ /**
2541
+ * Encodes ristretto point to Uint8Array.
2542
+ * Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-encode).
2543
+ */
2544
+ toBytes() {
2545
+ let { X, Y, Z, T } = this.ep;
2546
+ const P = ed25519_CURVE_p;
2547
+ const mod2 = (n) => Fp.create(n);
2548
+ const u1 = mod2(mod2(Z + Y) * mod2(Z - Y));
2549
+ const u2 = mod2(X * Y);
2550
+ const u2sq = mod2(u2 * u2);
2551
+ const { value: invsqrt } = invertSqrt(mod2(u1 * u2sq));
2552
+ const D1 = mod2(invsqrt * u1);
2553
+ const D2 = mod2(invsqrt * u2);
2554
+ const zInv = mod2(D1 * D2 * T);
2555
+ let D;
2556
+ if (isNegativeLE(T * zInv, P)) {
2557
+ let _x = mod2(Y * SQRT_M1);
2558
+ let _y = mod2(X * SQRT_M1);
2559
+ X = _x;
2560
+ Y = _y;
2561
+ D = mod2(D1 * INVSQRT_A_MINUS_D);
2562
+ } else {
2563
+ D = D2;
2564
+ }
2565
+ if (isNegativeLE(X * zInv, P))
2566
+ Y = mod2(-Y);
2567
+ let s = mod2((Z - Y) * D);
2568
+ if (isNegativeLE(s, P))
2569
+ s = mod2(-s);
2570
+ return Fp.toBytes(s);
2571
+ }
2572
+ /**
2573
+ * Compares two Ristretto points.
2574
+ * Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-equals).
2575
+ */
2576
+ equals(other) {
2577
+ this.assertSame(other);
2578
+ const { X: X1, Y: Y1 } = this.ep;
2579
+ const { X: X2, Y: Y2 } = other.ep;
2580
+ const mod2 = (n) => Fp.create(n);
2581
+ const one = mod2(X1 * Y2) === mod2(Y1 * X2);
2582
+ const two = mod2(Y1 * Y2) === mod2(X1 * X2);
2583
+ return one || two;
2584
+ }
2585
+ is0() {
2586
+ return this.equals(__RistrettoPoint.ZERO);
2587
+ }
2588
+ };
2589
+ Object.freeze(_RistrettoPoint.BASE);
2590
+ Object.freeze(_RistrettoPoint.ZERO);
2591
+ Object.freeze(_RistrettoPoint.prototype);
2592
+ Object.freeze(_RistrettoPoint);
2593
+ var ristretto255_hasher = Object.freeze({
2594
+ Point: _RistrettoPoint,
2595
+ /**
2596
+ * Spec: https://www.rfc-editor.org/rfc/rfc9380.html#name-hashing-to-ristretto255. Caveats:
2597
+ * * There are no test vectors
2598
+ * * encodeToCurve / mapToCurve is undefined
2599
+ * * mapToCurve would be `calcElligatorRistrettoMap(scalars[0])`, not ristretto255_map!
2600
+ * * hashToScalar is undefined too, so we just use OPRF implementation
2601
+ * * We cannot re-use 'createHasher', because ristretto255_map is different algorithm/RFC
2602
+ (os2ip -> bytes255ToNumberLE)
2603
+ * * mapToCurve == calcElligatorRistrettoMap, hashToCurve == ristretto255_map
2604
+ * * hashToScalar is undefined in RFC9380 for ristretto, so we use the OPRF
2605
+ version here. Using `bytes255ToNumblerLE` will create a different result
2606
+ if we use `bytes255ToNumberLE` as os2ip
2607
+ * * current version is closest to spec.
2608
+ */
2609
+ hashToCurve(msg, options) {
2610
+ const DST = options?.DST === void 0 ? "ristretto255_XMD:SHA-512_R255MAP_RO_" : options.DST;
2611
+ const xmd = expand_message_xmd(msg, DST, 64, sha512);
2612
+ return ristretto255_hasher.deriveToCurve(xmd);
2613
+ },
2614
+ hashToScalar(msg, options = { DST: _DST_scalar }) {
2615
+ const xmd = expand_message_xmd(msg, options.DST, 64, sha512);
2616
+ return Fn.create(bytesToNumberLE(xmd));
2617
+ },
2618
+ /**
2619
+ * HashToCurve-like construction based on RFC 9496 (Element Derivation).
2620
+ * Converts 64 uniform random bytes into a curve point.
2621
+ *
2622
+ * WARNING: This represents an older hash-to-curve construction from before
2623
+ * RFC 9380 was finalized.
2624
+ * It was later reused as a component in the newer
2625
+ * `hash_to_ristretto255` function defined in RFC 9380.
2626
+ */
2627
+ deriveToCurve(bytes) {
2628
+ abytes(bytes, 64);
2629
+ const r1 = bytes255ToNumberLE(bytes.subarray(0, 32));
2630
+ const R1 = calcElligatorRistrettoMap(r1);
2631
+ const r2 = bytes255ToNumberLE(bytes.subarray(32, 64));
2632
+ const R2 = calcElligatorRistrettoMap(r2);
2633
+ return new _RistrettoPoint(R1.add(R2));
2634
+ }
2635
+ });
2636
+ var ristretto255_oprf = /* @__PURE__ */ (() => createOPRF({
2637
+ name: "ristretto255-SHA512",
2638
+ Point: _RistrettoPoint,
2639
+ hash: sha512,
2640
+ hashToGroup: ristretto255_hasher.hashToCurve,
2641
+ hashToScalar: ristretto255_hasher.hashToScalar
2642
+ }))();
2643
+
2644
+ // node_modules/@noble/curves/abstract/weierstrass.js
2645
+ var divNearest = (num, den) => (num + (num >= 0 ? den : -den) / _2n4) / den;
2646
+ function _splitEndoScalar(k, basis, n) {
2647
+ aInRange("scalar", k, _0n6, n);
2648
+ const [[a1, b1], [a2, b2]] = basis;
2649
+ const c1 = divNearest(b2 * k, n);
2650
+ const c2 = divNearest(-b1 * k, n);
2651
+ let k1 = k - c1 * a1 - c2 * a2;
2652
+ let k2 = -c1 * b1 - c2 * b2;
2653
+ const k1neg = k1 < _0n6;
2654
+ const k2neg = k2 < _0n6;
2655
+ if (k1neg)
2656
+ k1 = -k1;
2657
+ if (k2neg)
2658
+ k2 = -k2;
2659
+ const MAX_NUM = bitMask(Math.ceil(bitLen(n) / 2)) + _1n6;
2660
+ if (k1 < _0n6 || k1 >= MAX_NUM || k2 < _0n6 || k2 >= MAX_NUM) {
2661
+ throw new Error("splitScalar (endomorphism): failed for k");
2662
+ }
2663
+ return { k1neg, k1, k2neg, k2 };
2664
+ }
2665
+ var DERErr = class extends Error {
2666
+ constructor(m = "") {
2667
+ super(m);
2668
+ }
2669
+ };
2670
+ var DER = {
2671
+ // asn.1 DER encoding utils
2672
+ Err: DERErr,
2673
+ // Basic building block is TLV (Tag-Length-Value)
2674
+ _tlv: {
2675
+ encode: (tag, data) => {
2676
+ const { Err: E } = DER;
2677
+ asafenumber(tag, "tag");
2678
+ if (tag < 0 || tag > 255)
2679
+ throw new E("tlv.encode: wrong tag");
2680
+ if (typeof data !== "string")
2681
+ throw new TypeError('"data" expected string, got type=' + typeof data);
2682
+ if (data.length & 1)
2683
+ throw new E("tlv.encode: unpadded data");
2684
+ const dataLen = data.length / 2;
2685
+ const len = numberToHexUnpadded(dataLen);
2686
+ if (len.length / 2 & 128)
2687
+ throw new E("tlv.encode: long form length too big");
2688
+ const lenLen = dataLen > 127 ? numberToHexUnpadded(len.length / 2 | 128) : "";
2689
+ const t = numberToHexUnpadded(tag);
2690
+ return t + lenLen + len + data;
2691
+ },
2692
+ // v - value, l - left bytes (unparsed)
2693
+ decode(tag, data) {
2694
+ const { Err: E } = DER;
2695
+ data = abytes2(data, void 0, "DER data");
2696
+ let pos = 0;
2697
+ if (tag < 0 || tag > 255)
2698
+ throw new E("tlv.encode: wrong tag");
2699
+ if (data.length < 2 || data[pos++] !== tag)
2700
+ throw new E("tlv.decode: wrong tlv");
2701
+ const first = data[pos++];
2702
+ const isLong = !!(first & 128);
2703
+ let length = 0;
2704
+ if (!isLong)
2705
+ length = first;
2706
+ else {
2707
+ const lenLen = first & 127;
2708
+ if (!lenLen)
2709
+ throw new E("tlv.decode(long): indefinite length not supported");
2710
+ if (lenLen > 4)
2711
+ throw new E("tlv.decode(long): byte length is too big");
2712
+ const lengthBytes = data.subarray(pos, pos + lenLen);
2713
+ if (lengthBytes.length !== lenLen)
2714
+ throw new E("tlv.decode: length bytes not complete");
2715
+ if (lengthBytes[0] === 0)
2716
+ throw new E("tlv.decode(long): zero leftmost byte");
2717
+ for (const b of lengthBytes)
2718
+ length = length << 8 | b;
2719
+ pos += lenLen;
2720
+ if (length < 128)
2721
+ throw new E("tlv.decode(long): not minimal encoding");
2722
+ }
2723
+ const v = data.subarray(pos, pos + length);
2724
+ if (v.length !== length)
2725
+ throw new E("tlv.decode: wrong value length");
2726
+ return { v, l: data.subarray(pos + length) };
2727
+ }
2728
+ },
2729
+ // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
2730
+ // since we always use positive integers here. It must always be empty:
2731
+ // - add zero byte if exists
2732
+ // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)
2733
+ _int: {
2734
+ encode(num) {
2735
+ const { Err: E } = DER;
2736
+ abignumber(num);
2737
+ if (num < _0n6)
2738
+ throw new E("integer: negative integers are not allowed");
2739
+ let hex = numberToHexUnpadded(num);
2740
+ if (Number.parseInt(hex[0], 16) & 8)
2741
+ hex = "00" + hex;
2742
+ if (hex.length & 1)
2743
+ throw new E("unexpected DER parsing assertion: unpadded hex");
2744
+ return hex;
2745
+ },
2746
+ decode(data) {
2747
+ const { Err: E } = DER;
2748
+ if (data.length < 1)
2749
+ throw new E("invalid signature integer: empty");
2750
+ if (data[0] & 128)
2751
+ throw new E("invalid signature integer: negative");
2752
+ if (data.length > 1 && data[0] === 0 && !(data[1] & 128))
2753
+ throw new E("invalid signature integer: unnecessary leading zero");
2754
+ return bytesToNumberBE(data);
2755
+ }
2756
+ },
2757
+ toSig(bytes) {
2758
+ const { Err: E, _int: int, _tlv: tlv } = DER;
2759
+ const data = abytes2(bytes, void 0, "signature");
2760
+ const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
2761
+ if (seqLeftBytes.length)
2762
+ throw new E("invalid signature: left bytes after parsing");
2763
+ const { v: rBytes, l: rLeftBytes } = tlv.decode(2, seqBytes);
2764
+ const { v: sBytes, l: sLeftBytes } = tlv.decode(2, rLeftBytes);
2765
+ if (sLeftBytes.length)
2766
+ throw new E("invalid signature: left bytes after parsing");
2767
+ return { r: int.decode(rBytes), s: int.decode(sBytes) };
2768
+ },
2769
+ hexFromSig(sig) {
2770
+ const { _tlv: tlv, _int: int } = DER;
2771
+ const rs = tlv.encode(2, int.encode(sig.r));
2772
+ const ss = tlv.encode(2, int.encode(sig.s));
2773
+ const seq = rs + ss;
2774
+ return tlv.encode(48, seq);
2775
+ }
2776
+ };
2777
+ Object.freeze(DER._tlv);
2778
+ Object.freeze(DER._int);
2779
+ Object.freeze(DER);
2780
+ var _0n6 = /* @__PURE__ */ BigInt(0);
2781
+ var _1n6 = /* @__PURE__ */ BigInt(1);
2782
+ var _2n4 = /* @__PURE__ */ BigInt(2);
2783
+ var _3n2 = /* @__PURE__ */ BigInt(3);
2784
+ var _4n2 = /* @__PURE__ */ BigInt(4);
2785
+ function weierstrass(params, extraOpts = {}) {
2786
+ const validated = createCurveFields("weierstrass", params, extraOpts);
2787
+ const Fp2 = validated.Fp;
2788
+ const Fn2 = validated.Fn;
2789
+ let CURVE = validated.CURVE;
2790
+ const { h: cofactor, n: CURVE_ORDER } = CURVE;
2791
+ validateObject(extraOpts, {}, {
2792
+ allowInfinityPoint: "boolean",
2793
+ clearCofactor: "function",
2794
+ isTorsionFree: "function",
2795
+ fromBytes: "function",
2796
+ toBytes: "function",
2797
+ endo: "object"
2798
+ });
2799
+ const { endo, allowInfinityPoint } = extraOpts;
2800
+ if (endo) {
2801
+ if (!Fp2.is0(CURVE.a) || typeof endo.beta !== "bigint" || !Array.isArray(endo.basises)) {
2802
+ throw new Error('invalid endo: expected "beta": bigint and "basises": array');
2803
+ }
2804
+ }
2805
+ const lengths = getWLengths(Fp2, Fn2);
2806
+ function assertCompressionIsSupported() {
2807
+ if (!Fp2.isOdd)
2808
+ throw new Error("compression is not supported: Field does not have .isOdd()");
2809
+ }
2810
+ function pointToBytes(_c, point, isCompressed) {
2811
+ if (allowInfinityPoint && point.is0())
2812
+ return Uint8Array.of(0);
2813
+ const { x, y } = point.toAffine();
2814
+ const bx = Fp2.toBytes(x);
2815
+ abool(isCompressed, "isCompressed");
2816
+ if (isCompressed) {
2817
+ assertCompressionIsSupported();
2818
+ const hasEvenY = !Fp2.isOdd(y);
2819
+ return concatBytes2(pprefix(hasEvenY), bx);
2820
+ } else {
2821
+ return concatBytes2(Uint8Array.of(4), bx, Fp2.toBytes(y));
2822
+ }
2823
+ }
2824
+ function pointFromBytes(bytes) {
2825
+ abytes2(bytes, void 0, "Point");
2826
+ const { publicKey: comp, publicKeyUncompressed: uncomp } = lengths;
2827
+ const length = bytes.length;
2828
+ const head = bytes[0];
2829
+ const tail = bytes.subarray(1);
2830
+ if (allowInfinityPoint && length === 1 && head === 0)
2831
+ return { x: Fp2.ZERO, y: Fp2.ZERO };
2832
+ if (length === comp && (head === 2 || head === 3)) {
2833
+ const x = Fp2.fromBytes(tail);
2834
+ if (!Fp2.isValid(x))
2835
+ throw new Error("bad point: is not on curve, wrong x");
2836
+ const y2 = weierstrassEquation(x);
2837
+ let y;
2838
+ try {
2839
+ y = Fp2.sqrt(y2);
2840
+ } catch (sqrtError) {
2841
+ const err = sqrtError instanceof Error ? ": " + sqrtError.message : "";
2842
+ throw new Error("bad point: is not on curve, sqrt error" + err);
2843
+ }
2844
+ assertCompressionIsSupported();
2845
+ const evenY = Fp2.isOdd(y);
2846
+ const evenH = (head & 1) === 1;
2847
+ if (evenH !== evenY)
2848
+ y = Fp2.neg(y);
2849
+ return { x, y };
2850
+ } else if (length === uncomp && head === 4) {
2851
+ const L = Fp2.BYTES;
2852
+ const x = Fp2.fromBytes(tail.subarray(0, L));
2853
+ const y = Fp2.fromBytes(tail.subarray(L, L * 2));
2854
+ if (!isValidXY(x, y))
2855
+ throw new Error("bad point: is not on curve");
2856
+ return { x, y };
2857
+ } else {
2858
+ throw new Error(`bad point: got length ${length}, expected compressed=${comp} or uncompressed=${uncomp}`);
2859
+ }
2860
+ }
2861
+ const encodePoint = extraOpts.toBytes === void 0 ? pointToBytes : extraOpts.toBytes;
2862
+ const decodePoint = extraOpts.fromBytes === void 0 ? pointFromBytes : extraOpts.fromBytes;
2863
+ function weierstrassEquation(x) {
2864
+ const x2 = Fp2.sqr(x);
2865
+ const x3 = Fp2.mul(x2, x);
2866
+ return Fp2.add(Fp2.add(x3, Fp2.mul(x, CURVE.a)), CURVE.b);
2867
+ }
2868
+ function isValidXY(x, y) {
2869
+ const left = Fp2.sqr(y);
2870
+ const right = weierstrassEquation(x);
2871
+ return Fp2.eql(left, right);
2872
+ }
2873
+ if (!isValidXY(CURVE.Gx, CURVE.Gy))
2874
+ throw new Error("bad curve params: generator point");
2875
+ const _4a3 = Fp2.mul(Fp2.pow(CURVE.a, _3n2), _4n2);
2876
+ const _27b2 = Fp2.mul(Fp2.sqr(CURVE.b), BigInt(27));
2877
+ if (Fp2.is0(Fp2.add(_4a3, _27b2)))
2878
+ throw new Error("bad curve params: a or b");
2879
+ function acoord(title, n, banZero = false) {
2880
+ if (!Fp2.isValid(n) || banZero && Fp2.is0(n))
2881
+ throw new Error(`bad point coordinate ${title}`);
2882
+ return n;
2883
+ }
2884
+ function aprjpoint(other) {
2885
+ if (!(other instanceof Point))
2886
+ throw new Error("Weierstrass Point expected");
2887
+ }
2888
+ function splitEndoScalarN(k) {
2889
+ if (!endo || !endo.basises)
2890
+ throw new Error("no endo");
2891
+ return _splitEndoScalar(k, endo.basises, Fn2.ORDER);
2892
+ }
2893
+ function finishEndo(endoBeta, k1p, k2p, k1neg, k2neg) {
2894
+ k2p = new Point(Fp2.mul(k2p.X, endoBeta), k2p.Y, k2p.Z);
2895
+ k1p = negateCt(k1neg, k1p);
2896
+ k2p = negateCt(k2neg, k2p);
2897
+ return k1p.add(k2p);
2898
+ }
2899
+ class Point {
2900
+ // base / generator point
2901
+ static BASE = new Point(CURVE.Gx, CURVE.Gy, Fp2.ONE);
2902
+ // zero / infinity / identity point
2903
+ static ZERO = new Point(Fp2.ZERO, Fp2.ONE, Fp2.ZERO);
2904
+ // 0, 1, 0
2905
+ // math field
2906
+ static Fp = Fp2;
2907
+ // scalar field
2908
+ static Fn = Fn2;
2909
+ X;
2910
+ Y;
2911
+ Z;
2912
+ /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
2913
+ constructor(X, Y, Z) {
2914
+ this.X = acoord("x", X);
2915
+ this.Y = acoord("y", Y, true);
2916
+ this.Z = acoord("z", Z);
2917
+ Object.freeze(this);
2918
+ }
2919
+ static CURVE() {
2920
+ return CURVE;
2921
+ }
2922
+ /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
2923
+ static fromAffine(p) {
2924
+ const { x, y } = p || {};
2925
+ if (!p || !Fp2.isValid(x) || !Fp2.isValid(y))
2926
+ throw new Error("invalid affine point");
2927
+ if (p instanceof Point)
2928
+ throw new Error("projective point not allowed");
2929
+ if (Fp2.is0(x) && Fp2.is0(y))
2930
+ return Point.ZERO;
2931
+ return new Point(x, y, Fp2.ONE);
2932
+ }
2933
+ static fromBytes(bytes) {
2934
+ const P = Point.fromAffine(decodePoint(abytes2(bytes, void 0, "point")));
2935
+ P.assertValidity();
2936
+ return P;
2937
+ }
2938
+ static fromHex(hex) {
2939
+ return Point.fromBytes(hexToBytes2(hex));
2940
+ }
2941
+ get x() {
2942
+ return this.toAffine().x;
2943
+ }
2944
+ get y() {
2945
+ return this.toAffine().y;
2946
+ }
2947
+ /**
2948
+ *
2949
+ * @param windowSize
2950
+ * @param isLazy - true will defer table computation until the first multiplication
2951
+ * @returns
2952
+ */
2953
+ precompute(windowSize = 8, isLazy = true) {
2954
+ wnaf.createCache(this, windowSize);
2955
+ if (!isLazy)
2956
+ this.multiply(_3n2);
2957
+ return this;
2958
+ }
2959
+ // TODO: return `this`
2960
+ /** A point on curve is valid if it conforms to equation. */
2961
+ assertValidity() {
2962
+ const p = this;
2963
+ if (p.is0()) {
2964
+ if (extraOpts.allowInfinityPoint && Fp2.is0(p.X) && Fp2.eql(p.Y, Fp2.ONE) && Fp2.is0(p.Z))
2965
+ return;
2966
+ throw new Error("bad point: ZERO");
2967
+ }
2968
+ const { x, y } = p.toAffine();
2969
+ if (!Fp2.isValid(x) || !Fp2.isValid(y))
2970
+ throw new Error("bad point: x or y not field elements");
2971
+ if (!isValidXY(x, y))
2972
+ throw new Error("bad point: equation left != right");
2973
+ if (!p.isTorsionFree())
2974
+ throw new Error("bad point: not in prime-order subgroup");
2975
+ }
2976
+ hasEvenY() {
2977
+ const { y } = this.toAffine();
2978
+ if (!Fp2.isOdd)
2979
+ throw new Error("Field doesn't support isOdd");
2980
+ return !Fp2.isOdd(y);
2981
+ }
2982
+ /** Compare one point to another. */
2983
+ equals(other) {
2984
+ aprjpoint(other);
2985
+ const { X: X1, Y: Y1, Z: Z1 } = this;
2986
+ const { X: X2, Y: Y2, Z: Z2 } = other;
2987
+ const U1 = Fp2.eql(Fp2.mul(X1, Z2), Fp2.mul(X2, Z1));
2988
+ const U2 = Fp2.eql(Fp2.mul(Y1, Z2), Fp2.mul(Y2, Z1));
2989
+ return U1 && U2;
2990
+ }
2991
+ /** Flips point to one corresponding to (x, -y) in Affine coordinates. */
2992
+ negate() {
2993
+ return new Point(this.X, Fp2.neg(this.Y), this.Z);
2994
+ }
2995
+ // Renes-Costello-Batina exception-free doubling formula.
2996
+ // There is 30% faster Jacobian formula, but it is not complete.
2997
+ // https://eprint.iacr.org/2015/1060, algorithm 3
2998
+ // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
2999
+ double() {
3000
+ const { a, b } = CURVE;
3001
+ const b3 = Fp2.mul(b, _3n2);
3002
+ const { X: X1, Y: Y1, Z: Z1 } = this;
3003
+ let X3 = Fp2.ZERO, Y3 = Fp2.ZERO, Z3 = Fp2.ZERO;
3004
+ let t0 = Fp2.mul(X1, X1);
3005
+ let t1 = Fp2.mul(Y1, Y1);
3006
+ let t2 = Fp2.mul(Z1, Z1);
3007
+ let t3 = Fp2.mul(X1, Y1);
3008
+ t3 = Fp2.add(t3, t3);
3009
+ Z3 = Fp2.mul(X1, Z1);
3010
+ Z3 = Fp2.add(Z3, Z3);
3011
+ X3 = Fp2.mul(a, Z3);
3012
+ Y3 = Fp2.mul(b3, t2);
3013
+ Y3 = Fp2.add(X3, Y3);
3014
+ X3 = Fp2.sub(t1, Y3);
3015
+ Y3 = Fp2.add(t1, Y3);
3016
+ Y3 = Fp2.mul(X3, Y3);
3017
+ X3 = Fp2.mul(t3, X3);
3018
+ Z3 = Fp2.mul(b3, Z3);
3019
+ t2 = Fp2.mul(a, t2);
3020
+ t3 = Fp2.sub(t0, t2);
3021
+ t3 = Fp2.mul(a, t3);
3022
+ t3 = Fp2.add(t3, Z3);
3023
+ Z3 = Fp2.add(t0, t0);
3024
+ t0 = Fp2.add(Z3, t0);
3025
+ t0 = Fp2.add(t0, t2);
3026
+ t0 = Fp2.mul(t0, t3);
3027
+ Y3 = Fp2.add(Y3, t0);
3028
+ t2 = Fp2.mul(Y1, Z1);
3029
+ t2 = Fp2.add(t2, t2);
3030
+ t0 = Fp2.mul(t2, t3);
3031
+ X3 = Fp2.sub(X3, t0);
3032
+ Z3 = Fp2.mul(t2, t1);
3033
+ Z3 = Fp2.add(Z3, Z3);
3034
+ Z3 = Fp2.add(Z3, Z3);
3035
+ return new Point(X3, Y3, Z3);
3036
+ }
3037
+ // Renes-Costello-Batina exception-free addition formula.
3038
+ // There is 30% faster Jacobian formula, but it is not complete.
3039
+ // https://eprint.iacr.org/2015/1060, algorithm 1
3040
+ // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
3041
+ add(other) {
3042
+ aprjpoint(other);
3043
+ const { X: X1, Y: Y1, Z: Z1 } = this;
3044
+ const { X: X2, Y: Y2, Z: Z2 } = other;
3045
+ let X3 = Fp2.ZERO, Y3 = Fp2.ZERO, Z3 = Fp2.ZERO;
3046
+ const a = CURVE.a;
3047
+ const b3 = Fp2.mul(CURVE.b, _3n2);
3048
+ let t0 = Fp2.mul(X1, X2);
3049
+ let t1 = Fp2.mul(Y1, Y2);
3050
+ let t2 = Fp2.mul(Z1, Z2);
3051
+ let t3 = Fp2.add(X1, Y1);
3052
+ let t4 = Fp2.add(X2, Y2);
3053
+ t3 = Fp2.mul(t3, t4);
3054
+ t4 = Fp2.add(t0, t1);
3055
+ t3 = Fp2.sub(t3, t4);
3056
+ t4 = Fp2.add(X1, Z1);
3057
+ let t5 = Fp2.add(X2, Z2);
3058
+ t4 = Fp2.mul(t4, t5);
3059
+ t5 = Fp2.add(t0, t2);
3060
+ t4 = Fp2.sub(t4, t5);
3061
+ t5 = Fp2.add(Y1, Z1);
3062
+ X3 = Fp2.add(Y2, Z2);
3063
+ t5 = Fp2.mul(t5, X3);
3064
+ X3 = Fp2.add(t1, t2);
3065
+ t5 = Fp2.sub(t5, X3);
3066
+ Z3 = Fp2.mul(a, t4);
3067
+ X3 = Fp2.mul(b3, t2);
3068
+ Z3 = Fp2.add(X3, Z3);
3069
+ X3 = Fp2.sub(t1, Z3);
3070
+ Z3 = Fp2.add(t1, Z3);
3071
+ Y3 = Fp2.mul(X3, Z3);
3072
+ t1 = Fp2.add(t0, t0);
3073
+ t1 = Fp2.add(t1, t0);
3074
+ t2 = Fp2.mul(a, t2);
3075
+ t4 = Fp2.mul(b3, t4);
3076
+ t1 = Fp2.add(t1, t2);
3077
+ t2 = Fp2.sub(t0, t2);
3078
+ t2 = Fp2.mul(a, t2);
3079
+ t4 = Fp2.add(t4, t2);
3080
+ t0 = Fp2.mul(t1, t4);
3081
+ Y3 = Fp2.add(Y3, t0);
3082
+ t0 = Fp2.mul(t5, t4);
3083
+ X3 = Fp2.mul(t3, X3);
3084
+ X3 = Fp2.sub(X3, t0);
3085
+ t0 = Fp2.mul(t3, t1);
3086
+ Z3 = Fp2.mul(t5, Z3);
3087
+ Z3 = Fp2.add(Z3, t0);
3088
+ return new Point(X3, Y3, Z3);
3089
+ }
3090
+ subtract(other) {
3091
+ aprjpoint(other);
3092
+ return this.add(other.negate());
3093
+ }
3094
+ is0() {
3095
+ return this.equals(Point.ZERO);
3096
+ }
3097
+ /**
3098
+ * Constant time multiplication.
3099
+ * Uses wNAF method. Windowed method may be 10% faster,
3100
+ * but takes 2x longer to generate and consumes 2x memory.
3101
+ * Uses precomputes when available.
3102
+ * Uses endomorphism for Koblitz curves.
3103
+ * @param scalar - by which the point would be multiplied
3104
+ * @returns New point
3105
+ */
3106
+ multiply(scalar) {
3107
+ const { endo: endo2 } = extraOpts;
3108
+ if (!Fn2.isValidNot0(scalar))
3109
+ throw new RangeError("invalid scalar: out of range");
3110
+ let point, fake;
3111
+ const mul = (n) => wnaf.cached(this, n, (p) => normalizeZ(Point, p));
3112
+ if (endo2) {
3113
+ const { k1neg, k1, k2neg, k2 } = splitEndoScalarN(scalar);
3114
+ const { p: k1p, f: k1f } = mul(k1);
3115
+ const { p: k2p, f: k2f } = mul(k2);
3116
+ fake = k1f.add(k2f);
3117
+ point = finishEndo(endo2.beta, k1p, k2p, k1neg, k2neg);
3118
+ } else {
3119
+ const { p, f } = mul(scalar);
3120
+ point = p;
3121
+ fake = f;
3122
+ }
3123
+ return normalizeZ(Point, [point, fake])[0];
3124
+ }
3125
+ /**
3126
+ * Non-constant-time multiplication. Uses double-and-add algorithm.
3127
+ * It's faster, but should only be used when you don't care about
3128
+ * an exposed secret key e.g. sig verification, which works over *public* keys.
3129
+ */
3130
+ multiplyUnsafe(scalar) {
3131
+ const { endo: endo2 } = extraOpts;
3132
+ const p = this;
3133
+ const sc = scalar;
3134
+ if (!Fn2.isValid(sc))
3135
+ throw new RangeError("invalid scalar: out of range");
3136
+ if (sc === _0n6 || p.is0())
3137
+ return Point.ZERO;
3138
+ if (sc === _1n6)
3139
+ return p;
3140
+ if (wnaf.hasCache(this))
3141
+ return this.multiply(sc);
3142
+ if (endo2) {
3143
+ const { k1neg, k1, k2neg, k2 } = splitEndoScalarN(sc);
3144
+ const { p1, p2 } = mulEndoUnsafe(Point, p, k1, k2);
3145
+ return finishEndo(endo2.beta, p1, p2, k1neg, k2neg);
3146
+ } else {
3147
+ return wnaf.unsafe(p, sc);
3148
+ }
3149
+ }
3150
+ /**
3151
+ * Converts Projective point to affine (x, y) coordinates.
3152
+ * (X, Y, Z) ∋ (x=X/Z, y=Y/Z).
3153
+ * @param invertedZ - Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
3154
+ */
3155
+ toAffine(invertedZ) {
3156
+ const p = this;
3157
+ let iz = invertedZ;
3158
+ const { X, Y, Z } = p;
3159
+ if (Fp2.eql(Z, Fp2.ONE))
3160
+ return { x: X, y: Y };
3161
+ const is0 = p.is0();
3162
+ if (iz == null)
3163
+ iz = is0 ? Fp2.ONE : Fp2.inv(Z);
3164
+ const x = Fp2.mul(X, iz);
3165
+ const y = Fp2.mul(Y, iz);
3166
+ const zz = Fp2.mul(Z, iz);
3167
+ if (is0)
3168
+ return { x: Fp2.ZERO, y: Fp2.ZERO };
3169
+ if (!Fp2.eql(zz, Fp2.ONE))
3170
+ throw new Error("invZ was invalid");
3171
+ return { x, y };
3172
+ }
3173
+ /**
3174
+ * Checks whether Point is free of torsion elements (is in prime subgroup).
3175
+ * Always torsion-free for cofactor=1 curves.
3176
+ */
3177
+ isTorsionFree() {
3178
+ const { isTorsionFree } = extraOpts;
3179
+ if (cofactor === _1n6)
3180
+ return true;
3181
+ if (isTorsionFree)
3182
+ return isTorsionFree(Point, this);
3183
+ return wnaf.unsafe(this, CURVE_ORDER).is0();
3184
+ }
3185
+ clearCofactor() {
3186
+ const { clearCofactor } = extraOpts;
3187
+ if (cofactor === _1n6)
3188
+ return this;
3189
+ if (clearCofactor)
3190
+ return clearCofactor(Point, this);
3191
+ return this.multiplyUnsafe(cofactor);
3192
+ }
3193
+ isSmallOrder() {
3194
+ if (cofactor === _1n6)
3195
+ return this.is0();
3196
+ return this.clearCofactor().is0();
3197
+ }
3198
+ toBytes(isCompressed = true) {
3199
+ abool(isCompressed, "isCompressed");
3200
+ this.assertValidity();
3201
+ return encodePoint(Point, this, isCompressed);
3202
+ }
3203
+ toHex(isCompressed = true) {
3204
+ return bytesToHex2(this.toBytes(isCompressed));
3205
+ }
3206
+ toString() {
3207
+ return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
3208
+ }
3209
+ }
3210
+ const bits = Fn2.BITS;
3211
+ const wnaf = new wNAF(Point, extraOpts.endo ? Math.ceil(bits / 2) : bits);
3212
+ if (bits >= 8)
3213
+ Point.BASE.precompute(8);
3214
+ Object.freeze(Point.prototype);
3215
+ Object.freeze(Point);
3216
+ return Point;
3217
+ }
3218
+ function pprefix(hasEvenY) {
3219
+ return Uint8Array.of(hasEvenY ? 2 : 3);
3220
+ }
3221
+ function SWUFpSqrtRatio(Fp2, Z) {
3222
+ const F = validateField(Fp2);
3223
+ const q = F.ORDER;
3224
+ let l = _0n6;
3225
+ for (let o = q - _1n6; o % _2n4 === _0n6; o /= _2n4)
3226
+ l += _1n6;
3227
+ const c1 = l;
3228
+ const _2n_pow_c1_1 = _2n4 << c1 - _1n6 - _1n6;
3229
+ const _2n_pow_c1 = _2n_pow_c1_1 * _2n4;
3230
+ const c2 = (q - _1n6) / _2n_pow_c1;
3231
+ const c3 = (c2 - _1n6) / _2n4;
3232
+ const c4 = _2n_pow_c1 - _1n6;
3233
+ const c5 = _2n_pow_c1_1;
3234
+ const c6 = F.pow(Z, c2);
3235
+ const c7 = F.pow(Z, (c2 + _1n6) / _2n4);
3236
+ let sqrtRatio = (u, v) => {
3237
+ let tv1 = c6;
3238
+ let tv2 = F.pow(v, c4);
3239
+ let tv3 = F.sqr(tv2);
3240
+ tv3 = F.mul(tv3, v);
3241
+ let tv5 = F.mul(u, tv3);
3242
+ tv5 = F.pow(tv5, c3);
3243
+ tv5 = F.mul(tv5, tv2);
3244
+ tv2 = F.mul(tv5, v);
3245
+ tv3 = F.mul(tv5, u);
3246
+ let tv4 = F.mul(tv3, tv2);
3247
+ tv5 = F.pow(tv4, c5);
3248
+ let isQR = F.eql(tv5, F.ONE);
3249
+ tv2 = F.mul(tv3, c7);
3250
+ tv5 = F.mul(tv4, tv1);
3251
+ tv3 = F.cmov(tv2, tv3, isQR);
3252
+ tv4 = F.cmov(tv5, tv4, isQR);
3253
+ for (let i = c1; i > _1n6; i--) {
3254
+ let tv52 = i - _2n4;
3255
+ tv52 = _2n4 << tv52 - _1n6;
3256
+ let tvv5 = F.pow(tv4, tv52);
3257
+ const e1 = F.eql(tvv5, F.ONE);
3258
+ tv2 = F.mul(tv3, tv1);
3259
+ tv1 = F.mul(tv1, tv1);
3260
+ tvv5 = F.mul(tv4, tv1);
3261
+ tv3 = F.cmov(tv2, tv3, e1);
3262
+ tv4 = F.cmov(tvv5, tv4, e1);
3263
+ }
3264
+ return { isValid: !F.is0(v) && (isQR || F.is0(u)), value: tv3 };
3265
+ };
3266
+ if (F.ORDER % _4n2 === _3n2) {
3267
+ const c12 = (F.ORDER - _3n2) / _4n2;
3268
+ const c22 = F.sqrt(F.neg(Z));
3269
+ sqrtRatio = (u, v) => {
3270
+ let tv1 = F.sqr(v);
3271
+ const tv2 = F.mul(u, v);
3272
+ tv1 = F.mul(tv1, tv2);
3273
+ let y1 = F.pow(tv1, c12);
3274
+ y1 = F.mul(y1, tv2);
3275
+ const y2 = F.mul(y1, c22);
3276
+ const tv3 = F.mul(F.sqr(y1), v);
3277
+ const isQR = F.eql(tv3, u);
3278
+ let y = F.cmov(y2, y1, isQR);
3279
+ return { isValid: !F.is0(v) && isQR, value: y };
3280
+ };
3281
+ }
3282
+ return sqrtRatio;
3283
+ }
3284
+ function mapToCurveSimpleSWU(Fp2, opts) {
3285
+ const F = validateField(Fp2);
3286
+ const { A, B, Z } = opts;
3287
+ if (!F.isValidNot0(A) || !F.isValidNot0(B) || !F.isValid(Z))
3288
+ throw new Error("mapToCurveSimpleSWU: invalid opts");
3289
+ if (F.eql(Z, F.neg(F.ONE)) || FpIsSquare(F, Z))
3290
+ throw new Error("mapToCurveSimpleSWU: invalid opts");
3291
+ const x = F.mul(B, F.inv(F.mul(Z, A)));
3292
+ const gx = F.add(F.add(F.mul(F.sqr(x), x), F.mul(A, x)), B);
3293
+ if (!FpIsSquare(F, gx))
3294
+ throw new Error("mapToCurveSimpleSWU: invalid opts");
3295
+ const sqrtRatio = SWUFpSqrtRatio(F, Z);
3296
+ if (!F.isOdd)
3297
+ throw new Error("Field does not have .isOdd()");
3298
+ return (u) => {
3299
+ let tv1, tv2, tv3, tv4, tv5, tv6, x2, y;
3300
+ tv1 = F.sqr(u);
3301
+ tv1 = F.mul(tv1, Z);
3302
+ tv2 = F.sqr(tv1);
3303
+ tv2 = F.add(tv2, tv1);
3304
+ tv3 = F.add(tv2, F.ONE);
3305
+ tv3 = F.mul(tv3, B);
3306
+ tv4 = F.cmov(Z, F.neg(tv2), !F.eql(tv2, F.ZERO));
3307
+ tv4 = F.mul(tv4, A);
3308
+ tv2 = F.sqr(tv3);
3309
+ tv6 = F.sqr(tv4);
3310
+ tv5 = F.mul(tv6, A);
3311
+ tv2 = F.add(tv2, tv5);
3312
+ tv2 = F.mul(tv2, tv3);
3313
+ tv6 = F.mul(tv6, tv4);
3314
+ tv5 = F.mul(tv6, B);
3315
+ tv2 = F.add(tv2, tv5);
3316
+ x2 = F.mul(tv1, tv3);
3317
+ const { isValid, value } = sqrtRatio(tv2, tv6);
3318
+ y = F.mul(tv1, u);
3319
+ y = F.mul(y, value);
3320
+ x2 = F.cmov(x2, tv3, isValid);
3321
+ y = F.cmov(y, value, isValid);
3322
+ const e1 = F.isOdd(u) === F.isOdd(y);
3323
+ y = F.cmov(F.neg(y), y, e1);
3324
+ const tv4_inv = FpInvertBatch(F, [tv4], true)[0];
3325
+ x2 = F.mul(x2, tv4_inv);
3326
+ return { x: x2, y };
3327
+ };
3328
+ }
3329
+ function getWLengths(Fp2, Fn2) {
3330
+ return {
3331
+ secretKey: Fn2.BYTES,
3332
+ publicKey: 1 + Fp2.BYTES,
3333
+ publicKeyUncompressed: 1 + 2 * Fp2.BYTES,
3334
+ publicKeyHasPrefix: true,
3335
+ // Raw compact `(r || s)` signature width; DER and recovered signatures use
3336
+ // different lengths outside this helper.
3337
+ signature: 2 * Fn2.BYTES
3338
+ };
3339
+ }
3340
+
3341
+ // node_modules/@noble/curves/nist.js
3342
+ var p256_CURVE = /* @__PURE__ */ (() => ({
3343
+ p: BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),
3344
+ n: BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),
3345
+ h: BigInt(1),
3346
+ a: BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),
3347
+ b: BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),
3348
+ Gx: BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),
3349
+ Gy: BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")
3350
+ }))();
3351
+ var p384_CURVE = /* @__PURE__ */ (() => ({
3352
+ p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),
3353
+ n: BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),
3354
+ h: BigInt(1),
3355
+ a: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),
3356
+ b: BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),
3357
+ Gx: BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),
3358
+ Gy: BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")
3359
+ }))();
3360
+ var p521_CURVE = /* @__PURE__ */ (() => ({
3361
+ p: BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
3362
+ n: BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),
3363
+ h: BigInt(1),
3364
+ a: BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),
3365
+ b: BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),
3366
+ Gx: BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),
3367
+ Gy: BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")
3368
+ }))();
3369
+ function createSWU(Point, opts) {
3370
+ let map;
3371
+ return (scalars) => (map || (map = mapToCurveSimpleSWU(Point.Fp, opts)))(scalars[0]);
3372
+ }
3373
+ var p256_Point = /* @__PURE__ */ weierstrass(p256_CURVE);
3374
+ var p256_hasher = /* @__PURE__ */ (() => {
3375
+ return createHasher2(p256_Point, createSWU(p256_Point, {
3376
+ A: p256_CURVE.a,
3377
+ B: p256_CURVE.b,
3378
+ Z: p256_Point.Fp.create(BigInt("-10"))
3379
+ }), {
3380
+ DST: "P256_XMD:SHA-256_SSWU_RO_",
3381
+ encodeDST: "P256_XMD:SHA-256_SSWU_NU_",
3382
+ p: p256_CURVE.p,
3383
+ m: 1,
3384
+ k: 128,
3385
+ expand: "xmd",
3386
+ hash: sha256
3387
+ });
3388
+ })();
3389
+ var p256_oprf = /* @__PURE__ */ (() => createOPRF({
3390
+ name: "P256-SHA256",
3391
+ Point: p256_Point,
3392
+ hash: sha256,
3393
+ hashToGroup: p256_hasher.hashToCurve,
3394
+ hashToScalar: p256_hasher.hashToScalar
3395
+ }))();
3396
+ var p384_Point = /* @__PURE__ */ weierstrass(p384_CURVE);
3397
+ var p384_hasher = /* @__PURE__ */ (() => {
3398
+ return createHasher2(p384_Point, createSWU(p384_Point, {
3399
+ A: p384_CURVE.a,
3400
+ B: p384_CURVE.b,
3401
+ Z: p384_Point.Fp.create(BigInt("-12"))
3402
+ }), {
3403
+ DST: "P384_XMD:SHA-384_SSWU_RO_",
3404
+ encodeDST: "P384_XMD:SHA-384_SSWU_NU_",
3405
+ p: p384_CURVE.p,
3406
+ m: 1,
3407
+ k: 192,
3408
+ expand: "xmd",
3409
+ hash: sha384
3410
+ });
3411
+ })();
3412
+ var p384_oprf = /* @__PURE__ */ (() => createOPRF({
3413
+ name: "P384-SHA384",
3414
+ Point: p384_Point,
3415
+ hash: sha384,
3416
+ hashToGroup: p384_hasher.hashToCurve,
3417
+ hashToScalar: p384_hasher.hashToScalar
3418
+ }))();
3419
+ var p521_Point = /* @__PURE__ */ weierstrass(p521_CURVE);
3420
+ var p521_hasher = /* @__PURE__ */ (() => {
3421
+ return createHasher2(p521_Point, createSWU(p521_Point, {
3422
+ A: p521_CURVE.a,
3423
+ B: p521_CURVE.b,
3424
+ Z: p521_Point.Fp.create(BigInt("-4"))
3425
+ }), {
3426
+ DST: "P521_XMD:SHA-512_SSWU_RO_",
3427
+ encodeDST: "P521_XMD:SHA-512_SSWU_NU_",
3428
+ p: p521_CURVE.p,
3429
+ m: 1,
3430
+ k: 256,
3431
+ expand: "xmd",
3432
+ hash: sha512
3433
+ });
3434
+ })();
3435
+ var p521_oprf = /* @__PURE__ */ (() => createOPRF({
3436
+ name: "P521-SHA512",
3437
+ Point: p521_Point,
3438
+ hash: sha512,
3439
+ hashToGroup: p521_hasher.hashToCurve,
3440
+ hashToScalar: p521_hasher.hashToScalar
3441
+ // produces L=98 just like in RFC
3442
+ }))();
3443
+ // Annotate the CommonJS export names for ESM import in node:
3444
+ 0 && (module.exports = {
3445
+ p256_oprf,
3446
+ p384_oprf,
3447
+ p521_oprf,
3448
+ ristretto255_oprf
3449
+ });
8
3450
  /*! Bundled license information:
9
3451
 
10
3452
  @noble/curves/utils.js: