diff --git a/src/fmtseq.cpp b/src/fmtseq.cpp new file mode 100644 index 0000000..925dec3 --- /dev/null +++ b/src/fmtseq.cpp @@ -0,0 +1,21 @@ + +/* + * This file is part of Codecrypt. + * + * Codecrypt is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Codecrypt is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Codecrypt. If not, see . + */ + +#include "fmtseq.h" + + diff --git a/src/fmtseq.h b/src/fmtseq.h index 97d478a..2c03201 100644 --- a/src/fmtseq.h +++ b/src/fmtseq.h @@ -19,6 +19,14 @@ #ifndef _fmtseq_h_ #define _fmtseq_h_ +#include +#include +#include "types.h" +#include "bvector.h" +#include "sencode.h" +#include "hash.h" +#include "prng.h" + /* * FMTseq - Merkle signatures with fractal tree traversal, using original * Lamport signatures for speed. @@ -30,24 +38,23 @@ class privkey { public: std::vector SK; //secret key - uint h, l; + uint h, l; //l=level count, h=level height (root-leaf path length) + //therefore, H = h*l uint sigs_used; - //FMT cache - std::vector > > node_cache; + //FMT caches + std::vector > exist; + std::vector > desired; + std::vector > desired_stack; int sign (const bvector&, bvector&, hash_func&); uint sigs_remaining() { - return (1 << h) - sigs_used; + return (1 << () ) - sigs_used; } - uint hash_size (hash_func&) { - hf.size(); - } - - uint signature_size (hash_func&) { - //TODO + uint hash_size (hash_func&hf) { + return hf.size() * 8; } sencode* serialize(); @@ -58,14 +65,12 @@ class pubkey { public: std::vector check; //tree top verification hash - uint h; + uint H; - uint hash_size() { - return hf.size(); - } + int verify (const bvector&, const bvector&, hash_func&); - uint signature_size() { - //TODO + uint hash_size (hash_func&hf) { + return hf.size() * 8; } sencode* serialize(); diff --git a/src/hash.h b/src/hash.h index d0a6e16..99af329 100644 --- a/src/hash.h +++ b/src/hash.h @@ -29,7 +29,7 @@ class hash_func { public: virtual std::vector operator() (const std::vector&) = 0; - virtual uint size(); + virtual uint size(); //in bytes }; #endif