bls

package module
v0.0.0-...-5144ac0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2024 License: MPL-2.0 Imports: 17 Imported by: 0

README

gRPC Client for BLS12-381 Sign

bls.go provides an abstraction to interface with our BLS12-381 Sign library via a simple IPC-based gRPC client that connects to a running instance of our provided 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 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:

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 for a few examples.

Documentation

Index

Constants

This section is empty.

Variables

View Source
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,
	}
)

Enum value maps for Error.

View Source
var Binary []byte
View Source
var File_bls12381sig_proto protoreflect.FileDescriptor

Functions

func AggregatePk

func AggregatePk(apk []byte, pks ...[]byte) (
	newApk []byte,
	err error,
)

func AggregateSig

func AggregateSig(sig []byte, sigs ...[]byte) (
	aggregatedSig []byte,
	err error,
)

func Connect

func Connect()

Connect starts up the GRPC server and connects through a unix socket

func CreateApk

func CreateApk(pk []byte) (apk []byte, err error)

func Disconnect

func Disconnect()

Disconnect closes the socket, stops the GRPC server and cleans up

func GenerateKeys

func GenerateKeys() (secret []byte, public []byte)

func RegisterSignerServer

func RegisterSignerServer(s *grpc.Server, srv SignerServer)

func Sign

func Sign(sk, pk, msg []byte) (
	signature []byte,
	err error,
)

func Verify

func Verify(apk, sig, msg []byte) (err error)

Types

type AggregatePKRequest

type AggregatePKRequest struct {
	APK  []byte   `protobuf:"bytes,1,opt,name=APK,proto3" json:"APK,omitempty"`
	Keys [][]byte `protobuf:"bytes,2,rep,name=Keys,proto3" json:"Keys,omitempty"`
	// contains filtered or unexported fields
}

func (*AggregatePKRequest) Descriptor deprecated

func (*AggregatePKRequest) Descriptor() ([]byte, []int)

Deprecated: Use AggregatePKRequest.ProtoReflect.Descriptor instead.

func (*AggregatePKRequest) GetAPK

func (x *AggregatePKRequest) GetAPK() []byte

func (*AggregatePKRequest) GetKeys

func (x *AggregatePKRequest) GetKeys() [][]byte

func (*AggregatePKRequest) ProtoMessage

func (*AggregatePKRequest) ProtoMessage()

func (*AggregatePKRequest) ProtoReflect

func (x *AggregatePKRequest) ProtoReflect() protoreflect.Message

func (*AggregatePKRequest) Reset

func (x *AggregatePKRequest) Reset()

func (*AggregatePKRequest) String

func (x *AggregatePKRequest) String() string

type AggregateResponse

type AggregateResponse struct {

	// Types that are assignable to Agg:
	//	*AggregateResponse_Code
	//	*AggregateResponse_Error
	Agg isAggregateResponse_Agg `protobuf_oneof:"agg"`
	// contains filtered or unexported fields
}

func (*AggregateResponse) Descriptor deprecated

func (*AggregateResponse) Descriptor() ([]byte, []int)

Deprecated: Use AggregateResponse.ProtoReflect.Descriptor instead.

func (*AggregateResponse) GetAgg

func (m *AggregateResponse) GetAgg() isAggregateResponse_Agg

func (*AggregateResponse) GetCode

func (x *AggregateResponse) GetCode() []byte

func (*AggregateResponse) GetError

func (x *AggregateResponse) GetError() Error

func (*AggregateResponse) ProtoMessage

func (*AggregateResponse) ProtoMessage()

func (*AggregateResponse) ProtoReflect

func (x *AggregateResponse) ProtoReflect() protoreflect.Message

func (*AggregateResponse) Reset

func (x *AggregateResponse) Reset()

func (*AggregateResponse) String

func (x *AggregateResponse) String() string

type AggregateResponse_Code

type AggregateResponse_Code struct {
	Code []byte `protobuf:"bytes,1,opt,name=Code,proto3,oneof"`
}

type AggregateResponse_Error

