diff --git a/sage/curve_family_bls12.sage b/sage/curve_family_bls12.sage index abe9223..701c8aa 100644 --- a/sage/curve_family_bls12.sage +++ b/sage/curve_family_bls12.sage @@ -1,3 +1,21 @@ +# Constantine +# Copyright (c) 2018-2019 Status Research & Development GmbH +# Copyright (c) 2020-Present Mamy André-Ratsimbazafy +# Licensed and distributed under either of +# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT). +# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0). +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +# ############################################################ +# +# BLS12 Curves parameters +# (Barreto-Lynn-Scott with embedding degree of 12) +# +# ############################################################ +# +# This module derives a BLS12 curve parameters from +# its base parameter u + def compute_curve_characteristic(u_str): u = sage_eval(u_str) p = (u - 1)^2 * (u^4 - u^2 + 1)//3 + u diff --git a/sage/curve_family_bn.sage b/sage/curve_family_bn.sage index 8945793..2a2a443 100644 --- a/sage/curve_family_bn.sage +++ b/sage/curve_family_bn.sage @@ -1,3 +1,21 @@ +# Constantine +# Copyright (c) 2018-2019 Status Research & Development GmbH +# Copyright (c) 2020-Present Mamy André-Ratsimbazafy +# Licensed and distributed under either of +# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT). +# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0). +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +# ############################################################ +# +# BN Curves parameters +# (Barreto-Naehrig curves) +# +# ############################################################ +# +# This module derives a BN curve parameters from +# its base parameter u + def compute_curve_characteristic(u_str): u = sage_eval(u_str) p = 36*u^4 + 36*u^3 + 24*u^2 + 6*u + 1 diff --git a/sage/non_residues.sage b/sage/non_residues.sage new file mode 100644 index 0000000..7f76199 --- /dev/null +++ b/sage/non_residues.sage @@ -0,0 +1,68 @@ +# Constantine +# Copyright (c) 2018-2019 Status Research & Development GmbH +# Copyright (c) 2020-Present Mamy André-Ratsimbazafy +# Licensed and distributed under either of +# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT). +# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0). +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +# ############################################################ +# +# Quadratic and Cubic Non-Residue +# +# ############################################################ +# +# This script checks the compatibility of a field modulus +# with given tower extensions + +# ############################################################ +# 1st try + +# # Create the field of x ∈ [0, p-1] +# K.
= NumberField(x - 1)
+#
+# # Tower Fp² with Fp[u] / (u² + 1) <=> u = 𝑖
+# L. = NumberField(x - 1)
+r1 = Fp(-1).residue_symbol(Fp.ideal(modulus),2)
+print('Fp² = Fp[sqrt(-1)]: ' + str(r1))
+
+Fp2.