diff options
Diffstat (limited to 'analysis/countermeasures')
| -rw-r--r-- | analysis/countermeasures/combinations.ipynb | 613 |
1 files changed, 564 insertions, 49 deletions
diff --git a/analysis/countermeasures/combinations.ipynb b/analysis/countermeasures/combinations.ipynb index feba401..cd07889 100644 --- a/analysis/countermeasures/combinations.ipynb +++ b/analysis/countermeasures/combinations.ipynb @@ -100,7 +100,75 @@ " test_3n(countermeasure, generate_scalars_mod3(1, samples))\n", " print()\n", " print(\"k = 2 mod 3\")\n", - " test_3n(countermeasure, generate_scalars_mod3(2, samples))" + " test_3n(countermeasure, generate_scalars_mod3(2, samples))\n", + "\n", + "\n", + "def test_composite(countermeasure, samples):\n", + " G = composite.generator\n", + " Gaff = G.to_affine()\n", + " correct = 0\n", + " errors = 0\n", + " wrong = 0\n", + " for _ in range(samples):\n", + " k = random.randrange(0, composite.full_order)\n", + " countermeasure.init(composite, G)\n", + " try:\n", + " res = countermeasure.multiply(k)\n", + " res_aff = composite.curve.affine_multiply(Gaff, k)\n", + " \n", + " if res.equals_scaled(res_aff.to_model(composite.curve.coordinate_model, composite.curve)):\n", + " correct += 1\n", + " else:\n", + " wrong += 1\n", + " except Exception as e:\n", + " errors += 1\n", + " print(f\"{errors} errors, {wrong} wrong results\")\n", + "\n", + "\n", + "def test_k10(countermeasure, samples, k_range = None, zero_fails = True, plot=True):\n", + " G = paramsk10.generator\n", + " Gaff = G.to_affine()\n", + " if k_range is None:\n", + " ks = list(range(2, 21))\n", + " else:\n", + " ks = list(k_range)\n", + " fails = []\n", + " for k in ks:\n", + " correct = 0\n", + " failed = 0\n", + " expected = paramsk10.curve.affine_multiply(Gaff, k).to_model(paramsk10.curve.coordinate_model, paramsk10.curve)\n", + " for _ in range(samples):\n", + " with local(DefaultContext()) as ctx:\n", + " countermeasure.init(paramsk10, paramsk10.generator)\n", + " res = countermeasure.multiply(k)\n", + " smults = set()\n", + " ctx.actions[0].walk(lambda action: smults.add(action.scalar) if isinstance(action, ScalarMultiplicationAction) else None)\n", + " if 0 in smults and zero_fails:\n", + " failed += 1\n", + " continue\n", + " try:\n", + " if res.equals_scaled(expected):\n", + " correct += 1\n", + " else:\n", + " failed += 1\n", + " except:\n", + " failed += 1\n", + " print(f\"k = {k}: failed in {failed} out of {samples}.\")\n", + " fails.append(failed / samples)\n", + " if plot:\n", + " fig, ax = plt.subplots()\n", + " xs = list(range(len(ks)))\n", + " ax.plot(xs, fails, label=\"Error rate\")\n", + " if any(k > 100 for k in ks):\n", + " ax.set_xticks(xs, (f\"2^{int(math.log2(k))}\" for k in ks))\n", + " else:\n", + " ax.set_xticks(xs, ks)\n", + " ax.set_ylim(-0.05, 1.05)\n", + " ax.set_xlabel(\"k\")\n", + " ax.set_ylabel(\"Error rate\")\n", + " ax.legend()\n", + " plt.show()\n", + " return fails" ] }, { @@ -141,6 +209,31 @@ ] }, { + "cell_type": "code", + "execution_count": null, + "id": "76c61ded-55b4-46fd-b0cc-cbdc80f82775", + "metadata": {}, + "outputs": [], + "source": [ + "paramsk10 = get_params(\"secg\", \"secp256r1\", \"projective\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "17eddcbb-bc16-416d-bab1-b8826fd8db14", + "metadata": {}, + "outputs": [], + "source": [ + "composite = load_params_ectester(io.BytesIO(b\"0xc7a3ef9fa4ea63b537eedefc6bd52c3f35dc45be933d44270a1536c2ff9b6543,0x395f3675858362cbe7ac0d3e85708750aa42428368ae6ab1fda0d2a56255039b,0x61ca87695d4f6147b35975326eeee1a77f93226487315cd2419b4a1fe23f32d1,0x56e9a905d29f0f512cf709522bdd43a862d4e32c46268eec2f4c3fd9a70cb9d6,0xaf77a4ef604d33e3cf6c2ecaaa2913a5c51660e40365832ab98488950f3c348e,0xc7a3ef9fa4ea63b537eedefc6bd52c40f5e8e3bfe0f6dd05ac513edbcaa3cc47,0x01\"), \"projective\")\n", + "print(f\"prime:\\t0x{composite.curve.prime:x}\")\n", + "print(f\"a:\\t0x{composite.curve.parameters['a']:x}\")\n", + "print(f\"b:\\t0x{composite.curve.parameters['b']:x}\")\n", + "print(f\"G:\\t[0x{composite.generator.X:x},\\n\\t 0x{composite.generator.Y:x}]\")\n", + "print(f\"n:\\t0x{composite.order:x}\")" + ] + }, + { "cell_type": "markdown", "id": "c7535814", "metadata": {}, @@ -272,7 +365,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar(ga1, 10)" + "test_3n_random_scalar(ga1, 1000)" ] }, { @@ -282,7 +375,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar(ga2, 10)" + "test_3n_random_scalar(ga2, 1000)" ] }, { @@ -292,7 +385,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar_projected(ga1,10)" + "test_3n_random_scalar_projected(ga1,1000)" ] }, { @@ -302,7 +395,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar_projected(ga2, 10)" + "test_3n_random_scalar_projected(ga2, 1000)" ] }, { @@ -312,7 +405,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_fixed_scalar(ga1,10)" + "test_3n_fixed_scalar(ga1,1000)" ] }, { @@ -322,7 +415,55 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_fixed_scalar(ga2, 10)" + "test_3n_fixed_scalar(ga2, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6d959ee5-754a-46c4-94c0-7d57b1e2fbc1", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(ga1, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "59761622-5d10-4a9d-8eab-4158b2c986e6", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(ga2, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "be2fdd7c-81fe-4a56-af7a-1696e20e7902", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(ga1, 100, k_range = range(8,11))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a3e4d77f-770b-49f5-b919-a0866755e89d", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(ga2, 100, k_range = range(8,11))" + ] + }, + { + "cell_type": "markdown", + "id": "79218e51-8b00-495f-ac03-8f6c7a19aaa4", + "metadata": {}, + "source": [ + "#### Experiments with fixed masks" ] }, { @@ -567,7 +708,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar(gm1, 10)" + "test_3n_random_scalar(gm1, 1000)" ] }, { @@ -577,7 +718,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar(gm2, 10)" + "test_3n_random_scalar(gm2, 1000)" ] }, { @@ -587,7 +728,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar(gm3, 10)" + "test_3n_random_scalar(gm3, 1000)" ] }, { @@ -597,7 +738,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar_projected(gm1,10)" + "test_3n_random_scalar_projected(gm1,1000)" ] }, { @@ -607,7 +748,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar_projected(gm2,10)" + "test_3n_random_scalar_projected(gm2,1000)" ] }, { @@ -617,7 +758,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar_projected(gm3,10)" + "test_3n_random_scalar_projected(gm3,1000)" ] }, { @@ -627,7 +768,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_fixed_scalar(gm1,10)" + "test_3n_fixed_scalar(gm1,1000)" ] }, { @@ -637,7 +778,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_fixed_scalar(gm2,10)" + "test_3n_fixed_scalar(gm2,1000)" ] }, { @@ -647,7 +788,75 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_fixed_scalar(gm3,10)" + "test_3n_fixed_scalar(gm3,1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d6636e68-2218-4bfd-b280-5c864d6da8c0", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(gm1, 100, k_range = range(8,11))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2e88c407-f041-4653-9f32-70a3fc2fa0b0", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(gm2, 100, k_range = range(8,11))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "929539c0-93c8-49e0-806a-216d4d083c53", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(gm3, 100, k_range = range(8,11))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1205ddd6-14a8-406a-9c86-b00b14248882", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(gm1, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9aa2c845-f81a-4993-8c66-498008348874", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(gm2, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6d1a9dac-f579-430e-9a15-8ee8d9e41ca8", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(gm3, 1000)" + ] + }, + { + "cell_type": "markdown", + "id": "101280dd-3c14-4906-a63c-e5c0e753452a", + "metadata": {}, + "source": [ + "#### Experiments with fixed masks" ] }, { @@ -791,10 +1000,11 @@ " if self.params is None or self.point is None:\n", " raise ValueError(\"Not initialized.\")\n", " with ScalarMultiplicationAction(self.point, self.params, scalar) as action:\n", - " half_bits = self.params.order.bit_length() // 2\n", + " \n", " order = self.params.order\n", " r = int(Mod.random(1 << self.rand_bits_gsr)) if self.r is None else self.r\n", " gsr = scalar+r*order\n", + " half_bits = gsr.bit_length() // 2\n", " s = int(Mod.random(1 << half_bits)) if self.s is None else self.s\n", " S = self.mult.multiply(s)\n", " k1 = gsr % s\n", @@ -916,7 +1126,62 @@ " self.params.curve.prime, R, T, **self.params.curve.parameters\n", " )[0]\n", " return action.exit(res)\n", - " \n" + " \n", + "@public\n", + "class GSR_Eucl_4(ScalarMultiplierCountermeasure):\n", + " r\"\"\"\n", + " GSR with Eucl, option 4.\n", + " k = k1+k2s\n", + " [k1+r1*n]+[k2+r2*n][s+r3*n]\n", + " \"\"\"\n", + "\n", + " add: Optional[AdditionFormula]\n", + "\n", + " def __init__(self, mult: ScalarMultiplier, rand_bits_gsr: int = 32, add: Optional[AdditionFormula] = None):\n", + " \"\"\"\n", + " :param mult: The multiplier to use.\n", + " :param add: Addition formula to use, if None, the formula from the multiplier is used.\n", + " \"\"\"\n", + " super().__init__(mult)\n", + " self.add = add\n", + " self.rand_bits_gsr = rand_bits_gsr\n", + " self.r1: int = None\n", + " self.r2: int = None\n", + " self.r3: int = None\n", + " self.s: int = None\n", + " \n", + " def init(self, params: DomainParameters, point: Point):\n", + " self.params = params\n", + " self.point = point\n", + " self.mult.init(\n", + " self.params,\n", + " self.point,\n", + " bits=params.full_order.bit_length() + self.rand_bits_gsr,\n", + " )\n", + "\n", + " def multiply(self, scalar: int) -> Point:\n", + " if self.params is None or self.point is None:\n", + " raise ValueError(\"Not initialized.\")\n", + " with ScalarMultiplicationAction(self.point, self.params, scalar) as action:\n", + " half_bits = self.params.order.bit_length() // 2\n", + " order = self.params.order\n", + " r1 = int(Mod.random(1 << self.rand_bits_gsr)) if self.r1 is None else self.r1\n", + " r2 = int(Mod.random(1 << self.rand_bits_gsr)) if self.r2 is None else self.r2\n", + " r3 = int(Mod.random(1 << self.rand_bits_gsr)) if self.r3 is None else self.r3\n", + " s = int(Mod.random(1 << half_bits)) if self.s is None else self.s\n", + " S = self.mult.multiply(s+r3*order)\n", + " k1 = scalar % s\n", + " k2 = scalar // s\n", + " T = self.mult.multiply(k1+r1*order)\n", + " self.mult.init(self.params, S)\n", + " R = self.mult.multiply(k2+r2*order)\n", + " if self.add is None:\n", + " res = self.mult._add(R, T) # noqa: This is OK.\n", + " else:\n", + " res = self.add(\n", + " self.params.curve.prime, R, T, **self.params.curve.parameters\n", + " )[0]\n", + " return action.exit(res)" ] }, { @@ -928,7 +1193,8 @@ "source": [ "ge1 = GSR_Eucl_1(mult)\n", "ge2 = GSR_Eucl_2(mult)\n", - "ge3 = GSR_Eucl_3(mult)" + "ge3 = GSR_Eucl_3(mult)\n", + "ge4 = GSR_Eucl_4(mult)" ] }, { @@ -938,7 +1204,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar(ge1, 10)" + "test_3n_random_scalar(ge1, 1000)" ] }, { @@ -948,7 +1214,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar(ge2, 10)" + "test_3n_random_scalar(ge2, 1000)" ] }, { @@ -958,7 +1224,17 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar(ge3, 10)" + "test_3n_random_scalar(ge3, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "351c0dbd-e659-4cb4-8af9-d532ff03237e", + "metadata": {}, + "outputs": [], + "source": [ + "test_3n_random_scalar(ge4, 1000)" ] }, { @@ -968,7 +1244,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar_projected(ge1,10)" + "test_3n_random_scalar_projected(ge1,1000)" ] }, { @@ -978,7 +1254,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar_projected(ge2,10)" + "test_3n_random_scalar_projected(ge2,1000)" ] }, { @@ -988,7 +1264,17 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar_projected(ge3,10)" + "test_3n_random_scalar_projected(ge3,1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "62a1b4c3-6fd8-4a89-979f-66041566d67d", + "metadata": {}, + "outputs": [], + "source": [ + "test_3n_random_scalar_projected(ge4,1000)" ] }, { @@ -998,7 +1284,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_fixed_scalar(ge1,10)" + "test_3n_fixed_scalar(ge1,1000)" ] }, { @@ -1008,7 +1294,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_fixed_scalar(ge2,10)" + "test_3n_fixed_scalar(ge2,1000)" ] }, { @@ -1018,7 +1304,105 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_fixed_scalar(ge3,10)" + "test_3n_fixed_scalar(ge3,1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cf65daf5-ae32-4973-b41b-e86f621eba0f", + "metadata": {}, + "outputs": [], + "source": [ + "test_3n_fixed_scalar(ge4,1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "167d3839-22df-40b7-80ff-7a11cd5b915d", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(ge1, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "84f59798-27b6-45a7-b14d-8cf820aac83f", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(ge2, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c60e0075-215b-489c-a6b3-945079dc7e3b", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(ge3, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "82a8d754-47a4-4864-a36f-24144c6858d9", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(ge4, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1c3a77e2-b577-4570-830c-285bc19c235c", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(ge1, 100, k_range = range(8,11))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "dc7b7967-fdda-48cd-b136-c0f6a970aedb", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(ge2, 100, k_range = range(8,11))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0e2696f1-1266-480b-9831-d90c01f384a0", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(ge3, 100, k_range = range(8,11))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7e1cd225-004a-4c56-8f7d-d149e42a65d9", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(ge4, 100, k_range = range(8,11))" + ] + }, + { + "cell_type": "markdown", + "id": "27776d8b-ba29-4cef-8f6d-dce78b515030", + "metadata": {}, + "source": [ + "#### Experiments with fixed masks" ] }, { @@ -1231,7 +1615,8 @@ " res = self.add(\n", " self.params.curve.prime, R, S, **self.params.curve.parameters\n", " )[0]\n", - " return action.exit(res)" + " return action.exit(res)\n", + "\n" ] }, { @@ -1252,7 +1637,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar(am1, 10)" + "test_3n_random_scalar(am1, 1000)" ] }, { @@ -1262,7 +1647,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar(am2, 10)" + "test_3n_random_scalar(am2, 1000)" ] }, { @@ -1272,7 +1657,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar_projected(am1, 10)" + "test_3n_random_scalar_projected(am1, 1000)" ] }, { @@ -1282,7 +1667,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar_projected(am2, 10)" + "test_3n_random_scalar_projected(am2, 1000)" ] }, { @@ -1292,7 +1677,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_fixed_scalar(am1,10)" + "test_3n_fixed_scalar(am1,1000)" ] }, { @@ -1302,7 +1687,47 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_fixed_scalar(am2,10)" + "test_3n_fixed_scalar(am2,1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d9029c1b-b166-4106-97e5-92319def0ab5", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(am1, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d4c0f1dd-ebf3-4e54-97b0-4e2594a6f8f1", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(am2, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0fe42ac2-3776-4bf7-8562-7d0748259738", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(am1, 100, k_range = range(8,11))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a2913fe4-83f8-4d30-84d1-c56008274931", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(am2, 100, k_range = range(8,11))" ] }, { @@ -1458,7 +1883,7 @@ "outputs": [], "source": [ "ae1 = Add_Eucl_1(mult)\n", - "ae2 = Add_Eucl_2(mult)\n" + "ae2 = Add_Eucl_2(mult)" ] }, { @@ -1468,7 +1893,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar(ae1, 10)" + "test_3n_random_scalar(ae1, 1000)" ] }, { @@ -1478,7 +1903,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar(ae2, 10)" + "test_3n_random_scalar(ae2, 1000)" ] }, { @@ -1488,7 +1913,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar_projected(ae1, 10)" + "test_3n_random_scalar_projected(ae1, 1000)" ] }, { @@ -1498,7 +1923,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar_projected(ae2, 10)" + "test_3n_random_scalar_projected(ae2, 1000)" ] }, { @@ -1508,7 +1933,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_fixed_scalar(ae1,10)" + "test_3n_fixed_scalar(ae1,1000)" ] }, { @@ -1518,7 +1943,47 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_fixed_scalar(ae2,10)" + "test_3n_fixed_scalar(ae2,1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "adf2e610-fb35-45a5-aa20-d793b69d1ca4", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(ae1, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a8adab56-1cc1-4174-98ce-858a2a90def8", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(ae2, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f617263d-8d49-4dc0-9645-bb5388f0ef03", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(ae1, 100, k_range = range(8,11))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "64af0ce4-e827-4b76-9372-b90b61fe5464", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(ae2, 100, k_range = range(8,11))" ] }, { @@ -1641,7 +2106,7 @@ " self.params.curve.prime, R1, R2, **self.params.curve.parameters\n", " )[0]\n", " return action.exit(res)\n", - " \n" + "\n" ] }, { @@ -1662,7 +2127,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar(me1, 10)" + "test_3n_random_scalar(me1, 1000)" ] }, { @@ -1672,7 +2137,17 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar(me2, 10)" + "test_3n_random_scalar(me2, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "51edb972-54e0-4c2f-b3f4-45c29ba7d898", + "metadata": {}, + "outputs": [], + "source": [ + "test_3n_random_scalar(me3, 1000)" ] }, { @@ -1682,7 +2157,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar_projected(me1, 10)" + "test_3n_random_scalar_projected(me1, 1000)" ] }, { @@ -1692,7 +2167,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_random_scalar_projected(me2, 10)" + "test_3n_random_scalar_projected(me2, 1000)" ] }, { @@ -1702,7 +2177,7 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_fixed_scalar(me1,10)" + "test_3n_fixed_scalar(me1,1000)" ] }, { @@ -1712,7 +2187,47 @@ "metadata": {}, "outputs": [], "source": [ - "test_3n_fixed_scalar(me2,10)" + "test_3n_fixed_scalar(me2,1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "270569f6-4a24-4752-b06a-887ccd823447", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(me1, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d59db17a-32c4-4aa2-8ff1-7991c2e1c9a9", + "metadata": {}, + "outputs": [], + "source": [ + "test_composite(me2, 1000)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "268034b3-974f-480a-955f-bc32263c878a", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(me1, 100, k_range = range(8,11))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fe20f1a6-df47-4727-a997-333b64a2b03f", + "metadata": {}, + "outputs": [], + "source": [ + "test_k10(me2, 100, k_range = range(8,11))" ] } ], |