type AggregateResponse_Error struct {
	Error Error `protobuf:"varint,2,opt,name=Error,proto3,enum=signer.Error,oneof"`
}

type AggregateSigRequest

type AggregateSigRequest struct {
	Signature  []byte   `protobuf:"bytes,1,opt,name=Signature,proto3" json:"Signature,omitempty"`
	Signatures [][]byte `protobuf:"bytes,2,rep,name=Signatures,proto3" json:"Signatures,omitempty"`
	// contains filtered or unexported fields
}

func (*AggregateSigRequest) Descriptor deprecated

func (*AggregateSigRequest) Descriptor() ([]byte, []int)

Deprecated: Use AggregateSigRequest.ProtoReflect.Descriptor instead.

func (*AggregateSigRequest) GetSignature

func (x *AggregateSigRequest) GetSignature() []byte

func (*AggregateSigRequest) GetSignatures

func (x *AggregateSigRequest) GetSignatures() [][]byte

func (*AggregateSigRequest) ProtoMessage

func (*AggregateSigRequest) ProtoMessage()

func (*AggregateSigRequest) ProtoReflect

func (x *AggregateSigRequest) ProtoReflect() protoreflect.Message

func (*AggregateSigRequest) Reset

func (x *AggregateSigRequest) Reset()

func (*AggregateSigRequest) String

func (x *AggregateSigRequest) String() string

type CreateAPKRequest

type CreateAPKRequest struct {
	PublicKey []byte `protobuf:"bytes,1,opt,name=PublicKey,proto3" json:"PublicKey,omitempty"`
	// contains filtered or unexported fields
}

func (*CreateAPKRequest) Descriptor deprecated

func (*CreateAPKRequest) Descriptor() ([]byte, []int)

Deprecated: Use CreateAPKRequest.ProtoReflect.Descriptor instead.

func (*CreateAPKRequest) GetPublicKey

func (x *CreateAPKRequest) GetPublicKey() []byte

func (*CreateAPKRequest) ProtoMessage

func (*CreateAPKRequest) ProtoMessage()

func (*CreateAPKRequest) ProtoReflect

func (x *CreateAPKRequest) ProtoReflect() protoreflect.Message

func (*CreateAPKRequest) Reset

func (x *CreateAPKRequest) Reset()

func (*CreateAPKRequest) String

func (x *CreateAPKRequest) String() string

type CreateAPKResponse

type CreateAPKResponse struct {

	// Types that are assignable to Apk:
	//	*CreateAPKResponse_APK
	//	*CreateAPKResponse_Error
	Apk isCreateAPKResponse_Apk `protobuf_oneof:"apk"`
	// contains filtered or unexported fields
}

func (*CreateAPKResponse) Descriptor deprecated

func (*CreateAPKResponse) Descriptor() ([]byte, []int)

Deprecated: Use CreateAPKResponse.ProtoReflect.Descriptor instead.

func (*CreateAPKResponse) GetAPK

func (x *CreateAPKResponse) GetAPK() []byte

func (*CreateAPKResponse) GetApk

func (m *CreateAPKResponse) GetApk() isCreateAPKResponse_Apk

func (*CreateAPKResponse) GetError

func (x *CreateAPKResponse) GetError() Error

func (*CreateAPKResponse) ProtoMessage

func (*CreateAPKResponse) ProtoMessage()

func (*CreateAPKResponse) ProtoReflect

func (x *CreateAPKResponse) ProtoReflect() protoreflect.Message

func (*CreateAPKResponse) Reset

func (x *CreateAPKResponse) Reset()

func (*CreateAPKResponse) String

func (x *CreateAPKResponse) String() string

type CreateAPKResponse_APK

type CreateAPKResponse_APK struct {
	APK []byte `protobuf:"bytes,1,opt,name=APK,proto3,oneof"`
}

type CreateAPKResponse_Error

type CreateAPKResponse_Error struct {
	Error Error `protobuf:"varint,2,opt,name=Error,proto3,enum=signer.Error,oneof"`
}

type Error

