charm-crypto-framework 0.61.1__cp313-cp313-macosx_10_13_universal2.whl

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 (323) hide show
  1. charm/__init__.py +5 -0
  2. charm/adapters/__init__.py +0 -0
  3. charm/adapters/abenc_adapt_hybrid.py +90 -0
  4. charm/adapters/dabenc_adapt_hybrid.py +145 -0
  5. charm/adapters/ibenc_adapt_hybrid.py +72 -0
  6. charm/adapters/ibenc_adapt_identityhash.py +80 -0
  7. charm/adapters/kpabenc_adapt_hybrid.py +91 -0
  8. charm/adapters/pkenc_adapt_bchk05.py +121 -0
  9. charm/adapters/pkenc_adapt_chk04.py +91 -0
  10. charm/adapters/pkenc_adapt_hybrid.py +98 -0
  11. charm/adapters/pksig_adapt_naor01.py +89 -0
  12. charm/config.py +7 -0
  13. charm/core/__init__.py +0 -0
  14. charm/core/benchmark/benchmark_util.c +353 -0
  15. charm/core/benchmark/benchmark_util.h +61 -0
  16. charm/core/benchmark/benchmarkmodule.c +476 -0
  17. charm/core/benchmark/benchmarkmodule.h +162 -0
  18. charm/core/benchmark.cpython-313-darwin.so +0 -0
  19. charm/core/crypto/AES/AES.c +1464 -0
  20. charm/core/crypto/AES.cpython-313-darwin.so +0 -0
  21. charm/core/crypto/DES/DES.c +113 -0
  22. charm/core/crypto/DES.cpython-313-darwin.so +0 -0
  23. charm/core/crypto/DES3/DES3.c +26 -0
  24. charm/core/crypto/DES3.cpython-313-darwin.so +0 -0
  25. charm/core/crypto/__init__.py +0 -0
  26. charm/core/crypto/cryptobase/XOR.c +80 -0
  27. charm/core/crypto/cryptobase/_counter.c +496 -0
  28. charm/core/crypto/cryptobase/_counter.h +54 -0
  29. charm/core/crypto/cryptobase/block_template.c +900 -0
  30. charm/core/crypto/cryptobase/block_template.h +69 -0
  31. charm/core/crypto/cryptobase/cryptobasemodule.c +220 -0
  32. charm/core/crypto/cryptobase/libtom/tomcrypt.h +90 -0
  33. charm/core/crypto/cryptobase/libtom/tomcrypt_argchk.h +44 -0
  34. charm/core/crypto/cryptobase/libtom/tomcrypt_cfg.h +186 -0
  35. charm/core/crypto/cryptobase/libtom/tomcrypt_cipher.h +941 -0
  36. charm/core/crypto/cryptobase/libtom/tomcrypt_custom.h +556 -0
  37. charm/core/crypto/cryptobase/libtom/tomcrypt_des.c +1912 -0
  38. charm/core/crypto/cryptobase/libtom/tomcrypt_hash.h +407 -0
  39. charm/core/crypto/cryptobase/libtom/tomcrypt_mac.h +496 -0
  40. charm/core/crypto/cryptobase/libtom/tomcrypt_macros.h +435 -0
  41. charm/core/crypto/cryptobase/libtom/tomcrypt_math.h +534 -0
  42. charm/core/crypto/cryptobase/libtom/tomcrypt_misc.h +103 -0
  43. charm/core/crypto/cryptobase/libtom/tomcrypt_pk.h +653 -0
  44. charm/core/crypto/cryptobase/libtom/tomcrypt_pkcs.h +90 -0
  45. charm/core/crypto/cryptobase/libtom/tomcrypt_prng.h +199 -0
  46. charm/core/crypto/cryptobase/stream_template.c +271 -0
  47. charm/core/crypto/cryptobase/strxor.c +229 -0
  48. charm/core/crypto/cryptobase.cpython-313-darwin.so +0 -0
  49. charm/core/engine/__init__.py +5 -0
  50. charm/core/engine/protocol.py +293 -0
  51. charm/core/engine/util.py +174 -0
  52. charm/core/math/__init__.py +0 -0
  53. charm/core/math/elliptic_curve/ecmodule.c +1986 -0
  54. charm/core/math/elliptic_curve/ecmodule.h +230 -0
  55. charm/core/math/elliptic_curve.cpython-313-darwin.so +0 -0
  56. charm/core/math/elliptic_curve.pyi +63 -0
  57. charm/core/math/integer/integermodule.c +2539 -0
  58. charm/core/math/integer/integermodule.h +145 -0
  59. charm/core/math/integer.cpython-313-darwin.so +0 -0
  60. charm/core/math/integer.pyi +76 -0
  61. charm/core/math/pairing/miracl/miracl_config.h +37 -0
  62. charm/core/math/pairing/miracl/miracl_interface.h +118 -0
  63. charm/core/math/pairing/miracl/miracl_interface2.h +126 -0
  64. charm/core/math/pairing/miracl/pairingmodule2.c +2094 -0
  65. charm/core/math/pairing/miracl/pairingmodule2.h +307 -0
  66. charm/core/math/pairing/pairingmodule.c +2230 -0
  67. charm/core/math/pairing/pairingmodule.h +241 -0
  68. charm/core/math/pairing/relic/pairingmodule3.c +1853 -0
  69. charm/core/math/pairing/relic/pairingmodule3.h +233 -0
  70. charm/core/math/pairing/relic/relic_interface.c +1337 -0
  71. charm/core/math/pairing/relic/relic_interface.h +217 -0
  72. charm/core/math/pairing/relic/test_relic.c +171 -0
  73. charm/core/math/pairing.cpython-313-darwin.so +0 -0
  74. charm/core/math/pairing.pyi +69 -0
  75. charm/core/utilities/base64.c +248 -0
  76. charm/core/utilities/base64.h +15 -0
  77. charm/schemes/__init__.py +0 -0
  78. charm/schemes/abenc/__init__.py +0 -0
  79. charm/schemes/abenc/abenc_accountability_jyjxgd20.py +647 -0
  80. charm/schemes/abenc/abenc_bsw07.py +146 -0
  81. charm/schemes/abenc/abenc_ca_cpabe_ar17.py +684 -0
  82. charm/schemes/abenc/abenc_dacmacs_yj14.py +298 -0
  83. charm/schemes/abenc/abenc_lsw08.py +159 -0
  84. charm/schemes/abenc/abenc_maabe_rw15.py +236 -0
  85. charm/schemes/abenc/abenc_maabe_yj14.py +297 -0
  86. charm/schemes/abenc/abenc_tbpre_lww14.py +309 -0
  87. charm/schemes/abenc/abenc_unmcpabe_yahk14.py +223 -0
  88. charm/schemes/abenc/abenc_waters09.py +144 -0
  89. charm/schemes/abenc/abenc_yct14.py +208 -0
  90. charm/schemes/abenc/abenc_yllc15.py +178 -0
  91. charm/schemes/abenc/ac17.py +248 -0
  92. charm/schemes/abenc/bsw07.py +141 -0
  93. charm/schemes/abenc/cgw15.py +277 -0
  94. charm/schemes/abenc/dabe_aw11.py +204 -0
  95. charm/schemes/abenc/dfa_fe12.py +144 -0
  96. charm/schemes/abenc/pk_hve08.py +179 -0
  97. charm/schemes/abenc/waters11.py +143 -0
  98. charm/schemes/aggrsign_MuSig.py +150 -0
  99. charm/schemes/aggrsign_bls.py +267 -0
  100. charm/schemes/blindsig_ps16.py +654 -0
  101. charm/schemes/chamhash_adm05.py +113 -0
  102. charm/schemes/chamhash_rsa_hw09.py +100 -0
  103. charm/schemes/commit/__init__.py +0 -0
  104. charm/schemes/commit/commit_gs08.py +77 -0
  105. charm/schemes/commit/commit_pedersen92.py +53 -0
  106. charm/schemes/encap_bchk05.py +62 -0
  107. charm/schemes/grpsig/__init__.py +0 -0
  108. charm/schemes/grpsig/groupsig_bgls04.py +114 -0
  109. charm/schemes/grpsig/groupsig_bgls04_var.py +115 -0
  110. charm/schemes/hibenc/__init__.py +0 -0
  111. charm/schemes/hibenc/hibenc_bb04.py +105 -0
  112. charm/schemes/hibenc/hibenc_lew11.py +193 -0
  113. charm/schemes/ibenc/__init__.py +0 -0
  114. charm/schemes/ibenc/clpkc_rp03.py +119 -0
  115. charm/schemes/ibenc/ibenc_CW13_z.py +168 -0
  116. charm/schemes/ibenc/ibenc_bb03.py +94 -0
  117. charm/schemes/ibenc/ibenc_bf01.py +121 -0
  118. charm/schemes/ibenc/ibenc_ckrs09.py +120 -0
  119. charm/schemes/ibenc/ibenc_cllww12_z.py +172 -0
  120. charm/schemes/ibenc/ibenc_lsw08.py +120 -0
  121. charm/schemes/ibenc/ibenc_sw05.py +238 -0
  122. charm/schemes/ibenc/ibenc_waters05.py +144 -0
  123. charm/schemes/ibenc/ibenc_waters05_z.py +164 -0
  124. charm/schemes/ibenc/ibenc_waters09.py +107 -0
  125. charm/schemes/ibenc/ibenc_waters09_z.py +147 -0
  126. charm/schemes/joye_scheme.py +106 -0
  127. charm/schemes/lem_scheme.py +207 -0
  128. charm/schemes/pk_fre_ccv11.py +107 -0
  129. charm/schemes/pk_vrf.py +127 -0
  130. charm/schemes/pkenc/__init__.py +0 -0
  131. charm/schemes/pkenc/pkenc_cs98.py +108 -0
  132. charm/schemes/pkenc/pkenc_elgamal85.py +122 -0
  133. charm/schemes/pkenc/pkenc_gm82.py +98 -0
  134. charm/schemes/pkenc/pkenc_paillier99.py +118 -0
  135. charm/schemes/pkenc/pkenc_rabin.py +254 -0
  136. charm/schemes/pkenc/pkenc_rsa.py +186 -0
  137. charm/schemes/pksig/__init__.py +0 -0
  138. charm/schemes/pksig/pksig_CW13_z.py +135 -0
  139. charm/schemes/pksig/pksig_bls04.py +87 -0
  140. charm/schemes/pksig/pksig_boyen.py +156 -0
  141. charm/schemes/pksig/pksig_chch.py +97 -0
  142. charm/schemes/pksig/pksig_chp.py +70 -0
  143. charm/schemes/pksig/pksig_cl03.py +150 -0
  144. charm/schemes/pksig/pksig_cl04.py +87 -0
  145. charm/schemes/pksig/pksig_cllww12_z.py +142 -0
  146. charm/schemes/pksig/pksig_cyh.py +132 -0
  147. charm/schemes/pksig/pksig_dsa.py +76 -0
  148. charm/schemes/pksig/pksig_ecdsa.py +71 -0
  149. charm/schemes/pksig/pksig_hess.py +104 -0
  150. charm/schemes/pksig/pksig_hw.py +110 -0
  151. charm/schemes/pksig/pksig_lamport.py +63 -0
  152. charm/schemes/pksig/pksig_ps01.py +135 -0
  153. charm/schemes/pksig/pksig_ps02.py +124 -0
  154. charm/schemes/pksig/pksig_ps03.py +119 -0
  155. charm/schemes/pksig/pksig_rsa_hw09.py +206 -0
  156. charm/schemes/pksig/pksig_schnorr91.py +77 -0
  157. charm/schemes/pksig/pksig_waters.py +115 -0
  158. charm/schemes/pksig/pksig_waters05.py +121 -0
  159. charm/schemes/pksig/pksig_waters09.py +121 -0
  160. charm/schemes/pre_mg07.py +150 -0
  161. charm/schemes/prenc/pre_afgh06.py +126 -0
  162. charm/schemes/prenc/pre_bbs98.py +123 -0
  163. charm/schemes/prenc/pre_nal16.py +216 -0
  164. charm/schemes/protocol_a01.py +272 -0
  165. charm/schemes/protocol_ao00.py +215 -0
  166. charm/schemes/protocol_cns07.py +274 -0
  167. charm/schemes/protocol_schnorr91.py +125 -0
  168. charm/schemes/sigma1.py +64 -0
  169. charm/schemes/sigma2.py +129 -0
  170. charm/schemes/sigma3.py +126 -0
  171. charm/schemes/threshold/__init__.py +59 -0
  172. charm/schemes/threshold/dkls23_dkg.py +556 -0
  173. charm/schemes/threshold/dkls23_presign.py +1089 -0
  174. charm/schemes/threshold/dkls23_sign.py +761 -0
  175. charm/schemes/threshold/xrpl_wallet.py +967 -0
  176. charm/test/__init__.py +0 -0
  177. charm/test/adapters/__init__.py +0 -0
  178. charm/test/adapters/abenc_adapt_hybrid_test.py +29 -0
  179. charm/test/adapters/dabenc_adapt_hybrid_test.py +56 -0
  180. charm/test/adapters/ibenc_adapt_hybrid_test.py +36 -0
  181. charm/test/adapters/ibenc_adapt_identityhash_test.py +32 -0
  182. charm/test/adapters/kpabenc_adapt_hybrid_test.py +30 -0
  183. charm/test/benchmark/abenc_yllc15_bench.py +92 -0
  184. charm/test/benchmark/benchmark_test.py +148 -0
  185. charm/test/benchmark_threshold.py +260 -0
  186. charm/test/conftest.py +38 -0
  187. charm/test/fuzz/__init__.py +1 -0
  188. charm/test/fuzz/conftest.py +5 -0
  189. charm/test/fuzz/fuzz_policy_parser.py +76 -0
  190. charm/test/fuzz/fuzz_serialization.py +83 -0
  191. charm/test/schemes/__init__.py +0 -0
  192. charm/test/schemes/abenc/__init__.py +0 -0
  193. charm/test/schemes/abenc/abenc_bsw07_test.py +39 -0
  194. charm/test/schemes/abenc/abenc_dacmacs_yj14_test.py +16 -0
  195. charm/test/schemes/abenc/abenc_lsw08_test.py +33 -0
  196. charm/test/schemes/abenc/abenc_maabe_yj14_test.py +16 -0
  197. charm/test/schemes/abenc/abenc_tbpre_lww14_test.py +16 -0
  198. charm/test/schemes/abenc/abenc_waters09_test.py +38 -0
  199. charm/test/schemes/abenc/abenc_yllc15_test.py +74 -0
  200. charm/test/schemes/chamhash_adm05_test.py +31 -0
  201. charm/test/schemes/chamhash_rsa_hw09_test.py +29 -0
  202. charm/test/schemes/commit/__init__.py +0 -0
  203. charm/test/schemes/commit/commit_gs08_test.py +24 -0
  204. charm/test/schemes/commit/commit_pedersen92_test.py +26 -0
  205. charm/test/schemes/dabe_aw11_test.py +45 -0
  206. charm/test/schemes/encap_bchk05_test.py +21 -0
  207. charm/test/schemes/grpsig/__init__.py +0 -0
  208. charm/test/schemes/grpsig/groupsig_bgls04_test.py +35 -0
  209. charm/test/schemes/grpsig/groupsig_bgls04_var_test.py +39 -0
  210. charm/test/schemes/hibenc/__init__.py +0 -0
  211. charm/test/schemes/hibenc/hibenc_bb04_test.py +28 -0
  212. charm/test/schemes/ibenc/__init__.py +0 -0
  213. charm/test/schemes/ibenc/ibenc_bb03_test.py +26 -0
  214. charm/test/schemes/ibenc/ibenc_bf01_test.py +24 -0
  215. charm/test/schemes/ibenc/ibenc_ckrs09_test.py +25 -0
  216. charm/test/schemes/ibenc/ibenc_lsw08_test.py +31 -0
  217. charm/test/schemes/ibenc/ibenc_sw05_test.py +32 -0
  218. charm/test/schemes/ibenc/ibenc_waters05_test.py +31 -0
  219. charm/test/schemes/ibenc/ibenc_waters09_test.py +27 -0
  220. charm/test/schemes/pk_vrf_test.py +29 -0
  221. charm/test/schemes/pkenc/__init__.py +0 -0
  222. charm/test/schemes/pkenc_test.py +255 -0
  223. charm/test/schemes/pksig/__init__.py +0 -0
  224. charm/test/schemes/pksig_test.py +376 -0
  225. charm/test/schemes/rsa_alg_test.py +340 -0
  226. charm/test/schemes/threshold_test.py +1792 -0
  227. charm/test/serialize/__init__.py +0 -0
  228. charm/test/serialize/serialize_test.py +40 -0
  229. charm/test/toolbox/__init__.py +0 -0
  230. charm/test/toolbox/conversion_test.py +30 -0
  231. charm/test/toolbox/ecgroup_test.py +53 -0
  232. charm/test/toolbox/integer_arithmetic_test.py +441 -0
  233. charm/test/toolbox/paddingschemes_test.py +238 -0
  234. charm/test/toolbox/policy_parser_stress_test.py +969 -0
  235. charm/test/toolbox/secretshare_test.py +28 -0
  236. charm/test/toolbox/symcrypto_test.py +108 -0
  237. charm/test/toolbox/test_policy_expression.py +16 -0
  238. charm/test/vectors/__init__.py +1 -0
  239. charm/test/vectors/test_bls_vectors.py +289 -0
  240. charm/test/vectors/test_pedersen_vectors.py +315 -0
  241. charm/test/vectors/test_schnorr_vectors.py +368 -0
  242. charm/test/zkp_compiler/__init__.py +9 -0
  243. charm/test/zkp_compiler/benchmark_zkp.py +258 -0
  244. charm/test/zkp_compiler/test_and_proof.py +240 -0
  245. charm/test/zkp_compiler/test_batch_verify.py +248 -0
  246. charm/test/zkp_compiler/test_dleq_proof.py +264 -0
  247. charm/test/zkp_compiler/test_or_proof.py +231 -0
  248. charm/test/zkp_compiler/test_proof_serialization.py +121 -0
  249. charm/test/zkp_compiler/test_range_proof.py +241 -0
  250. charm/test/zkp_compiler/test_representation_proof.py +325 -0
  251. charm/test/zkp_compiler/test_schnorr_proof.py +221 -0
  252. charm/test/zkp_compiler/test_thread_safety.py +169 -0
  253. charm/test/zkp_compiler/test_zkp_parser.py +139 -0
  254. charm/toolbox/ABEnc.py +26 -0
  255. charm/toolbox/ABEncMultiAuth.py +66 -0
  256. charm/toolbox/ABEnumeric.py +800 -0
  257. charm/toolbox/Commit.py +24 -0
  258. charm/toolbox/DFA.py +89 -0
  259. charm/toolbox/FSA.py +1254 -0
  260. charm/toolbox/Hash.py +39 -0
  261. charm/toolbox/IBEnc.py +62 -0
  262. charm/toolbox/IBSig.py +64 -0
  263. charm/toolbox/PKEnc.py +66 -0
  264. charm/toolbox/PKSig.py +56 -0
  265. charm/toolbox/PREnc.py +32 -0
  266. charm/toolbox/ZKProof.py +289 -0
  267. charm/toolbox/__init__.py +0 -0
  268. charm/toolbox/bitstring.py +49 -0
  269. charm/toolbox/broadcast.py +220 -0
  270. charm/toolbox/conversion.py +100 -0
  271. charm/toolbox/eccurve.py +149 -0
  272. charm/toolbox/ecgroup.py +143 -0
  273. charm/toolbox/enum.py +60 -0
  274. charm/toolbox/hash_module.py +91 -0
  275. charm/toolbox/integergroup.py +323 -0
  276. charm/toolbox/iterate.py +22 -0
  277. charm/toolbox/matrixops.py +76 -0
  278. charm/toolbox/mpc_utils.py +296 -0
  279. charm/toolbox/msp.py +175 -0
  280. charm/toolbox/mta.py +985 -0
  281. charm/toolbox/node.py +120 -0
  282. charm/toolbox/ot/__init__.py +22 -0
  283. charm/toolbox/ot/base_ot.py +374 -0
  284. charm/toolbox/ot/dpf.py +642 -0
  285. charm/toolbox/ot/mpfss.py +228 -0
  286. charm/toolbox/ot/ot_extension.py +589 -0
  287. charm/toolbox/ot/silent_ot.py +378 -0
  288. charm/toolbox/paddingschemes.py +423 -0
  289. charm/toolbox/paddingschemes_test.py +238 -0
  290. charm/toolbox/pairingcurves.py +85 -0
  291. charm/toolbox/pairinggroup.py +186 -0
  292. charm/toolbox/policy_expression_spec.py +70 -0
  293. charm/toolbox/policytree.py +189 -0
  294. charm/toolbox/reCompiler.py +346 -0
  295. charm/toolbox/redundancyschemes.py +65 -0
  296. charm/toolbox/schemebase.py +188 -0
  297. charm/toolbox/secretshare.py +104 -0
  298. charm/toolbox/secretutil.py +174 -0
  299. charm/toolbox/securerandom.py +73 -0
  300. charm/toolbox/sigmaprotocol.py +46 -0
  301. charm/toolbox/specialprimes.py +45 -0
  302. charm/toolbox/symcrypto.py +279 -0
  303. charm/toolbox/threshold_sharing.py +553 -0
  304. charm/toolbox/xmlserialize.py +94 -0
  305. charm/toolbox/zknode.py +105 -0
  306. charm/zkp_compiler/__init__.py +89 -0
  307. charm/zkp_compiler/and_proof.py +460 -0
  308. charm/zkp_compiler/batch_verify.py +324 -0
  309. charm/zkp_compiler/dleq_proof.py +423 -0
  310. charm/zkp_compiler/or_proof.py +305 -0
  311. charm/zkp_compiler/range_proof.py +417 -0
  312. charm/zkp_compiler/representation_proof.py +466 -0
  313. charm/zkp_compiler/schnorr_proof.py +273 -0
  314. charm/zkp_compiler/thread_safe.py +150 -0
  315. charm/zkp_compiler/zk_demo.py +489 -0
  316. charm/zkp_compiler/zkp_factory.py +330 -0
  317. charm/zkp_compiler/zkp_generator.py +370 -0
  318. charm/zkp_compiler/zkparser.py +269 -0
  319. charm_crypto_framework-0.61.1.dist-info/METADATA +337 -0
  320. charm_crypto_framework-0.61.1.dist-info/RECORD +323 -0
  321. charm_crypto_framework-0.61.1.dist-info/WHEEL +5 -0
  322. charm_crypto_framework-0.61.1.dist-info/licenses/LICENSE.txt +165 -0
  323. charm_crypto_framework-0.61.1.dist-info/top_level.txt +1 -0
