monotone

monotone Mtn Source Tree

Root/botan/blinding.cpp

1/*************************************************
2* Blinder Source File *
3* (C) 1999-2007 The Botan Project *
4*************************************************/
5
6#include <botan/blinding.h>
7#include <botan/numthry.h>
8
9namespace Botan {
10
11/*************************************************
12* Blinder Constructor *
13*************************************************/
14Blinder::Blinder(const BigInt& e, const BigInt& d, const BigInt& n)
15 {
16 if(e < 1 || d < 1 || n < 1)
17 throw Invalid_Argument("Blinder: Arguments too small");
18
19 reducer = Modular_Reducer(n);
20 this->e = e;
21 this->d = d;
22 }
23
24/*************************************************
25* Blind a number *
26*************************************************/
27BigInt Blinder::blind(const BigInt& i) const
28 {
29 if(!reducer.initialized())
30 return i;
31
32 e = reducer.square(e);
33 d = reducer.square(d);
34 return reducer.multiply(i, e);
35 }
36
37/*************************************************
38* Unblind a number *
39*************************************************/
40BigInt Blinder::unblind(const BigInt& i) const
41 {
42 if(!reducer.initialized())
43 return i;
44 return reducer.multiply(i, d);
45 }
46
47}

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status