github.com/yinchengtsinghua/golang-Eos-dpos-Ethereum@v0.0.0-20190121132951-92cc4225ed8e/crypto/bn256/cloudflare/lattice_test.go (about) 1 2 //此源码被清华学神尹成大魔王专业翻译分析并修改 3 //尹成QQ77025077 4 //尹成微信18510341407 5 //尹成所在QQ群721929980 6 //尹成邮箱 yinc13@mails.tsinghua.edu.cn 7 //尹成毕业于清华大学,微软区块链领域全球最有价值专家 8 //https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 9 package bn256 10 11 import ( 12 "crypto/rand" 13 14 "testing" 15 ) 16 17 func TestLatticeReduceCurve(t *testing.T) { 18 k, _ := rand.Int(rand.Reader, Order) 19 ks := curveLattice.decompose(k) 20 21 if ks[0].BitLen() > 130 || ks[1].BitLen() > 130 { 22 t.Fatal("reduction too large") 23 } else if ks[0].Sign() < 0 || ks[1].Sign() < 0 { 24 t.Fatal("reduction must be positive") 25 } 26 } 27 28 func TestLatticeReduceTarget(t *testing.T) { 29 k, _ := rand.Int(rand.Reader, Order) 30 ks := targetLattice.decompose(k) 31 32 if ks[0].BitLen() > 66 || ks[1].BitLen() > 66 || ks[2].BitLen() > 66 || ks[3].BitLen() > 66 { 33 t.Fatal("reduction too large") 34 } else if ks[0].Sign() < 0 || ks[1].Sign() < 0 || ks[2].Sign() < 0 || ks[3].Sign() < 0 { 35 t.Fatal("reduction must be positive") 36 } 37 }