From af41a3d3ae0915817f12b0afd6055fdb72621c7e Mon Sep 17 00:00:00 2001
From: Rudolf Polzer <divverent@xonotic.org>
Date: Fri, 9 Dec 2011 12:30:21 +0100
Subject: [PATCH] also add d0_blind_id_verify_private_id

---
 Makefile.am   |  2 +-
 configure.ac  |  2 +-
 d0_blind_id.c | 17 +++++++++++++++++
 d0_blind_id.h |  1 +
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 3cb22c7..99122c4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,7 @@ else
 libd0_blind_id_la_SOURCES += d0_bignum-gmp.c
 endif
 endif
-libd0_blind_id_la_LDFLAGS = -versioninfo 6:0:6
+libd0_blind_id_la_LDFLAGS = -versioninfo 7:0:7
 libd0_blind_id_la_CFLAGS = -fvisibility=hidden -Wold-style-definition -Wstrict-prototypes -Wsign-compare -Wdeclaration-after-statement
 library_includedir = $(includedir)/d0_blind_id
 library_include_HEADERS = d0_blind_id.h d0.h
diff --git a/configure.ac b/configure.ac
index 5c98c65..83a8258 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([d0_blind_id],[0.4],[divVerent@xonotic.org])
+AC_INIT([d0_blind_id],[0.5],[divVerent@xonotic.org])
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([-Wall foreign])
 AC_PROG_CC
diff --git a/d0_blind_id.c b/d0_blind_id.c
index 68d3c64..57ca8fd 100644
--- a/d0_blind_id.c
+++ b/d0_blind_id.c
@@ -1440,6 +1440,23 @@ fail:
 	return 0;
 }
 
+D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_verify_private_id(const d0_blind_id_t *ctx)
+{
+	USINGTEMPS(); // temps: temp0 = order, temp1 = g^s
+	USING(schnorr_G); USING(schnorr_s); USING(schnorr_g_to_s);
+
+	LOCKTEMPS();
+	CHECK(d0_dl_get_order(temp0, ctx->schnorr_G));
+	CHECK(d0_bignum_mod_pow(temp1, four, ctx->schnorr_s, ctx->schnorr_G));
+	CHECK(!d0_bignum_cmp(temp1, ctx->schnorr_g_to_s));
+	UNLOCKTEMPS();
+	return 1;
+
+fail:
+	UNLOCKTEMPS();
+	return 0;
+}
+
 d0_blind_id_t *d0_blind_id_new(void)
 {
 	d0_blind_id_t *b = d0_malloc(sizeof(d0_blind_id_t));
diff --git a/d0_blind_id.h b/d0_blind_id.h
index c4f772a..bf838f4 100644
--- a/d0_blind_id.h
+++ b/d0_blind_id.h
@@ -76,6 +76,7 @@ D0_EXPORT D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_sign_with_private_id_verify(
 D0_EXPORT D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_sign_with_private_id_verify_detached(d0_blind_id_t *ctx, D0_BOOL is_first, D0_BOOL recv_modulus, const char *inbuf, size_t inbuflen, const char *msg, size_t msglen, D0_BOOL *status);
 D0_EXPORT D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_fingerprint64_public_id(const d0_blind_id_t *ctx, char *outbuf, size_t *outbuflen);
 D0_EXPORT D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_verify_public_id(const d0_blind_id_t *ctx, D0_BOOL *status);
+D0_EXPORT D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_verify_private_id(const d0_blind_id_t *ctx);
 D0_EXPORT D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_sessionkey_public_id(const d0_blind_id_t *ctx, char *outbuf, size_t *outbuflen); // can only be done after successful key exchange, this performs a modpow; key length is limited by SHA_DIGESTSIZE for now; also ONLY valid after successful d0_blind_id_authenticate_with_private_id_verify/d0_blind_id_fingerprint64_public_id
 
 D0_EXPORT D0_WARN_UNUSED_RESULT D0_BOOL d0_blind_id_INITIALIZE(void);
-- 
2.39.5