Last active
December 10, 2024 14:36
-
-
Save dcb9/a9936b59c1d9cd8a08ff874ca734e8c9 to your computer and use it in GitHub Desktop.
babylon EOTS(Extractable one-time signatures) example in go https://go.dev/play/p/5cdeTT96Sj0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/rand" | |
"fmt" | |
"github.com/babylonchain/babylon/crypto/eots" | |
) | |
func main() { | |
// Generate keys | |
secretKey, _ := eots.KeyGen(rand.Reader) | |
publicKey := eots.PubGen(secretKey) | |
privateRand, publicRand, _ := eots.RandGen(rand.Reader) | |
// sign for message 1 | |
h1 := []byte("hello") | |
s1, _ := eots.Sign(secretKey, privateRand, h1) | |
// sign for message 2 | |
h2 := []byte("world") | |
s2, _ := eots.Sign(secretKey, privateRand, h2) | |
// extract private key | |
extractedKey, _ := eots.Extract(publicKey, publicRand, h1, s1, h2, s2) | |
fmt.Println(" original secret key:", secretKey) | |
fmt.Println("extracted secret key:", extractedKey) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment