diff --git a/.github/workflows/dusk_ci.yml b/.github/workflows/dusk_ci.yml index ffc7ce1..5eccb1b 100644 --- a/.github/workflows/dusk_ci.yml +++ b/.github/workflows/dusk_ci.yml @@ -1,101 +1,29 @@ -on: [pull_request] +on: [pull_request, push] -name: Continuous integration +name: Dusk CI jobs: - analyze: - name: Dusk Analyzer - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 - with: - command: install - args: --git https://github.com/dusk-network/cargo-dusk-analyzer - - uses: actions-rs/cargo@v1 - with: - command: dusk-analyzer - args: --manifest-path rust/Cargo.toml - - check_nightly_no_std: - name: Nightly check no_std - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - target: thumbv6m-none-eabi - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 - with: - command: check - args: --manifest-path rust/bls12_381-sign/Cargo.toml --no-default-features --target thumbv6m-none-eabi + code_analysis: + name: Code Analysis + uses: dusk-network/.github/.github/workflows/code-analysis.yml@main + with: + clippy_default: false + clippy_args: --release --features=rkyv-impl,rkyv/size_16 -- -D warnings - test_nightly: - name: Nightly tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 - with: - command: test - args: --manifest-path rust/Cargo.toml --workspace --release - - fmt: - name: Rustfmt - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - - run: rustup component add rustfmt - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --manifest-path rust/Cargo.toml --all -- --check + dusk_analysis: + name: Dusk Analyzer + uses: dusk-network/.github/.github/workflows/dusk-analysis.yml@main - test: - strategy: - matrix: - go-version: [ 1.17.x ] - os: [ ubuntu-latest, macos-latest ] - runs-on: ${{ matrix.os }} + check_no_std: + name: check no_std + runs-on: core steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v2 - - name: Change toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - - name: Rustfmt - run: rustup component add rustfmt - - name: Generate Rust FFI and IPC binaries - run: make lib - - name: Upload binaries for platform - uses: actions/upload-artifact@v2 - with: - name: bls12_381_sign_${{ matrix.os }} - path: | - go/cgo/bls/libdusk_bls12_381_sign_ffi_${{ matrix.os }}.a - - name: Build Go Stuff - run: make build - - name: Test Go Stuff - run: make test - - name: Run all bls12-381 benches for Cgo, IPC - run: make bench + - uses: actions/checkout@v4 + - uses: dsherret/rust-toolchain-file@v1 + - run: cargo check --no-default-features --target thumbv6m-none-eabi + + test_std: + name: Nightly std tests + uses: dusk-network/.github/.github/workflows/run-tests.yml@main + with: + test_flags: --features=rkyv-impl,rkyv/size_16 diff --git a/.gitignore b/.gitignore index 00c883d..6a59f55 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -.DS_Store /target -/rust/target Cargo.lock -.idea +/.idea \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..dc3ce86 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,20 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.1.0] - 2024-01-08 + +### Added + +- Add initial commit, this package continues the development of [dusk-bls12_381-sign](https://github.com/dusk-network/bls12_381-sign/) at version `0.6.0` under the new name: `bls12_381-bls` and without the go related code. + + + + +[Unreleased]: https://github.com/dusk-network/bls12_381-bls/compare/v0.1.0...HEAD +[0.1.0]: https://github.com/dusk-network/bls12_381-bls/releases/tag/v0.1.0 diff --git a/rust/bls12_381-sign/Cargo.toml b/Cargo.toml similarity index 85% rename from rust/bls12_381-sign/Cargo.toml rename to Cargo.toml index 5137f61..36c7b17 100644 --- a/rust/bls12_381-sign/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "dusk-bls12_381-sign" -version = "0.6.0" +name = "bls12_381-bls" +version = "0.1.0" edition = "2021" description = "Implementation of BLS signatures using the BLS12-381 curve" license = "MPL-2.0" @@ -9,7 +9,7 @@ license = "MPL-2.0" blake2 = { version = "0.10", default-features = false } dusk-bls12_381 = { version = "0.13", default-features = false, features = ["alloc", "pairings"] } dusk-bytes = "0.1" -rand_core = { version = "0.6", default-features = false } +rand_core = { version = "0.6", default-features = false, features = ["getrandom"] } rkyv = { version = "0.7", optional = true, default-features = false } bytecheck = { version = "0.6", optional = true, default-features = false } ff = { version = "0.13", default-features = false } diff --git a/Makefile b/Makefile deleted file mode 100644 index fa8f769..0000000 --- a/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -OS := $(shell sh -c 'uname -s 2>/dev/null || echo linux' | tr "[:upper:]" "[:lower:]") -PROTOC := $(shell which protoc) -platform = ubuntu-latest - -# Protobuf compiler (aka Protoc) -ifeq ($(OS), linux) -protoc=protoc-3.14.0-linux-x86_64.zip -endif -ifeq ($(OS), darwin) -protoc = protoc-3.14.0-osx-x86_64.zip -platform = macos-latest -endif - -all: schema lib build test - -schema: -ifeq (,$(wildcard ./tmp/protoc/bin/protoc)) - make protoc -endif - ./tmp/protoc/bin/protoc --proto_path=./schema ./schema/bls12381sig.proto \ - --go_opt=paths=source_relative \ - --go_out=plugins=grpc:./go/grpc/bls/; \ - -lib: - cargo build --workspace --manifest-path rust/Cargo.toml --exclude dusk-bls12_381-sign-ipc --release - cp rust/target/release/libdusk_bls12_381_sign_ffi.a ./go/cgo/bls/libdusk_bls12_381_sign_ffi_$(platform).a - -grpc: - cargo build --workspace --manifest-path rust/Cargo.toml --release - cp rust/target/release/bls12381svc ./go/grpc/bls/bls12381svc_$(platform) - -build: schema lib grpc - (cd go/cgo/bls && go build) - (cd go/grpc/bls && go build) - -test: build - (cd go/cgo/bls && go test) - (cd go/grpc/bls && go test) - -bench: build - (cd go/cgo/bls && go test -v -bench=.) - (cd go/grpc/bls && go test -v -bench=.) - -clean: - rm -fv /tmp/bls12381svc* - rm -rf ./tmp - -protoc: - curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/$(protoc) - mkdir -p ./tmp/protoc - unzip -o $(protoc) -d ./tmp/protoc bin/protoc - unzip -o $(protoc) -d ./tmp/protoc 'include/*' - rm -f $(protoc) - go install google.golang.org/grpc@v1.42.0 - go install github.com/golang/protobuf/protoc-gen-go@latest - -memprofile: - go test -run=. -bench=. -benchtime=5s -count 1 -benchmem -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out ./... | tee bench.txt - go tool pprof -http :8081 mem.out - -benchmem: build test - go test -run=. -bench=. -benchtime=5s -count 1 -benchmem ./... - cargo bench; - #cd bls/bls12_381-sign; diff --git a/README.md b/README.md index 760d5d8..d902dbd 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,30 @@ -# BLS12-381 Curve Signature +# Implementation of [BLS signatures](https://crypto.stanford.edu/~dabo/pubs/papers/BLSmultisig.html) using the BLS12-381 curve. -This repo contains Dusk Network's [implementation](/rust/bls12_381-sign) of the BLS Signatures using the BLS12-381 curve. This implementation currently only supports rogue-key attack resistant batching, and does not support distinct message verification. - -## Rust - -The [library](/rust/bls12_381-sign) is written in rust. - -We also provide a sample IPC [micro-service](/rust/grpc-server) that provides a synchronous gRPC interface to the library for third-party clients. - -## Go - -We provide a couple options to work with the library using Go: - -1. [Using CGo](/go/cgo/bls) to build and link directly to the lib binaries. -1. [Using gRPC](/go/grpc/bls) to communicate with our simple lib IPC server. +This implementation currently only supports rogue-key attack resistant batching, and does not support distinct message verification. ## Benchmarks -We've found the CGo version to perform faster with `Go 1.17+` +### Machine specs -Recent benchmarks are attached for reference: +The benchmarks were ran on a 2020 13.3" MacBook Pro. -### CGo +CPU: ``` -cpu: Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz -BenchmarkSign 1264 4416508 ns/op 48 B/op 1 allocs/op -BenchmarkVerify 706 8568588 ns/op 0 B/op 0 allocs/op -BenchmarkAggregatePk 864 6687951 ns/op 216 B/op 3 allocs/op -BenchmarkAggregateSig 4274 1443901 ns/op 120 B/op 3 allocs/op +$ lscpu +Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz ``` -### gRPC +RAM: +``` +16 GB 3733 MHz LPDDR4X +``` +### Results + +``` +test benches::bench_aggregate_pk ... bench: 1,654,552 ns/iter (+/- 107,025) +test benches::bench_aggregate_sig ... bench: 36,893 ns/iter (+/- 3,399) +test benches::bench_sign ... bench: 1,480,169 ns/iter (+/- 106,151) +test benches::bench_sign_vulnerable ... bench: 1,024,052 ns/iter (+/- 111,395) +test benches::bench_verify ... bench: 4,740,114 ns/iter (+/- 336,036) ``` -BenchmarkSign 1317 4507956 ns/op 5317 B/op 95 allocs/op -BenchmarkVerify 693 8767921 ns/op 5207 B/op 94 allocs/op -BenchmarkAggregatePk 656 9209897 ns/op 5385 B/op 96 allocs/op -BenchmarkAggregateSig 3651 1645111 ns/op 5194 B/op 96 allocs/op -``` \ No newline at end of file diff --git a/rust/bls12_381-sign/benches/signature_bench.rs b/benches/signature_bench.rs similarity index 98% rename from rust/bls12_381-sign/benches/signature_bench.rs rename to benches/signature_bench.rs index 6c2da35..5177b13 100644 --- a/rust/bls12_381-sign/benches/signature_bench.rs +++ b/benches/signature_bench.rs @@ -9,7 +9,7 @@ extern crate test; mod benches { - use dusk_bls12_381_sign::{PublicKey, SecretKey, APK}; + use bls12_381_bls::{PublicKey, SecretKey, APK}; use dusk_bytes::Serializable; use rand_core::{OsRng, RngCore}; use test::Bencher; diff --git a/go/cgo/bls/README.md b/go/cgo/bls/README.md deleted file mode 100644 index ac9ab70..0000000 --- a/go/cgo/bls/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# CGo Wrapper for BLS12-381 Sign - -`bls.go` exposes a CGo wrapper to the native rust [bls12-381 signing library](/rust/bls12_381-sign). - -## Building - -`Makefile` at the repo root takes care of everything, but essentially you'll want to have the built lib binaries in this directory for GCC to link against them as specified in the CGo headers at the top of `bls.go`. We provide pre-built binaries for Ubuntu and Darwin for convenience. - -## Usage - -``` -$ go get github.com/dusk-network/bls12_381-sign/go/cgo/bls -``` - -This package exports the following methods: - -```go -GenerateKeys() ([]byte, []byte) -GenerateKeysWithRaw() ([]byte, []byte, []byte) -Sign(sk, pk, msg []byte) ([]byte, error) -Verify(apk, sig, msg []byte) error -CreateApk(pk []byte) ([]byte, error) -AggregatePk(apk []byte, pks ...[]byte) ([]byte, error) -AggregatePKsUnchecked(pks ...[]byte) ([]byte, error) -AggregateSig(sig []byte, sigs ...[]byte) ([]byte, error) -PkToRaw(pk []byte) ([]byte, error) -```` - -Please check [`bls_test.go`](/go/cgo/bls/bls_test.go) for a few examples. \ No newline at end of file diff --git a/go/cgo/bls/bls.go b/go/cgo/bls/bls.go deleted file mode 100644 index 6f7e6ae..0000000 --- a/go/cgo/bls/bls.go +++ /dev/null @@ -1,136 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -package bls - -// #cgo darwin LDFLAGS: -L./ -ldusk_bls12_381_sign_ffi_macos-latest -ldl -lm -// #cgo linux LDFLAGS: -L./ -ldusk_bls12_381_sign_ffi_ubuntu-latest -ldl -lm -// #include "./libbls.h" -import "C" - -import ( - "errors" - "unsafe" -) - -func GenerateKeys() ([]byte, []byte) { - skBuf := make([]byte, C.SK_SIZE) - pkBuf := make([]byte, C.PK_SIZE) - - sk_ptr := toPtr(skBuf) - pk_ptr := toPtr(pkBuf) - - C.generate_keys(sk_ptr, pk_ptr) - return skBuf, pkBuf -} - -func GenerateKeysWithRaw() ([]byte, []byte, []byte) { - skBuf := make([]byte, C.SK_SIZE) - pkBuf := make([]byte, C.PK_SIZE) - pkBufRaw := make([]byte, C.PK_RAW_SIZE) - - sk_ptr := toPtr(skBuf) - pk_ptr := toPtr(pkBuf) - pk_raw_ptr := toPtr(pkBufRaw) - - C.generate_keys_with_raw(sk_ptr, pk_ptr, pk_raw_ptr) - return skBuf, pkBuf, pkBufRaw -} - -func Sign(sk, pk, msg []byte) ([]byte, error) { - sk_ptr := toPtr(sk) - pk_ptr := toPtr(pk) - msg_ptr := toPtr(msg) - sigBuf := make([]byte, C.SIG_SIZE) - sig_ptr := toPtr(sigBuf) - code := C.sign(sk_ptr, pk_ptr, msg_ptr, C.size_t(len(msg)), sig_ptr) - return sigBuf, formatErr(code) -} - -func Verify(apk, sig, msg []byte) error { - apk_ptr := toPtr(apk) - sig_ptr := toPtr(sig) - msg_ptr := toPtr(msg) - code := C.verify(apk_ptr, sig_ptr, msg_ptr, C.size_t(len(msg))) - return formatErr(code) -} - -func CreateApk(pk []byte) ([]byte, error) { - pk_ptr := toPtr(pk) - apkBuf := make([]byte, C.PK_SIZE) - apk_ptr := toPtr(apkBuf) - code := C.create_apk(pk_ptr, apk_ptr) - return apkBuf, formatErr(code) -} - -func AggregatePk(apk []byte, pks ...[]byte) ([]byte, error) { - apk_ptr := toPtr(apk) - pkBytes := make([]byte, 0) - for _, pk := range pks { - pkBytes = append(pkBytes, pk...) - } - - pk_ptr := toPtr(pkBytes) - retBuf := make([]byte, C.PK_SIZE) - ret_ptr := toPtr(retBuf) - code := C.aggregate_pk(apk_ptr, pk_ptr, C.size_t(len(pkBytes)), ret_ptr) - return retBuf, formatErr(code) -} - -func AggregatePKsUnchecked(pks ...[]byte) ([]byte, error) { - pkBytes := make([]byte, 0) - for _, pk := range pks { - if C.int(len(pk)) != C.PK_RAW_SIZE { - return nil, errors.New("invalid bytes provided") - } - pkBytes = append(pkBytes, pk...) - } - - pk_ptr := toPtr(pkBytes) - retBuf := make([]byte, C.PK_SIZE) - ret_ptr := toPtr(retBuf) - C.aggregate_pks_unchecked(pk_ptr, C.size_t(len(pkBytes)), ret_ptr) - return retBuf, nil -} - -func AggregateSig(sig []byte, sigs ...[]byte) ([]byte, error) { - sig_ptr := toPtr(sig) - sigBytes := make([]byte, 0) - for _, sig := range sigs { - sigBytes = append(sigBytes, sig...) - } - - sigs_ptr := toPtr(sigBytes) - retBuf := make([]byte, C.SIG_SIZE) - ret_ptr := toPtr(retBuf) - code := C.aggregate_sig(sig_ptr, sigs_ptr, C.size_t(len(sigBytes)), ret_ptr) - return retBuf, formatErr(code) -} - -func PkToRaw(pk []byte) ([]byte, error) { - pk_ptr := toPtr(pk) - pkRawBuf := make([]byte, C.PK_RAW_SIZE) - pkRaw_ptr := toPtr(pkRawBuf) - code := C.pk_to_raw(pk_ptr, pkRaw_ptr) - return pkRawBuf, formatErr(code) -} - -func toPtr(data []byte) *C.uchar { - return (*C.uchar)(unsafe.Pointer(&data[0])) -} - -func formatErr(errCode C.bls_sign_status) error { - switch errCode { - case C.BLS_OK: - return nil - case C.BLS_INVALID_BYTES: - return errors.New("invalid bytes provided") - case C.BLS_VERIFICATION_FAILED: - return errors.New("verification failed") - default: - return errors.New("encountered unknown exit code") - } -} diff --git a/go/cgo/bls/bls_test.go b/go/cgo/bls/bls_test.go deleted file mode 100644 index a71d049..0000000 --- a/go/cgo/bls/bls_test.go +++ /dev/null @@ -1,260 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -package bls - -import ( - "crypto/rand" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestGenerateKeys(t *testing.T) { - sk, pk := GenerateKeys() - if sk == nil || pk == nil { - t.Fatal("generate keys failed") - } - assert.NotEqual(t, sk, make([]byte, 32)) - assert.NotEqual(t, pk, make([]byte, 96)) -} - -func TestSignVerify(t *testing.T) { - sk, pk := GenerateKeys() - msg := make([]byte, 100) - rand.Read(msg) - sig, err := Sign(sk, pk, msg) - if err != nil { - t.Fatal(err) - } - - apk, err := CreateApk(pk) - if err != nil { - t.Fatal(err) - } - - err = Verify(apk, sig, msg) - if err != nil { - t.Fatal(err) - } -} - -func TestVerifyWrongKey(t *testing.T) { - sk, pk := GenerateKeys() - msg := make([]byte, 100) - rand.Read(msg) - sig, err := Sign(sk, pk, msg) - if err != nil { - t.Fatal(err) - } - - _, pk = GenerateKeys() - - apk, err := CreateApk(pk) - if err != nil { - t.Fatal(err) - } - - assert.Error(t, Verify(apk, sig, msg)) -} - -func TestAggregation(t *testing.T) { - sk1, pk1 := GenerateKeys() - msg := make([]byte, 100) - rand.Read(msg) - sig1, err := Sign(sk1, pk1, msg) - if err != nil { - t.Fatal(err) - } - - apk1, err := CreateApk(pk1) - if err != nil { - t.Fatal(err) - } - - // Aggregating pk - sk2, pk2 := GenerateKeys() - sk3, pk3 := GenerateKeys() - apk2, err := AggregatePk(apk1, pk2, pk3) - if err != nil { - t.Fatal(err) - } - - // Aggregating sigs - sig2, err := Sign(sk2, pk2, msg) - if err != nil { - t.Fatal(err) - } - - sig3, err := Sign(sk3, pk3, msg) - if err != nil { - t.Fatal(err) - } - - aggSig, err := AggregateSig(sig1, sig2, sig3) - if err != nil { - t.Fatal(err) - } - - // Aggregated verification - err = Verify(apk2, aggSig, msg) - if err != nil { - t.Fatal(err) - } -} - -func BenchmarkSign(b *testing.B) { - sk, pk := GenerateKeys() - msg := make([]byte, 100) - rand.Read(msg) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - if _, err := Sign(sk, pk, msg); err != nil { - b.Fatal(err) - } - } -} - -func BenchmarkVerify(b *testing.B) { - sk, pk := GenerateKeys() - msg := make([]byte, 100) - rand.Read(msg) - - sig, err := Sign(sk, pk, msg) - if err != nil { - b.Fatal(err) - } - - apk, err := CreateApk(pk) - if err != nil { - b.Fatal(err) - } - - b.ResetTimer() - for i := 0; i < b.N; i++ { - if err := Verify(apk, sig, msg); err != nil { - b.Fatal(err) - } - } -} - -func BenchmarkAggregatePk(b *testing.B) { - _, pk := GenerateKeys() - - apk, err := CreateApk(pk) - if err != nil { - b.Fatal(err) - } - - pks := make([][]byte, b.N) - for i := 0; i < b.N; i++ { - _, pk := GenerateKeys() - pks[i] = pk - } - - b.ResetTimer() - for i := 0; i < len(pks); i++ { - AggregatePk(apk, pks[i]) - } -} - -func BenchmarkAggregateSig(b *testing.B) { - sk, pk := GenerateKeys() - msg := make([]byte, 100) - rand.Read(msg) - - sig, err := Sign(sk, pk, msg) - if err != nil { - b.Fatal(err) - } - - b.ResetTimer() - for i := 0; i < b.N; i++ { - if _, err := AggregateSig(sig, sig); err != nil { - b.Fatal(err) - } - } -} - -/* -func BenchmarkSwitchToIPC(b *testing.B) { - SwitchToIPC() -} -func BenchmarkSignIPC(b *testing.B) { - sk, pk := GenerateKeys() - msg := make([]byte, 100) - rand.Read(msg) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - if _, err := Sign(sk, pk, msg); err != nil { - b.Fatal(err) - } - } -} - -func BenchmarkVerifyIPC(b *testing.B) { - sk, pk := GenerateKeys() - msg := make([]byte, 100) - rand.Read(msg) - - sig, err := Sign(sk, pk, msg) - if err != nil { - b.Fatal(err) - } - - apk, err := CreateApk(pk) - if err != nil { - b.Fatal(err) - } - - b.ResetTimer() - for i := 0; i < b.N; i++ { - if err := Verify(apk, sig, msg); err != nil { - b.Fatal(err) - } - } -} - -func BenchmarkAggregatePkIPC(b *testing.B) { - _, pk := GenerateKeys() - - apk, err := CreateApk(pk) - if err != nil { - b.Fatal(err) - } - - pks := make([][]byte, b.N) - for i := 0; i < b.N; i++ { - _, pk := GenerateKeys() - pks[i] = pk - } - - b.ResetTimer() - for i := 0; i < len(pks); i++ { - AggregatePk(apk, pks[i]) - } -} - -func BenchmarkAggregateSigIPC(b *testing.B) { - sk, pk := GenerateKeys() - msg := make([]byte, 100) - rand.Read(msg) - - sig, err := Sign(sk, pk, msg) - if err != nil { - b.Fatal(err) - } - - b.ResetTimer() - for i := 0; i < b.N; i++ { - if _, err := AggregateSig(sig, sig); err != nil { - b.Fatal(err) - } - } -} -*/ diff --git a/go/cgo/bls/go.mod b/go/cgo/bls/go.mod deleted file mode 100644 index 425b008..0000000 --- a/go/cgo/bls/go.mod +++ /dev/null @@ -1,11 +0,0 @@ -module github.com/dusk-network/bls12_381-sign/go/cgo/bls - -go 1.17 - -require github.com/stretchr/testify v1.7.0 - -require ( - github.com/davecgh/go-spew v1.1.0 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect -) diff --git a/go/cgo/bls/go.sum b/go/cgo/bls/go.sum deleted file mode 100644 index acb88a4..0000000 --- a/go/cgo/bls/go.sum +++ /dev/null @@ -1,11 +0,0 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/go/cgo/bls/libbls.h b/go/cgo/bls/libbls.h deleted file mode 100644 index 94a8a10..0000000 --- a/go/cgo/bls/libbls.h +++ /dev/null @@ -1,69 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - - -/* libbls Header Version 0.1.0 */ - -#include -#include -#include - -const int SK_SIZE = 32; -const int SIG_SIZE = 48; -const int PK_SIZE = 96; -const int PK_RAW_SIZE = 193; - -typedef enum { - BLS_OK = 0, - BLS_INVALID_BYTES = 1, - BLS_VERIFICATION_FAILED = 2, -} bls_sign_status; - -void generate_keys(const uint8_t *sk_ptr, - const uint8_t *pk_ptr); - -void generate_keys_with_raw(const uint8_t *sk_ptr, - const uint8_t *pk_ptr, - const uint8_t *pk_raw_ptr); - -bls_sign_status sign(const uint8_t *sk_ptr, - const uint8_t *pk_ptr, - const uint8_t *msg_ptr, - size_t msg_len, - const uint8_t *sig_ptr); - -bls_sign_status verify(const uint8_t *apk_ptr, - const uint8_t *sig_ptr, - const uint8_t *msg_ptr, - size_t msg_len); - -bls_sign_status create_apk(const uint8_t *pk_ptr, - const uint8_t *apk_ptr); - -bls_sign_status aggregate_pk(const uint8_t *apk_ptr, - const uint8_t *pk_ptr, - size_t pk_len, - const uint8_t *ret_ptr); - -bls_sign_status aggregate_sig(const uint8_t *sig_ptr, - const uint8_t *sigs_ptr, - size_t sigs_len, - const uint8_t *ret_ptr); - - -bls_sign_status apk_to_raw( - const uint8_t *apk_ptr, - const uint8_t *ret_ptr); - - -bls_sign_status pk_to_raw( - const uint8_t *pk_ptr, - const uint8_t *ret_ptr); - -/// Aggregate a set of raw [`PublicKey`]. Returns a compressed [`APK`] -void aggregate_pks_unchecked(const uint8_t *pks_ptr, - size_t pks_len, - uint8_t *ret_ptr); \ No newline at end of file diff --git a/go/cgo/bls/libdusk_bls12_381_sign_ffi_macos-latest.a b/go/cgo/bls/libdusk_bls12_381_sign_ffi_macos-latest.a deleted file mode 100644 index 6c8b812..0000000 Binary files a/go/cgo/bls/libdusk_bls12_381_sign_ffi_macos-latest.a and /dev/null differ diff --git a/go/cgo/bls/libdusk_bls12_381_sign_ffi_ubuntu-latest.a b/go/cgo/bls/libdusk_bls12_381_sign_ffi_ubuntu-latest.a deleted file mode 100644 index 9c35a61..0000000 Binary files a/go/cgo/bls/libdusk_bls12_381_sign_ffi_ubuntu-latest.a and /dev/null differ diff --git a/go/grpc/bls/.gitignore b/go/grpc/bls/.gitignore deleted file mode 100644 index c941f9f..0000000 --- a/go/grpc/bls/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -bls12381svc_ubuntu-latest -bls12381svc_macos-latest \ No newline at end of file diff --git a/go/grpc/bls/README.md b/go/grpc/bls/README.md deleted file mode 100644 index 22c6876..0000000 --- a/go/grpc/bls/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# gRPC Client for BLS12-381 Sign - -`bls.go` provides an abstraction to interface with our [BLS12-381 Sign library](/rust/bls12_381-sign) via a simple IPC-based gRPC client that connects to a running instance of our provided [gRPC server](/rust/grpc-server). - -## Building - -`Makefile` at the repo root takes care of everything, but essentially you'll need the following to build the code: - - The compiled protobuf definitions (with the auto-generated client implementation) - - The [service](/rust/grpc-server) binaries for your platform, so `go:embed` directives can find them. - -## Usage - -``` -$ go get github.com/dusk-network/bls12_381-sign/go/grpc/bls -``` - -This package exports the following methods: - -```go -Connect() -Disconnect() -GenerateKeys() ([]byte, []byte) -Sign(sk, pk, msg []byte) ([]byte, error) -Verify(apk, sig, msg []byte) error -CreateApk(pk []byte) ([]byte, error) -AggregatePk(apk []byte, pks ...[]byte) ([]byte, error) -AggregateSig(sig []byte, sigs ...[]byte) ([]byte, error) -```` - -Please check [`bls_test.go`](/go/grpc/bls/bls_test.go) for a few examples. \ No newline at end of file diff --git a/go/grpc/bls/bls.go b/go/grpc/bls/bls.go deleted file mode 100644 index a155bcb..0000000 --- a/go/grpc/bls/bls.go +++ /dev/null @@ -1,237 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -//go:build !windows -// +build !windows - -package bls - -import ( - "context" - "errors" - "fmt" - "io/ioutil" - "net" - "os" - "os/exec" - "syscall" - "time" - - "google.golang.org/grpc" -) - -const ( - ipcPath = "/tmp/bls12381svc.sock" - ipcSvcBinPath = "/tmp/bls12381svc" -) - -// ipcState holds the state of IPC connection -type ipcState struct { - connected bool - cmd *exec.Cmd - SignerClient - *grpc.ClientConn -} - -var ipc = new(ipcState) - -// Connect starts up the GRPC server and connects through a unix socket -func Connect() { - if ipc.connected { - return - } - - // write the IPC service binary to disk - if _, err := os.Stat(ipcSvcBinPath); os.IsNotExist(err) { - if err := ioutil.WriteFile( - ipcSvcBinPath, Binary, 0o700, - ); err != nil { - panic(err) // not sure what better to do just yet - } - } - - // spawn the IPC service - ipc.cmd = exec.Command(ipcSvcBinPath) - - // command will print output to parent terminal - ipc.cmd.Stdout = os.Stdout - ipc.cmd.Stderr = os.Stderr - if err := ipc.cmd.Start(); err != nil { - panic(err) - } - - time.Sleep(time.Second / 4) - - // connect the IPC - dialer := func(ctx context.Context, path string) (net.Conn, error) { - return net.Dial("unix", ipcPath) - } - - var err error - ipc.ClientConn, err = grpc.Dial( - "unix://"+ipcPath, - grpc.WithInsecure(), - grpc.WithContextDialer(dialer), - ) - if err != nil { - panic(err) - } - - ipc.SignerClient = NewSignerClient(ipc.ClientConn) - ipc.ClientConn.Connect() - ipc.connected = true -} - -// Disconnect closes the socket, stops the GRPC server and cleans up -func Disconnect() { - if !ipc.connected { - return - } - - // mark that we are not connected so nobody tries to use this (not concurrent safe!, but should only be done once - // at termination) - ipc.connected = false - - // disconnect the IPC - if err := ipc.ClientConn.Close(); err != nil { - eprintln(err) - } - - // stop the IPC service. The service knows SIGINT means shut down so it will - // stop and release its resources from this signal - if err := ipc.cmd.Process.Signal(syscall.SIGINT); err != nil { - eprintln(err) - } - - // remove the socket file - if err := os.Remove(ipcPath); err != nil { - eprintln(err) - } - - // remove the service binary - if err := os.Remove(ipcSvcBinPath); err != nil { - eprintln(err) - } -} - -func GenerateKeys() (secret []byte, public []byte) { - if !ipc.connected { - eprintln("attempting to call API without being connected") - return - } - ctx, cancel := context.WithCancel(context.Background()) - keys, err := ipc.SignerClient.GenerateKeys( - ctx, - &GenerateKeysRequest{}, - ) - if err != nil { - eprintln(err) - cancel() - return nil, nil - } - sk, pk := keys.GetSecretKey(), keys.GetPublicKey() - cancel() - return sk, pk -} - -func Sign(sk, pk, msg []byte) ( - signature []byte, - err error, -) { - if !ipc.connected { - eprintln("attempting to call API without being connected") - return - } - sig, err := ipc.SignerClient.Sign(context.Background(), - &SignRequest{ - SecretKey: sk, - PublicKey: pk, - Message: msg, - }, - ) - if err != nil { - return nil, err - } - sign := sig.GetSignature() - return sign, nil -} - -func Verify(apk, sig, msg []byte) (err error) { - if !ipc.connected { - eprintln("attempting to call API without being connected") - return - } - var vr *VerifyResponse - vr, err = ipc.SignerClient.Verify(context.Background(), - &VerifyRequest{ - Apk: apk, - Signature: sig, - Message: msg, - }, - ) - if !vr.GetValid() { - return errors.New("invalid signature") - } - return err -} - -func CreateApk(pk []byte) (apk []byte, err error) { - if !ipc.connected { - eprintln("attempting to call API without being connected") - return - } - var a *CreateAPKResponse - a, err = ipc.SignerClient.CreateAPK(context.Background(), - &CreateAPKRequest{ - PublicKey: pk, - }, - ) - apk = a.GetAPK() - return -} - -func AggregatePk(apk []byte, pks ...[]byte) ( - newApk []byte, - err error, -) { - if !ipc.connected { - eprintln("attempting to call API without being connected") - return - } - var a *AggregateResponse - a, err = ipc.SignerClient.AggregatePK(context.Background(), - &AggregatePKRequest{ - APK: apk, - Keys: pks, - }, - ) - newApk = a.GetCode() - return -} - -func AggregateSig(sig []byte, sigs ...[]byte) ( - aggregatedSig []byte, - err error, -) { - if !ipc.connected { - eprintln("attempting to call API without being connected") - return - } - var a *AggregateResponse - a, err = ipc.SignerClient.AggregateSig(context.Background(), - &AggregateSigRequest{ - Signature: sig, - Signatures: sigs, - }, - ) - aggregatedSig = a.GetCode() - return -} - -func eprintln(args ...interface{}) { - _, _ = fmt.Fprint(os.Stderr, "cli: ") - _, _ = fmt.Fprintln(os.Stderr, args...) -} diff --git a/go/grpc/bls/bls12381sig.pb.go b/go/grpc/bls/bls12381sig.pb.go deleted file mode 100644 index f50b090..0000000 --- a/go/grpc/bls/bls12381sig.pb.go +++ /dev/null @@ -1,1359 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.27.1 -// protoc v3.14.0 -// source: bls12381sig.proto - -package bls - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Error int32 - -const ( - Error_BLS_INVALID_BYTES Error = 0 - Error_BLS_VERIFICATION_FAILED Error = 1 - Error_UNKNOWN Error = 2 -) - -// Enum value maps for Error. -var ( - Error_name = map[int32]string{ - 0: "BLS_INVALID_BYTES", - 1: "BLS_VERIFICATION_FAILED", - 2: "UNKNOWN", - } - Error_value = map[string]int32{ - "BLS_INVALID_BYTES": 0, - "BLS_VERIFICATION_FAILED": 1, - "UNKNOWN": 2, - } -) - -func (x Error) Enum() *Error { - p := new(Error) - *p = x - return p -} - -func (x Error) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Error) Descriptor() protoreflect.EnumDescriptor { - return file_bls12381sig_proto_enumTypes[0].Descriptor() -} - -func (Error) Type() protoreflect.EnumType { - return &file_bls12381sig_proto_enumTypes[0] -} - -func (x Error) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Error.Descriptor instead. -func (Error) EnumDescriptor() ([]byte, []int) { - return file_bls12381sig_proto_rawDescGZIP(), []int{0} -} - -type GenerateKeysRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *GenerateKeysRequest) Reset() { - *x = GenerateKeysRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_bls12381sig_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GenerateKeysRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GenerateKeysRequest) ProtoMessage() {} - -func (x *GenerateKeysRequest) ProtoReflect() protoreflect.Message { - mi := &file_bls12381sig_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GenerateKeysRequest.ProtoReflect.Descriptor instead. -func (*GenerateKeysRequest) Descriptor() ([]byte, []int) { - return file_bls12381sig_proto_rawDescGZIP(), []int{0} -} - -type GenerateKeysResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - SecretKey []byte `protobuf:"bytes,1,opt,name=SecretKey,proto3" json:"SecretKey,omitempty"` - PublicKey []byte `protobuf:"bytes,2,opt,name=PublicKey,proto3" json:"PublicKey,omitempty"` -} - -func (x *GenerateKeysResponse) Reset() { - *x = GenerateKeysResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_bls12381sig_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GenerateKeysResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GenerateKeysResponse) ProtoMessage() {} - -func (x *GenerateKeysResponse) ProtoReflect() protoreflect.Message { - mi := &file_bls12381sig_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GenerateKeysResponse.ProtoReflect.Descriptor instead. -func (*GenerateKeysResponse) Descriptor() ([]byte, []int) { - return file_bls12381sig_proto_rawDescGZIP(), []int{1} -} - -func (x *GenerateKeysResponse) GetSecretKey() []byte { - if x != nil { - return x.SecretKey - } - return nil -} - -func (x *GenerateKeysResponse) GetPublicKey() []byte { - if x != nil { - return x.PublicKey - } - return nil -} - -type SignRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - SecretKey []byte `protobuf:"bytes,1,opt,name=SecretKey,proto3" json:"SecretKey,omitempty"` - PublicKey []byte `protobuf:"bytes,2,opt,name=PublicKey,proto3" json:"PublicKey,omitempty"` - Message []byte `protobuf:"bytes,3,opt,name=Message,proto3" json:"Message,omitempty"` -} - -func (x *SignRequest) Reset() { - *x = SignRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_bls12381sig_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SignRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SignRequest) ProtoMessage() {} - -func (x *SignRequest) ProtoReflect() protoreflect.Message { - mi := &file_bls12381sig_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SignRequest.ProtoReflect.Descriptor instead. -func (*SignRequest) Descriptor() ([]byte, []int) { - return file_bls12381sig_proto_rawDescGZIP(), []int{2} -} - -func (x *SignRequest) GetSecretKey() []byte { - if x != nil { - return x.SecretKey - } - return nil -} - -func (x *SignRequest) GetPublicKey() []byte { - if x != nil { - return x.PublicKey - } - return nil -} - -func (x *SignRequest) GetMessage() []byte { - if x != nil { - return x.Message - } - return nil -} - -type SignResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Types that are assignable to Sig: - // *SignResponse_Signature - // *SignResponse_Error - Sig isSignResponse_Sig `protobuf_oneof:"sig"` -} - -func (x *SignResponse) Reset() { - *x = SignResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_bls12381sig_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SignResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SignResponse) ProtoMessage() {} - -func (x *SignResponse) ProtoReflect() protoreflect.Message { - mi := &file_bls12381sig_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SignResponse.ProtoReflect.Descriptor instead. -func (*SignResponse) Descriptor() ([]byte, []int) { - return file_bls12381sig_proto_rawDescGZIP(), []int{3} -} - -func (m *SignResponse) GetSig() isSignResponse_Sig { - if m != nil { - return m.Sig - } - return nil -} - -func (x *SignResponse) GetSignature() []byte { - if x, ok := x.GetSig().(*SignResponse_Signature); ok { - return x.Signature - } - return nil -} - -func (x *SignResponse) GetError() Error { - if x, ok := x.GetSig().(*SignResponse_Error); ok { - return x.Error - } - return Error_BLS_INVALID_BYTES -} - -type isSignResponse_Sig interface { - isSignResponse_Sig() -} - -type SignResponse_Signature struct { - Signature []byte `protobuf:"bytes,1,opt,name=Signature,proto3,oneof"` -} - -type SignResponse_Error struct { - Error Error `protobuf:"varint,2,opt,name=Error,proto3,enum=signer.Error,oneof"` -} - -func (*SignResponse_Signature) isSignResponse_Sig() {} - -func (*SignResponse_Error) isSignResponse_Sig() {} - -type VerifyRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Apk []byte `protobuf:"bytes,1,opt,name=Apk,proto3" json:"Apk,omitempty"` - Signature []byte `protobuf:"bytes,2,opt,name=Signature,proto3" json:"Signature,omitempty"` - Message []byte `protobuf:"bytes,3,opt,name=Message,proto3" json:"Message,omitempty"` -} - -func (x *VerifyRequest) Reset() { - *x = VerifyRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_bls12381sig_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *VerifyRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*VerifyRequest) ProtoMessage() {} - -func (x *VerifyRequest) ProtoReflect() protoreflect.Message { - mi := &file_bls12381sig_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use VerifyRequest.ProtoReflect.Descriptor instead. -func (*VerifyRequest) Descriptor() ([]byte, []int) { - return file_bls12381sig_proto_rawDescGZIP(), []int{4} -} - -func (x *VerifyRequest) GetApk() []byte { - if x != nil { - return x.Apk - } - return nil -} - -func (x *VerifyRequest) GetSignature() []byte { - if x != nil { - return x.Signature - } - return nil -} - -func (x *VerifyRequest) GetMessage() []byte { - if x != nil { - return x.Message - } - return nil -} - -type VerifyResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Types that are assignable to Ver: - // *VerifyResponse_Valid - // *VerifyResponse_Error - Ver isVerifyResponse_Ver `protobuf_oneof:"ver"` -} - -func (x *VerifyResponse) Reset() { - *x = VerifyResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_bls12381sig_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *VerifyResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*VerifyResponse) ProtoMessage() {} - -func (x *VerifyResponse) ProtoReflect() protoreflect.Message { - mi := &file_bls12381sig_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use VerifyResponse.ProtoReflect.Descriptor instead. -func (*VerifyResponse) Descriptor() ([]byte, []int) { - return file_bls12381sig_proto_rawDescGZIP(), []int{5} -} - -func (m *VerifyResponse) GetVer() isVerifyResponse_Ver { - if m != nil { - return m.Ver - } - return nil -} - -func (x *VerifyResponse) GetValid() bool { - if x, ok := x.GetVer().(*VerifyResponse_Valid); ok { - return x.Valid - } - return false -} - -func (x *VerifyResponse) GetError() Error { - if x, ok := x.GetVer().(*VerifyResponse_Error); ok { - return x.Error - } - return Error_BLS_INVALID_BYTES -} - -type isVerifyResponse_Ver interface { - isVerifyResponse_Ver() -} - -type VerifyResponse_Valid struct { - Valid bool `protobuf:"varint,1,opt,name=Valid,proto3,oneof"` -} - -type VerifyResponse_Error struct { - Error Error `protobuf:"varint,2,opt,name=Error,proto3,enum=signer.Error,oneof"` -} - -func (*VerifyResponse_Valid) isVerifyResponse_Ver() {} - -func (*VerifyResponse_Error) isVerifyResponse_Ver() {} - -type CreateAPKRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - PublicKey []byte `protobuf:"bytes,1,opt,name=PublicKey,proto3" json:"PublicKey,omitempty"` -} - -func (x *CreateAPKRequest) Reset() { - *x = CreateAPKRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_bls12381sig_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateAPKRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateAPKRequest) ProtoMessage() {} - -func (x *CreateAPKRequest) ProtoReflect() protoreflect.Message { - mi := &file_bls12381sig_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateAPKRequest.ProtoReflect.Descriptor instead. -func (*CreateAPKRequest) Descriptor() ([]byte, []int) { - return file_bls12381sig_proto_rawDescGZIP(), []int{6} -} - -func (x *CreateAPKRequest) GetPublicKey() []byte { - if x != nil { - return x.PublicKey - } - return nil -} - -type CreateAPKResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Types that are assignable to Apk: - // *CreateAPKResponse_APK - // *CreateAPKResponse_Error - Apk isCreateAPKResponse_Apk `protobuf_oneof:"apk"` -} - -func (x *CreateAPKResponse) Reset() { - *x = CreateAPKResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_bls12381sig_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateAPKResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateAPKResponse) ProtoMessage() {} - -func (x *CreateAPKResponse) ProtoReflect() protoreflect.Message { - mi := &file_bls12381sig_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateAPKResponse.ProtoReflect.Descriptor instead. -func (*CreateAPKResponse) Descriptor() ([]byte, []int) { - return file_bls12381sig_proto_rawDescGZIP(), []int{7} -} - -func (m *CreateAPKResponse) GetApk() isCreateAPKResponse_Apk { - if m != nil { - return m.Apk - } - return nil -} - -func (x *CreateAPKResponse) GetAPK() []byte { - if x, ok := x.GetApk().(*CreateAPKResponse_APK); ok { - return x.APK - } - return nil -} - -func (x *CreateAPKResponse) GetError() Error { - if x, ok := x.GetApk().(*CreateAPKResponse_Error); ok { - return x.Error - } - return Error_BLS_INVALID_BYTES -} - -type isCreateAPKResponse_Apk interface { - isCreateAPKResponse_Apk() -} - -type CreateAPKResponse_APK struct { - APK []byte `protobuf:"bytes,1,opt,name=APK,proto3,oneof"` -} - -type CreateAPKResponse_Error struct { - Error Error `protobuf:"varint,2,opt,name=Error,proto3,enum=signer.Error,oneof"` -} - -func (*CreateAPKResponse_APK) isCreateAPKResponse_Apk() {} - -func (*CreateAPKResponse_Error) isCreateAPKResponse_Apk() {} - -type AggregatePKRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - APK []byte `protobuf:"bytes,1,opt,name=APK,proto3" json:"APK,omitempty"` - Keys [][]byte `protobuf:"bytes,2,rep,name=Keys,proto3" json:"Keys,omitempty"` -} - -func (x *AggregatePKRequest) Reset() { - *x = AggregatePKRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_bls12381sig_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AggregatePKRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AggregatePKRequest) ProtoMessage() {} - -func (x *AggregatePKRequest) ProtoReflect() protoreflect.Message { - mi := &file_bls12381sig_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AggregatePKRequest.ProtoReflect.Descriptor instead. -func (*AggregatePKRequest) Descriptor() ([]byte, []int) { - return file_bls12381sig_proto_rawDescGZIP(), []int{8} -} - -func (x *AggregatePKRequest) GetAPK() []byte { - if x != nil { - return x.APK - } - return nil -} - -func (x *AggregatePKRequest) GetKeys() [][]byte { - if x != nil { - return x.Keys - } - return nil -} - -type AggregateResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Types that are assignable to Agg: - // *AggregateResponse_Code - // *AggregateResponse_Error - Agg isAggregateResponse_Agg `protobuf_oneof:"agg"` -} - -func (x *AggregateResponse) Reset() { - *x = AggregateResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_bls12381sig_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AggregateResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AggregateResponse) ProtoMessage() {} - -func (x *AggregateResponse) ProtoReflect() protoreflect.Message { - mi := &file_bls12381sig_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AggregateResponse.ProtoReflect.Descriptor instead. -func (*AggregateResponse) Descriptor() ([]byte, []int) { - return file_bls12381sig_proto_rawDescGZIP(), []int{9} -} - -func (m *AggregateResponse) GetAgg() isAggregateResponse_Agg { - if m != nil { - return m.Agg - } - return nil -} - -func (x *AggregateResponse) GetCode() []byte { - if x, ok := x.GetAgg().(*AggregateResponse_Code); ok { - return x.Code - } - return nil -} - -func (x *AggregateResponse) GetError() Error { - if x, ok := x.GetAgg().(*AggregateResponse_Error); ok { - return x.Error - } - return Error_BLS_INVALID_BYTES -} - -type isAggregateResponse_Agg interface { - isAggregateResponse_Agg() -} - -type AggregateResponse_Code struct { - Code []byte `protobuf:"bytes,1,opt,name=Code,proto3,oneof"` -} - -type AggregateResponse_Error struct { - Error Error `protobuf:"varint,2,opt,name=Error,proto3,enum=signer.Error,oneof"` -} - -func (*AggregateResponse_Code) isAggregateResponse_Agg() {} - -func (*AggregateResponse_Error) isAggregateResponse_Agg() {} - -type AggregateSigRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Signature []byte `protobuf:"bytes,1,opt,name=Signature,proto3" json:"Signature,omitempty"` - Signatures [][]byte `protobuf:"bytes,2,rep,name=Signatures,proto3" json:"Signatures,omitempty"` -} - -func (x *AggregateSigRequest) Reset() { - *x = AggregateSigRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_bls12381sig_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *AggregateSigRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AggregateSigRequest) ProtoMessage() {} - -func (x *AggregateSigRequest) ProtoReflect() protoreflect.Message { - mi := &file_bls12381sig_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use AggregateSigRequest.ProtoReflect.Descriptor instead. -func (*AggregateSigRequest) Descriptor() ([]byte, []int) { - return file_bls12381sig_proto_rawDescGZIP(), []int{10} -} - -func (x *AggregateSigRequest) GetSignature() []byte { - if x != nil { - return x.Signature - } - return nil -} - -func (x *AggregateSigRequest) GetSignatures() [][]byte { - if x != nil { - return x.Signatures - } - return nil -} - -var File_bls12381sig_proto protoreflect.FileDescriptor - -var file_bls12381sig_proto_rawDesc = []byte{ - 0x0a, 0x11, 0x62, 0x6c, 0x73, 0x31, 0x32, 0x33, 0x38, 0x31, 0x73, 0x69, 0x67, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x22, 0x15, 0x0a, 0x13, 0x47, - 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x22, 0x52, 0x0a, 0x14, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x4b, 0x65, - 0x79, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x65, - 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x53, - 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x75, 0x62, 0x6c, - 0x69, 0x63, 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x50, 0x75, 0x62, - 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x22, 0x63, 0x0a, 0x0b, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, - 0x4b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, - 0x79, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x5c, 0x0a, 0x0c, 0x53, - 0x69, 0x67, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x09, 0x53, - 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, - 0x52, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x25, 0x0a, 0x05, 0x45, - 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x73, 0x69, 0x67, - 0x6e, 0x65, 0x72, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x48, 0x00, 0x52, 0x05, 0x45, 0x72, 0x72, - 0x6f, 0x72, 0x42, 0x05, 0x0a, 0x03, 0x73, 0x69, 0x67, 0x22, 0x59, 0x0a, 0x0d, 0x56, 0x65, 0x72, - 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x41, 0x70, - 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x41, 0x70, 0x6b, 0x12, 0x1c, 0x0a, 0x09, - 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x22, 0x56, 0x0a, 0x0e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x05, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x25, - 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0d, 0x2e, - 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x48, 0x00, 0x52, 0x05, - 0x45, 0x72, 0x72, 0x6f, 0x72, 0x42, 0x05, 0x0a, 0x03, 0x76, 0x65, 0x72, 0x22, 0x30, 0x0a, 0x10, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x50, 0x4b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x09, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x22, 0x55, - 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x50, 0x4b, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x03, 0x41, 0x50, 0x4b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, - 0x48, 0x00, 0x52, 0x03, 0x41, 0x50, 0x4b, 0x12, 0x25, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x2e, - 0x45, 0x72, 0x72, 0x6f, 0x72, 0x48, 0x00, 0x52, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x42, 0x05, - 0x0a, 0x03, 0x61, 0x70, 0x6b, 0x22, 0x3a, 0x0a, 0x12, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, - 0x74, 0x65, 0x50, 0x4b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x41, - 0x50, 0x4b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x41, 0x50, 0x4b, 0x12, 0x12, 0x0a, - 0x04, 0x4b, 0x65, 0x79, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x04, 0x4b, 0x65, 0x79, - 0x73, 0x22, 0x57, 0x0a, 0x11, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x25, 0x0a, 0x05, - 0x45, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0d, 0x2e, 0x73, 0x69, - 0x67, 0x6e, 0x65, 0x72, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x48, 0x00, 0x52, 0x05, 0x45, 0x72, - 0x72, 0x6f, 0x72, 0x42, 0x05, 0x0a, 0x03, 0x61, 0x67, 0x67, 0x22, 0x53, 0x0a, 0x13, 0x41, 0x67, - 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x53, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, - 0x1e, 0x0a, 0x0a, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0c, 0x52, 0x0a, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x2a, - 0x48, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x15, 0x0a, 0x11, 0x42, 0x4c, 0x53, 0x5f, - 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x42, 0x59, 0x54, 0x45, 0x53, 0x10, 0x00, 0x12, - 0x1b, 0x0a, 0x17, 0x42, 0x4c, 0x53, 0x5f, 0x56, 0x45, 0x52, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, - 0x49, 0x4f, 0x4e, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, - 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x02, 0x32, 0x8f, 0x03, 0x0a, 0x06, 0x53, 0x69, - 0x67, 0x6e, 0x65, 0x72, 0x12, 0x49, 0x0a, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, - 0x4b, 0x65, 0x79, 0x73, 0x12, 0x1b, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x2e, 0x47, 0x65, - 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x1c, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, - 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x31, 0x0a, 0x04, 0x53, 0x69, 0x67, 0x6e, 0x12, 0x13, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, - 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x73, - 0x69, 0x67, 0x6e, 0x65, 0x72, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x37, 0x0a, 0x06, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x12, 0x15, 0x2e, 0x73, - 0x69, 0x67, 0x6e, 0x65, 0x72, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x2e, 0x56, 0x65, 0x72, - 0x69, 0x66, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x40, 0x0a, 0x09, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x50, 0x4b, 0x12, 0x18, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x65, - 0x72, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x41, 0x50, 0x4b, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x2e, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x41, 0x50, 0x4b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, - 0x0b, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x50, 0x4b, 0x12, 0x1a, 0x2e, 0x73, - 0x69, 0x67, 0x6e, 0x65, 0x72, 0x2e, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x50, - 0x4b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x65, - 0x72, 0x2e, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x46, 0x0a, 0x0c, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, - 0x53, 0x69, 0x67, 0x12, 0x1b, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x2e, 0x41, 0x67, 0x67, - 0x72, 0x65, 0x67, 0x61, 0x74, 0x65, 0x53, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x19, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x2e, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, - 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3e, 0x5a, 0x3c, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x75, 0x73, 0x6b, 0x2d, 0x6e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2f, 0x62, 0x6c, 0x73, 0x31, 0x32, 0x5f, 0x33, 0x38, 0x31, - 0x2d, 0x73, 0x69, 0x67, 0x6e, 0x2f, 0x62, 0x6c, 0x73, 0x31, 0x32, 0x5f, 0x33, 0x38, 0x31, 0x2d, - 0x73, 0x69, 0x67, 0x6e, 0x2d, 0x67, 0x6f, 0x2f, 0x62, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, -} - -var ( - file_bls12381sig_proto_rawDescOnce sync.Once - file_bls12381sig_proto_rawDescData = file_bls12381sig_proto_rawDesc -) - -func file_bls12381sig_proto_rawDescGZIP() []byte { - file_bls12381sig_proto_rawDescOnce.Do(func() { - file_bls12381sig_proto_rawDescData = protoimpl.X.CompressGZIP(file_bls12381sig_proto_rawDescData) - }) - return file_bls12381sig_proto_rawDescData -} - -var file_bls12381sig_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_bls12381sig_proto_msgTypes = make([]protoimpl.MessageInfo, 11) -var file_bls12381sig_proto_goTypes = []interface{}{ - (Error)(0), // 0: signer.Error - (*GenerateKeysRequest)(nil), // 1: signer.GenerateKeysRequest - (*GenerateKeysResponse)(nil), // 2: signer.GenerateKeysResponse - (*SignRequest)(nil), // 3: signer.SignRequest - (*SignResponse)(nil), // 4: signer.SignResponse - (*VerifyRequest)(nil), // 5: signer.VerifyRequest - (*VerifyResponse)(nil), // 6: signer.VerifyResponse - (*CreateAPKRequest)(nil), // 7: signer.CreateAPKRequest - (*CreateAPKResponse)(nil), // 8: signer.CreateAPKResponse - (*AggregatePKRequest)(nil), // 9: signer.AggregatePKRequest - (*AggregateResponse)(nil), // 10: signer.AggregateResponse - (*AggregateSigRequest)(nil), // 11: signer.AggregateSigRequest -} -var file_bls12381sig_proto_depIdxs = []int32{ - 0, // 0: signer.SignResponse.Error:type_name -> signer.Error - 0, // 1: signer.VerifyResponse.Error:type_name -> signer.Error - 0, // 2: signer.CreateAPKResponse.Error:type_name -> signer.Error - 0, // 3: signer.AggregateResponse.Error:type_name -> signer.Error - 1, // 4: signer.Signer.GenerateKeys:input_type -> signer.GenerateKeysRequest - 3, // 5: signer.Signer.Sign:input_type -> signer.SignRequest - 5, // 6: signer.Signer.Verify:input_type -> signer.VerifyRequest - 7, // 7: signer.Signer.CreateAPK:input_type -> signer.CreateAPKRequest - 9, // 8: signer.Signer.AggregatePK:input_type -> signer.AggregatePKRequest - 11, // 9: signer.Signer.AggregateSig:input_type -> signer.AggregateSigRequest - 2, // 10: signer.Signer.GenerateKeys:output_type -> signer.GenerateKeysResponse - 4, // 11: signer.Signer.Sign:output_type -> signer.SignResponse - 6, // 12: signer.Signer.Verify:output_type -> signer.VerifyResponse - 8, // 13: signer.Signer.CreateAPK:output_type -> signer.CreateAPKResponse - 10, // 14: signer.Signer.AggregatePK:output_type -> signer.AggregateResponse - 10, // 15: signer.Signer.AggregateSig:output_type -> signer.AggregateResponse - 10, // [10:16] is the sub-list for method output_type - 4, // [4:10] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name -} - -func init() { file_bls12381sig_proto_init() } -func file_bls12381sig_proto_init() { - if File_bls12381sig_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_bls12381sig_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GenerateKeysRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_bls12381sig_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GenerateKeysResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_bls12381sig_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SignRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_bls12381sig_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SignResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_bls12381sig_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*VerifyRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_bls12381sig_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*VerifyResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_bls12381sig_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateAPKRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_bls12381sig_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateAPKResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_bls12381sig_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AggregatePKRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_bls12381sig_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AggregateResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_bls12381sig_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AggregateSigRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_bls12381sig_proto_msgTypes[3].OneofWrappers = []interface{}{ - (*SignResponse_Signature)(nil), - (*SignResponse_Error)(nil), - } - file_bls12381sig_proto_msgTypes[5].OneofWrappers = []interface{}{ - (*VerifyResponse_Valid)(nil), - (*VerifyResponse_Error)(nil), - } - file_bls12381sig_proto_msgTypes[7].OneofWrappers = []interface{}{ - (*CreateAPKResponse_APK)(nil), - (*CreateAPKResponse_Error)(nil), - } - file_bls12381sig_proto_msgTypes[9].OneofWrappers = []interface{}{ - (*AggregateResponse_Code)(nil), - (*AggregateResponse_Error)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_bls12381sig_proto_rawDesc, - NumEnums: 1, - NumMessages: 11, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_bls12381sig_proto_goTypes, - DependencyIndexes: file_bls12381sig_proto_depIdxs, - EnumInfos: file_bls12381sig_proto_enumTypes, - MessageInfos: file_bls12381sig_proto_msgTypes, - }.Build() - File_bls12381sig_proto = out.File - file_bls12381sig_proto_rawDesc = nil - file_bls12381sig_proto_goTypes = nil - file_bls12381sig_proto_depIdxs = nil -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConnInterface - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 - -// SignerClient is the client API for Signer service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type SignerClient interface { - GenerateKeys(ctx context.Context, in *GenerateKeysRequest, opts ...grpc.CallOption) (*GenerateKeysResponse, error) - Sign(ctx context.Context, in *SignRequest, opts ...grpc.CallOption) (*SignResponse, error) - Verify(ctx context.Context, in *VerifyRequest, opts ...grpc.CallOption) (*VerifyResponse, error) - CreateAPK(ctx context.Context, in *CreateAPKRequest, opts ...grpc.CallOption) (*CreateAPKResponse, error) - AggregatePK(ctx context.Context, in *AggregatePKRequest, opts ...grpc.CallOption) (*AggregateResponse, error) - AggregateSig(ctx context.Context, in *AggregateSigRequest, opts ...grpc.CallOption) (*AggregateResponse, error) -} - -type signerClient struct { - cc grpc.ClientConnInterface -} - -func NewSignerClient(cc grpc.ClientConnInterface) SignerClient { - return &signerClient{cc} -} - -func (c *signerClient) GenerateKeys(ctx context.Context, in *GenerateKeysRequest, opts ...grpc.CallOption) (*GenerateKeysResponse, error) { - out := new(GenerateKeysResponse) - err := c.cc.Invoke(ctx, "/signer.Signer/GenerateKeys", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *signerClient) Sign(ctx context.Context, in *SignRequest, opts ...grpc.CallOption) (*SignResponse, error) { - out := new(SignResponse) - err := c.cc.Invoke(ctx, "/signer.Signer/Sign", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *signerClient) Verify(ctx context.Context, in *VerifyRequest, opts ...grpc.CallOption) (*VerifyResponse, error) { - out := new(VerifyResponse) - err := c.cc.Invoke(ctx, "/signer.Signer/Verify", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *signerClient) CreateAPK(ctx context.Context, in *CreateAPKRequest, opts ...grpc.CallOption) (*CreateAPKResponse, error) { - out := new(CreateAPKResponse) - err := c.cc.Invoke(ctx, "/signer.Signer/CreateAPK", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *signerClient) AggregatePK(ctx context.Context, in *AggregatePKRequest, opts ...grpc.CallOption) (*AggregateResponse, error) { - out := new(AggregateResponse) - err := c.cc.Invoke(ctx, "/signer.Signer/AggregatePK", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *signerClient) AggregateSig(ctx context.Context, in *AggregateSigRequest, opts ...grpc.CallOption) (*AggregateResponse, error) { - out := new(AggregateResponse) - err := c.cc.Invoke(ctx, "/signer.Signer/AggregateSig", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// SignerServer is the server API for Signer service. -type SignerServer interface { - GenerateKeys(context.Context, *GenerateKeysRequest) (*GenerateKeysResponse, error) - Sign(context.Context, *SignRequest) (*SignResponse, error) - Verify(context.Context, *VerifyRequest) (*VerifyResponse, error) - CreateAPK(context.Context, *CreateAPKRequest) (*CreateAPKResponse, error) - AggregatePK(context.Context, *AggregatePKRequest) (*AggregateResponse, error) - AggregateSig(context.Context, *AggregateSigRequest) (*AggregateResponse, error) -} - -// UnimplementedSignerServer can be embedded to have forward compatible implementations. -type UnimplementedSignerServer struct { -} - -func (*UnimplementedSignerServer) GenerateKeys(context.Context, *GenerateKeysRequest) (*GenerateKeysResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GenerateKeys not implemented") -} -func (*UnimplementedSignerServer) Sign(context.Context, *SignRequest) (*SignResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Sign not implemented") -} -func (*UnimplementedSignerServer) Verify(context.Context, *VerifyRequest) (*VerifyResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Verify not implemented") -} -func (*UnimplementedSignerServer) CreateAPK(context.Context, *CreateAPKRequest) (*CreateAPKResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateAPK not implemented") -} -func (*UnimplementedSignerServer) AggregatePK(context.Context, *AggregatePKRequest) (*AggregateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AggregatePK not implemented") -} -func (*UnimplementedSignerServer) AggregateSig(context.Context, *AggregateSigRequest) (*AggregateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AggregateSig not implemented") -} - -func RegisterSignerServer(s *grpc.Server, srv SignerServer) { - s.RegisterService(&_Signer_serviceDesc, srv) -} - -func _Signer_GenerateKeys_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GenerateKeysRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(SignerServer).GenerateKeys(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/signer.Signer/GenerateKeys", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SignerServer).GenerateKeys(ctx, req.(*GenerateKeysRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Signer_Sign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SignRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(SignerServer).Sign(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/signer.Signer/Sign", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SignerServer).Sign(ctx, req.(*SignRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Signer_Verify_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(VerifyRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(SignerServer).Verify(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/signer.Signer/Verify", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SignerServer).Verify(ctx, req.(*VerifyRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Signer_CreateAPK_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateAPKRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(SignerServer).CreateAPK(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/signer.Signer/CreateAPK", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SignerServer).CreateAPK(ctx, req.(*CreateAPKRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Signer_AggregatePK_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AggregatePKRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(SignerServer).AggregatePK(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/signer.Signer/AggregatePK", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SignerServer).AggregatePK(ctx, req.(*AggregatePKRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Signer_AggregateSig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AggregateSigRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(SignerServer).AggregateSig(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/signer.Signer/AggregateSig", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SignerServer).AggregateSig(ctx, req.(*AggregateSigRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Signer_serviceDesc = grpc.ServiceDesc{ - ServiceName: "signer.Signer", - HandlerType: (*SignerServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GenerateKeys", - Handler: _Signer_GenerateKeys_Handler, - }, - { - MethodName: "Sign", - Handler: _Signer_Sign_Handler, - }, - { - MethodName: "Verify", - Handler: _Signer_Verify_Handler, - }, - { - MethodName: "CreateAPK", - Handler: _Signer_CreateAPK_Handler, - }, - { - MethodName: "AggregatePK", - Handler: _Signer_AggregatePK_Handler, - }, - { - MethodName: "AggregateSig", - Handler: _Signer_AggregateSig_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "bls12381sig.proto", -} diff --git a/go/grpc/bls/bls_test.go b/go/grpc/bls/bls_test.go deleted file mode 100644 index f15f075..0000000 --- a/go/grpc/bls/bls_test.go +++ /dev/null @@ -1,190 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -package bls - -import ( - "crypto/rand" - "encoding/hex" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestConnect(t *testing.T) { - Connect() -} - -func TestGenerateKeysIPC(t *testing.T) { - - sk, pk := GenerateKeys() - if sk == nil || pk == nil { - t.Fatal("generate keys failed") - } - assert.NotEqual(t, sk, make([]byte, 32)) - assert.NotEqual(t, pk, make([]byte, 96)) -} - -func TestSignVerifyIPC(t *testing.T) { - - sk, pk := GenerateKeys() - msg := make([]byte, 100) - rand.Read(msg) - sig, err := Sign(sk, pk, msg) - if err != nil { - t.Fatal(err) - } - - apk, err := CreateApk(pk) - if err != nil { - t.Fatal(err) - } - - err = Verify(apk, sig, msg) - if err != nil { - t.Fatal(err) - } -} - -func TestVerifyWrongKeyIPC(t *testing.T) { - - sk, pk := GenerateKeys() - msg := make([]byte, 100) - rand.Read(msg) - sig, err := Sign(sk, pk, msg) - if err != nil { - t.Fatal(err) - } - - _, pk = GenerateKeys() - - apk, err := CreateApk(pk) - if err != nil { - t.Fatal(err) - } - - assert.Error(t, Verify(apk, sig, msg)) -} - -func TestAggregationIPC(t *testing.T) { - - // Generate keys - sk1, pk1 := GenerateKeys() - msg := make([]byte, 100) - rand.Read(msg) - sig1, err := Sign(sk1, pk1, msg) - if err != nil { - t.Fatal(err) - } - - apk1, err := CreateApk(pk1) - if err != nil { - t.Fatal(err) - } - - // Aggregating pk - sk2, pk2 := GenerateKeys() - sk3, pk3 := GenerateKeys() - apk2, err := AggregatePk(apk1, pk2, pk3) - if err != nil { - t.Fatal(err) - } - - // Aggregating sigs - sig2, err := Sign(sk2, pk2, msg) - if err != nil { - t.Fatal(err) - } - - sig3, err := Sign(sk3, pk3, msg) - if err != nil { - t.Fatal(err) - } - - aggSig, err := AggregateSig(sig1, sig2, sig3) - if err != nil { - t.Fatal(err) - } - - // Aggregated verification - err = Verify(apk2, aggSig, msg) - if err != nil { - t.Fatal(err) - } -} - -func mustDecode(str string) []byte { - ret, err := hex.DecodeString(str) - if err != nil { - panic(err) - } - return ret -} - -func TestAggregationSxS(t *testing.T) { - sk1 := mustDecode("275825c0c399fe8aa175dfb048632982ac8c67f9a1e1b99c85da7773d135eb20") - pk1 := mustDecode("abd2734535d9d46c150b716ed7b61e269e2fe50d34cc1a3ba4d3b88b2a56b70df7452d049c2b836da7030e809ceb2aab0b7580f7a07d25b27e52ca50a4b47d77e5b803a4cd6693947081623f03b5085c4738019529db74caab836af2e6bd7899") - msg := mustDecode("3ca997e58872f360c0435bf095631be4744455101c180c6f54534523db2ab9a228ce4923736905eb3570559011af2c6016856b3c264679e5efc0157ab08eb0aed14f383951bca11a3d55ce045522a5ebbcf7f31ca42bce27bbe21051571cfef20e275ff4") - sig1 := mustDecode("8a8c630f0ef76ef839e5efc381c8c4e174a4df519c3ece7700cf4fc3605e8b28eb4939aae29a0d6a7d886f09951e8524") - apk1 := mustDecode("a30093bf196c836c7bab41bdc31157654d9e62688093bb38263a9c87b91f04adecfb0d8cce54b05acdf13a7d1812a83d0888322868d58fc3536bf03e3e36929d3811ee0219d80760307ce1cf6abe6f069b246a6b00390693368824c4d807a470") - sk2 := mustDecode("aeae057edbe5f444a060f6f91ed2a1ca3408bebb337b695f2819c90c62283917") - pk2 := mustDecode("afb3ab8b5a4a86875921f9779ce82026b90ec0d60def8819f5f99e6e1cf3960d33ec8999f347bdef1fd356c30a585e73067f47f9ee371d45ff3f92b7df21df1b79ec5e58dd4b7b781d06a83b97ed5d3034c88de68461fad5d8f6f4107f7d8e9f") - sk3 := mustDecode("5f618fef73a63402929892ad6242cafc9d5e2c7ecef02aa90646887b9a9bd335") - pk3 := mustDecode("89337f90d1aaff5f4884e068435596d0d157b424c0f6eb88554f1f922edcd69ca8e92408942609441b4b4b31a0ff7a331810e6cc835ee8a483f9d8d93347f2559e5db04a0aaeff8a175013652cb7f772e14e68f7c49c89f202ac0988c296a0bb") - apk2 := mustDecode("8abacd1d201478f19898cc31c7fb7dc3c631698e497c641c6cfe1628f55f6b592cedc6903a009cdc080f13e732763b65123c854563e20894c31c538543e452e47057a3c66ca85b6a58ea8518c9ac56fe3b8489cbded4610d5a2763cc9a0dfb35") - sig2 := mustDecode("913e34c462f1d171a08df75da1fdcbb6a6f6268be14fd304014459feb7201254bc43ddbb2456acb2f454ae4f8b603fa7") - sig3 := mustDecode("b6b42e47d92f011afb4f63266a4a40af458c2d050d6ccb4320e498a37d0d11565e67783c9f0202f864db591c70f8f4f4") - aggSig := mustDecode("b36d9f47b3b0dc9c370d034c9ab56adcd826bda37744c5f24f1b874c50f740dcb161d0d4a32eb36ee7b2f7ac94982300") - - - sig1a, err := Sign(sk1, pk1, msg) - if err != nil { - t.Fatal(err) - } - assert.Equal(t, hex.EncodeToString(sig1), hex.EncodeToString(sig1a)) - - apk1a, err := CreateApk(pk1) - if err != nil { - t.Fatal(err) - } - assert.Equal(t, hex.EncodeToString(apk1), hex.EncodeToString(apk1a)) - - // Aggregating pk - apk2a, err := AggregatePk(apk1, pk2, pk3) - if err != nil { - t.Fatal(err) - } - assert.Equal(t, hex.EncodeToString(apk2), hex.EncodeToString(apk2a)) - - // Aggregating sigs - sig2a, err := Sign(sk2, pk2, msg) - if err != nil { - t.Fatal(err) - } - assert.Equal(t, hex.EncodeToString(sig2), hex.EncodeToString(sig2a)) - - sig3a, err := Sign(sk3, pk3, msg) - if err != nil { - t.Fatal(err) - } - assert.Equal(t, hex.EncodeToString(sig3), hex.EncodeToString(sig3a)) - - aggSiga, err := AggregateSig(sig1, sig2, sig3) - if err != nil { - t.Fatal(err) - } - assert.Equal(t, hex.EncodeToString(aggSig), hex.EncodeToString(aggSiga)) - - // Aggregated verification - err = Verify(apk2, aggSig, msg) - if err != nil { - t.Fatal(err) - } -} - -func TestDisconnect(t *testing.T) { - Disconnect() -} diff --git a/go/grpc/bls/go.mod b/go/grpc/bls/go.mod deleted file mode 100644 index bebca1f..0000000 --- a/go/grpc/bls/go.mod +++ /dev/null @@ -1,20 +0,0 @@ -module github.com/dusk-network/bls12_381-sign/go/grpc/bls - -go 1.17 - -require ( - github.com/stretchr/testify v1.7.0 - google.golang.org/grpc v1.42.0 - google.golang.org/protobuf v1.25.0 -) - -require ( - github.com/davecgh/go-spew v1.1.0 // indirect - github.com/golang/protobuf v1.4.3 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/net v0.0.0-20200822124328-c89045814202 // indirect - golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd // indirect - golang.org/x/text v0.3.0 // indirect - google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect - gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect -) diff --git a/go/grpc/bls/go.sum b/go/grpc/bls/go.sum deleted file mode 100644 index ddb5ebd..0000000 --- a/go/grpc/bls/go.sum +++ /dev/null @@ -1,120 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A= -google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/go/grpc/bls/ipc_windows.go b/go/grpc/bls/ipc_windows.go deleted file mode 100644 index 328dcf7..0000000 --- a/go/grpc/bls/ipc_windows.go +++ /dev/null @@ -1,15 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -package bls - -func SwitchToCgo() { - panic("does not run on windows due to no unix domain sockets") -} - -func SwitchToIPC() { - panic("does not run on windows due to no unix domain sockets") -} diff --git a/go/grpc/bls/svc_darwin.go b/go/grpc/bls/svc_darwin.go deleted file mode 100644 index c3f9e73..0000000 --- a/go/grpc/bls/svc_darwin.go +++ /dev/null @@ -1,14 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -package bls - -import ( - _ "embed" -) - -//go:embed bls12381svc_macos-latest -var Binary []byte diff --git a/go/grpc/bls/svc_linux.go b/go/grpc/bls/svc_linux.go deleted file mode 100644 index 8454cdd..0000000 --- a/go/grpc/bls/svc_linux.go +++ /dev/null @@ -1,14 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -package bls - -import ( - _ "embed" -) - -//go:embed bls12381svc_ubuntu-latest -var Binary []byte diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 8b57f60..0000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -nightly-2023-10-29 diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..12b69ce --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "nightly-2023-10-29" +components = ["rustfmt", "clippy"] +targets = ["thumbv6m-none-eabi"] diff --git a/rust/Cargo.toml b/rust/Cargo.toml deleted file mode 100644 index c6fdc0b..0000000 --- a/rust/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[workspace] -members = [ - "bls12_381-sign", "bls12_381-sign-ffi", "grpc-server" -] - -[profile.dev] -panic = "abort" - -[profile.release] -panic = "abort" -lto = true -incremental = false -codegen-units = 1 - diff --git a/rust/LICENSE b/rust/LICENSE deleted file mode 100644 index 52d1351..0000000 --- a/rust/LICENSE +++ /dev/null @@ -1,374 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. - diff --git a/rust/bls12_381-sign-ffi/Cargo.toml b/rust/bls12_381-sign-ffi/Cargo.toml deleted file mode 100644 index 500d484..0000000 --- a/rust/bls12_381-sign-ffi/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "dusk-bls12_381-sign-ffi" -version = "0.4.0" -authors = [ - "Jules de Smit ", - "Matteo Ferretti ", - "Emanuele Paterna ", - "David Vennik ", -] -edition = "2021" -description = "Implementation of BLS signatures using the BLS12-381 curve" -license = "MPL-2.0" - -[dependencies] -dusk-bls12_381 = { version = "0.12", default-features = false, features = ["groups"] } -dusk-bls12_381-sign = { path = "../bls12_381-sign" } -dusk-bytes = "0.1" -libc = "0.2" -rand_core = { version = "0.6", default-features = false, features = ["getrandom"] } - -[lib] -crate-type = ["rlib", "staticlib"] diff --git a/rust/bls12_381-sign-ffi/src/lib.rs b/rust/bls12_381-sign-ffi/src/lib.rs deleted file mode 100644 index bca3a6b..0000000 --- a/rust/bls12_381-sign-ffi/src/lib.rs +++ /dev/null @@ -1,207 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -use dusk_bls12_381::G2Affine; -use dusk_bls12_381_sign::{Error, PublicKey, SecretKey, Signature, APK}; -use dusk_bytes::Serializable; -use libc::{c_int, c_uchar, size_t}; - -use core::{ptr, slice}; - -pub const SK_SIZE: usize = SecretKey::SIZE; -pub const SIG_SIZE: usize = Signature::SIZE; -pub const PK_SIZE: usize = PublicKey::SIZE; -pub const PK_RAW_SIZE: usize = G2Affine::RAW_SIZE; - -pub const RES_OK: c_int = 0; -pub const RES_BYTES_ERROR: c_int = 1; -pub const RES_INVALID_SIGNATURE: c_int = 2; - -macro_rules! unwrap_or_bail { - ( $e: expr ) => { - match $e.map_err(|e| e.into()) { - Ok(v) => v, - Err(Error::BytesError(_)) => return RES_BYTES_ERROR, - Err(Error::InvalidSignature) => return RES_INVALID_SIGNATURE, - } - }; -} - -#[no_mangle] -pub unsafe extern "C" fn generate_keys(sk_ptr: *mut u8, pk_ptr: *mut u8) { - let sk = SecretKey::random(&mut rand_core::OsRng); - let pk = PublicKey::from(&sk); - - ptr::copy_nonoverlapping(&sk.to_bytes()[0] as *const u8, sk_ptr, SK_SIZE); - ptr::copy_nonoverlapping(&pk.to_bytes()[0] as *const u8, pk_ptr, PK_SIZE); -} - -#[no_mangle] -pub unsafe extern "C" fn generate_keys_with_raw( - sk_ptr: *mut u8, - pk_ptr: *mut u8, - pk_raw_ptr: *mut u8, -) { - let sk = SecretKey::random(&mut rand_core::OsRng); - let pk = PublicKey::from(&sk); - - ptr::copy_nonoverlapping(&sk.to_bytes()[0] as *const u8, sk_ptr, SK_SIZE); - ptr::copy_nonoverlapping(&pk.to_bytes()[0] as *const u8, pk_ptr, PK_SIZE); - ptr::copy_nonoverlapping( - &pk.to_raw_bytes()[0] as *const u8, - pk_raw_ptr, - PK_RAW_SIZE, - ); -} - -#[no_mangle] -pub unsafe extern "C" fn sign( - sk_ptr: *const [c_uchar; SK_SIZE], - pk_ptr: *const [c_uchar; PK_SIZE], - msg_ptr: *mut u8, - msg_len: size_t, - sig_ptr: *mut u8, -) -> c_int { - let sk = unwrap_or_bail!(SecretKey::from_bytes(&*sk_ptr)); - let pk = unwrap_or_bail!(PublicKey::from_bytes(&*pk_ptr)); - - let msg = slice::from_raw_parts(msg_ptr, msg_len); - - let sig = sk.sign(&pk, msg); - ptr::copy_nonoverlapping( - &sig.to_bytes()[0] as *const u8, - sig_ptr, - SIG_SIZE, - ); - RES_OK -} - -#[no_mangle] -pub unsafe extern "C" fn verify( - apk_ptr: *const [c_uchar; PK_SIZE], - sig_ptr: *const [c_uchar; SIG_SIZE], - msg_ptr: *mut u8, - msg_len: size_t, -) -> c_int { - let apk = unwrap_or_bail!(APK::from_bytes(&*apk_ptr)); - let sig = unwrap_or_bail!(Signature::from_bytes(&*sig_ptr)); - - let msg = slice::from_raw_parts(msg_ptr, msg_len); - - match apk.verify(&sig, msg).is_ok() { - true => RES_OK, - false => RES_INVALID_SIGNATURE, - } -} - -#[no_mangle] -pub unsafe extern "C" fn create_apk( - pk_ptr: *const [c_uchar; PK_SIZE], - apk_ptr: *mut u8, -) -> c_int { - let pk = unwrap_or_bail!(PublicKey::from_bytes(&*pk_ptr)); - - let apk = APK::from(&pk); - ptr::copy_nonoverlapping(&apk.to_bytes()[0] as *const u8, apk_ptr, PK_SIZE); - RES_OK -} - -#[no_mangle] -pub unsafe extern "C" fn aggregate_pk( - apk_ptr: *const [c_uchar; PK_SIZE], - pk_ptr: *mut u8, - pk_len: size_t, - ret_ptr: *mut u8, -) -> c_int { - let mut apk = unwrap_or_bail!(APK::from_bytes(&*apk_ptr)); - - let pk_slice = slice::from_raw_parts(pk_ptr, pk_len); - let pks: Result, dusk_bytes::Error> = pk_slice - .chunks(PK_SIZE) - .map(|bytes| { - let mut arr = [0u8; PK_SIZE]; - arr.copy_from_slice(bytes); - PublicKey::from_bytes(&arr) - }) - .collect(); - - let pks = unwrap_or_bail!(pks); - apk.aggregate(&pks); - ptr::copy_nonoverlapping(&apk.to_bytes()[0] as *const u8, ret_ptr, PK_SIZE); - RES_OK -} - -#[no_mangle] -pub unsafe extern "C" fn aggregate_sig( - sig_ptr: *const [c_uchar; SIG_SIZE], - sigs_ptr: *mut u8, - sigs_len: size_t, - ret_ptr: *mut u8, -) -> c_int { - let sig = unwrap_or_bail!(Signature::from_bytes(&*sig_ptr)); - - let sig_slice = slice::from_raw_parts(sigs_ptr, sigs_len); - let sigs: Result, Error> = sig_slice - .chunks(SIG_SIZE) - .map(|bytes| { - let mut arr = [0u8; SIG_SIZE]; - arr.copy_from_slice(bytes); - Signature::from_bytes(&arr) - }) - .collect(); - - let sigs = unwrap_or_bail!(sigs); - let sig = sig.aggregate(&sigs); - ptr::copy_nonoverlapping( - &sig.to_bytes()[0] as *const u8, - ret_ptr, - SIG_SIZE, - ); - RES_OK -} - -#[no_mangle] -pub unsafe extern "C" fn apk_to_raw( - apk_ptr: *const [c_uchar; PK_SIZE], - ret_ptr: *mut u8, -) -> c_int { - let apk = unwrap_or_bail!(APK::from_bytes(&*apk_ptr)); - let apk_raw = apk.to_raw_bytes(); - ptr::copy_nonoverlapping(&apk_raw[0] as *const u8, ret_ptr, PK_RAW_SIZE); - RES_OK -} - -#[no_mangle] -pub unsafe extern "C" fn pk_to_raw( - apk_ptr: *const [c_uchar; PK_SIZE], - ret_ptr: *mut u8, -) -> c_int { - let apk = unwrap_or_bail!(PublicKey::from_bytes(&*apk_ptr)); - let apk_raw = apk.to_raw_bytes(); - ptr::copy_nonoverlapping(&apk_raw[0] as *const u8, ret_ptr, PK_RAW_SIZE); - RES_OK -} - -#[no_mangle] -/// Aggregate a set of raw [`PublicKey`]. Returns a compressed [`APK`] -pub unsafe extern "C" fn aggregate_pks_unchecked( - pks_ptr: *mut u8, - pks_len: size_t, - ret_ptr: *mut u8, -) { - let pk_slice = slice::from_raw_parts(pks_ptr, pks_len); - let pks: Vec = pk_slice - .chunks(PK_RAW_SIZE) - .map(|bytes| { - let mut arr = [0u8; PK_RAW_SIZE]; - arr.copy_from_slice(bytes); - PublicKey::from_slice_unchecked(&arr) - }) - .collect(); - let mut apk = APK::from(pks.get_unchecked(0)); - apk.aggregate(&pks[1..]); - ptr::copy_nonoverlapping(&apk.to_bytes()[0] as *const u8, ret_ptr, PK_SIZE); -} diff --git a/rust/bls12_381-sign/.gitignore b/rust/bls12_381-sign/.gitignore deleted file mode 100644 index 6a59f55..0000000 --- a/rust/bls12_381-sign/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target -Cargo.lock -/.idea \ No newline at end of file diff --git a/rust/bls12_381-sign/README.md b/rust/bls12_381-sign/README.md deleted file mode 100644 index d902dbd..0000000 --- a/rust/bls12_381-sign/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# Implementation of [BLS signatures](https://crypto.stanford.edu/~dabo/pubs/papers/BLSmultisig.html) using the BLS12-381 curve. - -This implementation currently only supports rogue-key attack resistant batching, and does not support distinct message verification. - -## Benchmarks - -### Machine specs - -The benchmarks were ran on a 2020 13.3" MacBook Pro. - -CPU: -``` -$ lscpu -Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz -``` - -RAM: -``` -16 GB 3733 MHz LPDDR4X -``` - -### Results - -``` -test benches::bench_aggregate_pk ... bench: 1,654,552 ns/iter (+/- 107,025) -test benches::bench_aggregate_sig ... bench: 36,893 ns/iter (+/- 3,399) -test benches::bench_sign ... bench: 1,480,169 ns/iter (+/- 106,151) -test benches::bench_sign_vulnerable ... bench: 1,024,052 ns/iter (+/- 111,395) -test benches::bench_verify ... bench: 4,740,114 ns/iter (+/- 336,036) -``` diff --git a/rust/bls12_381-sign/src/ffi.rs b/rust/bls12_381-sign/src/ffi.rs deleted file mode 100644 index 3682d9b..0000000 --- a/rust/bls12_381-sign/src/ffi.rs +++ /dev/null @@ -1,215 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -use crate::{Error, PublicKey, SecretKey, Signature, APK}; - -use dusk_bls12_381::G2Affine; -use dusk_bytes::Serializable; -use libc::{c_int, c_uchar, size_t}; - -use alloc::vec::Vec; -use core::{ptr, slice}; - -pub const SK_SIZE: usize = SecretKey::SIZE; -pub const SIG_SIZE: usize = Signature::SIZE; -pub const PK_SIZE: usize = PublicKey::SIZE; -pub const PK_RAW_SIZE: usize = G2Affine::RAW_SIZE; - -const BLS_OK: c_int = 0; - -impl From for c_int { - fn from(e: Error) -> Self { - match e { - Error::BytesError(_) => 1, - Error::InvalidSignature => 2, - } - } -} - -macro_rules! unwrap_or_bail { - ( $e: expr ) => { - match $e { - Ok(v) => v, - Err(e) => return e.into(), - } - }; -} - -#[no_mangle] -pub unsafe extern "C" fn generate_keys(sk_ptr: *mut u8, pk_ptr: *mut u8) { - let sk = SecretKey::random(&mut rand_core::OsRng); - let pk = PublicKey::from(&sk); - - ptr::copy_nonoverlapping(&sk.to_bytes()[0] as *const u8, sk_ptr, SK_SIZE); - ptr::copy_nonoverlapping(&pk.to_bytes()[0] as *const u8, pk_ptr, PK_SIZE); -} - -#[no_mangle] -pub unsafe extern "C" fn generate_keys_with_raw( - sk_ptr: *mut u8, - pk_ptr: *mut u8, - pk_raw_ptr: *mut u8, -) { - let sk = SecretKey::random(&mut rand_core::OsRng); - let pk = PublicKey::from(&sk); - - ptr::copy_nonoverlapping(&sk.to_bytes()[0] as *const u8, sk_ptr, SK_SIZE); - ptr::copy_nonoverlapping(&pk.to_bytes()[0] as *const u8, pk_ptr, PK_SIZE); - ptr::copy_nonoverlapping( - &pk.to_raw_bytes()[0] as *const u8, - pk_raw_ptr, - PK_RAW_SIZE, - ); -} - -#[no_mangle] -pub unsafe extern "C" fn sign( - sk_ptr: *const [c_uchar; SK_SIZE], - pk_ptr: *const [c_uchar; PK_SIZE], - msg_ptr: *mut u8, - msg_len: size_t, - sig_ptr: *mut u8, -) -> c_int { - let sk = unwrap_or_bail!(SecretKey::from_bytes(&*sk_ptr)); - let pk = unwrap_or_bail!(PublicKey::from_bytes(&*pk_ptr)); - - let msg = slice::from_raw_parts(msg_ptr, msg_len); - - let sig = sk.sign(&pk, msg); - ptr::copy_nonoverlapping( - &sig.to_bytes()[0] as *const u8, - sig_ptr, - SIG_SIZE, - ); - BLS_OK -} - -#[no_mangle] -pub unsafe extern "C" fn verify( - apk_ptr: *const [c_uchar; PK_SIZE], - sig_ptr: *const [c_uchar; SIG_SIZE], - msg_ptr: *mut u8, - msg_len: size_t, -) -> c_int { - let apk = unwrap_or_bail!(APK::from_bytes(&*apk_ptr)); - let sig = unwrap_or_bail!(Signature::from_bytes(&*sig_ptr)); - - let msg = slice::from_raw_parts(msg_ptr, msg_len); - - match apk.verify(&sig, msg).is_ok() { - true => BLS_OK, - false => Error::InvalidSignature.into(), - } -} - -#[no_mangle] -pub unsafe extern "C" fn create_apk( - pk_ptr: *const [c_uchar; PK_SIZE], - apk_ptr: *mut u8, -) -> c_int { - let pk = unwrap_or_bail!(PublicKey::from_bytes(&*pk_ptr)); - - let apk = APK::from(&pk); - ptr::copy_nonoverlapping(&apk.to_bytes()[0] as *const u8, apk_ptr, PK_SIZE); - BLS_OK -} - -#[no_mangle] -pub unsafe extern "C" fn aggregate_pk( - apk_ptr: *const [c_uchar; PK_SIZE], - pk_ptr: *mut u8, - pk_len: size_t, - ret_ptr: *mut u8, -) -> c_int { - let mut apk = unwrap_or_bail!(APK::from_bytes(&*apk_ptr)); - - let pk_slice = slice::from_raw_parts(pk_ptr, pk_len); - let pks: Result, Error> = pk_slice - .chunks(PK_SIZE) - .map(|bytes| { - let mut arr = [0u8; PK_SIZE]; - arr.copy_from_slice(bytes); - PublicKey::from_bytes(&arr) - }) - .collect(); - - let pks = unwrap_or_bail!(pks); - apk.aggregate(&pks); - ptr::copy_nonoverlapping(&apk.to_bytes()[0] as *const u8, ret_ptr, PK_SIZE); - BLS_OK -} - -#[no_mangle] -pub unsafe extern "C" fn aggregate_sig( - sig_ptr: *const [c_uchar; SIG_SIZE], - sigs_ptr: *mut u8, - sigs_len: size_t, - ret_ptr: *mut u8, -) -> c_int { - let sig = unwrap_or_bail!(Signature::from_bytes(&*sig_ptr)); - - let sig_slice = slice::from_raw_parts(sigs_ptr, sigs_len); - let sigs: Result, Error> = sig_slice - .chunks(SIG_SIZE) - .map(|bytes| { - let mut arr = [0u8; SIG_SIZE]; - arr.copy_from_slice(bytes); - Signature::from_bytes(&arr) - }) - .collect(); - - let sigs = unwrap_or_bail!(sigs); - let sig = sig.aggregate(&sigs); - ptr::copy_nonoverlapping( - &sig.to_bytes()[0] as *const u8, - ret_ptr, - SIG_SIZE, - ); - BLS_OK -} - -#[no_mangle] -pub unsafe extern "C" fn apk_to_raw( - apk_ptr: *const [c_uchar; PK_SIZE], - ret_ptr: *mut u8, -) -> c_int { - let apk = unwrap_or_bail!(APK::from_bytes(&*apk_ptr)); - let apk_raw = apk.to_raw_bytes(); - ptr::copy_nonoverlapping(&apk_raw[0] as *const u8, ret_ptr, PK_RAW_SIZE); - BLS_OK -} - -#[no_mangle] -pub unsafe extern "C" fn pk_to_raw( - apk_ptr: *const [c_uchar; PK_SIZE], - ret_ptr: *mut u8, -) -> c_int { - let apk = unwrap_or_bail!(PublicKey::from_bytes(&*apk_ptr)); - let apk_raw = apk.to_raw_bytes(); - ptr::copy_nonoverlapping(&apk_raw[0] as *const u8, ret_ptr, PK_RAW_SIZE); - BLS_OK -} - -#[no_mangle] -/// Aggregate a set of raw [`PublicKey`]. Returns a compressed [`APK`] -pub unsafe extern "C" fn aggregate_pks_unchecked( - pks_ptr: *mut u8, - pks_len: size_t, - ret_ptr: *mut u8, -) { - let pk_slice = slice::from_raw_parts(pks_ptr, pks_len); - let pks: Vec = pk_slice - .chunks(PK_RAW_SIZE) - .map(|bytes| { - let mut arr = [0u8; PK_RAW_SIZE]; - arr.copy_from_slice(bytes); - PublicKey::from_slice_unchecked(&arr) - }) - .collect(); - let mut apk = APK::from(pks.get_unchecked(0)); - apk.aggregate(&pks[1..]); - ptr::copy_nonoverlapping(&apk.to_bytes()[0] as *const u8, ret_ptr, PK_SIZE); -} diff --git a/rust/grpc-server/.gitignore b/rust/grpc-server/.gitignore deleted file mode 100644 index 2de3917..0000000 --- a/rust/grpc-server/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target -Cargo.lock -/.idea diff --git a/rust/grpc-server/CHANGELOG.md b/rust/grpc-server/CHANGELOG.md deleted file mode 100644 index 186c592..0000000 --- a/rust/grpc-server/CHANGELOG.md +++ /dev/null @@ -1,26 +0,0 @@ -# Change log - -## 2021-10-19 - -Due to the slow execution and mysterious factors involved with Cgo, a gRPC/Protobuf service was created to provide this -EC signature library accessibility from Go (specifically `dusk-blockchain`), with the intention to explore improvements -over the Cgo implementation. - -It's pretty much your bog-standard microservice, and reasonable efforts have been made to ensure that it is not causing -excessive delays in processing. Some work has shown that we may be able to greatly improve performance (maybe up to 50% -execution time) by dodging checks on conversions of keys, specifically Public Keys and Aggregated Public Keys, which is -being worked on in parallel to this. - -It is still slower than the Cgo implementation as at release, but further work is being done to make it better, and -already we have seen improvements between 20-50% on benchmarks. - -I'm not sure what else can be said about the code in the repository here. A macro was used to eliminate 2- and 3-level -unwraps from result types and enable immediate return on error, derived from the stdlib, and modified for the specific -purpose of fixed length slices. Other than that, it simply implements all the calls with as little processing as -possible. - -The rest of the work that is integral to what has been done here is in `bls12_381-sign-go` which is the library that -consumes this service and provides access to Go applications. From its benchmarks, it appears that memory management in -Go is the main bottleneck. We have considered and partially completed an implementation that uses Capn Proto instead, -but this is waiting on the possible performance improvements by avoiding redundant checks with the gRPC/Protobuf -implementation. \ No newline at end of file diff --git a/rust/grpc-server/Cargo.toml b/rust/grpc-server/Cargo.toml deleted file mode 100644 index 90f09e9..0000000 --- a/rust/grpc-server/Cargo.toml +++ /dev/null @@ -1,38 +0,0 @@ -#![feature(min_const_generics)] -[package] -name = "dusk-bls12_381-sign-ipc" -version = "0.3.0" -authors = ["Loki "] -edition = "2018" - -[dependencies] -dusk-bls12_381-sign = { path = "../bls12_381-sign" } -async-stream = "0.3" -dusk-bytes = "0.1" -futures = { version = "0.3", default-features = false, features = ["alloc"] } -prost = "0.8" -rand = "0.8" -rand_core = { version = "0.6", default-features = false } -thiserror = { version = "1.0", default-features = false } -tokio = {version = "1.12", features = ["macros", "rt-multi-thread", "fs"]} -tonic = "0.5" -tower = "0.4" -ctrlc = "3.1.1" -log = "0.4" - -[build-dependencies] -tonic-build = "0.5" - -[dev-dependencies] -tower = "0.4" - -#[lib] -#crate-type = ["rlib", "staticlib"] - -[[bin]] -name = "bls12381svc" -path = "src/main.rs" - -[[bin]] -name = "bls12381cli" -path = "src/client.rs" diff --git a/rust/grpc-server/README.md b/rust/grpc-server/README.md deleted file mode 100644 index 8d2cbfa..0000000 --- a/rust/grpc-server/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# gRPC Server for BLS12-381 Sign - -Implementation of a simple IPC-based server to provide a synchronous gRPC interface to the [BLS12-381 library](/rust/bls12_381-sign) to external parties. - -## API definition -We use protobuf to strictly define the API. The schema is available [here](/schema/bls12381sig.proto). - -## Building - -`Makefile` at the repo root takes care of everything. Regardless, a simple `cargo build --release` should do the job if built independently. Built service binaries can be found at `./target/release` - -## Usage - -We provide a bloat-free [example](/go/grpc/bls) of a client written in Go which fully describes all API methods that can be used for reference. \ No newline at end of file diff --git a/rust/grpc-server/build.rs b/rust/grpc-server/build.rs deleted file mode 100644 index 68061f4..0000000 --- a/rust/grpc-server/build.rs +++ /dev/null @@ -1,4 +0,0 @@ -fn main() -> Result<(), Box> { - tonic_build::compile_protos("../../schema/bls12381sig.proto")?; - Ok(()) -} diff --git a/rust/grpc-server/src/client.rs b/rust/grpc-server/src/client.rs deleted file mode 100644 index 4dd0ca6..0000000 --- a/rust/grpc-server/src/client.rs +++ /dev/null @@ -1,76 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -#![cfg_attr(not(unix), allow(unused_imports))] - -tonic::include_proto!("signer"); - -use { - // clap::App, - signer_client::SignerClient, - std::convert::TryFrom, - tokio::net::UnixStream, - tonic::transport::{Endpoint, Uri}, - tower::service_fn, -}; - -#[tokio::main] -async fn main() -> Result<(), Box> { - // // define the command line parameters to call the bls12381svc - // let matches = App::new("bls12381cli") - // .version("v0.1.0") - // .author("Loki ") - // .about("Generate keys, sign, aggregate and verify messages using - // BLS12-381 elliptic curves") .subcommand(App::new("gen") - // .about("Generate a new BLS12-381 key pair")) - // .subcommand(App::new("sign") - // .about("Sign a message with a given key pair") - // .arg(" 'Secret key'") - // .arg(" 'Public key'") - // .arg(" 'Message to be signed'") - // ) - // .subcommand(App::new("verify") - // .about("Verify a signature against message and public key") - // .arg(" '(Aggregated) Public key'") - // .arg(" 'Signature'") - // .arg(" 'Message bearing signature'") - // ) - // .subcommand(App::new("createapk") - // .about("Convert a public key into an aggregated public key") - // .arg(" 'Public key'") - // ) - // .subcommand(App::new("aggregatepk") - // .about("Add more public keys to an aggregated public key") - // .arg(" 'Aggregated public key'") - // .arg("... 'Public Key'") - // ) - // .subcommand(App::new("aggregatesig") - // .about("Aggregate multiple signatures into one signature") - // .arg(" 'signature to aggregate into'") - // .arg("... 'signatures to be merged into the first'") - // ) - // .get_matches(); - // println!("{:?}", matches); - - // create a channel to connect to the socket of the server - let path: &str = "/tmp/bls12381svc.sock"; - let channel = Endpoint::try_from("http://[::]:50051") - .expect("Serde error on addr reading") - .connect_with_connector(service_fn(move |_: Uri| { - UnixStream::connect(path) - })) - .await - .expect("Error generating a Channel"); - - let mut client = SignerClient::new(channel); - // here we are just making a token request and not formatting the output - // correctly - let request = tonic::Request::new(GenerateKeysRequest {}); - let response = client.generate_keys(request).await?; - println!("Secret key {:?}", response.get_ref().secret_key); - println!("Public key {:?}", response.get_ref().public_key); - Ok(()) -} diff --git a/rust/grpc-server/src/main.rs b/rust/grpc-server/src/main.rs deleted file mode 100644 index bffdd1c..0000000 --- a/rust/grpc-server/src/main.rs +++ /dev/null @@ -1,235 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -#![cfg_attr(not(unix), allow(unused_imports))] - -#[cfg(unix)] -mod unix; - -tonic::include_proto!("signer"); - -use { - aggregate_response::Agg::Code, - create_apk_response::Apk::Apk, - dusk_bls12_381_sign::{PublicKey, SecretKey, Signature, APK}, - dusk_bytes::Serializable, - futures::TryFutureExt, - sign_response::Sig::Signature as ResponseSignature, - signer_server::{Signer, SignerServer}, - std::fs::remove_file, - std::process::exit, - tokio::net::UnixListener, - tonic::{transport::Server, Request, Response, Status}, - verify_response::Ver, -}; - -#[derive(Default)] -pub struct MySign {} - -/// The following macros are written to minimize memory handling with -/// [core::mem::transmute], and by early return on error from the calling -/// function to reduce repeated match branches that are basically all the same -#[macro_export] -macro_rules! slice_as_array_transmute { - ($slice:expr) => { - ::core::mem::transmute($slice) - }; -} - -#[macro_export] -macro_rules! slice_as { - ($slice:expr, $wrapper:ty, $note:literal) => {{ - unsafe fn this_transmute(xs: &[u8]) -> &[u8; <$wrapper>::SIZE] { - slice_as_array_transmute!(xs.as_ptr()) - } - - let s: &[u8] = $slice; - if s.len() != <$wrapper>::SIZE { - return Err(Status::invalid_argument(format!( - "{}: provided vector is wrong length: {} should be {}", - $note, - s.len(), - <$wrapper>::SIZE, - ))); - } else { - match <$wrapper>::from_bytes(unsafe { this_transmute(s) }) { - Ok(v) => v, - Err(_) => { - return Err(Status::invalid_argument(format!( - "unable to convert to type {}", - $note - ))) - } - } - } - }}; -} - -#[tonic::async_trait] -impl Signer for MySign { - /// BLS12-381 Signer service implementation - - /// Generate a new BLS12-381 key pair - async fn generate_keys( - &self, - _request: Request, - ) -> Result, Status> { - // get a new random secret key from system entropy - let sk = SecretKey::random(&mut rand_core::OsRng); - - // construct the gRPC response from the key and return it - Ok(Response::new(GenerateKeysResponse { - secret_key: sk.to_bytes().to_vec(), - public_key: PublicKey::from(&sk).to_bytes().to_vec(), - })) - } - - /// Sign a message using a provided BLS12-381 key pair - async fn sign( - &self, - request: Request, - ) -> Result, Status> { - // access the request parameters - let req = request.get_ref(); - let sk = slice_as!(&req.secret_key, SecretKey, "SecretKey"); - let pk = slice_as!(&req.public_key, PublicKey, "PublicKey"); - // sign the message - let res = - ResponseSignature(sk.sign(&pk, &req.message).to_bytes().to_vec()); - - // return the signature wrapped in the response type - Ok(Response::new(SignResponse { - sig: Option::Some(res), - })) - } - - /// Verify a BLS12-381 signature on a message with a given public key - async fn verify( - &self, - request: Request, - ) -> Result, Status> { - // access the request parameters - let req = request.get_ref(); - let apk = slice_as!(&req.apk, APK, "APK"); - let sig = slice_as!(&req.signature, Signature, "Signature"); - - // verify the message matches the signature and the signature matches - // the given public key - let res = apk.verify(&sig, &req.message); - - // return whether the verification returned no error - Ok(Response::new(VerifyResponse { - ver: Some(Ver::Valid(!res.is_err())), - })) - } - - /// Create an aggregated public key from a public key - async fn create_apk( - &self, - request: Request, - ) -> Result, Status> { - // access the request parameters - let req = request.get_ref(); - let apk = slice_as!(&req.public_key, PublicKey, "PublicKey"); - let apk = APK::from(&apk); - Ok(Response::new(CreateApkResponse { - apk: Some(Apk(apk.to_bytes().to_vec())), - })) - } - - /// Aggregate a collection of public keys to an aggregated public key - async fn aggregate_pk( - &self, - request: Request, - ) -> Result, Status> { - // access the request parameters - let req = request.get_ref(); - // get the apk first - let apk = slice_as!(&req.apk, PublicKey, "PublicKey"); - let mut apk = APK::from_bytes(&apk.to_bytes()).unwrap(); - // collect the list of public keys into a vector - let mut pks = Vec::with_capacity(req.keys.len()); - for elem in &req.keys { - pks.push(slice_as!(&elem, PublicKey, "PublicKey")); - } - // aggregate the keys - apk.aggregate(&pks); - let bytes = &apk.to_bytes(); - // convert public key to aggregated public key and return it - Ok(Response::new(AggregateResponse { - agg: Some(Code(bytes.to_vec())), - })) - } - - /// Aggregate a collection of signatures into an aggregated signature - async fn aggregate_sig( - &self, - request: Request, - ) -> Result, Status> { - // access the request parameters - let req = request.get_ref(); - let sig = slice_as!(&req.signature, Signature, "Signature"); - - // convert the raw bytes from the message to a collection of signatures - let mut sigs: Vec = Vec::with_capacity(req.signatures.len()); - // collect the list of public keys into a vector - for elem in &req.signatures { - sigs.push(slice_as!(&elem, Signature, "Signature")); - } - - // aggregate the signatures - let sig = sig.aggregate(&sigs); - - let bytes = Code(sig.to_bytes().to_vec()); - - // convert aggregate signature to bytes and return - Ok(Response::new(AggregateResponse { agg: Some(bytes) })) - } -} - -extern crate ctrlc; - -/// Default UDS path that Rusk GRPC-server will connect to. -pub const SOCKET_PATH: &str = "/tmp/bls12381svc.sock"; - -#[tokio::main] -async fn main() -> Result<(), Box> { - // Set up a unix domain socket at the default path - let uds = UnixListener::bind(SOCKET_PATH)?; - let incoming = { - async_stream::stream! { - loop{ - let item = uds.accept().map_ok(|(st, _)| unix::UnixStream(st)).await; - yield item; - }; - } - }; - - // Make sure to remove the socket, and shut down on interrupt. This is the - // normal way to terminate the service - ctrlc::set_handler(move || { - match remove_file(SOCKET_PATH) { - Ok(_) => { - println!("\nremoved socket at path: {}", SOCKET_PATH) - } - Err(e) => { - println!("error: {:?}", e) - } - }; - exit(0); - })?; - - Server::builder() - .add_service(SignerServer::new(MySign::default())) - .serve_with_incoming(incoming) - .await?; - Ok(()) -} - -#[cfg(not(unix))] -fn main() { - panic!("Unix Domain Sockets can only be used on unix systems!"); -} diff --git a/rust/grpc-server/src/unix.rs b/rust/grpc-server/src/unix.rs deleted file mode 100644 index 959c57c..0000000 --- a/rust/grpc-server/src/unix.rs +++ /dev/null @@ -1,65 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -use std::{ - pin::Pin, - task::{Context, Poll}, -}; - -use { - tokio::io::{AsyncRead, AsyncWrite, ReadBuf}, - tonic::transport::server::Connected, -}; - -#[derive(Debug)] -pub struct UnixStream(pub tokio::net::UnixStream); - -#[derive(Clone)] -pub struct UnixStreamConnectInfo { - // Metadata about your connection -} - -impl Connected for UnixStream { - type ConnectInfo = UnixStreamConnectInfo; - - fn connect_info(&self) -> Self::ConnectInfo { - UnixStreamConnectInfo {} - } -} - -impl AsyncRead for UnixStream { - fn poll_read( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - buf: &mut ReadBuf<'_>, - ) -> Poll> { - Pin::new(&mut self.0).poll_read(cx, buf) - } -} - -impl AsyncWrite for UnixStream { - fn poll_write( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - buf: &[u8], - ) -> Poll> { - Pin::new(&mut self.0).poll_write(cx, buf) - } - - fn poll_flush( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll> { - Pin::new(&mut self.0).poll_flush(cx) - } - - fn poll_shutdown( - mut self: Pin<&mut Self>, - cx: &mut Context<'_>, - ) -> Poll> { - Pin::new(&mut self.0).poll_shutdown(cx) - } -} diff --git a/rust/rustfmt.toml b/rustfmt.toml similarity index 100% rename from rust/rustfmt.toml rename to rustfmt.toml diff --git a/schema/bls12381sig.proto b/schema/bls12381sig.proto deleted file mode 100644 index 4a6c041..0000000 --- a/schema/bls12381sig.proto +++ /dev/null @@ -1,88 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -// -// Copyright (c) DUSK NETWORK. All rights reserved. - -syntax = "proto3"; -package signer; -option go_package = "github.com/dusk-network/bls12_381-sign/go/bls"; - -// Signer must always satisfy github.com/dusk-network/bls12_381-sign/go/bls -service Signer { - rpc GenerateKeys(GenerateKeysRequest) returns (GenerateKeysResponse); - rpc Sign(SignRequest) returns (SignResponse); - rpc Verify(VerifyRequest) returns (VerifyResponse); - rpc CreateAPK(CreateAPKRequest) returns (CreateAPKResponse); - rpc AggregatePK(AggregatePKRequest) returns (AggregateResponse); - rpc AggregateSig(AggregateSigRequest) returns (AggregateResponse); -} - -enum Error { - BLS_INVALID_BYTES = 0; - BLS_VERIFICATION_FAILED = 1; - UNKNOWN = 2; -} - -message GenerateKeysRequest{ -} - -message GenerateKeysResponse { - bytes SecretKey = 1; - bytes PublicKey = 2; -} - -message SignRequest { - bytes SecretKey = 1; - bytes PublicKey = 2; - bytes Message = 3; -} - -message SignResponse { - oneof sig { - bytes Signature = 1; - Error Error = 2; - } -} - -message VerifyRequest { - bytes Apk = 1; - bytes Signature = 2; - bytes Message = 3; -} - -message VerifyResponse { - oneof ver { - bool Valid = 1; - Error Error = 2; - } -} - -message CreateAPKRequest { - bytes PublicKey = 1; -} - -message CreateAPKResponse { - oneof apk { - bytes APK = 1; - Error Error = 2; - } -} - -message AggregatePKRequest { - bytes APK = 1; - repeated bytes Keys = 2; -} - -message AggregateSigRequest { - bytes Signature = 1; - repeated bytes Signatures = 2; -} - -message AggregateResponse { - oneof agg { - bytes Code = 1; - Error Error = 2; - } -} - diff --git a/rust/bls12_381-sign/src/error.rs b/src/error.rs similarity index 100% rename from rust/bls12_381-sign/src/error.rs rename to src/error.rs diff --git a/rust/bls12_381-sign/src/hash.rs b/src/hash.rs similarity index 100% rename from rust/bls12_381-sign/src/hash.rs rename to src/hash.rs diff --git a/rust/bls12_381-sign/src/keys.rs b/src/keys.rs similarity index 100% rename from rust/bls12_381-sign/src/keys.rs rename to src/keys.rs diff --git a/rust/bls12_381-sign/src/keys/apk.rs b/src/keys/apk.rs similarity index 100% rename from rust/bls12_381-sign/src/keys/apk.rs rename to src/keys/apk.rs diff --git a/rust/bls12_381-sign/src/keys/public.rs b/src/keys/public.rs similarity index 100% rename from rust/bls12_381-sign/src/keys/public.rs rename to src/keys/public.rs diff --git a/rust/bls12_381-sign/src/keys/secret.rs b/src/keys/secret.rs similarity index 100% rename from rust/bls12_381-sign/src/keys/secret.rs rename to src/keys/secret.rs diff --git a/rust/bls12_381-sign/src/lib.rs b/src/lib.rs similarity index 100% rename from rust/bls12_381-sign/src/lib.rs rename to src/lib.rs diff --git a/rust/bls12_381-sign/src/signature.rs b/src/signature.rs similarity index 100% rename from rust/bls12_381-sign/src/signature.rs rename to src/signature.rs diff --git a/rust/bls12_381-sign/src/tests.rs b/src/tests.rs similarity index 100% rename from rust/bls12_381-sign/src/tests.rs rename to src/tests.rs diff --git a/rust/bls12_381-sign/tests/signature.rs b/tests/signature.rs similarity index 98% rename from rust/bls12_381-sign/tests/signature.rs rename to tests/signature.rs index 6b61dc6..cba191d 100644 --- a/rust/bls12_381-sign/tests/signature.rs +++ b/tests/signature.rs @@ -4,7 +4,7 @@ // // Copyright (c) DUSK NETWORK. All rights reserved. -use dusk_bls12_381_sign::{PublicKey, SecretKey, APK}; +use bls12_381_bls::{PublicKey, SecretKey, APK}; use rand::rngs::StdRng; use rand::{RngCore, SeedableRng};