forked from noot/ring-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
229 additions
and
153 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Benchmarking | ||
|
||
cpu.prof | ||
mem.prof | ||
ring-go.test |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
.SILENT: | ||
|
||
##################### | ||
### General ### | ||
##################### | ||
|
||
.PHONY: help | ||
.DEFAULT_GOAL := help | ||
help: ## Prints all the targets in all the Makefiles | ||
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
.PHONY: list | ||
list: ## List all make targets | ||
@${MAKE} -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sort | ||
|
||
##################### | ||
#### Testing #### | ||
##################### | ||
|
||
.PHONY: test_all | ||
test_all: ## runs the test suite | ||
go test -v -p 1 ./... -mod=readonly -race | ||
|
||
########################## | ||
#### Benchmarking #### | ||
########################## | ||
|
||
.PHONY: benchmark_all | ||
benchmark_all: ## runs the benchmark suite | ||
go test -bench=. -benchmem -cpuprofile=cpu.prof -memprofile=mem.prof | ||
|
||
########################### | ||
### Release Helpers ### | ||
########################### | ||
|
||
# List tags: git tag | ||
# Delete tag locally: git tag -d v1.2.3 | ||
# Delete tag remotely: git push --delete origin v1.2.3 | ||
|
||
.PHONY: tag_bug_fix | ||
tag_bug_fix: ## Tag a new bug fix release (e.g., v1.0.1 -> v1.0.2) | ||
@$(eval LATEST_TAG=$(shell git tag --sort=-v:refname | head -n 1)) | ||
@$(eval NEW_TAG=$(shell echo $(LATEST_TAG) | awk -F. -v OFS=. '{ $$NF = sprintf("%d", $$NF + 1); print }')) | ||
@git tag $(NEW_TAG) | ||
@echo "New bug fix version tagged: $(NEW_TAG)" | ||
@echo "Run the following commands to push the new tag:" | ||
@echo " git push origin $(NEW_TAG)" | ||
@echo "And draft a new release at https://github.com/pokt-network/smt/releases/new" | ||
|
||
|
||
.PHONY: tag_minor_release | ||
tag_minor_release: ## Tag a new minor release (e.g. v1.0.0 -> v1.1.0) | ||
@$(eval LATEST_TAG=$(shell git tag --sort=-v:refname | head -n 1)) | ||
@$(eval NEW_TAG=$(shell echo $(LATEST_TAG) | awk -F. '{$$2 += 1; $$3 = 0; print $$1 "." $$2 "." $$3}')) | ||
@git tag $(NEW_TAG) | ||
@echo "New minor release version tagged: $(NEW_TAG)" | ||
@echo "Run the following commands to push the new tag:" | ||
@echo " git push origin $(NEW_TAG)" | ||
@echo "And draft a new release at https://github.com/pokt-network/smt/releases/new" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,72 @@ | ||
# ring-go | ||
# ring-go <!-- omit in toc --> | ||
|
||
Implementation of linkable ring signatures using elliptic curve crypto in pure Go. It supports ring signatures over both ed25519 and secp256k1. | ||
Implementation of linkable ring signatures using elliptic curve crypto in pure Go. | ||
It supports ring signatures over both ed25519 and secp256k1. | ||
|
||
### requirements | ||
- [Requirements](#requirements) | ||
- [Install](#install) | ||
- [References](#references) | ||
- [Usage](#usage) | ||
|
||
go 1.19 | ||
## Requirements | ||
|
||
### get | ||
go 1.22.2 | ||
|
||
## Install | ||
|
||
`go get github.com/pokt-network/ring-go` | ||
|
||
### references | ||
## References | ||
|
||
This implementation is based off of [Ring Confidential Transactions](https://eprint.iacr.org/2015/1098.pdf), in particular section 2, which defines MLSAG (Multilayered Linkable Spontaneous Anonymous Group signatures). | ||
|
||
### usage | ||
## Usage | ||
|
||
See `examples/main.go`. | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"fmt" | ||
|
||
ring "github.com/pokt-network/ring-go" | ||
"golang.org/x/crypto/sha3" | ||
ring "github.com/pokt-network/ring-go" | ||
"golang.org/x/crypto/sha3" | ||
) | ||
|
||
func signAndVerify(curve ring.Curve) { | ||
privkey := curve.NewRandomScalar() | ||
msgHash := sha3.Sum256([]byte("helloworld")) | ||
privKey := curve.NewRandomScalar() | ||
msgHash := sha3.Sum256([]byte("helloworld")) | ||
|
||
// size of the public key ring (anonymity set) | ||
const size = 16 | ||
// size of the public key ring (anonymity set) | ||
const size = 16 | ||
|
||
// our key's secret index within the set | ||
const idx = 7 | ||
// our key's secret index within the set | ||
const idx = 7 | ||
|
||
keyring, err := ring.NewKeyRing(curve, size, privkey, idx) | ||
if err != nil { | ||
panic(err) | ||
} | ||
keyring, err := ring.NewKeyRing(curve, size, privKey, idx) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
sig, err := keyring.Sign(msgHash, privkey) | ||
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 | ||
} | ||
ok := sig.Verify(msgHash) | ||
if !ok { | ||
fmt.Println("failed to verify :(") | ||
return | ||
} | ||
|
||
fmt.Println("verified signature!") | ||
fmt.Println("verified signature!") | ||
} | ||
|
||
func main() { | ||
fmt.Println("using secp256k1...") | ||
signAndVerify(ring.Secp256k1()) | ||
fmt.Println("using ed25519...") | ||
signAndVerify(ring.Ed25519()) | ||
fmt.Println("using secp256k1...") | ||
signAndVerify(ring.Secp256k1()) | ||
fmt.Println("using ed25519...") | ||
signAndVerify(ring.Ed25519()) | ||
} | ||
``` |
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
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
Oops, something went wrong.