Skip to content

mapToG1/mapToG2が全域関数になってないのは何か理由がありますか? #235

@kik

Description

@kik

エラー処理が必要になるので、できれば全域関数だとうれしいです。

論文 P.-A. Fouque and M. Tibouchi, "Indifferentiable hashing to Barreto Naehrig curves," を読んだ感じだと

Definition 2によるとt=0のときは適当な点を返すようにしてよいが、((-1+√3)/2, √(1+b))を使うとわりと自然じゃないかと書いてあります。
注3によると、1+bが平方でないときは残りの2つの点も拡張しないとだめと書いてあります。

ただ、注3は微妙におかしくて、1+bが平方でないときは上で割と自然と書いた((-1+√3)/2, √(1+b))も使えないので、3点とも新たに考えないといけなさそうです。

とりあえず途中まで書いて実験してみたので貼っておきます(1+bが平方のときのt=0しかたぶん動きません)。

	/*
		P.-A. Fouque and M. Tibouchi,
		"Indifferentiable hashing to Barreto Naehrig curves,"
		in Proc. Int. Conf. Cryptol. Inform. Security Latin Amer., 2012, vol. 7533, pp.1-17.

		w = sqrt(-3) t / (1 + b + t^2)
		Remark: throw exception if t = 0, c1, -c1 and b = 2
	*/
	template<class G, class F>
	bool calcBN(G& P, const F& t) const
	{
		F x, y, w;
		bool b;
		bool negative = legendre(&b, t) < 0;
		if (!b) return false;
		if (t.isZero()) {
			x.clear();
			*x.getFp0() += c2_;
			y = G::b_;
			*y.getFp0() += Fp::one();
			if (!F::squareRoot(y, y)) return false;
			P.set(&b, x, y, false);
			assert(b);
			return true;
		}
		F::sqr(w, t);
		w += G::b_;
		*w.getFp0() += Fp::one();
		if (w.isZero()) return false;
		F::inv(w, w);
		mulFp(w, c1_);
		w *= t;
		for (int i = 0; i < 3; i++) {
			switch (i) {
			case 0: F::mul(x, t, w); F::neg(x, x); *x.getFp0() += c2_; break;
			case 1: F::neg(x, x); *x.getFp0() -= Fp::one(); break;
			case 2: F::sqr(x, w); F::inv(x, x); *x.getFp0() += Fp::one(); break;
			}
			G::getWeierstrass(y, x);
			if (F::squareRoot(y, y)) {
				if (negative) F::neg(y, y);
				P.set(&b, x, y, false);
				assert(b);
				return true;
			}
		}
		return false;
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions