eprecomp.h

来自「VC实现的200种加密和解密的算法」· C头文件 代码 · 共 44 行

H
44
字号
#ifndef CRYPTOPP_EPRECOMP_H
#define CRYPTOPP_EPRECOMP_H

#include "integer.h"
#include <vector>

NAMESPACE_BEGIN(CryptoPP)

// Please do not directly use the following class.  It should be
// considered a private class for the library.  The following
// classes are public and use ExponentiationPrecomputation internally.
//
// ModExpPrecomputation;
// EcPrecomputation<EC2N>;
// EcPrecomputation<ECP>;

template <class T> class ExponentiationPrecomputation
{
public:
	typedef T Group;
	typedef typename Group::Element Element;

	ExponentiationPrecomputation(const Group &group) : group(group) {}

	ExponentiationPrecomputation(const Group &group, const Element &base, unsigned int maxExpBits, unsigned int storage)
		: group(group), storage(storage), g(storage) {Precompute(base, maxExpBits);}

	ExponentiationPrecomputation(const Group &group, const ExponentiationPrecomputation &pc)
		: group(group), storage(pc.storage), exponentBase(pc.exponentBase), g(pc.g)	{}

	void Precompute(const Element &base, unsigned int maxExpBits);
	Element Exponentiate(const Integer &exponent) const;
	Element CascadeExponentiate(const Integer &exponent, const ExponentiationPrecomputation<Group> &pc2, const Integer &exponent2) const;

	const Group &group;
	unsigned int storage;	// number of precalculated bases
	Integer exponentBase;	// what base to represent the exponent in
	std::vector<Element> g;		// precalculated bases
};

NAMESPACE_END

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?