type Error int32
const (
	Error_BLS_INVALID_BYTES       Error = 0
	Error_BLS_VERIFICATION_FAILED Error = 1
	Error_UNKNOWN                 Error = 2
)

func (Error) Descriptor

func (Error) Descriptor() protoreflect.EnumDescriptor

func (Error) Enum

func (x Error) Enum() *Error

func (Error) EnumDescriptor deprecated

func (Error) EnumDescriptor() ([]byte, []int)

Deprecated: Use Error.Descriptor instead.

func (Error) Number

func (x Error) Number() protoreflect.EnumNumber

func (Error) String

func (x Error) String() string

func (Error) Type

func (Error) Type() protoreflect.EnumType

type GenerateKeysRequest

type GenerateKeysRequest struct {
	// contains filtered or unexported fields
}

func (*GenerateKeysRequest) Descriptor deprecated

func (*GenerateKeysRequest) Descriptor() ([]byte, []int)

Deprecated: Use GenerateKeysRequest.ProtoReflect.Descriptor instead.

func (*GenerateKeysRequest) ProtoMessage

func (*GenerateKeysRequest) ProtoMessage()

func (*GenerateKeysRequest) ProtoReflect

func (x *GenerateKeysRequest) ProtoReflect() protoreflect.Message

func (*GenerateKeysRequest) Reset

func (x *GenerateKeysRequest) Reset()

func (*GenerateKeysRequest) String

func (x *GenerateKeysRequest) String() string

type GenerateKeysResponse

type GenerateKeysResponse struct {
	SecretKey []byte `protobuf:"bytes,1,opt,name=SecretKey,proto3" json:"SecretKey,omitempty"`
	PublicKey []byte `protobuf:"bytes,2,opt,name=PublicKey,proto3" json:"PublicKey,omitempty"`
	// contains filtered or unexported fields
}

func (*GenerateKeysResponse) Descriptor deprecated

func (*GenerateKeysResponse) Descriptor() ([]byte, []int)

Deprecated: Use GenerateKeysResponse.ProtoReflect.Descriptor instead.

func (*GenerateKeysResponse) GetPublicKey

func (x *GenerateKeysResponse) GetPublicKey() []byte

func (*GenerateKeysResponse) GetSecretKey

func (x *GenerateKeysResponse) GetSecretKey() []byte

func (*GenerateKeysResponse) ProtoMessage

func (*GenerateKeysResponse) ProtoMessage()

func (*GenerateKeysResponse) ProtoReflect

func (x *GenerateKeysResponse) ProtoReflect() protoreflect.Message

func (*GenerateKeysResponse) Reset

func (x *GenerateKeysResponse) Reset()

func (*GenerateKeysResponse) String

func (x *GenerateKeysResponse) String() string

type SignRequest

type SignRequest struct {
	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"`
	// contains filtered or unexported fields
}

func (*SignRequest) Descriptor deprecated

func (*SignRequest) Descriptor() ([]byte, []int)

Deprecated: Use SignRequest.ProtoReflect.Descriptor instead.

func (*SignRequest) GetMessage

func (x *SignRequest) GetMessage() []byte

func (*SignRequest) GetPublicKey

func (x *SignRequest) GetPublicKey() []byte

func (*SignRequest) GetSecretKey

func (x *SignRequest) GetSecretKey() []byte

func (*SignRequest) ProtoMessage

func (*SignRequest) ProtoMessage()

func (*SignRequest) ProtoReflect

func (x *SignRequest) ProtoReflect() protoreflect.Message

func (*SignRequest) Reset

func (x *SignRequest) Reset()

func (*SignRequest) String

func (x *SignRequest) String() string

type SignResponse

type SignResponse struct {

	// Types that are assignable to Sig:
	//	*SignResponse_Signature
	//	*SignResponse_Error
	Sig isSignResponse_Sig `protobuf_oneof:"sig"`
	// contains filtered or unexported fields
}

func (*SignResponse) Descriptor deprecated

func (*SignResponse) Descriptor() ([]byte, []int)

Deprecated: Use SignResponse.ProtoReflect.Descriptor instead.

func (*SignResponse) GetError

