Skip to content
Snippets Groups Projects
Unverified Commit e9e3a68c authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

Raise the stack limit while validating the proof

We don't need to mess with the Python stack limit.  The proof is validated in
Rust.  We just need to offer more stack space to the Rust implementation.
parent 9ba0e334
No related branches found
No related tags found
1 merge request!94Hard-code larger token count
......@@ -41,6 +41,15 @@ from base64 import (
b64encode,
b64decode,
)
from contextlib import (
contextmanager,
)
from resource import (
RLIMIT_STACK,
getrlimit,
setrlimit,
)
import attr
from zope.interface import (
......@@ -469,6 +478,8 @@ class RistrettoRedeemer(object):
clients_proof = privacypass.BatchDLEQProof.decode_base64(
marshaled_proof.encode("ascii"),
)
with unlimited_stack():
self._log.info("Decoded batch proof")
clients_unblinded_tokens = clients_proof.invalid_or_unblind(
random_tokens,
blinded_tokens,
......@@ -795,3 +806,16 @@ def bracket(first, last, between):
else:
yield last()
returnValue(result)
@contextmanager
def unlimited_stack():
"""
A context manager which removes the resource limit on stack size for
execution of the context.
"""
soft, hard = getrlimit(RLIMIT_STACK)
# We can raise the soft limit to the hard limit and no higher.
setrlimit(RLIMIT_STACK, (hard, hard))
yield
setrlimit(RLIMIT_STACK, (soft, hard))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment