This commit is contained in:
NikVolf
2019-03-13 12:27:07 +03:00
parent 8eac5b8a10
commit 4470c2ecfc
2 changed files with 17 additions and 8 deletions
+8 -8
View File
@@ -689,13 +689,13 @@ fn test_miller_loop() {
assert_eq!(gt,
Fq12::new(Fq6::new(
Fq2::new(Fq::from_str("14551901853310307118181117653102171756020286507151693083446930124375536995872").unwrap(), Fq::from_str("9312135802322424742640599513015426415694425842442244572104764725304978020017").unwrap()),
Fq2::new(Fq::from_str("2008578374540014049115224515107136454624926345291695498760935593377832328658").unwrap(), Fq::from_str("19401931167387470703307774451905975977586101231060812348184567722817888018105").unwrap()),
Fq2::new(Fq::from_str("14551901853310307118181117653102171756020286507151693083446930124375536995872").unwrap(), Fq::from_str("9312135802322424742640599513015426415694425842442244572104764725304978020017").unwrap()),
Fq2::new(Fq::from_str("2008578374540014049115224515107136454624926345291695498760935593377832328658").unwrap(), Fq::from_str("19401931167387470703307774451905975977586101231060812348184567722817888018105").unwrap()),
Fq2::new(Fq::from_str("15835061253582829097893482726334173316772697321004871665993836763948321578465").unwrap(), Fq::from_str("2434436628082562384254182545550914004674636606111293955202388712261962820365").unwrap())
),
Fq6::new(
Fq2::new(Fq::from_str("2874440054453559166574356420729655370224872280550180463983603224123901706537").unwrap(), Fq::from_str("21199736323249863378180814900160978651989782296293186487853700340281870105680").unwrap()),
Fq2::new(Fq::from_str("19165582755854282767090326095669835261356341739532443976394958023142879015770").unwrap(), Fq::from_str("1381947898997178910398427566832118260186305708991760706544743699683050330259").unwrap()),
Fq2::new(Fq::from_str("2874440054453559166574356420729655370224872280550180463983603224123901706537").unwrap(), Fq::from_str("21199736323249863378180814900160978651989782296293186487853700340281870105680").unwrap()),
Fq2::new(Fq::from_str("19165582755854282767090326095669835261356341739532443976394958023142879015770").unwrap(), Fq::from_str("1381947898997178910398427566832118260186305708991760706544743699683050330259").unwrap()),
Fq2::new(Fq::from_str("282285618133171001983721596014922591835675934808772882476123488581876545578").unwrap(), Fq::from_str("9533292755262567365755835323107174518472361243562718718917822947506880920117").unwrap())
)
)
@@ -1017,15 +1017,15 @@ fn predefined_pair() {
let g2 = AffineG2::new(
Fq2::new(
Fq::from_str("10857046999023057135944570762232829481370756359578518086990519993285655852781")
.expect("a-coeff of g2 x generator is of the right order"),
.expect("a-coeff of g2 x generator is of the right order"),
Fq::from_str("11559732032986387107991004021392285783925812861821192530917403151452391805634")
.expect("b-coeff of g2 x generator is of the right order"),
.expect("b-coeff of g2 x generator is of the right order"),
),
Fq2::new(
Fq::from_str("8495653923123431417604973247489272438418190587263600148770280649306958101930")
.expect("a-coeff of g2 y generator is of the right order"),
.expect("a-coeff of g2 y generator is of the right order"),
Fq::from_str("4082367875863433681332203403145435568316851327593401208105741076214120093531")
.expect("b-coeff of g2 y generator is of the right order"),
.expect("b-coeff of g2 y generator is of the right order"),
),
).expect("Point(11559732032986387107991004021392285783925812861821192530917403151452391805634 * i + 10857046999023057135944570762232829481370756359578518086990519993285655852781, 4082367875863433681332203403145435568316851327593401208105741076214120093531 * i + 8495653923123431417604973247489272438418190587263600148770280649306958101930) is a valid generator for G2")
.to_jacobian();
+9
View File
@@ -190,6 +190,10 @@ impl Fq2 {
Fq2(fields::Fq2::one())
}
pub fn i() -> Fq2 {
Fq2::new(Fq::zero(), Fq::one())
}
pub fn zero() -> Fq2 {
Fq2(fields::Fq2::zero())
}
@@ -202,9 +206,14 @@ impl Fq2 {
pub fn is_zero(&self) -> bool {
self.0.is_zero()
}
pub fn pow(&self, exp: Fq) -> Self {
Fq2(self.0.pow(exp.0))
}
pub fn neg(&self) -> Self {
Fq2(self.0.neg())
}
}
pub trait Group