From 0e0d0f530d3c9ccbe03c1f06a768860efbcc11ba Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Mon, 27 Feb 2023 22:59:27 +0000 Subject: [PATCH] benchmark: add tonneli-shanks sqrt --- benchmark/modular.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/benchmark/modular.js b/benchmark/modular.js index 5f4234b..5ebe918 100644 --- a/benchmark/modular.js +++ b/benchmark/modular.js @@ -1,10 +1,13 @@ import { run, mark } from 'micro-bmark'; import { secp256k1 } from '../secp256k1.js'; +import { Fp } from '../abstract/modular.js'; run(async () => { console.log(`\x1b[36mmodular, secp256k1 field\x1b[0m`); - const { Fp } = secp256k1.CURVE; - await mark('invert a', 30000, () => Fp.inv(2n ** 232n - 5910n)); - await mark('invert b', 30000, () => Fp.inv(2n ** 231n - 5910n)); - await mark('sqrt', 15000, () => Fp.sqrt(2n ** 231n - 5910n)); + const { Fp: secpFp } = secp256k1.CURVE; + await mark('invert a', 300000, () => secpFp.inv(2n ** 232n - 5910n)); + await mark('invert b', 300000, () => secpFp.inv(2n ** 231n - 5910n)); + await mark('sqrt p = 3 mod 4', 15000, () => secpFp.sqrt(2n ** 231n - 5910n)); + const FpStark = Fp(BigInt('0x800000000000011000000000000000000000000000000000000000000000001')); + await mark('sqrt tonneli-shanks', 500, () => FpStark.sqrt(2n ** 231n - 5909n)) });