Coder Social home page Coder Social logo

chia-bls-go's Introduction

Don't worry be happy

chia-bls-go's People

Contributors

chuwt avatar dinosaurchi avatar megagrindstone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

chia-bls-go's Issues

Wrapper around C++ BLS

Hi guys!

first of all, really good idea to create a Go port of the BLS Chia lib, this could open further possibilities Go side.

Why did you decide to do a complete port (I understand a native Go implementation was missing) instead of using CGO/SWIG and create an interface to the offcial C++ BLS lib?
This could avoid the need for code updates to be on par with the official lib and also use all the speedups due to GMP.

I would also suggest to keep the same naming convention as the official lib, for example using G1Element/G2Element

Farmer key miss match

TestCase:

func TestSignature(t *testing.T) {
	var seed [64]byte
	for i := 0; i < 100; i++ {
		_, _ = rand.Read(seed[:])

		// blsgo
		blsgoPrivateKey := blsgo.KeyGen(seed[:])
		blsgoFarmerPrivateKey := blsgoPrivateKey.FarmerSk()
		blsgoFarmerPrivateKeyBytes := blsgoFarmerPrivateKey.Bytes()

		// chia bls with cgo
		blsPrivateKey, _ := bls.GenerateKeyFromSeed(seed[:])
		blsFarmerPrivateKey := blsPrivateKey.DeriveChild([]int{12381, 8444, 0, 0})
		blsFarmerPrivateKeyBytes, _ := blsFarmerPrivateKey.MarshalBinary()

		if bytes.Compare(blsgoFarmerPrivateKeyBytes, blsFarmerPrivateKeyBytes) != 0 {
			t.Errorf("Bad farmer key: i=%d seed=%s blsgo=%s chia-bls=%s", i, hex.EncodeToString(seed[:]),
				hex.EncodeToString(blsgoFarmerPrivateKeyBytes),
				hex.EncodeToString(blsFarmerPrivateKeyBytes))
		}
	}
}

Output:

=== RUN   TestSignature
    service_test.go:142: Bad farmer key: i=23 seed=53f830604c1432a737b18b8f8d94fe897e735cba0fcd3f2cf0212973a521f84bf9ed8bb739012d6811c81d0c4dff726642225dcb8e63d4bdf02341a5fa5c1101 blsgo=090ccc11e11032e691f1c0671c8aa43b2fc6fef7b6e0101ffb289e2cce9bf422 chia-bls=3cd15ca01d255815a8dc24a6b3344761c3578b4d2b325aced906a65072f4f612
    service_test.go:142: Bad farmer key: i=35 seed=9ad7c719f59d794bb8527dcafa4a17243df11b12e1b077ad39d60cd4d0409432d13ba749d6932792b218b28a361a545cf5aa174e3d236039193f603eaa128dd6 blsgo=0433e87b7c5ea124b0ebe1cbb7d96c7fbf59aa49b2d891f50d99f517b82ab97d chia-bls=5479365fdd776bff9e8daa9ea79c58a1b8af08b907c733c81b9cfd3f43fbd31c
    service_test.go:142: Bad farmer key: i=70 seed=2d59eab383318d51a26290cb78cbcdc9941c21e175d446779025ddb20643da99b87dfcc14e012ba2029e5574bcc1e71344172c18810db086696ba0593b0c8500 blsgo=67d2819d00db4bc1d14a3cf7e131b3b1f4085f10bbcea53f225e9b9c6f9b1454 chia-bls=66c9a4109557cfe20199565e5138ceecdea77a5db8b1eb88cb1169ba5367edb5
    service_test.go:142: Bad farmer key: i=75 seed=eb0dcf3c89de963b4f047dd85f79212b0dbf269d73deae5ab3d043f815778394d6ac9ff01526127520d35916eed90aada0f4f05b50c17a1648a141f79b5d495b blsgo=3645c8df7e38d12464eca7f7f9711edc538d91aa8545d42c8c01d6848856105e chia-bls=05a891a033d8b47931bed5594eadf754e7d751fa15ddbd27bcd2b7c8283616d4
    service_test.go:142: Bad farmer key: i=79 seed=a83903c9c2acef4c279c98faaa2d6656f146139c2a0b0839e36a0304f6f2755c19f27575e3a5342f88f5a255290112c152b97032df5af5d1e3c6235f4e42fb39 blsgo=17721e215429eaf5657cea3b2ccb1b968df1c9475739c8a275216898a8abda7d chia-bls=666bf79655c82de816fa22781d0cce550b03820b4e6641f7938466577aa5700c
--- FAIL: TestSignature (1.12s)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.