charm/test/__init__.py ADDED
File without changes
File without changes
@@ -0,0 +1,29 @@
1
+ import unittest
2
+
3
+ from charm.adapters.abenc_adapt_hybrid import HybridABEnc as HybridABEnc
4
+ from charm.schemes.abenc.abenc_bsw07 import CPabe_BSW07
5
+ from charm.toolbox.pairinggroup import PairingGroup
6
+
7
+ debug = False
8
+
9
+
10
+ class HybridABEncTest(unittest.TestCase):
11
+ def testHybridABEnc(self):
12
+ groupObj = PairingGroup('SS512')
13
+ cpabe = CPabe_BSW07(groupObj)
14
+ hyb_abe = HybridABEnc(cpabe, groupObj)
15
+ access_policy = '((four or three) and (two or one))'
16
+ message = b"hello world this is an important message."
17
+ (pk, mk) = hyb_abe.setup()
18
+ if debug: print("pk => ", pk)
19
+ if debug: print("mk => ", mk)
20
+ sk = hyb_abe.keygen(pk, mk, ['ONE', 'TWO', 'THREE'])
21
+ if debug: print("sk => ", sk)
22
+ ct = hyb_abe.encrypt(pk, message, access_policy)
23
+ mdec = hyb_abe.decrypt(pk, sk, ct)
24
+ assert mdec == message, "Failed Decryption!!!"
25
+ if debug: print("Successful Decryption!!!")
26
+
27
+
28
+ if __name__ == "__main__":
29
+ unittest.main()
@@ -0,0 +1,56 @@
1
+ import unittest
2
+
3
+ from charm.adapters.dabenc_adapt_hybrid import HybridABEncMA
4
+ from charm.schemes.abenc.dabe_aw11 import Dabe
5
+ from charm.toolbox.pairinggroup import PairingGroup, GT
6
+
7
+ debug = False
8
+
9
+
10
+ class HybridABEncMATest(unittest.TestCase):
11
+ def testHybridABEncMA(self):
12
+ groupObj = PairingGroup('SS512')
13
+ dabe = Dabe(groupObj)
14
+
15
+ hyb_abema = HybridABEncMA(dabe, groupObj)
16
+
17
+ # Setup global parameters for all new authorities
18
+ gp = hyb_abema.setup()
19
+
20
+ # Instantiate a few authorities
21
+ # Attribute names must be globally unique. HybridABEncMA
22
+ # Two authorities may not issue keys for the same attribute.
23
+ # Otherwise, the decryption algorithm will not know which private key to use
24
+ jhu_attributes = ['jhu.professor', 'jhu.staff', 'jhu.student']
25
+ jhmi_attributes = ['jhmi.doctor', 'jhmi.nurse', 'jhmi.staff', 'jhmi.researcher']
26
+ (jhuSK, jhuPK) = hyb_abema.authsetup(gp, jhu_attributes)
27
+ (jhmiSK, jhmiPK) = hyb_abema.authsetup(gp, jhmi_attributes)
28
+ allAuthPK = {};
29
+ allAuthPK.update(jhuPK);
30
+ allAuthPK.update(jhmiPK)
31
+
32
+ # Setup a user with a few keys
33
+ bobs_gid = "20110615 bob@gmail.com cryptokey"
34
+ K = {}
35
+ hyb_abema.keygen(gp, jhuSK, 'jhu.professor', bobs_gid, K)
36
+ hyb_abema.keygen(gp, jhmiSK, 'jhmi.researcher', bobs_gid, K)
37
+
38
+ msg = b'Hello World, I am a sensitive record!'
39
+ size = len(msg)
40
+ policy_str = "(jhmi.doctor or (jhmi.researcher and jhu.professor))"
41
+ ct = hyb_abema.encrypt(gp, allAuthPK, msg, policy_str)
42
+
43
+ if debug:
44
+ print("Ciphertext")
45
+ print("c1 =>", ct['c1'])
46
+ print("c2 =>", ct['c2'])
47
+
48
+ decrypted_msg = hyb_abema.decrypt(gp, K, ct)
49
+ if debug: print("Result =>", decrypted_msg)
50
+ assert decrypted_msg == msg, "Failed Decryption!!!"
51
+ if debug: print("Successful Decryption!!!")
52
+ del groupObj
53
+
54
+
55
+ if __name__ == "__main__":
56
+ unittest.main()
@@ -0,0 +1,36 @@
1
+ import unittest
2
+
3
+ from charm.adapters.ibenc_adapt_hybrid import HybridIBEnc
4
+ from charm.adapters.ibenc_adapt_identityhash import HashIDAdapter
5
+ from charm.schemes.ibenc.ibenc_bb03 import IBE_BB04
6
+ from charm.toolbox.pairinggroup import PairingGroup
7
+
8
+ debug = False
9
+
10
+
11
+ class HybridIBEncTest(unittest.TestCase):
12
+ def testHybridIBEnc(self):
13
+ groupObj = PairingGroup('SS512')
14
+ ibe = IBE_BB04(groupObj)
15
+
16
+ hashID = HashIDAdapter(ibe, groupObj)
17
+
18
+ hyb_ibe = HybridIBEnc(hashID, groupObj)
19
+
20
+ (pk, mk) = hyb_ibe.setup()
21
+
22
+ kID = 'waldoayo@gmail.com'
23
+ sk = hyb_ibe.extract(mk, kID)
24
+
25
+ msg = b"This is a test message."
26
+
27
+ ct = hyb_ibe.encrypt(pk, kID, msg)
28
+ if debug:
29
+ print("Ciphertext")
30
+ print("c1 =>", ct['c1'])
31
+ print("c2 =>", ct['c2'])
32
+
33
+ decrypted_msg = hyb_ibe.decrypt(pk, sk, ct)
34
+ if debug: print("Result =>", decrypted_msg)
35
+ assert decrypted_msg == msg
36
+ del groupObj
@@ -0,0 +1,32 @@
1
+ import unittest
2
+
3
+ from charm.adapters.ibenc_adapt_identityhash import HashIDAdapter
4
+ from charm.schemes.ibenc.ibenc_bb03 import IBE_BB04
5
+ from charm.toolbox.pairinggroup import PairingGroup, GT
6
+
7
+ debug = False
8
+
9
+
10
+ class HashIDAdapterTest(unittest.TestCase):
11
+ def testHashIDAdapter(self):
12
+ group = PairingGroup('SS512')
13
+
14
+ ibe = IBE_BB04(group)
15
+
16
+ hashID = HashIDAdapter(ibe, group)
17
+
18
+ (pk, mk) = hashID.setup()
19
+
20
+ kID = 'waldoayo@email.com'
21
+ sk = hashID.extract(mk, kID)
22
+ if debug: print("Keygen for %s" % kID)
23
+ if debug: print(sk)
24
+
25
+ m = group.random(GT)
26
+ ct = hashID.encrypt(pk, kID, m)
27
+
28
+ orig_m = hashID.decrypt(pk, sk, ct)
29
+
30
+ assert m == orig_m
31
+ if debug: print("Successful Decryption!!!")
32
+ if debug: print("Result =>", orig_m)
@@ -0,0 +1,30 @@
1
+ import unittest
2
+
3
+ from charm.adapters.kpabenc_adapt_hybrid import HybridABEnc as HybridKPABEnc
4
+ from charm.schemes.abenc.abenc_lsw08 import KPabe
5
+ from charm.toolbox.pairinggroup import PairingGroup
6
+
7
+ debug = False
8
+
9
+
10
+ class HybridKPABEncTest(unittest.TestCase):
11
+ def testHybridKPABEnc(self):
12
+ groupObj = PairingGroup('SS512')
13
+ kpabe = KPabe(groupObj)
14
+ hyb_abe = HybridKPABEnc(kpabe, groupObj)
15
+ access_key = '((ONE or TWO) and THREE)'
16
+ access_policy = ['ONE', 'TWO', 'THREE']
17
+ message = b"hello world this is an important message."
18
+ (pk, mk) = hyb_abe.setup()
19
+ if debug: print("pk => ", pk)
20
+ if debug: print("mk => ", mk)
21
+ sk = hyb_abe.keygen(pk, mk, access_key)
22
+ if debug: print("sk => ", sk)
23
+ ct = hyb_abe.encrypt(pk, message, access_policy)
24
+ mdec = hyb_abe.decrypt(ct, sk)
25
+ assert mdec == message, "Failed Decryption!!!"
26
+ if debug: print("Successful Decryption!!!")
27
+
28
+
29
+ if __name__ == "__main__":
30
+ unittest.main()
@@ -0,0 +1,92 @@
1
+ import sys
2
+
3
+ from charm.core.engine.util import objectToBytes
4
+ from charm.schemes.abenc.abenc_yllc15 import YLLC15
5
+ from charm.toolbox.pairinggroup import PairingGroup, GT
6
+ from charm.toolbox.policy_expression_spec import policy_expressions
7
+ from charm.toolbox.secretutil import SecretUtil
8
+
9
+
10
+ def run_keygen_encrypt_proxy_decrypt_decrypt_round_trip(policy_str):
11
+ group = PairingGroup('SS512')
12
+ abe = YLLC15(group)
13
+ (params, msk) = abe.setup()
14
+ pkcs, skcs = abe.ukgen(params)
15
+ pku, sku = abe.ukgen(params)
16
+
17
+ attrs = extract_attributes(group, policy_str)
18
+ random_key_elem = abe.group.random(GT)
19
+
20
+ start_bench(group)
21
+ proxy_key_user = abe.proxy_keygen(params, msk, pkcs, pku, attrs)
22
+ n = len(attrs)
23
+ proxy_keygen_exec_time = end_bench(group, "proxy_keygen", n)
24
+ proxy_key_size = len(objectToBytes(proxy_key_user, group))
25
+
26
+ start_bench(group)
27
+ ciphertext = abe.encrypt(params, random_key_elem, policy_str)
28
+ encrypt_exec_time = end_bench(group, "encrypt", n)
29
+ ciphertext_size = len(objectToBytes(ciphertext, group))
30
+
31
+ start_bench(group)
32
+ intermediate_value = abe.proxy_decrypt(skcs, proxy_key_user, ciphertext)
33
+ proxy_decrypt_exec_time = end_bench(group, "proxy_decrypt", n)
34
+
35
+ start_bench(group)
36
+ recovered_key_elem = abe.decrypt(params, sku, intermediate_value)
37
+ decrypt_exec_time = end_bench(group, "decrypt", n)
38
+
39
+ assert random_key_elem == recovered_key_elem
40
+
41
+ return {'policy_str': policy_str,
42
+ 'attrs': attrs,
43
+ 'attrs_vs_proxy_key_size': "# attributes(n) vs proxy key size(B),%d,%d" % (n, proxy_key_size),
44
+ 'policy_leave_vs_ciphertext_size': "# Policy leaf nodes (n) vs Ciphertext size (B),%d,%d" %
45
+ (n, ciphertext_size),
46
+ 'proxy_keygen_exec_time': proxy_keygen_exec_time,
47
+ 'encrypt_exec_time': encrypt_exec_time,
48
+ 'proxy_decrypt_exec_time': proxy_decrypt_exec_time,
49
+ 'decrypt_exec_time': decrypt_exec_time
50
+ }
51
+
52
+
53
+ def extract_attributes(group, policy_str):
54
+ util = SecretUtil(group)
55
+ policy = util.createPolicy(policy_str)
56
+ return [util.strip_index(policy_attr) for policy_attr in util.getAttributeList(policy)]
57
+
58
+
59
+ def end_bench(group, operation, n):
60
+ group.EndBenchmark()
61
+ benchmarks = group.GetGeneralBenchmarks()
62
+ cpu_time = benchmarks['CpuTime']
63
+ real_time = benchmarks['RealTime']
64
+ return "%s,%d,%f,%f" % (operation, n, cpu_time, real_time)
65
+
66
+
67
+ def start_bench(group):
68
+ group.InitBenchmark()
69
+ group.StartBenchmark(["RealTime", "CpuTime"])
70
+
71
+
72
+ if __name__ == '__main__':
73
+ """
74
+ Performance test for YLLC15
75
+
76
+ :arg n: the input size n. Number of attributes or leaf nodes in policy tree.
77
+
78
+ Example invocation:
79
+ `$ python charm/test/benchmark/abenc_yllc15_bench.py 5`
80
+
81
+ The technique:
82
+ + uses an input generator to model the expected input data.
83
+ + successively calls the algorithm under test with sample input data size
84
+ growing up n.
85
+ + measures and returns performance stats.
86
+ + prints the results in a "grep-able" format.
87
+ """
88
+ for n in range(1, int(sys.argv[1])):
89
+ policy_str = policy_expressions(min_leaves=n, max_leaves=n).example()
90
+ result = run_keygen_encrypt_proxy_decrypt_decrypt_round_trip(policy_str)
91
+ print("function,n,CpuTime,RealTime")
92
+ [print(v) for v in result.values()]
@@ -0,0 +1,148 @@
1
+ from charm.toolbox.pairinggroup import PairingGroup,ZR,G1,G2,GT,pair
2
+ from charm.toolbox.ecgroup import ECGroup,ZR,G
3
+ from charm.toolbox.eccurve import prime192v2
4
+ from charm.core.math.integer import *
5
+
6
+ import unittest, sys
7
+
8
+ debug = False
9
+
10
+ def isSaneBenchmark(dct):
11
+ isSane=True
12
+ for val in dct.values():
13
+ if(type(val)==list):
14
+ for v in val:
15
+ isSane&=v>=0
16
+ else:
17
+ isSane&=val>=0
18
+ return isSane
19
+
20
+ @unittest.skipIf(sys.platform == 'darwin', "expected issues on Mac OS X.")
21
+ class BenchmarkTest1(unittest.TestCase):
22
+ def testPairing(self):
23
+ trials = 10
24
+ trials2 = trials * 3
25
+ group = PairingGroup("SS512")
26
+ g = group.random(G1)
27
+ h = group.random(G1)
28
+ i = group.random(G2)
29
+
30
+ self.assertTrue(group.InitBenchmark())
31
+ group.StartBenchmark(["RealTime", "Exp", "Pair"])
32
+ for a in range(trials):
33
+ j = g * h
34
+ k = i ** group.random(ZR)
35
+ t = (j ** group.random(ZR)) / h
36
+ n = pair(h, i)
37
+ group.EndBenchmark()
38
+
39
+ msmtDict = group.GetGeneralBenchmarks()
40
+ self.assertTrue(isSaneBenchmark(msmtDict))
41
+
42
+ self.assertTrue(group.InitBenchmark())
43
+
44
+ group.StartBenchmark(["CpuTime", "Mul", "Pair"])
45
+ for a in range(trials2):
46
+ j = g * h
47
+ k = i ** group.random(ZR)
48
+ n = pair(h, i)
49
+ group.EndBenchmark()
50
+
51
+ msmtDict = group.GetGeneralBenchmarks()
52
+ del group
53
+ self.assertTrue(isSaneBenchmark(msmtDict))
54
+
55
+ @unittest.skipIf(sys.platform == 'darwin', "expected issues on Mac OS X.")
56
+ class BenchmarkTest2(unittest.TestCase):
57
+ def testECGroup(self):
58
+ trials = 10
59
+ group = ECGroup(prime192v2)
60
+ g = group.random(G)
61
+ h = group.random(G)
62
+ i = group.random(G)
63
+
64
+ self.assertTrue(group.InitBenchmark())
65
+ group.StartBenchmark(["RealTime", "Mul", "Div", "Exp", "Granular"])
66
+ for a in range(trials):
67
+ j = g * h
68
+ k = h ** group.random(ZR)
69
+ t = (j ** group.random(ZR)) / k
70
+ group.EndBenchmark()
71
+
72
+ msmtDict = group.GetGeneralBenchmarks()
73
+ self.assertTrue(isSaneBenchmark(msmtDict))
74
+
75
+ granDict = group.GetGranularBenchmarks()
76
+ self.assertTrue(isSaneBenchmark(granDict))
77
+
78
+ self.assertTrue(group.InitBenchmark())
79
+ group.StartBenchmark(["RealTime", "Mul", "Div", "Exp", "Granular"])
80
+ for a in range(trials*2):
81
+ j = g * h
82
+ k = h ** group.random(ZR)
83
+ t = (j ** group.random(ZR)) / k
84
+ group.EndBenchmark()
85
+
86
+ msmtDict = group.GetGeneralBenchmarks()
87
+ granDict = group.GetGranularBenchmarks()
88
+ del group
89
+ self.assertTrue(isSaneBenchmark(msmtDict))
90
+ self.assertTrue(isSaneBenchmark(granDict))
91
+
92
+ @unittest.skipIf(sys.platform == 'darwin', "expected issues on Mac OS X.")
93
+ class BenchmarkTest3(unittest.TestCase):
94
+ def testInterleave(self):
95
+ trials = 10
96
+ trials2 = trials * 3
97
+ group1 = PairingGroup("MNT224")
98
+ group2 = PairingGroup("MNT224")
99
+
100
+ g = group1.random(G1)
101
+ h = group1.random(G1)
102
+ i = group1.random(G2)
103
+
104
+ self.assertTrue(group1.InitBenchmark())
105
+ self.assertTrue(group2.InitBenchmark())
106
+ group1.StartBenchmark(["RealTime", "Exp", "Pair", "Div", "Mul"])
107
+ for a in range(trials):
108
+ j = g * h
109
+ k = i ** group1.random(ZR)
110
+ t = (j ** group1.random(ZR)) / h
111
+ n = pair(h, i)
112
+ group1.EndBenchmark()
113
+ msmtDict = group1.GetGeneralBenchmarks()
114
+ del group1, group2
115
+ self.assertTrue(isSaneBenchmark(msmtDict))
116
+
117
+ @unittest.skipIf(sys.platform == 'darwin', "expected issues on Mac OS X.")
118
+ class BenchmarkTest4(unittest.TestCase):
119
+ def testInteger(self):
120
+ count = 5
121
+ time_in_ms = 1000
122
+
123
+ a = integer(10)
124
+
125
+ self.assertTrue(InitBenchmark())
126
+ StartBenchmark(["RealTime", "Exp", "Mul"])
127
+ for k in range(count):
128
+ r = randomPrime(256)
129
+ s = r * (r ** a)
130
+ j = r * (r ** a)
131
+ EndBenchmark()
132
+ msmtDict = GetGeneralBenchmarks()
133
+ self.assertTrue(isSaneBenchmark(msmtDict))
134
+
135
+ self.assertTrue(InitBenchmark())
136
+ StartBenchmark(["RealTime", "Exp", "Mul", "Add", "Sub"])
137
+ for k in range(count):
138
+ r = randomPrime(256)
139
+ s = r * (r ** a)
140
+ j = r * (r ** a)
141
+ u = s + j - j
142
+ EndBenchmark()
143
+ msmtDict = GetGeneralBenchmarks()
144
+ self.assertTrue(isSaneBenchmark(msmtDict))
145
+
146
+
147
+ if __name__ == "__main__":
148
+ unittest.main()
@@ -0,0 +1,260 @@
1
+ """
2
+ Benchmark suite for DKLS23 Threshold ECDSA implementation.
3
+
4
+ Run with: python charm/test/benchmark_threshold.py
5
+
6
+ This module benchmarks:
7
+ - DKG (Distributed Key Generation)
8
+ - Presigning (Round 1 and Round 2 only - full protocol WIP)
9
+ - Signing (simulated with pre-computed values)
10
+ - Full threshold signing flow (DKG only - other phases WIP)
11
+
12
+ Note: Some benchmarks are limited as the full protocol implementation
13
+ is still in development.
14
+ """
15
+
16
+ import time
17
+ import tracemalloc
18
+ from charm.toolbox.ecgroup import ECGroup, ZR, G
19
+ from charm.toolbox.eccurve import secp256k1
20
+
21
+
22
+ def run_dkg(group, t, n, g):
23
+ """
24
+ Run DKG protocol and return key_shares, public_key.
25
+
26
+ This function handles the tuple return from keygen_round3.
27
+ """
28
+ from charm.schemes.threshold.dkls23_dkg import DKLS23_DKG
29
+
30
+ dkg = DKLS23_DKG(group, threshold=t, num_parties=n)
31
+
32
+ # Round 1
33
+ party_states = [dkg.keygen_round1(i + 1, g) for i in range(n)]
34
+ round1_msgs = [s[0] for s in party_states]
35
+ priv_states = [s[1] for s in party_states]
36
+
37
+ # Round 2
38
+ round2_results = [
39
+ dkg.keygen_round2(i + 1, priv_states[i], round1_msgs) for i in range(n)
40
+ ]
41
+ shares_for_others = [r[0] for r in round2_results]
42
+ states_r2 = [r[1] for r in round2_results]
43
+
44
+ # Round 3 - keygen_round3 returns (KeyShare, complaint) tuple
45
+ key_shares = {}
46
+ for party_id in range(1, n + 1):
47
+ received = {
48
+ sender + 1: shares_for_others[sender][party_id] for sender in range(n)
49
+ }
50
+ ks, complaint = dkg.keygen_round3(
51
+ party_id, states_r2[party_id - 1], received, round1_msgs
52
+ )
53
+ if complaint is not None:
54
+ raise RuntimeError(f"DKG failed: {complaint}")
55
+ key_shares[party_id] = ks
56
+
57
+ public_key = key_shares[1].X
58
+ return key_shares, public_key
59
+
60
+
61
+ def benchmark_dkg(t, n, iterations=10):
62
+ """
63
+ Benchmark Distributed Key Generation.
64
+
65
+ Parameters
66
+ ----------
67
+ t : int
68
+ Threshold value
69
+ n : int
70
+ Number of parties
71
+ iterations : int
72
+ Number of iterations to average over
73
+
74
+ Returns
75
+ -------
76
+ float
77
+ Average time in milliseconds
78
+ """
79
+ group = ECGroup(secp256k1)
80
+ g = group.random(G)
81
+
82
+ times = []
83
+ for _ in range(iterations):
84
+ start = time.perf_counter()
85
+ key_shares, public_key = run_dkg(group, t, n, g)
86
+ end = time.perf_counter()
87
+ times.append((end - start) * 1000) # Convert to ms
88
+
89
+ return sum(times) / len(times)
90
+
91
+
92
+ def benchmark_presign(t, n, iterations=10):
93
+ """
94
+ Benchmark presigning rounds 1 and 2.
95
+
96
+ Note: Round 3 is not included as the MtA integration is still in development.
97
+
98
+ Parameters
99
+ ----------
100
+ t : int
101
+ Threshold value
102
+ n : int
103
+ Number of parties
104
+ iterations : int
105
+ Number of iterations to average over
106
+
107
+ Returns
108
+ -------
109
+ float
110
+ Average time in milliseconds for rounds 1-2
111
+ """
112
+ from charm.schemes.threshold.dkls23_presign import DKLS23_Presign
113
+
114
+ group = ECGroup(secp256k1)
115
+ g = group.random(G)
116
+
117
+ # Setup: generate key shares first
118
+ key_shares, _ = run_dkg(group, t, n, g)
119
+ participants = list(range(1, t + 1))
120
+
121
+ times = []
122
+ for _ in range(iterations):
123
+ presign = DKLS23_Presign(group)
124
+
125
+ start = time.perf_counter()
126
+
127
+ # Round 1
128
+ r1 = {}
129
+ st = {}
130
+ for pid in participants:
131
+ msg, s = presign.presign_round1(pid, key_shares[pid].x_i, participants, g)
132
+ r1[pid], st[pid] = msg, s
133
+
134
+ # Round 2
135
+ for pid in participants:
136
+ b, m, s = presign.presign_round2(pid, st[pid], r1)
137
+
138
+ end = time.perf_counter()
139
+ times.append((end - start) * 1000)
140
+
141
+ return sum(times) / len(times)
142
+
143
+
144
+ def benchmark_sign(t, n, iterations=10):
145
+ """
146
+ Benchmark signing operation (simulated).
147
+
148
+ This benchmarks the signing computation with pre-computed values,
149
+ as the full presigning flow is still in development.
150
+
151
+ Parameters
152
+ ----------
153
+ t : int
154
+ Threshold value
155
+ n : int
156
+ Number of parties
157
+ iterations : int
158
+ Number of iterations to average over
159
+
160
+ Returns
161
+ -------
162
+ float
163
+ Average time in milliseconds
164
+ """
165
+ from charm.schemes.threshold.dkls23_sign import DKLS23_Sign
166
+
167
+ group = ECGroup(secp256k1)
168
+ g = group.random(G)
169
+ signer = DKLS23_Sign(group)
170
+
171
+ # Simulate signature computation timing
172
+ # (actual full flow requires working presigning)
173
+ message = b"Benchmark signing message"
174
+
175
+ times = []
176
+ for _ in range(iterations):
177
+ # Generate simulated values
178
+ k = group.random(ZR)
179
+ x = group.random(ZR)
180
+ R = g**k
181
+ r = group.zr(R)
182
+
183
+ start = time.perf_counter()
184
+ # Simulate signature computation
185
+ e = signer._hash_message(message)
186
+ s = (e + r * x) * (k ** (-1))
187
+ end = time.perf_counter()
188
+ times.append((end - start) * 1000)
189
+
190
+ return sum(times) / len(times)
191
+
192
+
193
+ def benchmark_full_flow(t, n, num_signatures=5):
194
+ """
195
+ Benchmark complete DKG flow with memory usage tracking.
196
+
197
+ Note: Only DKG is fully benchmarked; presigning/signing are placeholders
198
+ until the full protocol is integrated.
199
+
200
+ Parameters
201
+ ----------
202
+ t : int
203
+ Threshold value
204
+ n : int
205
+ Number of parties
206
+ num_signatures : int
207
+ Number of DKG runs to measure
208
+
209
+ Returns
210
+ -------
211
+ tuple
212
+ (total_time_ms, peak_memory_kb, avg_per_dkg_ms)
213
+ """
214
+ group = ECGroup(secp256k1)
215
+ g = group.random(G)
216
+
217
+ tracemalloc.start()
218
+ start = time.perf_counter()
219
+
220
+ # Run DKG multiple times to measure memory and performance
221
+ for i in range(num_signatures):
222
+ key_shares, public_key = run_dkg(group, t, n, g)
223
+
224
+ end = time.perf_counter()
225
+ current, peak = tracemalloc.get_traced_memory()
226
+ tracemalloc.stop()
227
+
228
+ total_ms = (end - start) * 1000
229
+ peak_kb = peak / 1024
230
+ avg_per_run = total_ms / num_signatures
231
+
232
+ return total_ms, peak_kb, avg_per_run
233
+
234
+
235
+ def run_benchmarks(t=2, n=3):
236
+ """Run all benchmarks and print formatted results."""
237
+ print(f"\nDKLS23 Threshold ECDSA Benchmarks ({t}-of-{n})")
238
+ print("=" * 50)
239
+
240
+ # Run individual benchmarks
241
+ dkg_time = benchmark_dkg(t, n, iterations=10)
242
+ print(f"DKG: {dkg_time:6.1f} ms (avg over 10 runs)")
243
+
244
+ presign_time = benchmark_presign(t, n, iterations=10)
245
+ print(f"Presign: {presign_time:6.1f} ms (avg over 10 runs, rounds 1-2)")
246
+
247
+ sign_time = benchmark_sign(t, n, iterations=10)
248
+ print(f"Sign: {sign_time:6.1f} ms (avg over 10 runs, simulated)")
249
+
250
+ # Full flow benchmark
251
+ total_time, peak_mem, avg_per_run = benchmark_full_flow(t, n, num_signatures=5)
252
+ print(f"Full flow: {total_time:6.1f} ms total (5 DKG runs)")
253
+ print(f"Peak memory: {peak_mem:6.1f} KB")
254
+ print(f"Avg per DKG: {avg_per_run:6.1f} ms")
255
+ print("=" * 50)
256
+
257
+
258
+ if __name__ == "__main__":
259
+ run_benchmarks(t=2, n=3)
260
+