You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
2.0 KiB

6 years ago
6 years ago
  1. # BLS [![GoDoc](https://godoc.org/github.com/arnaucube/cryptofun/bls?status.svg)](https://godoc.org/github.com/arnaucube/cryptofun/bls)
  2. Boneh–Lynn–Shacham (BLS) signature scheme implemented in Go.
  3. https://en.wikipedia.org/wiki/Boneh%E2%80%93Lynn%E2%80%93Shacham
  4. This package uses the BN128 Pairing Go implementation from https://github.com/arnaucube/go-snark/tree/master/bn128
  5. ### Usage
  6. ```go
  7. bls, err := NewKeys()
  8. assert.Nil(t, err)
  9. fmt.Println("privK:", bls.PrivK)
  10. fmt.Println("pubK:", bls.PubK)
  11. m := []byte("test")
  12. sig := bls.Sign(m)
  13. fmt.Println("signature:", sig)
  14. verified := bls.Verify(m, sig, bls.PubK)
  15. assert.True(t, verified)
  16. /* out:
  17. privK: 28151522174243194157727175362620544050084772361374505986857263387912025505082855947281432752362814690196305655335201716186584298643231993241609823412370437094839017595372164876997343464950463323765646363122343203470911131219733598647659483557447955173651057370197665461325593653581904430885385707255151472097067657072671643359241937143381958053903725229458882818033464163487351806079175441316235756460455300637131488613568714712448336232283394011955460567718918055245116200622473324300828876609569556897836255866438665750954410544846238847540023603735360532628141508114304504053826700874403280496870140784630677100277
  18. pubK: [528167154220154970470523315181365784447502116458960328551053767278433374201 18282159022449399855128689249640771309991127595389457870089153259100566421596 19728585501269572907574045312283749798205079570296187960832716959652451330253]
  19. signature: [[12832528436266902887734423636380781315321578271441494003771296275495461508593 6964131770814642748778827029569297554111206304527781019989920684169107205085] [6508357389516441729339280841134358160957092583050390612877406497974519092306 12073245715182483402311045895787625736998570529454024932833669602347318770866] [13520730275909614846121720877644124261162513989808465368770765804305866618385 19571107788574492009101590535904131414163790958090376021518899789800327786039]]
  20. verified: true
  21. */
  22. ```