modulepackage
0.0.0-20240617213643-1a8bebebd522
Repository: https://github.com/noot/ring-go.git
Documentation: pkg.go.dev
# README
ring-go
Implementation of linkable ring signatures using elliptic curve crypto in pure Go. It supports ring signatures over both ed25519 and secp256k1.
requirements
go 1.19
get
go get github.com/noot/ring-go
references
This implementation is based off of Ring Confidential Transactions, in particular section 2, which defines MLSAG (Multilayered Linkable Spontaneous Anonymous Group signatures).
usage
See examples/main.go
.
package main
import (
"fmt"
ring "github.com/noot/ring-go"
"golang.org/x/crypto/sha3"
)
func signAndVerify(curve ring.Curve) {
privkey := curve.NewRandomScalar()
msgHash := sha3.Sum256([]byte("helloworld"))
// size of the public key ring (anonymity set)
const size = 16
// our key's secret index within the set
const idx = 7
keyring, err := ring.NewKeyRing(curve, size, privkey, idx)
if err != nil {
panic(err)
}
sig, err := keyring.Sign(msgHash, privkey)
if err != nil {
panic(err)
}
ok := sig.Verify(msgHash)
if !ok {
fmt.Println("failed to verify :(")
return
}
fmt.Println("verified signature!")
}
func main() {
fmt.Println("using secp256k1...")
signAndVerify(ring.Secp256k1())
fmt.Println("using ed25519...")
signAndVerify(ring.Ed25519())
}
# Packages
No description provided by the author
# Functions
Ed25519 returns a new ed25519 curve instance.
Link returns true if the two signatures were created by the same signer, false otherwise.
NewFixedKeyRingFromPublicKeys takes public keys and a curve to create a ring.
NewKeyRing creates a ring with size specified by `size` and places the public key corresponding to `privkey` in index idx of the ring.
NewKeyRingFromPublicKeys takes public key ring and places the public key corresponding to `privkey` in index idx of the ring.
Secp256k1 returns a new secp256k1 curve instance.
Sign creates a ring signature on the given message using the provided private key and ring of public keys.
# Type aliases
No description provided by the author