func (x *SignResponse) GetError() Error

func (*SignResponse) GetSig

func (m *SignResponse) GetSig() isSignResponse_Sig

func (*SignResponse) GetSignature

func (x *SignResponse) GetSignature() []byte

func (*SignResponse) ProtoMessage

func (*SignResponse) ProtoMessage()

func (*SignResponse) ProtoReflect

func (x *SignResponse) ProtoReflect() protoreflect.Message

func (*SignResponse) Reset

func (x *SignResponse) Reset()

func (*SignResponse) String

func (x *SignResponse) String() string

type SignResponse_Error

type SignResponse_Error struct {
	Error Error `protobuf:"varint,2,opt,name=Error,proto3,enum=signer.Error,oneof"`
}

type SignResponse_Signature

type SignResponse_Signature struct {
	Signature []byte `protobuf:"bytes,1,opt,name=Signature,proto3,oneof"`
}

type SignerClient

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)
}

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.

func NewSignerClient

func NewSignerClient(cc grpc.ClientConnInterface) SignerClient

type SignerServer

SignerServer is the server API for Signer service.

type UnimplementedSignerServer

type UnimplementedSignerServer struct {
}

UnimplementedSignerServer can be embedded to have forward compatible implementations.

func (*UnimplementedSignerServer) AggregatePK

func (*UnimplementedSignerServer) AggregateSig

func (*UnimplementedSignerServer) CreateAPK

func (*UnimplementedSignerServer) GenerateKeys

func (*UnimplementedSignerServer) Sign

func (*UnimplementedSignerServer) Verify

type VerifyRequest

type VerifyRequest struct {
	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"`
	// contains filtered or unexported fields
}

func (*VerifyRequest) Descriptor deprecated

func (*VerifyRequest) Descriptor() ([]byte, []int)

Deprecated: Use VerifyRequest.ProtoReflect.Descriptor instead.

func (*VerifyRequest) GetApk

func (x *VerifyRequest) GetApk() []byte

func (*VerifyRequest) GetMessage

func (x *VerifyRequest) GetMessage() []byte

func (*VerifyRequest) GetSignature

func (x *VerifyRequest) GetSignature() []byte

func (*VerifyRequest) ProtoMessage

func (*VerifyRequest) ProtoMessage()

func (*VerifyRequest) ProtoReflect

func (x *VerifyRequest) ProtoReflect() protoreflect.Message

func (*VerifyRequest) Reset

func (x *VerifyRequest) Reset()

func (*VerifyRequest) String

func (x *VerifyRequest) String() string

type VerifyResponse

type VerifyResponse struct {

	// Types that are assignable to Ver:
	//	*VerifyResponse_Valid
	//	*VerifyResponse_Error
	Ver isVerifyResponse_Ver `protobuf_oneof:"ver"`
	// contains filtered or unexported fields
}

func (*VerifyResponse) Descriptor deprecated

func (*VerifyResponse) Descriptor() ([]byte, []int)

Deprecated: Use VerifyResponse.ProtoReflect.Descriptor instead.

func (*VerifyResponse) GetError

func (x *VerifyResponse) GetError() Error

func (*VerifyResponse) GetValid

func (x *VerifyResponse) GetValid() bool

func (*VerifyResponse) GetVer

func (m *VerifyResponse) GetVer() isVerifyResponse_Ver

func (*VerifyResponse) ProtoMessage

func (*VerifyResponse) ProtoMessage()

func (*VerifyResponse) ProtoReflect

func (x *VerifyResponse) ProtoReflect() protoreflect.Message

func (*VerifyResponse) Reset

func (x *VerifyResponse) Reset()

func (*VerifyResponse) String

func (x *VerifyResponse) String() string

type VerifyResponse_Error

type VerifyResponse_Error struct {
	Error Error `protobuf:"varint,2,opt,name=Error,proto3,enum=signer.Error,oneof"`
}

type VerifyResponse_Valid

type VerifyResponse_Valid struct {
	Valid bool `protobuf:"varint,1,opt,name=Valid,proto3,oneof"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL