crypto

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package crypto implements some routines to go back and forth from a protobuf point and scalar to a kyber Point and Scalar interface, as well as standard JSON representations.

Index

Constants

This section is empty.

Variables

View Source
var GroupID_name = map[int32]string{
	0:  "Ed25519",
	21: "BN256_G1",
	22: "BN256_G2",
	23: "BN256_GT",
}
View Source
var GroupID_value = map[string]int32{
	"Ed25519":  0,
	"BN256_G1": 21,
	"BN256_G2": 22,
	"BN256_GT": 23,
}

Functions

func GroupToID added in v0.4.0

func GroupToID(g kyber.Group) (int32, bool)

GroupToID returns the ID of a group

func IDToGroup added in v0.4.0

func IDToGroup(id int32) (kyber.Group, bool)

IDToGroup returns the kyber.Group corresponding to the given ID if provided

func ProtoToKyberPoint

func ProtoToKyberPoint(p *ProtobufPoint) (kyber.Point, error)

ProtoToKyberPoint converts a protobuf point to a kyber point

func ProtoToKyberScalar

func ProtoToKyberScalar(p *ProtobufScalar) (kyber.Scalar, error)

ProtoToKyberScalar converts a protobuf scalar to a kyber scalar

Types

type GroupID

type GroupID int32

GroupID is an enumeration holding all possible groups that can be marshalled / unmarshalled, supported by the kyber library

const (
	GroupID_Ed25519  GroupID = 0
	GroupID_BN256_G1 GroupID = 21
	GroupID_BN256_G2 GroupID = 22
	GroupID_BN256_GT GroupID = 23
)

func (GroupID) EnumDescriptor

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

func (GroupID) String

func (x GroupID) String() string

type Point

type Point struct {
	Gid                  GroupID  `protobuf:"varint,1,opt,name=gid,proto3,enum=element.GroupID" json:"gid,omitempty"`
	Point                []byte   `protobuf:"bytes,2,opt,name=point,proto3" json:"point,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Point represents a point on a curve,i.e. a public key, a commitment etc It is parametrized by its group.

func (*Point) Descriptor

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

func (*Point) GetGid

func (m *Point) GetGid() GroupID

func (*Point) GetPoint added in v0.4.0

func (m *Point) GetPoint() []byte

func (*Point) ProtoMessage

func (*Point) ProtoMessage()

func (*Point) Reset

func (m *Point) Reset()

func (*Point) String

func (m *Point) String() string

func (*Point) XXX_DiscardUnknown added in v0.3.7

func (m *Point) XXX_DiscardUnknown()

func (*Point) XXX_Marshal added in v0.3.7

func (m *Point) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Point) XXX_Merge added in v0.3.7

func (dst *Point) XXX_Merge(src proto.Message)

func (*Point) XXX_Size added in v0.3.7

func (m *Point) XXX_Size() int

func (*Point) XXX_Unmarshal added in v0.3.7

func (m *Point) XXX_Unmarshal(b []byte) error

type ProtobufPoint

type ProtobufPoint = Point

ProtobufPoint is an alias to a Point represented in a protobuf packet

func KyberToProtoPoint

func KyberToProtoPoint(p kyber.Point) (*ProtobufPoint, error)

KyberToProtoPoint converts a kyber point to a protobuf scalar

func (*ProtobufPoint) FromKyber added in v0.4.0

func (p *ProtobufPoint) FromKyber(point kyber.Point) error

FromKyber unmarshals the protobuf point from the kyber representation

func (*ProtobufPoint) ToKyber added in v0.4.0

func (p *ProtobufPoint) ToKyber() (kyber.Point, error)

ToKyber returns the kyber represnetation of this protobuf point

type ProtobufScalar

type ProtobufScalar = Scalar

ProtobufScalar is an alias to a Scalar represented in a protobuf packet

func KyberToProtoScalar

func KyberToProtoScalar(s kyber.Scalar) (*ProtobufScalar, error)

KyberToProtoScalar converts a kyber scalar to a protobuf scalar

func (*ProtobufScalar) FromKyber added in v0.4.0

func (p *ProtobufScalar) FromKyber(s kyber.Scalar) error

FromKyber unmarshals the protobuf scalar from the kyber representation

func (*ProtobufScalar) ToKyber added in v0.4.0

func (p *ProtobufScalar) ToKyber() (kyber.Scalar, error)

ToKyber returns the kyber represnetation of this protobuf scalar

type Scalar

type Scalar struct {
	Gid                  GroupID  `protobuf:"varint,1,opt,name=gid,proto3,enum=element.GroupID" json:"gid,omitempty"`
	Scalar               []byte   `protobuf:"bytes,2,opt,name=scalar,proto3" json:"scalar,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Scalar represents a scalar on the field attached to the group. It is parametrized by the group using this field (1-1 mapping).

func (*Scalar) Descriptor

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

func (*Scalar) GetGid

func (m *Scalar) GetGid() GroupID

func (*Scalar) GetScalar added in v0.4.0

func (m *Scalar) GetScalar() []byte

func (*Scalar) ProtoMessage

func (*Scalar) ProtoMessage()

func (*Scalar) Reset

func (m *Scalar) Reset()

func (*Scalar) String

func (m *Scalar) String() string

func (*Scalar) XXX_DiscardUnknown added in v0.3.7

func (m *Scalar) XXX_DiscardUnknown()

func (*Scalar) XXX_Marshal added in v0.3.7

func (m *Scalar) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Scalar) XXX_Merge added in v0.3.7

func (dst *Scalar) XXX_Merge(src proto.Message)

func (*Scalar) XXX_Size added in v0.3.7

func (m *Scalar) XXX_Size() int

func (*Scalar) XXX_Unmarshal added in v0.3.7

func (m *Scalar) XXX_Unmarshal(b []byte) error

Directories

Path Synopsis
vss

Jump to

Keyboard shortcuts

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