コード例 #1
0
void eb_mul_sim_gen(eb_t r, const bn_t k, const eb_t q, const bn_t m) {
	eb_t g;

	eb_null(g);

	if (bn_is_zero(k)) {
		eb_mul(r, q, m);
		return;
	}
	if (bn_is_zero(m) || eb_is_infty(q)) {
		eb_mul_gen(r, k);
		return;
	}

	TRY {
		eb_new(g);

		eb_curve_get_gen(g);

#if defined(EB_KBLTZ)
#if EB_SIM == INTER && EB_FIX == LWNAF && defined(EB_PRECO)
		if (eb_curve_is_kbltz()) {
			eb_mul_sim_kbltz(r, g, k, q, m, eb_curve_get_tab());
		}
#else
		if (eb_curve_is_kbltz()) {
			eb_mul_sim(r, g, k, q, m);
		}
#endif
#endif

#if defined(EB_PLAIN)
#if EB_SIM == INTER && EB_FIX == LWNAF && defined(EB_PRECO)
		if (!eb_curve_is_kbltz()) {
			eb_mul_sim_plain(r, g, k, q, m, eb_curve_get_tab());
		}
#else
		if (!eb_curve_is_kbltz()) {
			eb_mul_sim(r, g, k, q, m);
		}
#endif
#endif
	}
	CATCH_ANY {
		THROW(ERR_CAUGHT);
	}
	FINALLY {
		eb_free(g);
	}
}
コード例 #2
0
void eb_curve_set_ordin(fb_t a, fb_t b, eb_t g, bn_t r, bn_t h) {
	fb_copy(curve_a, a);
	fb_copy(curve_b, b);

	detect_opt(&curve_opt_a, curve_a);
	detect_opt(&curve_opt_b, curve_b);

	curve_is_super = 0;
	if (fb_cmp_dig(curve_b, 1) == CMP_EQ) {
		curve_is_kbltz = 1;
	} else {
		curve_is_kbltz = 0;
	}
#if defined(EB_KBLTZ) && (EB_MUL == LWNAF || EB_FIX == LWNAF || EB_SIM == INTER || !defined(STRIP))
	if (curve_is_kbltz) {
		compute_kbltz();
	}
#endif

	eb_norm(g, g);
	eb_copy(&curve_g, g);
	bn_copy(&curve_r, r);
	bn_copy(&curve_h, h);
#if defined(EB_PRECO)
	eb_mul_pre(eb_curve_get_tab(), &curve_g);
#endif
}
コード例 #3
0
ファイル: relic_eb_curve.c プロジェクト: ekr/hacrypto
void eb_curve_set_ordin(const fb_t a, const fb_t b, const eb_t g, const bn_t r,
		const bn_t h) {
	ctx_t *ctx = core_get();
	fb_copy(ctx->eb_a, a);
	fb_copy(ctx->eb_b, b);

	detect_opt(&(ctx->eb_opt_a), ctx->eb_a);
	detect_opt(&(ctx->eb_opt_b), ctx->eb_b);

	ctx->eb_is_super = 0;
	if (fb_cmp_dig(ctx->eb_b, 1) == CMP_EQ) {
		ctx->eb_is_kbltz = 1;
	} else {
		ctx->eb_is_kbltz = 0;
	}
#if defined(EB_KBLTZ) && (EB_MUL == LWNAF || EB_FIX == LWNAF || EB_SIM == INTER || !defined(STRIP))
	if (ctx->eb_is_kbltz) {
		compute_kbltz();
	}
#endif

	eb_norm(&(ctx->eb_g), g);
	bn_copy(&(ctx->eb_r), r);
	bn_copy(&(ctx->eb_h), h);
#if defined(EB_PRECO)
	eb_mul_pre((eb_t *)eb_curve_get_tab(), &(ctx->eb_g));
#endif
}
コード例 #4
0
void eb_curve_set_super(fb_t a, fb_t b, fb_t c, eb_t g, bn_t r, bn_t h) {
	curve_is_kbltz = 0;
	curve_is_super = 1;

	fb_copy(curve_a, a);
	fb_copy(curve_b, b);
	fb_copy(curve_c, c);

	detect_opt(&curve_opt_a, curve_a);
	detect_opt(&curve_opt_b, curve_b);
	detect_opt(&curve_opt_c, curve_c);

	eb_norm(g, g);
	eb_copy(&curve_g, g);
	bn_copy(&curve_r, r);
	bn_copy(&curve_h, h);
#if defined(EB_PRECO)
	eb_mul_pre(eb_curve_get_tab(), &curve_g);
#endif
}
コード例 #5
0
void eb_curve_set_kbltz(fb_t a, eb_t g, bn_t r, bn_t h) {
	curve_is_kbltz = 1;
	curve_is_super = 0;

	fb_copy(curve_a, a);
	fb_set_dig(curve_b, 1);

	detect_opt(&curve_opt_a, curve_a);
	detect_opt(&curve_opt_b, curve_b);

#if EB_MUL == LWNAF || EB_FIX == LWNAF || EB_SIM == INTER || !defined(STRIP)
	compute_kbltz();
#endif
	eb_norm(g, g);
	eb_copy(&curve_g, g);
	bn_copy(&curve_r, r);
	bn_copy(&curve_h, h);
#if defined(EB_PRECO)
	eb_mul_pre(eb_curve_get_tab(), &curve_g);
#endif
}
コード例 #6
0
ファイル: relic_eb_curve.c プロジェクト: ekr/hacrypto
void eb_curve_set_super(const fb_t a, const fb_t b, const fb_t c, const eb_t g,
		const bn_t r, const bn_t h) {
	ctx_t *ctx = core_get();

	ctx->eb_is_kbltz = 0;
	ctx->eb_is_super = 1;

	fb_copy(ctx->eb_a, a);
	fb_copy(ctx->eb_b, b);
	fb_copy(ctx->eb_c, c);

	detect_opt(&(ctx->eb_opt_a), ctx->eb_a);
	detect_opt(&(ctx->eb_opt_b), ctx->eb_b);
	detect_opt(&(ctx->eb_opt_c), ctx->eb_c);

	eb_norm(&(ctx->eb_g), g);
	bn_copy(&(ctx->eb_r), r);
	bn_copy(&(ctx->eb_h), h);
#if defined(EB_PRECO)
	eb_mul_pre((eb_t *)eb_curve_get_tab(), &(ctx->eb_g));
#endif
}
コード例 #7
0
ファイル: relic_eb_curve.c プロジェクト: ekr/hacrypto
void eb_curve_set_kbltz(const fb_t a, const eb_t g, const bn_t r, const bn_t h) {
	ctx_t *ctx = core_get();

	ctx->eb_is_kbltz = 1;
	ctx->eb_is_super = 0;

	fb_copy(ctx->eb_a, a);
	fb_set_dig(ctx->eb_b, 1);

	detect_opt(&(ctx->eb_opt_a), ctx->eb_a);
	detect_opt(&(ctx->eb_opt_b), ctx->eb_b);

#if EB_MUL == LWNAF || EB_FIX == LWNAF || EB_SIM == INTER || !defined(STRIP)
	compute_kbltz();
#endif
	eb_norm(&(ctx->eb_g), g);
	bn_copy(&(ctx->eb_r), r);
	bn_copy(&(ctx->eb_h), h);
#if defined(EB_PRECO)
	eb_mul_pre((eb_t *)eb_curve_get_tab(), &(ctx->eb_g));
#endif
}