mirror of
https://github.com/arnaucube/cryptofun.git
synced 2026-02-28 05:16:46 +01:00
add travis
This commit is contained in:
8
.travis.yml
Normal file
8
.travis.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
language: go
|
||||||
|
|
||||||
|
go:
|
||||||
|
- "1.12"
|
||||||
|
|
||||||
|
env:
|
||||||
|
- GO111MODULE=on
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
# cryptofun [](https://goreportcard.com/report/github.com/arnaucube/cryptofun)
|
# cryptofun [](https://goreportcard.com/report/github.com/arnaucube/cryptofun) [](https://travis-ci.org/arnaucube/cryptofun)
|
||||||
|
|
||||||
|
|
||||||
Crypto algorithms from scratch. Academic purposes only.
|
Crypto algorithms from scratch. Academic purposes only.
|
||||||
|
|
||||||
|
|||||||
30
bls/bls.go
30
bls/bls.go
@@ -92,26 +92,24 @@ func (bls BLS) AggregateSignatures(signatures ...[3][2]*big.Int) [3][2]*big.Int
|
|||||||
|
|
||||||
// VerifyAggregatedSignatures
|
// VerifyAggregatedSignatures
|
||||||
// ê(G,S) == ê(P, H(m))
|
// ê(G,S) == ê(P, H(m))
|
||||||
// ê(G, s0+s1+s2...) == ê(p0, H(m)) x ê(p1, H(m)) x ê(p2, H(m)) ...
|
// ê(G, s0+s1+s2...) == ê(p0+p1+p2..., H(m))
|
||||||
func (bls BLS) VerifyAggregatedSignatures(aggrsig [3][2]*big.Int, pubKArray [][3]*big.Int, m []byte) bool {
|
func (bls BLS) VerifyAggregatedSignatures(aggrsig [3][2]*big.Int, pubKArray [][3]*big.Int, m []byte) bool {
|
||||||
pairingGS, err := bls.Bn.Pairing(bls.Bn.G1.G, aggrsig)
|
aggrPubKs := pubKArray[0]
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
pairingsMul, err := bls.Bn.Pairing(pubKArray[0], bls.Hash(m))
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
for i := 1; i < len(pubKArray); i++ {
|
for i := 1; i < len(pubKArray); i++ {
|
||||||
e, err := bls.Bn.Pairing(pubKArray[i], bls.Hash(m))
|
aggrPubKs = bls.Bn.G1.Add(aggrPubKs, pubKArray[i])
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
pairingsMul = bls.Bn.Fq12.Mul(pairingsMul, e)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bls.Bn.Fq12.Equal(pairingGS, pairingsMul) {
|
left, err := bls.Bn.Pairing(bls.Bn.G1.G, aggrsig)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
right, err := bls.Bn.Pairing(aggrPubKs, bls.Hash(m))
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if !bls.Bn.Fq12.Equal(left, right) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -24,8 +24,22 @@ func TestEncryptDecrypt(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestHomomorphicAddition(t *testing.T) {
|
func TestHomomorphicAddition(t *testing.T) {
|
||||||
key, err := GenerateKeyPair()
|
// key, err := GenerateKeyPair()
|
||||||
assert.Nil(t, err)
|
// assert.Nil(t, err)
|
||||||
|
|
||||||
|
// key harcoded for tests
|
||||||
|
pubK := PublicKey{
|
||||||
|
N: big.NewInt(204223),
|
||||||
|
G: big.NewInt(24929195694),
|
||||||
|
}
|
||||||
|
privK := PrivateKey{
|
||||||
|
Lambda: big.NewInt(101660),
|
||||||
|
Mu: big.NewInt(117648),
|
||||||
|
}
|
||||||
|
key := Key{
|
||||||
|
PubK: pubK,
|
||||||
|
PrivK: privK,
|
||||||
|
}
|
||||||
|
|
||||||
n1 := big.NewInt(int64(110))
|
n1 := big.NewInt(int64(110))
|
||||||
n2 := big.NewInt(int64(150))
|
n2 := big.NewInt(int64(150))
|
||||||
|
|||||||
Reference in New Issue
Block a user