From b5ae7ca4dd0acd2b73f22962f66f3d6528424768 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sat, 25 May 2013 19:19:22 +0200 Subject: [PATCH] algos_sig: added H=20 fmtseq variant ...that provide around 1 million signatures per key. That seems more than sufficient for human usage. Note that generating the key takes 16 times longer than for already present algorithms (that have H=16). On my computer, it is around 4 minutes for fmtseq128N20 and 16 minutes for fmtseq256N20. --- src/algo_suite.cpp | 28 +++++------- src/algos_sig.cpp | 112 +++++++++++++++++++++++++++++++++++++++++++++ src/algos_sig.h | 66 ++++++++++++++++++++++++++ 3 files changed, 189 insertions(+), 17 deletions(-) diff --git a/src/algo_suite.cpp b/src/algo_suite.cpp index 2de614a..6df2f2b 100644 --- a/src/algo_suite.cpp +++ b/src/algo_suite.cpp @@ -23,21 +23,15 @@ void fill_algorithm_suite (algorithm_suite&s) { - static algo_mceqd128 mce128; - mce128.register_into_suite (s); - - static algo_mceqd192 mce192; - mce192.register_into_suite (s); - - static algo_mceqd256 mce256; - mce256.register_into_suite (s); - - static algo_fmtseq128 fmt128; - fmt128.register_into_suite (s); - - static algo_fmtseq192 fmt192; - fmt192.register_into_suite (s); - - static algo_fmtseq256 fmt256; - fmt256.register_into_suite (s); +#define do_alg(x) static x var_##x ; var_##x.register_into_suite(s); + do_alg (algo_mceqd128); + do_alg (algo_mceqd192); + do_alg (algo_mceqd256); + do_alg (algo_fmtseq128); + do_alg (algo_fmtseq192); + do_alg (algo_fmtseq256); + do_alg (algo_fmtseq128h20); + do_alg (algo_fmtseq192h20); + do_alg (algo_fmtseq256h20); +#undef do_alg } diff --git a/src/algos_sig.cpp b/src/algos_sig.cpp index 41ba3c6..a1ae9c1 100644 --- a/src/algos_sig.cpp +++ b/src/algos_sig.cpp @@ -270,3 +270,115 @@ int algo_fmtseq256::create_keypair (sencode**pub, sencode**priv, prng&rng) return 0; } +/* + * h=20 variants for signature count 1048576. + * + * Chosen were parameters h=4,l=5 over the h=5,l=4 variant for smaller runtime + * space needed, as signature time is not really a concern here. + */ + +int algo_fmtseq128h20::sign (const bvector&msg, + bvector&sig, + sencode**privkey, + bool&dirty, + prng&rng) +{ + return fmtseq_generic_sign + <4, 5, 256, sha256hash, rmd128hash> + (msg, sig, privkey, dirty, rng); +} + +int algo_fmtseq128h20::verify (const bvector&sig, + const bvector&msg, + sencode*pubkey) +{ + return fmtseq_generic_verify + <4, 5, 256, sha256hash, rmd128hash> + (sig, msg, pubkey); +} + +int algo_fmtseq192h20::sign (const bvector&msg, + bvector&sig, + sencode**privkey, + bool&dirty, + prng&rng) +{ + return fmtseq_generic_sign + <4, 5, 384, sha384hash, tiger192hash> + (msg, sig, privkey, dirty, rng); +} + +int algo_fmtseq192h20::verify (const bvector&sig, + const bvector&msg, + sencode*pubkey) +{ + return fmtseq_generic_verify + <4, 5, 384, sha384hash, tiger192hash> + (sig, msg, pubkey); +} + +int algo_fmtseq256h20::sign (const bvector&msg, + bvector&sig, + sencode**privkey, + bool&dirty, + prng&rng) +{ + return fmtseq_generic_sign + <4, 5, 512, sha512hash, sha256hash> + (msg, sig, privkey, dirty, rng); +} + +int algo_fmtseq256h20::verify (const bvector&sig, + const bvector&msg, + sencode*pubkey) +{ + return fmtseq_generic_verify + <4, 5, 512, sha512hash, sha256hash> + (sig, msg, pubkey); +} + +int algo_fmtseq128h20::create_keypair (sencode**pub, sencode**priv, prng&rng) +{ + fmtseq::pubkey Pub; + fmtseq::privkey Priv; + + rmd128hash hf; + + if (fmtseq::generate (Pub, Priv, rng, hf, 256, 4, 5) ) + return 1; + + *pub = Pub.serialize(); + *priv = Priv.serialize(); + return 0; +} + +int algo_fmtseq192h20::create_keypair (sencode**pub, sencode**priv, prng&rng) +{ + fmtseq::pubkey Pub; + fmtseq::privkey Priv; + + tiger192hash hf; + + if (fmtseq::generate (Pub, Priv, rng, hf, 384, 4, 5) ) + return 1; + + *pub = Pub.serialize(); + *priv = Priv.serialize(); + return 0; +} + +int algo_fmtseq256h20::create_keypair (sencode**pub, sencode**priv, prng&rng) +{ + fmtseq::pubkey Pub; + fmtseq::privkey Priv; + + sha256hash hf; + + if (fmtseq::generate (Pub, Priv, rng, hf, 512, 4, 5) ) + return 1; + + *pub = Pub.serialize(); + *priv = Priv.serialize(); + return 0; +} + diff --git a/src/algos_sig.h b/src/algos_sig.h index c696d1e..42c966a 100644 --- a/src/algos_sig.h +++ b/src/algos_sig.h @@ -87,5 +87,71 @@ public: int create_keypair (sencode**pub, sencode**priv, prng&rng); }; +class algo_fmtseq128h20 : public algorithm +{ +public: + bool provides_signatures() { + return true; + } + + bool provides_encryption() { + return false; + } + + std::string get_alg_id() { + return "FMTSEQ128H20-SHA256-RIPEMD128"; + } + + virtual int sign (const bvector&msg, bvector&sig, + sencode** privkey, bool&dirty, prng&rng); + virtual int verify (const bvector&sig, const bvector&msg, + sencode* pubkey); + int create_keypair (sencode**pub, sencode**priv, prng&rng); +}; + +class algo_fmtseq192h20 : public algorithm +{ +public: + bool provides_signatures() { + return true; + } + + bool provides_encryption() { + return false; + } + + std::string get_alg_id() { + return "FMTSEQ192H20-SHA384-TIGER192"; + } + + virtual int sign (const bvector&msg, bvector&sig, + sencode** privkey, bool&dirty, prng&rng); + virtual int verify (const bvector&sig, const bvector&msg, + sencode* pubkey); + int create_keypair (sencode**pub, sencode**priv, prng&rng); +}; + +class algo_fmtseq256h20 : public algorithm +{ +public: + bool provides_signatures() { + return true; + } + + bool provides_encryption() { + return false; + } + + std::string get_alg_id() { + return "FMTSEQ256H20-SHA512-SHA256"; + } + + virtual int sign (const bvector&msg, bvector&sig, + sencode** privkey, bool&dirty, prng&rng); + virtual int verify (const bvector&sig, const bvector&msg, + sencode* pubkey); + int create_keypair (sencode**pub, sencode**priv, prng&rng); +}; + #endif