Skip to content

store pqcrystals polynomial in secure memory - #5362

Open
falko-strenzke wants to merge 2 commits into
masterfrom
polynomial-secmem
Open

store pqcrystals polynomial in secure memory#5362
falko-strenzke wants to merge 2 commits into
masterfrom
polynomial-secmem

Conversation

@falko-strenzke

Copy link
Copy Markdown
Collaborator

No description provided.

@reneme

reneme commented Feb 19, 2026

Copy link
Copy Markdown
Collaborator

Note that the PolynomialVector class is tightly coupled with the Polynomial class in a sense that it can borrow its byte storage (that's what the redundant std::span is for). I.e. also the std::vector in the PolynomialVector should be replaced by secure_vector then.

@randombit

Copy link
Copy Markdown
Owner

How much does this affect performance?

@randombit

Copy link
Copy Markdown
Owner

Actually @reneme isn't this always of known length namely Trait::N? Why not a std::array?

@reneme

reneme commented Feb 23, 2026

Copy link
Copy Markdown
Collaborator

Actually @reneme isn't this always of known length namely Trait::N? Why not a std::array?

This was done to allow the Polynomial class to borrow its storage from the PolynomialVector, in which case the array would just be wasted stack space. Essentially, instances of polynomials can be free-standing (owning their own storage in the std::vector) or part of a vector of polynomials where the storage is coalesced into a single (appropriately larger) std::vector in the outer PolynomialVector instance. I'm not 100% sure anymore why we added this complexity, frankly. I believe it was faster.

Anyway, the computation is always implemented over the std::span<T, Trait::N> to let the compiler leverage the statically known bounds.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 90.335% (-1.6%) from 91.974%
when pulling b312daa on polynomial-secmem
into b4032cd on master.

@falko-strenzke
falko-strenzke marked this pull request as ready for review February 24, 2026 13:17
@falko-strenzke

Copy link
Copy Markdown
Collaborator Author

How much does this affect performance?

I tried to measure performance with the speed test. The natural variation of the timings is so large that observing any performance impact is impossible. If the performance aspect is really so important here, I would have to ask for the preferred exact method to measure it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants