Python¶
RNS polynomial arithmetic over Z_q[X]/(X^N+1) (Ring, Polynomial), finite fields and their vectors (Field, FieldElement, FieldVector), and multilinear extensions over any of them (MLE, SparseMLE).
Ring(N, bits, split_degree=...) resolves to an implementation through the
registry (resolve, implementations, backends): RNSRing is the one every
scheme computes in, ComplexRing the CKKS encoder’s, ExtensionField and
PseudoMersenneField the SNARK stack’s. On a ring or a field, random_*
returns a new element; on an element or a vector, sample_* overwrites it
in place. Every sampler takes a random= source (vfhe.crypto.random.Random), the
entropy stream by default. Implementations cache native state per process;
reset_state empties the caches.
>>> from vfhe.arith import Ring
>>> ring = Ring(256, 120, split_degree=1)
>>> a, b = ring.random_element(), ring.random_element()
>>> (a + b) - b == a
True