Browse Source

more rigorous tests. elligator still fails. problem: extracting xy is quite technical

master
Michael Hamburg 9 years ago
parent
commit
5a3fe27c03
2 changed files with 19 additions and 0 deletions
  1. +12
    -0
      include/decaf_255.hxx
  2. +7
    -0
      test/test_decaf.cxx

+ 12
- 0
include/decaf_255.hxx View File

@@ -107,6 +107,18 @@ public:
throw LengthException();
return Block(data()+off, length);
}
/* Content-wise comparison; constant-time if they are the same length.
* FIXME: is it wise to have a content-wise compare on objects that may be mutable?
*/
inline decaf_bool_t operator==(const Block &b) const NOEXCEPT {
return ~(*this != b);
}
inline decaf_bool_t operator!=(const Block &b) const NOEXCEPT {
if (b.size() != size()) return true;
return ~decaf_memeq(b,*this,size());
}

/** Virtual destructor for SecureBlock. TODO: probably means vtable? Make bool? */
inline virtual ~Block() {};


+ 7
- 0
test/test_decaf.cxx View File

@@ -215,6 +215,13 @@ static void test_ec() {
Point r = Point::from_hash(buffer);
point_check(test,p,q,r,0,0,p,Point((decaf::SecureBuffer)p),"round-trip");
Point pp = p;
(pp).debugging_torque_in_place();
if (decaf::SecureBuffer(pp) != decaf::SecureBuffer(p)) {
test.fail();
printf("Fail torque seq test\n");
}
point_check(test,p,q,r,0,0,p,pp,"torque eq");
point_check(test,p,q,r,0,0,p+q,q+p,"commute add");
point_check(test,p,q,r,0,0,(p-q)+q,p,"correct sub");
point_check(test,p,q,r,0,0,p+(q+r),(p+q)+r,"assoc add");


Loading…
Cancel
Save