Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLS12 final exponentiation (eprint 2020/875) #29

Merged
merged 3 commits into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 21 additions & 30 deletions bls377/pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func FinalExponentiation(z *GT, _z ...*GT) GT {
}

// https://eprint.iacr.org/2016/130.pdf
var t [6]GT
var t [3]GT

// easy part
t[0].Conjugate(&result)
Expand All @@ -71,36 +71,27 @@ func FinalExponentiation(z *GT, _z ...*GT) GT {
Mul(&result, &t[0])

// hard part (up to permutation)
t[0].InverseUnitary(&result).Square(&t[0])
t[5].Expt(&result)
t[1].CyclotomicSquare(&t[5])
t[3].Mul(&t[0], &t[5])

t[0].Expt(&t[3])
// Daiki Hayashida and Kenichiro Hayasaka
// and Tadanori Teruya
// https://eprint.iacr.org/2020/875.pdf
t[0].CyclotomicSquare(&result)
t[1].Expt(&result)
t[2].InverseUnitary(&result)
t[1].Mul(&t[1], &t[2])
t[2].Expt(&t[1])
t[1].InverseUnitary(&t[1])
t[1].Mul(&t[1], &t[2])
t[2].Expt(&t[1])
t[1].Frobenius(&t[1])
t[1].Mul(&t[1], &t[2])
result.Mul(&result, &t[0])
t[0].Expt(&t[1])
t[2].Expt(&t[0])
t[4].Expt(&t[2])

t[4].Mul(&t[1], &t[4])
t[1].Expt(&t[4])
t[3].InverseUnitary(&t[3])
t[1].Mul(&t[3], &t[1])
t[1].Mul(&t[1], &result)

t[0].Mul(&t[0], &result)
t[0].FrobeniusCube(&t[0])

t[3].InverseUnitary(&result)
t[4].Mul(&t[3], &t[4])
t[4].Frobenius(&t[4])

t[5].Mul(&t[2], &t[5])
t[5].FrobeniusSquare(&t[5])

t[5].Mul(&t[5], &t[0])
t[5].Mul(&t[5], &t[4])
t[5].Mul(&t[5], &t[1])

result.Set(&t[5])
t[0].FrobeniusSquare(&t[1])
t[1].InverseUnitary(&t[1])
t[1].Mul(&t[1], &t[2])
t[1].Mul(&t[1], &t[0])
result.Mul(&result, &t[1])

return result
}
Expand Down
33 changes: 15 additions & 18 deletions bls381/pairing.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func FinalExponentiation(z *GT, _z ...*GT) GT {
result.Mul(&result, e)
}

var t [4]GT
var t [3]GT

// easy part
t[0].Conjugate(&result)
Expand All @@ -68,30 +68,27 @@ func FinalExponentiation(z *GT, _z ...*GT) GT {
Mul(&result, &t[0])

// hard part (up to permutation)
// Alg.2 from https://eprint.iacr.org/2016/130.pdf
// Daiki Hayashida and Kenichiro Hayasaka
// and Tadanori Teruya
// https://eprint.iacr.org/2020/875.pdf
t[0].CyclotomicSquare(&result)
t[1].Expt(&t[0])
t[2].ExptHalf(&t[1])
t[3].InverseUnitary(&result)
t[1].Mul(&t[1], &t[3])
t[1].InverseUnitary(&t[1])
t[1].ExptHalf(&t[0])
t[2].InverseUnitary(&result)
t[1].Mul(&t[1], &t[2])
t[2].Expt(&t[1])
t[3].Expt(&t[2])
t[1].InverseUnitary(&t[1])
t[3].Mul(&t[1], &t[3])
t[1].InverseUnitary(&t[1])
t[1].FrobeniusCube(&t[1])
t[2].FrobeniusSquare(&t[2])
t[1].Mul(&t[1], &t[2])
t[2].Expt(&t[3])
t[2].Mul(&t[2], &t[0])
t[2].Mul(&t[2], &result)
t[2].Expt(&t[1])
t[1].Frobenius(&t[1])
t[1].Mul(&t[1], &t[2])
t[2].Frobenius(&t[3])
result.Mul(&result, &t[0])
t[0].Expt(&t[1])
t[2].Expt(&t[0])
t[0].FrobeniusSquare(&t[1])
t[1].InverseUnitary(&t[1])
t[1].Mul(&t[1], &t[2])

result.Set(&t[1])
t[1].Mul(&t[1], &t[0])
result.Mul(&result, &t[1])

return result
}
Expand Down