oxilean_std/cryptography/functions.rs
1//! Auto-generated module
2//!
3//! ๐ค Generated with [SplitRS](https://github.com/cool-japan/splitrs)
4#![allow(clippy::items_after_test_module)]
5
6use oxilean_kernel::{BinderInfo, Declaration, Environment, Expr, Level, Name};
7
8use super::types::{
9 DiffieHellmanSim, HashChain, ModularArithmetic, RsaKeyGen, ShamirSecretShare, ToyDiffieHellman,
10 ToyRsa,
11};
12
13pub fn app(f: Expr, a: Expr) -> Expr {
14 Expr::App(Box::new(f), Box::new(a))
15}
16pub fn app2(f: Expr, a: Expr, b: Expr) -> Expr {
17 app(app(f, a), b)
18}
19pub fn app3(f: Expr, a: Expr, b: Expr, c: Expr) -> Expr {
20 app(app2(f, a, b), c)
21}
22pub fn cst(s: &str) -> Expr {
23 Expr::Const(Name::str(s), vec![])
24}
25pub fn prop() -> Expr {
26 Expr::Sort(Level::zero())
27}
28pub fn type0() -> Expr {
29 Expr::Sort(Level::succ(Level::zero()))
30}
31pub fn pi(bi: BinderInfo, name: &str, dom: Expr, body: Expr) -> Expr {
32 Expr::Pi(bi, Name::str(name), Box::new(dom), Box::new(body))
33}
34pub fn arrow(a: Expr, b: Expr) -> Expr {
35 pi(BinderInfo::Default, "_", a, b)
36}
37pub fn bvar(n: u32) -> Expr {
38 Expr::BVar(n)
39}
40pub fn nat_ty() -> Expr {
41 cst("Nat")
42}
43pub fn bool_ty() -> Expr {
44 cst("Bool")
45}
46/// `List Nat` โ used to represent byte arrays / messages / hashes
47pub fn bytes_ty() -> Expr {
48 app(cst("List"), nat_ty())
49}
50/// `HashFunction : (List Nat) โ (List Nat)` โ a hash function mapping messages to digests.
51pub fn hash_function_ty() -> Expr {
52 arrow(bytes_ty(), bytes_ty())
53}
54/// `SymmetricKey : List Nat` โ a symmetric key (byte sequence).
55pub fn symmetric_key_ty() -> Expr {
56 bytes_ty()
57}
58/// `PublicKey : Type` โ an abstract public key type.
59pub fn public_key_ty() -> Expr {
60 type0()
61}
62/// `PrivateKey : Type` โ an abstract private key type.
63pub fn private_key_ty() -> Expr {
64 type0()
65}
66/// `Signature : List Nat` โ a digital signature (byte sequence).
67pub fn signature_ty() -> Expr {
68 bytes_ty()
69}
70/// `Ciphertext : List Nat` โ an encrypted message (byte sequence).
71pub fn ciphertext_ty() -> Expr {
72 bytes_ty()
73}
74/// `Group : Type` โ a cyclic group used in discrete-logarithm-based cryptography.
75pub fn group_ty() -> Expr {
76 type0()
77}
78/// `RsaParams : Type` โ an RSA parameter triple (n, e, d).
79pub fn rsa_params_ty() -> Expr {
80 type0()
81}
82/// `OneWayFunction : (List Nat) โ (List Nat)`
83///
84/// A function that is computationally hard to invert (pre-image resistance).
85/// OWFs are the foundational assumption underlying most symmetric cryptography.
86pub fn one_way_function_ty() -> Expr {
87 arrow(bytes_ty(), bytes_ty())
88}
89/// `CollisionResistant : HashFunction โ Prop`
90///
91/// A hash function H is collision-resistant if it is computationally infeasible
92/// to find distinct messages x โ y such that H(x) = H(y).
93pub fn collision_resistant_ty() -> Expr {
94 arrow(hash_function_ty(), prop())
95}
96/// `IndCpa : Prop`
97///
98/// IND-CPA (indistinguishability under chosen-plaintext attack) security.
99/// A public-key encryption scheme is IND-CPA secure if no polynomial-time
100/// adversary can distinguish encryptions of two chosen plaintexts with
101/// advantage non-negligibly better than 1/2.
102pub fn ind_cpa_ty() -> Expr {
103 prop()
104}
105/// `IndCca : Prop`
106///
107/// IND-CCA (indistinguishability under chosen-ciphertext attack) security.
108/// Stronger than IND-CPA: the adversary also has access to a decryption oracle
109/// (but cannot query the challenge ciphertext itself).
110pub fn ind_cca_ty() -> Expr {
111 prop()
112}
113/// `EufCma : Prop`
114///
115/// EUF-CMA (existential unforgeability under chosen-message attack) security.
116/// A signature scheme is EUF-CMA secure if no polynomial-time adversary can
117/// produce a valid signature on a new message after seeing signatures on
118/// polynomially many chosen messages.
119pub fn euf_cma_ty() -> Expr {
120 prop()
121}
122/// `DiscreteLogHard : Prop`
123///
124/// The discrete logarithm problem is computationally hard in the group G:
125/// given g and g^x, it is infeasible to recover x in polynomial time.
126pub fn discrete_log_hard_ty() -> Expr {
127 prop()
128}
129/// `RsaHard : Prop`
130///
131/// The RSA hardness assumption: given (n, e, c = m^e mod n), it is
132/// computationally infeasible to recover m without knowing the factorization
133/// of n (or equivalently, the private exponent d).
134pub fn rsa_hard_ty() -> Expr {
135 prop()
136}
137/// `RsaCorrectness : Prop`
138///
139/// For properly chosen RSA parameters (n = p*q, e*d โก 1 mod ฮป(n)),
140/// decryption is the inverse of encryption: (m^e)^d โก m (mod n).
141pub fn rsa_correctness_ty() -> Expr {
142 prop()
143}
144/// `DhCorrectness : Prop`
145///
146/// Diffie-Hellman correctness: in a cyclic group G with generator g,
147/// (g^a)^b = (g^b)^a, so both parties derive the same shared secret.
148pub fn dh_correctness_ty() -> Expr {
149 prop()
150}
151/// `BirthdayBound : Prop`
152///
153/// Birthday paradox bound for hash collision probability:
154/// after q queries to a random oracle with n-bit output, the collision
155/// probability is approximately q*(q-1)/2^(n+1) โ qยฒ/2^n.
156pub fn birthday_bound_ty() -> Expr {
157 prop()
158}
159/// `TrapdoorFunction : Type`
160///
161/// A trapdoor one-way function: a function f that is easy to compute but
162/// computationally hard to invert without the trapdoor information t.
163/// Given t, inversion becomes efficient: f^{-1}(t, y) = x such that f(x) = y.
164/// RSA and discrete exponentiation are canonical trapdoor functions.
165pub fn trapdoor_function_ty() -> Expr {
166 type0()
167}
168/// `TrapdoorInvertible : TrapdoorFunction โ Prop`
169///
170/// Correctness of a trapdoor function: given the trapdoor, inversion succeeds
171/// with probability 1. Without the trapdoor, inversion succeeds with only
172/// negligible probability in the security parameter.
173pub fn trapdoor_invertible_ty() -> Expr {
174 arrow(trapdoor_function_ty(), prop())
175}
176/// `GoldreichLevinHardCoreBit : OneWayFunction โ Prop`
177///
178/// Goldreich-Levin theorem (1989): if f is a one-way function then
179/// b(x, r) = โจx, rโฉ mod 2 is a hard-core bit for f(x) paired with r.
180/// That is, given f(x) and r, no efficient algorithm can predict b(x, r)
181/// with advantage non-negligibly better than 1/2.
182pub fn goldreich_levin_ty() -> Expr {
183 arrow(one_way_function_ty(), prop())
184}
185/// `PseudorandomGenerator : Nat โ Nat โ Type`
186///
187/// A pseudorandom generator (PRG) stretching l-bit seeds to p-bit outputs (p > l).
188/// No polynomial-time distinguisher can tell PRG output from truly random bits
189/// with non-negligible advantage.
190pub fn prg_ty() -> Expr {
191 arrow(nat_ty(), arrow(nat_ty(), type0()))
192}
193/// `PrgSecure : PseudorandomGenerator โ Prop`
194///
195/// Computational indistinguishability: PRG(s) for uniform s is computationally
196/// indistinguishable from uniform over {0,1}^p.
197pub fn prg_secure_ty() -> Expr {
198 arrow(app2(cst("PRG"), nat_ty(), nat_ty()), prop())
199}
200/// `PseudorandomFunction : Nat โ Nat โ Type`
201///
202/// A pseudorandom function family (PRF): a family F_k: {0,1}^n โ {0,1}^m
203/// parameterized by key k โ {0,1}^ฮบ. No polynomial-time oracle adversary
204/// can distinguish F_k from a truly random function.
205pub fn prf_ty() -> Expr {
206 arrow(nat_ty(), arrow(nat_ty(), type0()))
207}
208/// `PrfSecure : PseudorandomFunction โ Prop`
209///
210/// PRF security: the PRF family is computationally indistinguishable from
211/// a random oracle, even for adaptive queries.
212pub fn prf_secure_ty() -> Expr {
213 arrow(app2(cst("PRF"), nat_ty(), nat_ty()), prop())
214}
215/// `PreimageResistant : HashFunction โ Prop`
216///
217/// Second-preimage resistance: given x, it is computationally infeasible
218/// to find x' โ x such that H(x') = H(x). This is a weaker property
219/// than collision resistance but stronger than one-wayness.
220pub fn preimage_resistant_ty() -> Expr {
221 arrow(hash_function_ty(), prop())
222}
223/// `SecondPreimageResistant : HashFunction โ Prop`
224///
225/// Second preimage resistance (target collision resistance): given a random x,
226/// no efficient adversary can find x' โ x with H(x') = H(x).
227/// Strictly implied by collision resistance.
228pub fn second_preimage_resistant_ty() -> Expr {
229 arrow(hash_function_ty(), prop())
230}
231/// `RandomOracleModel : Type`
232///
233/// The random oracle model (ROM): idealized model where the hash function H
234/// is replaced by a truly random oracle. Security proofs in the ROM give
235/// strong heuristic guarantees, though ROM โ standard model in general.
236pub fn random_oracle_model_ty() -> Expr {
237 type0()
238}
239/// `SignatureScheme : Type`
240///
241/// A digital signature scheme: triple (KeyGen, Sign, Verify) where
242/// KeyGen() โ (pk, sk), Sign(sk, m) โ ฯ, Verify(pk, m, ฯ) โ Bool.
243pub fn signature_scheme_ty() -> Expr {
244 type0()
245}
246/// `SignatureCorrectness : SignatureScheme โ Prop`
247///
248/// Correctness: for all (pk, sk) โ KeyGen() and all messages m,
249/// Verify(pk, m, Sign(sk, m)) = true.
250pub fn signature_correctness_ty() -> Expr {
251 arrow(signature_scheme_ty(), prop())
252}
253/// `EcdsaSignature : Type`
254///
255/// ECDSA (Elliptic Curve Digital Signature Algorithm) signature: a pair
256/// (r, s) โ Z_n ร Z_n* derived from an elliptic curve point and the
257/// hash of the message.
258pub fn ecdsa_signature_ty() -> Expr {
259 type0()
260}
261/// `EcdsaCorrectness : Prop`
262///
263/// ECDSA correctness: if (r, s) is a valid ECDSA signature for message m
264/// under key sk, then the verification algorithm with corresponding pk accepts.
265pub fn ecdsa_correctness_ty() -> Expr {
266 prop()
267}
268/// `EcdsaUnforgeability : Prop`
269///
270/// ECDSA unforgeability under ECDLP hardness: given a valid ECDSA implementation,
271/// forging signatures is reducible to solving the elliptic curve discrete
272/// logarithm problem, which is assumed computationally intractable.
273pub fn ecdsa_unforgeability_ty() -> Expr {
274 prop()
275}
276/// `PublicKeyEncScheme : Type`
277///
278/// A public-key encryption scheme: (KeyGen, Enc, Dec) where
279/// KeyGen() โ (pk, sk), Enc(pk, m) โ c, Dec(sk, c) โ m.
280pub fn pke_scheme_ty() -> Expr {
281 type0()
282}
283/// `PkeCorrectness : PublicKeyEncScheme โ Prop`
284///
285/// PKE correctness: Dec(sk, Enc(pk, m)) = m for all messages m and valid key pairs.
286pub fn pke_correctness_ty() -> Expr {
287 arrow(pke_scheme_ty(), prop())
288}
289/// `IndCca2 : Prop`
290///
291/// IND-CCA2 (indistinguishability under adaptive chosen-ciphertext attack).
292/// The strongest standard notion of PKE security: the adversary can adaptively
293/// query a decryption oracle both before and after receiving the challenge
294/// ciphertext (but not on the challenge itself).
295pub fn ind_cca2_ty() -> Expr {
296 prop()
297}
298/// `RsaOaep : Type`
299///
300/// RSA-OAEP (Optimal Asymmetric Encryption Padding): a padding scheme that
301/// transforms textbook RSA into an IND-CCA2 secure scheme in the random oracle
302/// model (Bellare-Rogaway 1994 / PKCS#1 v2.1 / RFC 3447).
303pub fn rsa_oaep_ty() -> Expr {
304 type0()
305}
306/// `RsaOaepIndCca2 : Prop`
307///
308/// RSA-OAEP is IND-CCA2 secure in the random oracle model, assuming the RSA
309/// problem is hard. This was proven by Fujisaki, Okamoto, Pointcheval, Stern (2001).
310pub fn rsa_oaep_ind_cca2_ty() -> Expr {
311 prop()
312}
313/// `EllipticCurve : Nat โ Type`
314///
315/// An elliptic curve E over a finite field F_p, parameterized by the field
316/// characteristic p. Points (x, y) satisfy yยฒ = xยณ + ax + b (Weierstrass form).
317pub fn elliptic_curve_ty() -> Expr {
318 arrow(nat_ty(), type0())
319}
320/// `EllipticCurvePoint : EllipticCurve โ Type`
321///
322/// A point on an elliptic curve, including the point at infinity O (identity).
323pub fn ec_point_ty() -> Expr {
324 arrow(app(cst("EllipticCurve"), nat_ty()), type0())
325}
326/// `EcGroupLaw : EllipticCurve โ Prop`
327///
328/// The elliptic curve group law: points on E form an abelian group under
329/// the chord-and-tangent addition rule, with the point at infinity as identity.
330pub fn ec_group_law_ty() -> Expr {
331 arrow(app(cst("EllipticCurve"), nat_ty()), prop())
332}
333/// `EcdlpHard : Nat โ Prop`
334///
335/// ECDLP hardness: the elliptic curve discrete logarithm problem is
336/// computationally hard over a curve of the given prime order.
337/// Given P and Q = kP, finding k is infeasible for well-chosen curves.
338/// The best known algorithms run in O(sqrt(p)) time (baby-step giant-step / Pollard rho).
339pub fn ecdlp_hard_ty() -> Expr {
340 arrow(nat_ty(), prop())
341}
342/// `EcdhCorrectness : Prop`
343///
344/// ECDH (Elliptic Curve Diffie-Hellman) key exchange correctness:
345/// Alice computes a*(b*G) and Bob computes b*(a*G); both equal ab*G.
346/// The shared secret is derived from this common point.
347pub fn ecdh_correctness_ty() -> Expr {
348 prop()
349}
350/// `EcdhHardness : Prop`
351///
352/// ECDH hardness (ECDHP): given G, aG, bG, computing abG is computationally
353/// hard, assuming ECDLP is hard. The computational ECDH problem reduces
354/// to ECDLP on most curves.
355pub fn ecdh_hardness_ty() -> Expr {
356 prop()
357}
358/// `BilinearMap : Type`
359///
360/// A bilinear pairing e: G1 ร G2 โ GT, where G1, G2, GT are cyclic groups
361/// of prime order q. The map satisfies:
362/// - Bilinearity: e(aP, bQ) = e(P, Q)^{ab}
363/// - Non-degeneracy: e(P, Q) โ 1_GT for generators P, Q
364/// Used in IBE, BLS signatures, zk-SNARKs, etc.
365pub fn bilinear_map_ty() -> Expr {
366 type0()
367}
368/// `PairingBilinearity : BilinearMap โ Prop`
369///
370/// Bilinearity axiom: e(aP, bQ) = e(P, Q)^{ab} for all a, b โ Z_q.
371pub fn pairing_bilinearity_ty() -> Expr {
372 arrow(bilinear_map_ty(), prop())
373}
374/// `BdhHard : Prop`
375///
376/// BDH hardness (Bilinear Diffie-Hellman): given (P, aP, bP, cP) in G,
377/// computing e(P, P)^{abc} is computationally hard. This is the foundation
378/// of pairing-based IBE (Boneh-Franklin 2001).
379pub fn bdh_hard_ty() -> Expr {
380 prop()
381}
382/// `BdddhHard : Prop`
383///
384/// Decisional BDH hardness (DBDH): distinguishing e(P,P)^{abc} from a
385/// random element in GT is computationally hard. Used in BLS signature security proofs.
386pub fn bdddh_hard_ty() -> Expr {
387 prop()
388}
389/// `BlsSignature : BilinearMap โ Type`
390///
391/// BLS (Boneh-Lynn-Shacham) signature: ฯ = skยทH(m), verified via
392/// e(ฯ, G) = e(H(m), pk). Supports efficient signature aggregation.
393pub fn bls_signature_ty() -> Expr {
394 arrow(bilinear_map_ty(), type0())
395}
396/// `BlsUnforgeability : BilinearMap โ Prop`
397///
398/// BLS EUF-CMA security: forging a BLS signature is as hard as solving
399/// the co-CDH problem in the bilinear group, in the random oracle model.
400pub fn bls_unforgeability_ty() -> Expr {
401 arrow(bilinear_map_ty(), prop())
402}
403/// `SigmaProtocol : Type`
404///
405/// A Sigma protocol (3-move honest-verifier zero-knowledge proof):
406/// (P โ V: commitment a; V โ P: challenge e; P โ V: response z).
407/// Used as a building block for non-interactive ZK via Fiat-Shamir.
408pub fn sigma_protocol_ty() -> Expr {
409 type0()
410}
411/// `ZkCompleteness : SigmaProtocol โ Prop`
412///
413/// Completeness: an honest prover with a valid witness always convinces
414/// the verifier. Pr[Verify(transcript) = 1 | honest prover] = 1.
415pub fn zk_completeness_ty() -> Expr {
416 arrow(sigma_protocol_ty(), prop())
417}
418/// `ZkSoundness : SigmaProtocol โ Prop`
419///
420/// Soundness (knowledge soundness / proof of knowledge): a cheating prover
421/// without a valid witness can convince the verifier with at most negligible
422/// probability. An extractor can recover the witness from two accepting transcripts.
423pub fn zk_soundness_ty() -> Expr {
424 arrow(sigma_protocol_ty(), prop())
425}
426/// `ZkZeroKnowledge : SigmaProtocol โ Prop`
427///
428/// Zero-knowledge property: the verifier's view can be efficiently simulated
429/// without the witness. The proof reveals nothing beyond the truth of the statement.
430pub fn zk_zero_knowledge_ty() -> Expr {
431 arrow(sigma_protocol_ty(), prop())
432}
433/// `FiatShamirTransform : SigmaProtocol โ Type`
434///
435/// The Fiat-Shamir transform: converts an interactive Sigma protocol into
436/// a non-interactive ZK argument (NIZK) by replacing the verifier's random
437/// challenge with a hash of the commitment.
438pub fn fiat_shamir_transform_ty() -> Expr {
439 arrow(sigma_protocol_ty(), type0())
440}
441/// `FiatShamirSoundness : SigmaProtocol โ Prop`
442///
443/// Soundness of the Fiat-Shamir transform in the random oracle model:
444/// the resulting NIZK is computationally sound (non-malleable argument).
445pub fn fiat_shamir_soundness_ty() -> Expr {
446 arrow(sigma_protocol_ty(), prop())
447}
448/// `IpEqPspace : Prop`
449///
450/// IP = PSPACE (Shamir 1992): the class of languages decidable by
451/// interactive proof systems equals PSPACE. This landmark result shows
452/// interactive proofs are far more powerful than one might expect.
453pub fn ip_eq_pspace_ty() -> Expr {
454 prop()
455}
456/// `SnarkCorrectness : Prop`
457///
458/// SNARK correctness: a succinct non-interactive argument of knowledge (SNARK)
459/// satisfies completeness, computational soundness (argument), and succinctness
460/// (proof size and verification time are poly-logarithmic in witness size).
461pub fn snark_correctness_ty() -> Expr {
462 prop()
463}
464/// `CommitmentScheme : Type`
465///
466/// A commitment scheme (Com, Open): Com(m, r) โ c (hiding phase),
467/// Open(c, m, r) โ Bool (binding phase). Instantiated by Pedersen or
468/// hash-based commitments.
469pub fn commitment_scheme_ty() -> Expr {
470 type0()
471}
472/// `CommitmentHiding : CommitmentScheme โ Prop`
473///
474/// Hiding property: the commitment c = Com(m, r) with fresh randomness r
475/// reveals no information about m to a computationally bounded adversary.
476pub fn commitment_hiding_ty() -> Expr {
477 arrow(commitment_scheme_ty(), prop())
478}
479/// `CommitmentBinding : CommitmentScheme โ Prop`
480///
481/// Binding property: it is computationally infeasible to open a commitment
482/// to two different messages m โ m', i.e., find (m, r), (m', r') such that
483/// Com(m, r) = Com(m', r').
484pub fn commitment_binding_ty() -> Expr {
485 arrow(commitment_scheme_ty(), prop())
486}
487/// `PedersenCommitment : Type`
488///
489/// Pedersen commitment scheme: Com(m, r) = g^m * h^r in a cyclic group.
490/// Perfectly hiding (statistically), computationally binding under DLH.
491pub fn pedersen_commitment_ty() -> Expr {
492 type0()
493}
494/// `ObliviousTransfer : Type`
495///
496/// 1-out-of-2 oblivious transfer (OT): sender has (m0, m1); receiver chooses
497/// bit b and receives m_b without the sender learning b, and without the receiver
498/// learning m_{1-b}. OT is complete for two-party computation.
499pub fn oblivious_transfer_ty() -> Expr {
500 type0()
501}
502/// `OtCorrectness : ObliviousTransfer โ Prop`
503///
504/// OT correctness: the receiver obtains the correct message m_b, the sender
505/// does not learn the choice bit b, and the receiver learns nothing about m_{1-b}.
506pub fn ot_correctness_ty() -> Expr {
507 arrow(oblivious_transfer_ty(), prop())
508}
509/// `SecureMpc : Nat โ Type`
510///
511/// Secure multi-party computation (MPC) for n parties: jointly compute a
512/// function f(x1, ..., xn) where party i holds xi, without revealing xi to
513/// other parties beyond what is implied by the output.
514pub fn secure_mpc_ty() -> Expr {
515 arrow(nat_ty(), type0())
516}
517/// `MpcSecurity : SecureMpc โ Prop`
518///
519/// MPC security (simulation-based definition): the real-world execution
520/// is computationally indistinguishable from an ideal execution with a
521/// trusted party, for any polynomial-time adversary corrupting a minority
522/// of parties (honest-majority setting).
523pub fn mpc_security_ty() -> Expr {
524 arrow(app(cst("SecureMPC"), nat_ty()), prop())
525}
526/// `SomewhatHomomorphicEncryption : Type`
527///
528/// Somewhat homomorphic encryption (SHE): supports a limited number of
529/// homomorphic additions and multiplications on ciphertexts, such that
530/// Dec(Enc(a) โ Enc(b)) = a + b and Dec(Enc(a) โ Enc(b)) = a * b,
531/// up to a bounded circuit depth.
532pub fn she_ty() -> Expr {
533 type0()
534}
535/// `SheCorrectness : SHE โ Prop`
536///
537/// SHE correctness: homomorphic evaluation of a circuit C preserves
538/// the plaintext computation up to the scheme's supported depth.
539pub fn she_correctness_ty() -> Expr {
540 arrow(she_ty(), prop())
541}
542/// `FullyHomomorphicEncryption : Type`
543///
544/// Fully homomorphic encryption (FHE โ Gentry 2009): supports evaluation
545/// of arbitrary circuits on ciphertexts. Constructed by bootstrapping SHE.
546/// Enables "computing on encrypted data" with no circuit depth restriction.
547pub fn fhe_ty() -> Expr {
548 type0()
549}
550/// `FheCorrectness : FHE โ Prop`
551///
552/// FHE correctness: for any Boolean circuit C,
553/// Dec(sk, Eval(pk, C, Enc(pk, x1), ..., Enc(pk, xn))) = C(x1, ..., xn).
554pub fn fhe_correctness_ty() -> Expr {
555 arrow(fhe_ty(), prop())
556}
557/// `BootstrappingTheorem : Prop`
558///
559/// Gentry's bootstrapping theorem: a SHE scheme that can evaluate its own
560/// decryption circuit (with one extra multiplication) can be bootstrapped
561/// into a FHE scheme.
562pub fn bootstrapping_theorem_ty() -> Expr {
563 prop()
564}
565/// `ShamirSecretSharing : Nat โ Nat โ Type`
566///
567/// Shamir's (k, n)-threshold secret sharing: a secret s is split into n shares
568/// such that any k shares can reconstruct s (via Lagrange interpolation over F_p),
569/// but any k-1 shares reveal no information about s.
570pub fn shamir_secret_sharing_ty() -> Expr {
571 arrow(nat_ty(), arrow(nat_ty(), type0()))
572}
573/// `ShamirPerfectSecrecy : Nat โ Nat โ Prop`
574///
575/// Perfect secrecy of Shamir's scheme: any set of fewer than k shares is
576/// statistically independent of the secret. This follows from the fact that
577/// a degree-(k-1) polynomial over F_p is determined by k points, and any
578/// value for f(0) is equally likely given only k-1 points.
579pub fn shamir_perfect_secrecy_ty() -> Expr {
580 arrow(nat_ty(), arrow(nat_ty(), prop()))
581}
582/// `ShamirReconstruction : Nat โ Nat โ Prop`
583///
584/// Shamir reconstruction correctness: any k shares can reconstruct the secret
585/// by Lagrange interpolation of the underlying degree-(k-1) polynomial.
586pub fn shamir_reconstruction_ty() -> Expr {
587 arrow(nat_ty(), arrow(nat_ty(), prop()))
588}
589/// `ThresholdScheme : Nat โ Nat โ Type`
590///
591/// General (k, n)-threshold scheme: a secret sharing scheme where any k-subset
592/// of n participants can recover the secret, and any (k-1)-subset cannot.
593pub fn threshold_scheme_ty() -> Expr {
594 arrow(nat_ty(), arrow(nat_ty(), type0()))
595}
596/// `HashChain : Nat โ Type`
597///
598/// A hash chain of length n: h_0 = genesis, h_{i+1} = H(h_i || data_i).
599/// Hash chains are used in blockchain ledgers, one-time passwords (S/KEY),
600/// and certificate transparency logs.
601pub fn hash_chain_ty() -> Expr {
602 arrow(nat_ty(), type0())
603}
604/// `HashChainIntegrity : HashChain โ Prop`
605///
606/// Hash chain integrity: if H is collision-resistant, then any
607/// tampering with block i invalidates all subsequent hashes.
608/// Formally, finding a valid tampered chain is as hard as finding a
609/// collision in H.
610pub fn hash_chain_integrity_ty() -> Expr {
611 arrow(app(cst("HashChain"), nat_ty()), prop())
612}
613/// `MerkleTree : Nat โ Type`
614///
615/// A Merkle hash tree of depth d: a binary tree whose leaves are data blocks,
616/// internal nodes hold the hash of their children's hashes, and the root
617/// is a compact commitment to all leaves.
618pub fn merkle_tree_ty() -> Expr {
619 arrow(nat_ty(), type0())
620}
621/// `MerkleInclusionProof : MerkleTree โ Prop`
622///
623/// Merkle inclusion proof: a path of sibling hashes from a leaf to the root
624/// proves a data block is included in the committed set, in O(log n) time
625/// and space. Security reduces to collision resistance of H.
626pub fn merkle_inclusion_proof_ty() -> Expr {
627 arrow(app(cst("MerkleTree"), nat_ty()), prop())
628}
629/// `BlockchainConsensus : Type`
630///
631/// A blockchain consensus protocol: agreement on an append-only log secured
632/// by proof-of-work (hash puzzle), proof-of-stake, or other mechanisms.
633/// Nakamoto consensus (Bitcoin) uses longest-chain rule.
634pub fn blockchain_consensus_ty() -> Expr {
635 type0()
636}
637/// Register all cryptography axioms and theorems into the kernel environment.
638///
639/// This populates the environment with:
640/// - Type formers for cryptographic objects (original + new)
641/// - Security property propositions (as axioms)
642/// - Correctness theorems (as axioms, to be proved externally)
643pub fn build_cryptography_env(env: &mut Environment) -> Result<(), String> {
644 let axioms: &[(&str, Expr)] = &[
645 ("Crypto.HashFunction", hash_function_ty()),
646 ("Crypto.SymmetricKey", symmetric_key_ty()),
647 ("Crypto.PublicKey", public_key_ty()),
648 ("Crypto.PrivateKey", private_key_ty()),
649 ("Crypto.Signature", signature_ty()),
650 ("Crypto.Ciphertext", ciphertext_ty()),
651 ("Crypto.Group", group_ty()),
652 ("Crypto.RsaParams", rsa_params_ty()),
653 ("Crypto.OneWayFunction", one_way_function_ty()),
654 ("Crypto.CollisionResistant", collision_resistant_ty()),
655 ("Crypto.IndCpa", ind_cpa_ty()),
656 ("Crypto.IndCca", ind_cca_ty()),
657 ("Crypto.EufCma", euf_cma_ty()),
658 ("Crypto.DiscreteLogHard", discrete_log_hard_ty()),
659 ("Crypto.RsaHard", rsa_hard_ty()),
660 ("Crypto.RsaCorrectness", rsa_correctness_ty()),
661 ("Crypto.DhCorrectness", dh_correctness_ty()),
662 ("Crypto.BirthdayBound", birthday_bound_ty()),
663 ("Crypto.TrapdoorFunction", trapdoor_function_ty()),
664 ("Crypto.TrapdoorInvertible", trapdoor_invertible_ty()),
665 ("Crypto.GoldreichLevinHardCoreBit", goldreich_levin_ty()),
666 ("Crypto.PRG", prg_ty()),
667 ("Crypto.PrgSecure", prg_secure_ty()),
668 ("Crypto.PRF", prf_ty()),
669 ("Crypto.PrfSecure", prf_secure_ty()),
670 ("Crypto.PreimageResistant", preimage_resistant_ty()),
671 (
672 "Crypto.SecondPreimageResistant",
673 second_preimage_resistant_ty(),
674 ),
675 ("Crypto.RandomOracleModel", random_oracle_model_ty()),
676 ("Crypto.SignatureScheme", signature_scheme_ty()),
677 ("Crypto.SignatureCorrectness", signature_correctness_ty()),
678 ("Crypto.EcdsaSignature", ecdsa_signature_ty()),
679 ("Crypto.EcdsaCorrectness", ecdsa_correctness_ty()),
680 ("Crypto.EcdsaUnforgeability", ecdsa_unforgeability_ty()),
681 ("Crypto.PKEScheme", pke_scheme_ty()),
682 ("Crypto.PkeCorrectness", pke_correctness_ty()),
683 ("Crypto.IndCca2", ind_cca2_ty()),
684 ("Crypto.RsaOaep", rsa_oaep_ty()),
685 ("Crypto.RsaOaepIndCca2", rsa_oaep_ind_cca2_ty()),
686 ("Crypto.EllipticCurve", elliptic_curve_ty()),
687 ("Crypto.ECPoint", ec_point_ty()),
688 ("Crypto.EcGroupLaw", ec_group_law_ty()),
689 ("Crypto.EcdlpHard", ecdlp_hard_ty()),
690 ("Crypto.EcdhCorrectness", ecdh_correctness_ty()),
691 ("Crypto.EcdhHardness", ecdh_hardness_ty()),
692 ("Crypto.BilinearMap", bilinear_map_ty()),
693 ("Crypto.PairingBilinearity", pairing_bilinearity_ty()),
694 ("Crypto.BdhHard", bdh_hard_ty()),
695 ("Crypto.BdddhHard", bdddh_hard_ty()),
696 ("Crypto.BlsSignature", bls_signature_ty()),
697 ("Crypto.BlsUnforgeability", bls_unforgeability_ty()),
698 ("Crypto.SigmaProtocol", sigma_protocol_ty()),
699 ("Crypto.ZkCompleteness", zk_completeness_ty()),
700 ("Crypto.ZkSoundness", zk_soundness_ty()),
701 ("Crypto.ZkZeroKnowledge", zk_zero_knowledge_ty()),
702 ("Crypto.FiatShamirTransform", fiat_shamir_transform_ty()),
703 ("Crypto.FiatShamirSoundness", fiat_shamir_soundness_ty()),
704 ("Crypto.IpEqPspace", ip_eq_pspace_ty()),
705 ("Crypto.SnarkCorrectness", snark_correctness_ty()),
706 ("Crypto.CommitmentScheme", commitment_scheme_ty()),
707 ("Crypto.CommitmentHiding", commitment_hiding_ty()),
708 ("Crypto.CommitmentBinding", commitment_binding_ty()),
709 ("Crypto.PedersenCommitment", pedersen_commitment_ty()),
710 ("Crypto.ObliviousTransfer", oblivious_transfer_ty()),
711 ("Crypto.OtCorrectness", ot_correctness_ty()),
712 ("Crypto.SecureMPC", secure_mpc_ty()),
713 ("Crypto.MpcSecurity", mpc_security_ty()),
714 ("Crypto.SHE", she_ty()),
715 ("Crypto.SheCorrectness", she_correctness_ty()),
716 ("Crypto.FHE", fhe_ty()),
717 ("Crypto.FheCorrectness", fhe_correctness_ty()),
718 ("Crypto.BootstrappingTheorem", bootstrapping_theorem_ty()),
719 ("Crypto.ShamirSecretSharing", shamir_secret_sharing_ty()),
720 ("Crypto.ShamirPerfectSecrecy", shamir_perfect_secrecy_ty()),
721 ("Crypto.ShamirReconstruction", shamir_reconstruction_ty()),
722 ("Crypto.ThresholdScheme", threshold_scheme_ty()),
723 ("Crypto.HashChain", hash_chain_ty()),
724 ("Crypto.HashChainIntegrity", hash_chain_integrity_ty()),
725 ("Crypto.MerkleTree", merkle_tree_ty()),
726 ("Crypto.MerkleInclusionProof", merkle_inclusion_proof_ty()),
727 ("Crypto.BlockchainConsensus", blockchain_consensus_ty()),
728 ];
729 for (name, ty) in axioms {
730 env.add(Declaration::Axiom {
731 name: Name::str(*name),
732 univ_params: vec![],
733 ty: ty.clone(),
734 })
735 .ok();
736 }
737 Ok(())
738}
739/// Fast modular exponentiation: computes `base^exp mod modulus`.
740///
741/// Uses repeated squaring (binary method) in O(log exp) multiplications.
742///
743/// # WARNING
744/// This is an educational implementation. For production use, employ a
745/// constant-time implementation from a vetted cryptography library.
746pub fn mod_exp(base: u64, exp: u64, modulus: u64) -> u64 {
747 if modulus == 1 {
748 return 0;
749 }
750 let mut result: u128 = 1;
751 let mut base = base as u128 % modulus as u128;
752 let mut exp = exp;
753 let modulus = modulus as u128;
754 while exp > 0 {
755 if exp & 1 == 1 {
756 result = result * base % modulus;
757 }
758 exp >>= 1;
759 base = base * base % modulus;
760 }
761 result as u64
762}
763/// Extended Euclidean algorithm.
764///
765/// Returns `(gcd, x, y)` such that `a*x + b*y = gcd(a, b)`.
766///
767/// # WARNING
768/// Educational implementation only.
769pub fn extended_gcd(a: i64, b: i64) -> (i64, i64, i64) {
770 if b == 0 {
771 return (a, 1, 0);
772 }
773 let (g, x1, y1) = extended_gcd(b, a % b);
774 (g, y1, x1 - (a / b) * y1)
775}
776/// Modular inverse of `a` modulo `m`, if it exists.
777///
778/// Returns `Some(x)` such that `a*x โก 1 (mod m)`, or `None` if gcd(a, m) โ 1.
779///
780/// # WARNING
781/// Educational implementation only.
782pub fn mod_inverse(a: u64, m: u64) -> Option<u64> {
783 let (g, x, _) = extended_gcd(a as i64, m as i64);
784 if g != 1 {
785 return None;
786 }
787 Some(((x % m as i64 + m as i64) % m as i64) as u64)
788}
789/// One round of the SHA-256 compression function (educational model).
790///
791/// Updates the 8-word working state `[a, b, c, d, e, f, g, h]` using
792/// the message schedule word `w` and round constant `k`.
793///
794/// # WARNING
795/// This is a simplified educational illustration. The full SHA-256 algorithm
796/// requires a complete message schedule, 64 rounds, and proper IV initialisation.
797/// Do NOT use this for any real hashing.
798pub fn sha256_compress_round(state: &mut [u32; 8], w: u32, k: u32) {
799 let [a, b, c, d, e, f, g, h] = *state;
800 let s1 = e.rotate_right(6) ^ e.rotate_right(11) ^ e.rotate_right(25);
801 let ch = (e & f) ^ ((!e) & g);
802 let temp1 = h
803 .wrapping_add(s1)
804 .wrapping_add(ch)
805 .wrapping_add(k)
806 .wrapping_add(w);
807 let s0 = a.rotate_right(2) ^ a.rotate_right(13) ^ a.rotate_right(22);
808 let maj = (a & b) ^ (a & c) ^ (b & c);
809 let temp2 = s0.wrapping_add(maj);
810 state[7] = g;
811 state[6] = f;
812 state[5] = e;
813 state[4] = d.wrapping_add(temp1);
814 state[3] = c;
815 state[2] = b;
816 state[1] = a;
817 state[0] = temp1.wrapping_add(temp2);
818}
819/// Simple polynomial rolling hash over a byte slice.
820///
821/// Computes `ฮฃ data[i] * BASE^i mod MOD`. This is a common non-cryptographic
822/// hash used in string algorithms (e.g., Rabin-Karp).
823///
824/// # WARNING
825/// This is NOT a cryptographic hash function. It provides no security
826/// guarantees whatsoever.
827pub fn simple_hash(data: &[u8]) -> u64 {
828 const BASE: u128 = 131;
829 const MOD: u128 = (1 << 61) - 1;
830 let mut hash: u128 = 0;
831 let mut power: u128 = 1;
832 for &byte in data {
833 hash = (hash + (byte as u128) * power) % MOD;
834 power = power * BASE % MOD;
835 }
836 hash as u64
837}
838/// Caesar cipher encryption: shifts each byte by `shift` (mod 256).
839///
840/// # WARNING
841/// The Caesar cipher has zero security. It is broken by simple frequency
842/// analysis and is included here purely for educational illustration.
843pub fn caesar_cipher(text: &[u8], shift: u8) -> Vec<u8> {
844 text.iter().map(|&b| b.wrapping_add(shift)).collect()
845}
846/// Caesar cipher decryption: shifts each byte back by `shift` (mod 256).
847///
848/// # WARNING
849/// Educational only. Not secure.
850pub fn caesar_decipher(text: &[u8], shift: u8) -> Vec<u8> {
851 text.iter().map(|&b| b.wrapping_sub(shift)).collect()
852}
853/// Vigenรจre cipher encryption: XORs each byte with the repeating key.
854///
855/// # WARNING
856/// The Vigenรจre cipher (and this XOR variant) is trivially broken when the
857/// key length is known or guessable. It is included for historical/educational
858/// purposes only.
859pub fn vigenere_cipher(text: &[u8], key: &[u8]) -> Vec<u8> {
860 if key.is_empty() {
861 return text.to_vec();
862 }
863 text.iter()
864 .enumerate()
865 .map(|(i, &b)| b ^ key[i % key.len()])
866 .collect()
867}
868/// Miller-Rabin primality test with explicit witnesses.
869///
870/// Returns `true` if `n` is (probably) prime for all given witnesses,
871/// `false` if `n` is definitely composite.
872///
873/// For deterministic results up to 3,215,031,751, use witnesses `[2, 3, 5, 7]`.
874/// For up to 3,474,749,660,383, use `[2, 3, 5, 7, 11, 13]`.
875///
876/// # WARNING
877/// This is a probabilistic test. With random witnesses the false-positive
878/// probability per witness is at most 1/4. For production use, employ a
879/// fully deterministic implementation with appropriate witness sets.
880pub fn miller_rabin(n: u64, witnesses: &[u64]) -> bool {
881 if n < 2 {
882 return false;
883 }
884 if n == 2 || n == 3 {
885 return true;
886 }
887 if n % 2 == 0 {
888 return false;
889 }
890 let mut d = n - 1;
891 let mut r = 0u32;
892 while d % 2 == 0 {
893 d /= 2;
894 r += 1;
895 }
896 'witness: for &a in witnesses {
897 if a >= n {
898 continue;
899 }
900 let mut x = mod_exp(a, d, n);
901 if x == 1 || x == n - 1 {
902 continue 'witness;
903 }
904 for _ in 0..r - 1 {
905 x = mod_exp(x, 2, n);
906 if x == n - 1 {
907 continue 'witness;
908 }
909 }
910 return false;
911 }
912 true
913}
914#[cfg(test)]
915mod tests {
916 use super::*;
917 use oxilean_kernel::Environment;
918 #[test]
919 fn test_mod_exp() {
920 assert_eq!(mod_exp(2, 10, 1000), 24);
921 assert_eq!(mod_exp(5, 0, 7), 1);
922 assert_eq!(mod_exp(0, 5, 7), 0);
923 assert_eq!(mod_exp(3, 6, 7), 1);
924 }
925 #[test]
926 fn test_extended_gcd() {
927 let (g, x, y) = extended_gcd(35, 15);
928 assert_eq!(g, 5);
929 assert_eq!(35 * x + 15 * y, g);
930 let (g2, x2, y2) = extended_gcd(48, 18);
931 assert_eq!(g2, 6);
932 assert_eq!(48 * x2 + 18 * y2, g2);
933 }
934 #[test]
935 fn test_mod_inverse() {
936 assert_eq!(mod_inverse(3, 7), Some(5));
937 assert_eq!(mod_inverse(2, 9), Some(5));
938 assert_eq!(mod_inverse(4, 6), None);
939 }
940 #[test]
941 fn test_toy_rsa() {
942 let rsa = ToyRsa::generate(61, 53).expect("RSA generation should succeed for p=61, q=53");
943 let message = 42u64;
944 assert!(message < rsa.n, "message must be smaller than modulus");
945 let ciphertext = rsa.encrypt(message);
946 let recovered = rsa.decrypt(ciphertext);
947 assert_eq!(
948 recovered, message,
949 "RSA decrypt(encrypt(m)) must equal m; got {} for message {}",
950 recovered, message
951 );
952 let msg2 = 100u64;
953 assert!(msg2 < rsa.n);
954 assert_eq!(rsa.decrypt(rsa.encrypt(msg2)), msg2);
955 }
956 #[test]
957 fn test_toy_dh() {
958 let dh = ToyDiffieHellman { p: 23, g: 5 };
959 let alice_private = 6u64;
960 let bob_private = 15u64;
961 let alice_public = dh.public_key(alice_private);
962 let bob_public = dh.public_key(bob_private);
963 let alice_secret = dh.shared_secret(bob_public, alice_private);
964 let bob_secret = dh.shared_secret(alice_public, bob_private);
965 assert_eq!(
966 alice_secret, bob_secret,
967 "Diffie-Hellman shared secrets must match: Alice got {}, Bob got {}",
968 alice_secret, bob_secret
969 );
970 assert_eq!(alice_secret, 2);
971 }
972 #[test]
973 fn test_miller_rabin() {
974 let primes = [2u64, 3, 5, 7, 11, 13, 17, 19, 23, 97, 101, 7919];
975 let witnesses = [2u64, 3, 5, 7];
976 for &p in &primes {
977 assert!(
978 miller_rabin(p, &witnesses),
979 "{} is prime but Miller-Rabin returned false",
980 p
981 );
982 }
983 let composites = [1u64, 4, 6, 8, 9, 10, 15, 21, 25, 100, 561];
984 for &c in &composites {
985 assert!(
986 !miller_rabin(c, &witnesses),
987 "{} is composite but Miller-Rabin returned true",
988 c
989 );
990 }
991 }
992 #[test]
993 fn test_caesar() {
994 let plaintext = b"hello";
995 let shift = 3u8;
996 let ciphertext = caesar_cipher(plaintext, shift);
997 let decrypted = caesar_decipher(&ciphertext, shift);
998 assert_eq!(
999 decrypted, plaintext,
1000 "Caesar decipher(cipher(text, k), k) must return original text"
1001 );
1002 assert_eq!(ciphertext[0], b'k');
1003 }
1004 #[test]
1005 fn test_vigenere() {
1006 let plaintext = b"attackatdawn";
1007 let key = b"lemon";
1008 let ciphertext = vigenere_cipher(plaintext, key);
1009 let decrypted = vigenere_cipher(&ciphertext, key);
1010 assert_eq!(decrypted, plaintext);
1011 }
1012 #[test]
1013 fn test_simple_hash() {
1014 assert_eq!(simple_hash(b"hello"), simple_hash(b"hello"));
1015 assert_ne!(simple_hash(b"hello"), simple_hash(b"world"));
1016 assert_eq!(simple_hash(b""), 0);
1017 }
1018 #[test]
1019 fn test_build_env() {
1020 let mut env = Environment::new();
1021 let result = build_cryptography_env(&mut env);
1022 assert!(
1023 result.is_ok(),
1024 "build_cryptography_env should succeed: {:?}",
1025 result
1026 );
1027 }
1028 #[test]
1029 fn test_modular_arithmetic() {
1030 let ma = ModularArithmetic::new(17);
1031 assert_eq!(ma.add(10, 9), 2);
1032 assert_eq!(ma.sub(3, 5), 15);
1033 assert_eq!(ma.mul(4, 5), 3);
1034 assert_eq!(ma.pow(2, 8), 1);
1035 assert_eq!(ma.inv(3), Some(6));
1036 assert_eq!(ma.legendre(4), 1);
1037 let ma7 = ModularArithmetic::new(7);
1038 assert_eq!(ma7.legendre(3), -1);
1039 }
1040 #[test]
1041 fn test_rsa_keygen() {
1042 let (rsa, p, q) =
1043 RsaKeyGen::generate_from_seed(500).expect("RsaKeyGen should succeed for seed=500");
1044 assert!(miller_rabin(p, &[2, 3, 5, 7]), "p should be prime");
1045 assert!(miller_rabin(q, &[2, 3, 5, 7]), "q should be prime");
1046 assert_eq!(rsa.n, p * q);
1047 let msg = 7u64;
1048 assert!(msg < rsa.n);
1049 assert_eq!(rsa.decrypt(rsa.encrypt(msg)), msg);
1050 }
1051 #[test]
1052 fn test_diffie_hellman_sim() {
1053 let sim = DiffieHellmanSim::new(23, 5, 6, 15);
1054 assert!(sim.secrets_match(), "DH shared secrets must match");
1055 assert_eq!(sim.alice_shared_secret(), 2);
1056 assert_eq!(sim.bob_shared_secret(), 2);
1057 }
1058 #[test]
1059 fn test_hash_chain() {
1060 let mut chain = HashChain::new(12345);
1061 let data = [111u64, 222, 333];
1062 for &d in &data {
1063 chain.append(d);
1064 }
1065 assert_eq!(chain.chain.len(), 4);
1066 assert!(chain.verify(&data), "Hash chain verification should pass");
1067 let mut tampered_chain = chain.clone();
1068 tampered_chain.chain[1] = tampered_chain.chain[1].wrapping_add(1);
1069 assert!(
1070 !tampered_chain.verify(&data),
1071 "Tampered chain should fail verification"
1072 );
1073 }
1074 #[test]
1075 fn test_shamir_secret_share() {
1076 let sss = ShamirSecretShare::new(97, 2, 3);
1077 let secret = 42u64;
1078 let shares = sss.share(secret, 12345);
1079 assert_eq!(shares.len(), 3);
1080 let from_01 = sss.reconstruct(&shares[..2]);
1081 let from_12 = sss.reconstruct(&[shares[1], shares[2]]);
1082 let from_02 = sss.reconstruct(&[shares[0], shares[2]]);
1083 assert_eq!(
1084 from_01,
1085 Some(secret),
1086 "shares[0,1] should reconstruct secret"
1087 );
1088 assert_eq!(
1089 from_12,
1090 Some(secret),
1091 "shares[1,2] should reconstruct secret"
1092 );
1093 assert_eq!(
1094 from_02,
1095 Some(secret),
1096 "shares[0,2] should reconstruct secret"
1097 );
1098 let from_all = sss.reconstruct(&shares);
1099 assert_eq!(
1100 from_all,
1101 Some(secret),
1102 "all 3 shares should reconstruct secret"
1103 );
1104 let from_one = sss.reconstruct(&shares[..1]);
1105 assert_eq!(from_one, None, "fewer than k shares should return None");
1106 }
1107 #[test]
1108 fn test_axioms_registered() {
1109 let mut env = Environment::new();
1110 build_cryptography_env(&mut env).expect("build_cryptography_env should succeed");
1111 let expected = [
1112 "Crypto.TrapdoorFunction",
1113 "Crypto.GoldreichLevinHardCoreBit",
1114 "Crypto.PRG",
1115 "Crypto.PRF",
1116 "Crypto.PreimageResistant",
1117 "Crypto.EcdsaUnforgeability",
1118 "Crypto.IndCca2",
1119 "Crypto.RsaOaepIndCca2",
1120 "Crypto.EllipticCurve",
1121 "Crypto.EcdlpHard",
1122 "Crypto.EcdhCorrectness",
1123 "Crypto.BilinearMap",
1124 "Crypto.BdhHard",
1125 "Crypto.BlsUnforgeability",
1126 "Crypto.SigmaProtocol",
1127 "Crypto.ZkCompleteness",
1128 "Crypto.ZkSoundness",
1129 "Crypto.ZkZeroKnowledge",
1130 "Crypto.FiatShamirTransform",
1131 "Crypto.IpEqPspace",
1132 "Crypto.SnarkCorrectness",
1133 "Crypto.CommitmentScheme",
1134 "Crypto.CommitmentHiding",
1135 "Crypto.CommitmentBinding",
1136 "Crypto.ObliviousTransfer",
1137 "Crypto.SecureMPC",
1138 "Crypto.FHE",
1139 "Crypto.BootstrappingTheorem",
1140 "Crypto.ShamirSecretSharing",
1141 "Crypto.ShamirPerfectSecrecy",
1142 "Crypto.HashChain",
1143 "Crypto.MerkleTree",
1144 "Crypto.BlockchainConsensus",
1145 ];
1146 for name in &expected {
1147 assert!(
1148 env.get(&Name::str(*name)).is_some(),
1149 "Expected axiom '{}' not found in environment",
1150 name
1151 );
1152 }
1153 }
1154}
1155/// `LweHardness : Nat โ Nat โ Prop`
1156///
1157/// Learning With Errors (LWE) hardness (Regev 2005): given (A, b = As + e mod q)
1158/// where s is a secret vector and e is a small-norm error vector, it is
1159/// computationally hard to recover s. LWE is the foundation of most
1160/// lattice-based public-key cryptography.
1161pub fn cry_ext_lwe_hardness_ty() -> Expr {
1162 arrow(nat_ty(), arrow(nat_ty(), prop()))
1163}
1164/// `RlweHardness : Nat โ Prop`
1165///
1166/// Ring-LWE (RLWE) hardness: the LWE problem instantiated over polynomial rings
1167/// Z_q[x]/(f(x)). More efficient than standard LWE while maintaining
1168/// comparable security. Basis of CRYSTALS-Kyber and CRYSTALS-Dilithium.
1169pub fn cry_ext_rlwe_hardness_ty() -> Expr {
1170 arrow(nat_ty(), prop())
1171}
1172/// `LweEncScheme : Nat โ Nat โ Type`
1173///
1174/// LWE-based public-key encryption scheme: a lattice-based PKE with
1175/// security reduction to LWE. Encryption adds error to hide the plaintext.
1176pub fn cry_ext_lwe_enc_ty() -> Expr {
1177 arrow(nat_ty(), arrow(nat_ty(), type0()))
1178}
1179/// `LweEncCorrectness : Nat โ Nat โ Prop`
1180///
1181/// LWE encryption correctness: decryption recovers the plaintext when
1182/// the error magnitude is bounded. The noise must stay below the
1183/// correctness threshold throughout computation.
1184pub fn cry_ext_lwe_enc_correct_ty() -> Expr {
1185 arrow(nat_ty(), arrow(nat_ty(), prop()))
1186}
1187/// `KyberKem : Nat โ Type`
1188///
1189/// CRYSTALS-Kyber key encapsulation mechanism: an IND-CCA2 secure KEM
1190/// based on Module-LWE. Selected by NIST for post-quantum standardization
1191/// (ML-KEM, FIPS 203). Parameterized by security level k โ {2, 3, 4}.
1192pub fn cry_ext_kyber_kem_ty() -> Expr {
1193 arrow(nat_ty(), type0())
1194}
1195/// `KyberIndCca2 : Nat โ Prop`
1196///
1197/// Kyber IND-CCA2 security: under the Module-LWE assumption, no
1198/// polynomial-time adversary can break the IND-CCA2 security of Kyber
1199/// with non-negligible advantage.
1200pub fn cry_ext_kyber_ind_cca2_ty() -> Expr {
1201 arrow(nat_ty(), prop())
1202}
1203/// `NtruHardness : Nat โ Prop`
1204///
1205/// NTRU hardness assumption: given (h = f^{-1} * g mod q) in the ring
1206/// Z[x]/(x^n - 1), it is computationally hard to recover the short
1207/// polynomials f and g. NTRU was one of the first lattice-based cryptosystems.
1208pub fn cry_ext_ntru_hardness_ty() -> Expr {
1209 arrow(nat_ty(), prop())
1210}
1211/// `DilithiumSig : Nat โ Type`
1212///
1213/// CRYSTALS-Dilithium digital signature scheme: a lattice-based signature
1214/// based on Module-LWE and Module-SIS. Selected by NIST for standardization
1215/// (ML-DSA, FIPS 204).
1216pub fn cry_ext_dilithium_sig_ty() -> Expr {
1217 arrow(nat_ty(), type0())
1218}
1219/// `DilithiumEufCma : Nat โ Prop`
1220///
1221/// EUF-CMA security of Dilithium: forging signatures is as hard as
1222/// solving Module-LWE and Module-SIS problems.
1223pub fn cry_ext_dilithium_euf_cma_ty() -> Expr {
1224 arrow(nat_ty(), prop())
1225}
1226/// `LinearCode : Nat โ Nat โ Nat โ Type`
1227///
1228/// A linear error-correcting code [n, k, d]: a k-dimensional subspace of F_2^n
1229/// with minimum Hamming distance d. Can correct up to โ(d-1)/2โ errors.
1230pub fn cry_ext_linear_code_ty() -> Expr {
1231 arrow(nat_ty(), arrow(nat_ty(), arrow(nat_ty(), type0())))
1232}
1233/// `McElieceEncryption : Nat โ Nat โ Nat โ Type`
1234///
1235/// McEliece cryptosystem (1978): public-key encryption based on the hardness
1236/// of decoding a random linear code. The public key is a scrambled generator
1237/// matrix; security relies on the NP-hardness of general decoding.
1238pub fn cry_ext_mceliece_ty() -> Expr {
1239 arrow(nat_ty(), arrow(nat_ty(), arrow(nat_ty(), type0())))
1240}
1241/// `McElieceHardness : Nat โ Nat โ Prop`
1242///
1243/// McEliece hardness: decoding a random linear code is NP-hard in the
1244/// worst case and believed hard on average. This provides post-quantum
1245/// security (no known quantum speedup beyond sqrt).
1246pub fn cry_ext_mceliece_hardness_ty() -> Expr {
1247 arrow(nat_ty(), arrow(nat_ty(), prop()))
1248}
1249/// `SyndromeDecode : Nat โ Nat โ Prop`
1250///
1251/// Syndrome decoding problem (SDP): given a parity-check matrix H and
1252/// syndrome s, find a low-weight vector e such that He = s. This is
1253/// NP-complete and underlies code-based cryptography.
1254pub fn cry_ext_syndrome_decode_ty() -> Expr {
1255 arrow(nat_ty(), arrow(nat_ty(), prop()))
1256}
1257/// `XmssSig : Nat โ Type`
1258///
1259/// XMSS (eXtended Merkle Signature Scheme): a stateful hash-based signature
1260/// scheme with security based only on the collision resistance of the hash
1261/// function. Standardized in RFC 8391. Parameterized by tree height h.
1262pub fn cry_ext_xmss_sig_ty() -> Expr {
1263 arrow(nat_ty(), type0())
1264}
1265/// `XmssEufCma : Nat โ Prop`
1266///
1267/// EUF-CMA security of XMSS: security reduces to the collision resistance
1268/// and second-preimage resistance of the underlying hash function.
1269/// No additional hardness assumptions required.
1270pub fn cry_ext_xmss_euf_cma_ty() -> Expr {
1271 arrow(nat_ty(), prop())
1272}
1273/// `SphincsSig : Type`
1274///
1275/// SPHINCS+: a stateless hash-based signature scheme. Unlike XMSS, it
1276/// requires no state management. Selected by NIST for standardization
1277/// (SLH-DSA, FIPS 205). Security based solely on hash function properties.
1278pub fn cry_ext_sphincs_sig_ty() -> Expr {
1279 type0()
1280}
1281/// `SphincsEufCma : Prop`
1282///
1283/// EUF-CMA security of SPHINCS+: the scheme is secure under the assumption
1284/// that the underlying hash function is a secure random oracle.
1285pub fn cry_ext_sphincs_euf_cma_ty() -> Expr {
1286 prop()
1287}
1288/// `WotsPlus : Nat โ Type`
1289///
1290/// WOTS+ (Winternitz One-Time Signature): a one-time signature scheme
1291/// used as a building block in XMSS and SPHINCS+.
1292/// Parameterized by the Winternitz parameter w.
1293pub fn cry_ext_wots_plus_ty() -> Expr {
1294 arrow(nat_ty(), type0())
1295}
1296/// `Isogeny : Nat โ Nat โ Type`
1297///
1298/// An isogeny between two elliptic curves E1 and E2: a non-constant rational
1299/// map ฯ: E1 โ E2 that is also a group homomorphism. The degree of the
1300/// isogeny is the size of its kernel.
1301pub fn cry_ext_isogeny_ty() -> Expr {
1302 arrow(nat_ty(), arrow(nat_ty(), type0()))
1303}
1304/// `SidhHardness : Nat โ Prop`
1305///
1306/// SIDH (Supersingular Isogeny Diffie-Hellman) hardness: computing the
1307/// shared secret from public parameters requires finding an isogeny between
1308/// supersingular elliptic curves. Note: SIKE was broken in 2022 by
1309/// Castryck-Decru; modern variants aim to repair this.
1310pub fn cry_ext_sidh_hardness_ty() -> Expr {
1311 arrow(nat_ty(), prop())
1312}
1313/// `SupersingularIsogenyCurve : Nat โ Type`
1314///
1315/// A supersingular elliptic curve over F_p^2: these form a special class
1316/// with desirable properties for isogeny-based cryptography, including
1317/// a well-structured isogeny graph (Ramanujan graph).
1318pub fn cry_ext_supersingular_curve_ty() -> Expr {
1319 arrow(nat_ty(), type0())
1320}
1321/// `ZkSnark : Type`
1322///
1323/// A zk-SNARK (zero-knowledge succinct non-interactive argument of knowledge):
1324/// a proof system with (1) completeness, (2) computational knowledge soundness,
1325/// (3) zero-knowledge, and (4) succinctness (|proof| = polylog(|circuit|)).
1326pub fn cry_ext_zk_snark_ty() -> Expr {
1327 type0()
1328}
1329/// `ZkSnarkSuccinctness : ZkSnark โ Prop`
1330///
1331/// Succinctness: the proof size and verification time are poly-logarithmic
1332/// in the witness size and circuit complexity.
1333pub fn cry_ext_zk_snark_succinctness_ty() -> Expr {
1334 arrow(cry_ext_zk_snark_ty(), prop())
1335}
1336/// `ZkSnarkKnowledgeSoundness : ZkSnark โ Prop`
1337///
1338/// Knowledge soundness (argument of knowledge): if a prover can produce
1339/// an accepting proof, then an extractor can efficiently recover a valid
1340/// witness from the prover's internal state.
1341pub fn cry_ext_zk_snark_knowledge_ty() -> Expr {
1342 arrow(cry_ext_zk_snark_ty(), prop())
1343}
1344/// `ZkStark : Type`
1345///
1346/// A zk-STARK (zero-knowledge scalable transparent argument of knowledge):
1347/// like SNARKs but with transparent (no trusted) setup and post-quantum
1348/// security via hash functions. Verification is O(polylog n).
1349pub fn cry_ext_zk_stark_ty() -> Expr {
1350 type0()
1351}
1352/// `ZkStarkSoundness : ZkStark โ Prop`
1353///
1354/// STARK soundness: security relies only on collision-resistant hash
1355/// functions, providing post-quantum security without trusted setup.
1356pub fn cry_ext_zk_stark_soundness_ty() -> Expr {
1357 arrow(cry_ext_zk_stark_ty(), prop())
1358}
1359/// `SchnorrIdentification : Type`
1360///
1361/// Schnorr identification protocol (1989): a 3-move honest-verifier ZK
1362/// proof of knowledge of a discrete logarithm. The basis of Schnorr
1363/// signatures and EdDSA. Secure under the discrete log assumption.
1364pub fn cry_ext_schnorr_id_ty() -> Expr {
1365 type0()
1366}
1367/// `SchnorrSoundness : SchnorrIdentification โ Prop`
1368///
1369/// Special soundness of Schnorr: given two accepting transcripts (a, e, z)
1370/// and (a, e', z') with e โ e', an extractor can compute the witness x.
1371pub fn cry_ext_schnorr_soundness_ty() -> Expr {
1372 arrow(cry_ext_schnorr_id_ty(), prop())
1373}
1374/// `NizkProof : Type`
1375///
1376/// Non-interactive zero-knowledge (NIZK) proof: a single-message proof
1377/// obtained from an interactive proof via the Fiat-Shamir transform or
1378/// through a CRS (common reference string).
1379pub fn cry_ext_nizk_proof_ty() -> Expr {
1380 type0()
1381}
1382/// `NizkSimulationSoundness : NizkProof โ Prop`
1383///
1384/// Simulation soundness: a NIZK is simulation sound if an adversary cannot
1385/// produce a valid proof for a false statement, even after seeing simulated
1386/// proofs for false statements. Stronger than standard soundness.
1387pub fn cry_ext_nizk_sim_soundness_ty() -> Expr {
1388 arrow(cry_ext_nizk_proof_ty(), prop())
1389}
1390/// `BlakleySecretSharing : Nat โ Nat โ Type`
1391///
1392/// Blakley's threshold secret sharing (1979): geometrically represents
1393/// the secret as a point in (k-1)-dimensional space. Each share is a
1394/// hyperplane through that point; k hyperplanes intersect at the secret.
1395pub fn cry_ext_blakley_ss_ty() -> Expr {
1396 arrow(nat_ty(), arrow(nat_ty(), type0()))
1397}
1398/// `BlakleyCorrectness : Nat โ Nat โ Prop`
1399///
1400/// Correctness of Blakley's scheme: any k hyperplanes (shares) uniquely
1401/// determine the intersection point (the secret).
1402pub fn cry_ext_blakley_correct_ty() -> Expr {
1403 arrow(nat_ty(), arrow(nat_ty(), prop()))
1404}
1405/// `GarbledCircuit : Type`
1406///
1407/// A garbled circuit (Yao 1986): an encoding of a Boolean circuit C such
1408/// that a party can evaluate C(x) on an encrypted input x without learning
1409/// anything about x or the circuit beyond C(x). Foundation of secure 2PC.
1410pub fn cry_ext_garbled_circuit_ty() -> Expr {
1411 type0()
1412}
1413/// `GarbledCircuitSecurity : GarbledCircuit โ Prop`
1414///
1415/// Security of garbled circuits: the garbling reveals no information
1416/// about the circuit inputs or intermediate wire values, only the output.
1417/// Proven secure in the random oracle model.
1418pub fn cry_ext_garbled_circuit_sec_ty() -> Expr {
1419 arrow(cry_ext_garbled_circuit_ty(), prop())
1420}
1421/// `ObliviousRam : Nat โ Type`
1422///
1423/// Oblivious RAM (ORAM โ Goldreich-Ostrovsky 1996): a protocol for accessing
1424/// memory such that the access pattern reveals no information about which
1425/// locations are being accessed. Storage overhead: O(log^2 n) per access.
1426pub fn cry_ext_oram_ty() -> Expr {
1427 arrow(nat_ty(), type0())
1428}
1429/// `OramSecurity : Nat โ Prop`
1430///
1431/// ORAM security: the sequence of physical memory accesses is computationally
1432/// indistinguishable from a fixed access pattern independent of the actual
1433/// logical accesses.
1434pub fn cry_ext_oram_security_ty() -> Expr {
1435 arrow(nat_ty(), prop())
1436}
1437/// `VerifiableSecretSharing : Nat โ Nat โ Type`
1438///
1439/// Verifiable secret sharing (VSS โ Chor et al. 1985): extends Shamir's
1440/// secret sharing so that shareholders can verify their shares are consistent
1441/// (detecting a cheating dealer). Based on Pedersen commitments.
1442pub fn cry_ext_vss_ty() -> Expr {
1443 arrow(nat_ty(), arrow(nat_ty(), type0()))
1444}
1445/// `VssCorrectness : Nat โ Nat โ Prop`
1446///
1447/// VSS correctness: honest shareholders can always reconstruct the secret,
1448/// and dishonest shareholders' invalid shares are detected with overwhelming probability.
1449pub fn cry_ext_vss_correct_ty() -> Expr {
1450 arrow(nat_ty(), arrow(nat_ty(), prop()))
1451}
1452/// `PedersenHiding : Prop`
1453///
1454/// Perfect hiding property of Pedersen commitments: given a commitment
1455/// c = g^m * h^r, the distribution over c is independent of m (statistically
1456/// hiding). This holds unconditionally.
1457pub fn cry_ext_pedersen_hiding_ty() -> Expr {
1458 prop()
1459}
1460/// `PedersenBinding : Prop`
1461///
1462/// Computational binding of Pedersen commitments: no polynomial-time
1463/// adversary can open a commitment to two different messages. Security
1464/// reduces to the discrete logarithm problem.
1465pub fn cry_ext_pedersen_binding_ty() -> Expr {
1466 prop()
1467}
1468/// `ElgamalEncryption : Type`
1469///
1470/// ElGamal encryption (1985): a public-key scheme based on the computational
1471/// Diffie-Hellman assumption. Ciphertext is (g^r, m * g^{ar}) for public key
1472/// g^a and randomness r. Multiplicatively homomorphic.
1473pub fn cry_ext_elgamal_ty() -> Expr {
1474 type0()
1475}
1476/// `ElgamalHomomorphism : ElgamalEncryption โ Prop`
1477///
1478/// ElGamal multiplicative homomorphism: Enc(m1) * Enc(m2) = Enc(m1 * m2).
1479/// This allows multiplying plaintexts by operating on ciphertexts.
1480pub fn cry_ext_elgamal_hom_ty() -> Expr {
1481 arrow(cry_ext_elgamal_ty(), prop())
1482}
1483/// `ElgamalIndCpa : Prop`
1484///
1485/// IND-CPA security of ElGamal: under the Decisional Diffie-Hellman (DDH)
1486/// assumption, ElGamal is IND-CPA secure. Not IND-CCA secure as-is due to
1487/// the homomorphic property.
1488pub fn cry_ext_elgamal_ind_cpa_ty() -> Expr {
1489 prop()
1490}
1491/// `PaillierEncryption : Type`
1492///
1493/// Paillier encryption (1999): a public-key scheme with additive homomorphism.
1494/// Enc(m1) * Enc(m2) = Enc(m1 + m2). Security based on the Composite
1495/// Residuosity assumption.
1496pub fn cry_ext_paillier_ty() -> Expr {
1497 type0()
1498}
1499/// `PaillierAdditiveHom : PaillierEncryption โ Prop`
1500///
1501/// Additive homomorphism of Paillier: Enc(m1) * Enc(m2) mod n^2 decrypts
1502/// to m1 + m2 mod n. Enables privacy-preserving summation.
1503pub fn cry_ext_paillier_add_hom_ty() -> Expr {
1504 arrow(cry_ext_paillier_ty(), prop())
1505}
1506/// `ThresholdSignature : Nat โ Nat โ Type`
1507///
1508/// A (t, n)-threshold signature scheme: n parties share a signing key such
1509/// that any t parties can collaboratively produce a valid signature, but
1510/// fewer than t parties cannot sign. Used in multi-sig wallets and distributed key management.
1511pub fn cry_ext_threshold_sig_ty() -> Expr {
1512 arrow(nat_ty(), arrow(nat_ty(), type0()))
1513}
1514/// `ThresholdSigCorrectness : Nat โ Nat โ Prop`
1515///
1516/// Threshold signature correctness: any t-subset of parties can produce
1517/// a signature verifiable under the group public key.
1518pub fn cry_ext_threshold_sig_correct_ty() -> Expr {
1519 arrow(nat_ty(), arrow(nat_ty(), prop()))
1520}
1521/// `ThresholdSigSecurity : Nat โ Nat โ Prop`
1522///
1523/// Security of threshold signatures: a coalition of fewer than t corrupted
1524/// parties cannot forge a signature, under standard cryptographic assumptions.
1525pub fn cry_ext_threshold_sig_sec_ty() -> Expr {
1526 arrow(nat_ty(), arrow(nat_ty(), prop()))
1527}
1528/// `FrostsignatureScheme : Nat โ Type`
1529///
1530/// FROST (Flexible Round-Optimized Schnorr Threshold) signature: a
1531/// round-optimized threshold Schnorr signature scheme. Produces standard
1532/// Schnorr signatures compatible with EdDSA infrastructure.
1533pub fn cry_ext_frost_sig_ty() -> Expr {
1534 arrow(nat_ty(), type0())
1535}
1536/// Register all extended cryptography axioms into the kernel environment.
1537///
1538/// Adds axioms for: LWE/RLWE lattice hardness, NTRU, Kyber, Dilithium,
1539/// McEliece, XMSS, SPHINCS+, isogeny-based crypto, zk-SNARKs, zk-STARKs,
1540/// Schnorr, NIZK, Blakley, garbled circuits, ORAM, VSS, Pedersen, ElGamal,
1541/// Paillier, threshold signatures, FROST.
1542pub fn register_cryptography_extended(env: &mut Environment) -> Result<(), String> {
1543 let axioms: &[(&str, Expr)] = &[
1544 ("Crypto.LweHardness", cry_ext_lwe_hardness_ty()),
1545 ("Crypto.RlweHardness", cry_ext_rlwe_hardness_ty()),
1546 ("Crypto.LweEncScheme", cry_ext_lwe_enc_ty()),
1547 ("Crypto.LweEncCorrectness", cry_ext_lwe_enc_correct_ty()),
1548 ("Crypto.KyberKem", cry_ext_kyber_kem_ty()),
1549 ("Crypto.KyberIndCca2", cry_ext_kyber_ind_cca2_ty()),
1550 ("Crypto.NtruHardness", cry_ext_ntru_hardness_ty()),
1551 ("Crypto.DilithiumSig", cry_ext_dilithium_sig_ty()),
1552 ("Crypto.DilithiumEufCma", cry_ext_dilithium_euf_cma_ty()),
1553 ("Crypto.LinearCode", cry_ext_linear_code_ty()),
1554 ("Crypto.McElieceEncryption", cry_ext_mceliece_ty()),
1555 ("Crypto.McElieceHardness", cry_ext_mceliece_hardness_ty()),
1556 ("Crypto.SyndromeDecode", cry_ext_syndrome_decode_ty()),
1557 ("Crypto.XmssSig", cry_ext_xmss_sig_ty()),
1558 ("Crypto.XmssEufCma", cry_ext_xmss_euf_cma_ty()),
1559 ("Crypto.SphincsSig", cry_ext_sphincs_sig_ty()),
1560 ("Crypto.SphincsEufCma", cry_ext_sphincs_euf_cma_ty()),
1561 ("Crypto.WotsPlus", cry_ext_wots_plus_ty()),
1562 ("Crypto.Isogeny", cry_ext_isogeny_ty()),
1563 ("Crypto.SidhHardness", cry_ext_sidh_hardness_ty()),
1564 (
1565 "Crypto.SupersingularCurve",
1566 cry_ext_supersingular_curve_ty(),
1567 ),
1568 ("Crypto.ZkSnark", cry_ext_zk_snark_ty()),
1569 (
1570 "Crypto.ZkSnarkSuccinctness",
1571 cry_ext_zk_snark_succinctness_ty(),
1572 ),
1573 (
1574 "Crypto.ZkSnarkKnowledgeSoundness",
1575 cry_ext_zk_snark_knowledge_ty(),
1576 ),
1577 ("Crypto.ZkStark", cry_ext_zk_stark_ty()),
1578 ("Crypto.ZkStarkSoundness", cry_ext_zk_stark_soundness_ty()),
1579 ("Crypto.SchnorrIdentification", cry_ext_schnorr_id_ty()),
1580 ("Crypto.SchnorrSoundness", cry_ext_schnorr_soundness_ty()),
1581 ("Crypto.NizkProof", cry_ext_nizk_proof_ty()),
1582 (
1583 "Crypto.NizkSimulationSoundness",
1584 cry_ext_nizk_sim_soundness_ty(),
1585 ),
1586 ("Crypto.BlakleySecretSharing", cry_ext_blakley_ss_ty()),
1587 ("Crypto.BlakleyCorrectness", cry_ext_blakley_correct_ty()),
1588 ("Crypto.GarbledCircuit", cry_ext_garbled_circuit_ty()),
1589 (
1590 "Crypto.GarbledCircuitSecurity",
1591 cry_ext_garbled_circuit_sec_ty(),
1592 ),
1593 ("Crypto.ObliviousRam", cry_ext_oram_ty()),
1594 ("Crypto.OramSecurity", cry_ext_oram_security_ty()),
1595 ("Crypto.VerifiableSecretSharing", cry_ext_vss_ty()),
1596 ("Crypto.VssCorrectness", cry_ext_vss_correct_ty()),
1597 ("Crypto.PedersenHiding", cry_ext_pedersen_hiding_ty()),
1598 ("Crypto.PedersenBinding", cry_ext_pedersen_binding_ty()),
1599 ("Crypto.ElgamalEncryption", cry_ext_elgamal_ty()),
1600 ("Crypto.ElgamalHomomorphism", cry_ext_elgamal_hom_ty()),
1601 ("Crypto.ElgamalIndCpa", cry_ext_elgamal_ind_cpa_ty()),
1602 ("Crypto.PaillierEncryption", cry_ext_paillier_ty()),
1603 ("Crypto.PaillierAdditiveHom", cry_ext_paillier_add_hom_ty()),
1604 ("Crypto.ThresholdSignature", cry_ext_threshold_sig_ty()),
1605 (
1606 "Crypto.ThresholdSigCorrectness",
1607 cry_ext_threshold_sig_correct_ty(),
1608 ),
1609 (
1610 "Crypto.ThresholdSigSecurity",
1611 cry_ext_threshold_sig_sec_ty(),
1612 ),
1613 ("Crypto.FrostSignature", cry_ext_frost_sig_ty()),
1614 ];
1615 for (name, ty) in axioms {
1616 env.add(Declaration::Axiom {
1617 name: Name::str(*name),
1618 univ_params: vec![],
1619 ty: ty.clone(),
1620 })
1621 .ok();
1622 }
1623 Ok(())
1624}