Browse Source

repent of that templating wickedness. at least until i can figure out the right way to do it

master
Michael Hamburg 10 years ago
parent
commit
0fc9ab3c8c
4 changed files with 432 additions and 649 deletions
  1. +420
    -637
      include/decaf.hxx
  2. +3
    -3
      include/shake.hxx
  3. +3
    -3
      test/bench_decaf.cxx
  4. +6
    -6
      test/test_decaf.cxx

+ 420
- 637
include/decaf.hxx
File diff suppressed because it is too large
View File


+ 3
- 3
include/shake.hxx View File

@@ -192,11 +192,11 @@ private:
}; };


/**@cond internal*/ /**@cond internal*/
template<GroupId g> EcGroup<g>::Scalar::Scalar(SpongeRng &rng) NOEXCEPT {
*this = rng.read(EcGroup<g>::Scalar::SER_BYTES);
inline Ed448::Scalar::Scalar(SpongeRng &rng) NOEXCEPT {
*this = rng.read(SER_BYTES);
} }


template<GroupId g> EcGroup<g>::Point::Point(SpongeRng &rng, bool uniform) NOEXCEPT {
inline Ed448::Point::Point(SpongeRng &rng, bool uniform) NOEXCEPT {
SecureBuffer buffer((uniform ? 2 : 1) * HASH_BYTES); SecureBuffer buffer((uniform ? 2 : 1) * HASH_BYTES);
rng.read(buffer); rng.read(buffer);
set_to_hash(buffer); set_to_hash(buffer);


+ 3
- 3
test/bench_decaf.cxx View File

@@ -21,9 +21,9 @@
#include <algorithm> #include <algorithm>


using namespace decaf; using namespace decaf;
typedef EcGroup<448>::Scalar Scalar;
typedef EcGroup<448>::Point Point;
typedef EcGroup<448>::Precomputed Precomputed;
typedef Ed448::Scalar Scalar;
typedef Ed448::Point Point;
typedef Ed448::Precomputed Precomputed;




static __inline__ void __attribute__((unused)) ignore_result ( int result ) { (void)result; } static __inline__ void __attribute__((unused)) ignore_result ( int result ) { (void)result; }


+ 6
- 6
test/test_decaf.cxx View File

@@ -40,11 +40,11 @@ public:
} }
}; };


template<decaf::GroupId GROUP> struct Tests {
template<typename Group> struct Tests {


typedef typename decaf::EcGroup<GROUP>::Scalar Scalar;
typedef typename decaf::EcGroup<GROUP>::Point Point;
typedef typename decaf::EcGroup<GROUP>::Precomputed Precomputed;
typedef typename Group::Scalar Scalar;
typedef typename Group::Point Point;
typedef typename Group::Precomputed Precomputed;


static void print(const char *name, const Scalar &x) { static void print(const char *name, const Scalar &x) {
unsigned char buffer[Scalar::SER_BYTES]; unsigned char buffer[Scalar::SER_BYTES];
@@ -199,8 +199,8 @@ static void test_ec() {
int main(int argc, char **argv) { int main(int argc, char **argv) {
(void) argc; (void) argv; (void) argc; (void) argv;
Tests<448>::test_arithmetic();
Tests<448>::test_ec();
Tests<decaf::Ed448>::test_arithmetic();
Tests<decaf::Ed448>::test_ec();
if (passing) printf("Passed all tests.\n"); if (passing) printf("Passed all tests.\n");


Loading…
Cancel
Save