Zero an mpz_t?

Marc Glisse marc.glisse at inria.fr
Mon Dec 19 10:54:47 CET 2011


On Sun, 18 Dec 2011, Christ Schlacta wrote:

> On 12/18/2011 12:56, Marc Glisse wrote:
>> On Sun, 18 Dec 2011, james at jamesbb.co.uk wrote:
>> 
>>> Hiya,
>>> 
>>> Is there a way to 'zero' an mpz_t integer, such that all of the bytes used 
>>> to
>>> store the number are overwritten?
>>> 
>>> I'm assuming that assigning the value of 0 will not do this, but I might 
>>> be
>>> mistaken!
>> 
>> Hello,
>> 
>> obviously, you can do it by hand (see 
>> http://gmplib.org/manual/Integer-Internals.html), but gmp doesn't provide 
>> an interface to do that because there is no (arithmetic) reason to do such 
>> a thing.
>> 
>> It is hard to give better advice without knowing what your exact goal is.
>> 
> I'd like to request an interface to do exactly what the OP requested,

In case you missed it in my message, it won't happen unless someone 
explains (convincingly) why this is useful.

> AND/OR to trim the internals to minimum storage requirements.

That seems completely unrelated. mpz_clear then mpz_init? Or if you want 
to keep the value, mpz_init_set a new variable, mpz_swap and mpz_clear.

> The reasons are purely application design time.

?

-- 
Marc Glisse


More information about the gmp-discuss mailing list