bliss

package module
v0.0.0-...-3b4ea22 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: MIT Imports: 13 Imported by: 1

README

Build Status GitHub license GoDoc Coverage Status Go Report Card

bliss

Overview

This library is for signing messages by BLISS.

Requirements

  • git
  • go 1.9+

are required to compile this.

Installation

 $ go get github.com/AidosKuneen/bliss

Usage

	text:=[]byte("some message")
	var seed [64]byte
	_, err := rand.Read(seed[:])
	pk := NewPrivateKey(bliss.B4, seed)
	pub := pk.PublicKey()
	sig := pk.Sign(text)
	err := pub.Verify(sig, text)
	bpub := pub.Bytes()
	bsig := sig.Bytes()
	pub2, err := NewPublicKey(bpub)
	sig2, err := NewSignature(bsig)

Performance

Using the following test environment...

* Compiler: go version go1.11 linux/amd64
* Kernel: Linux  4.18.9-arch1-1-ARCH #1 SMP PREEMPT Wed Sep 19 21:19:17 UTC 2018 x86_64 GNU/Linux
* CPU:  Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz 
* Memory: 8 GB

For signing, it takes about 670 μS.

For verification, it takes about 82 μS.

BenchmarkGen-8    	   10000	    172875 ns/op	   25811 B/op	      17 allocs/op
BenchmarkSign-8   	    2000	    674769 ns/op	   62103 B/op	      63 allocs/op
BenchmarkVeri-8   	   20000	     81750 ns/op	   15648 B/op	      16 allocs/op

Contribution

Improvements to the codebase and pull requests are encouraged.

Dependencies and Licenses

This software includes a rewrite (from C++ to go) of https://github.com/SRI-CSL/Bliss, which is covered by MIT License.

github.com/AidosKuneen/bliss/bit      MIT License
github.com/vmihailenco/msgpack/codes  BSD 2-clause "Simplified" License
golang.org/x/crypto                   BSD 3-clause "New" or "Revised" License 
golang.org/x/sys/cpu                  BSD 3-clause "New" or "Revised" License 
Golang Standard Library               BSD 3-clause License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthBliss = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowBliss   = fmt.Errorf("proto: integer overflow")
)

Functions

func Dec

func Dec(c *Ciphertext, r2 []int32) []byte

Dec decrypt a ciphertext with private key r2.

Types

type Ciphertext

type Ciphertext struct {
	C1  []int32 `protobuf:"varint,1,rep,packed,name=c1,proto3" json:"c1,omitempty"`
	C2  []int32 `protobuf:"varint,2,rep,packed,name=c2,proto3" json:"c2,omitempty"`
	Len byte    `protobuf:"varint,3,opt,name=len,proto3,casttype=byte" json:"len,omitempty"`
}

Ciphertext is a ciphertext after encryption.

func Enc

func Enc(pub []int32, m []byte) (*Ciphertext, error)

Enc encrypt a message with public key.

func NewPopulatedCiphertext

func NewPopulatedCiphertext(r randyBliss, easy bool) *Ciphertext

func (*Ciphertext) Add

func (ct *Ciphertext) Add(ct2 *Ciphertext) *Ciphertext

Add calculates a ciphertext when these two plaintexts messages are xor'ed.

func (*Ciphertext) Descriptor

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

func (*Ciphertext) Equal

func (this *Ciphertext) Equal(that interface{}) bool

func (*Ciphertext) Marshal

func (m *Ciphertext) Marshal() (dAtA []byte, err error)

func (*Ciphertext) MarshalTo

func (m *Ciphertext) MarshalTo(dAtA []byte) (int, error)

func (*Ciphertext) ProtoMessage

func (*Ciphertext) ProtoMessage()

func (*Ciphertext) Reset

func (m *Ciphertext) Reset()

func (*Ciphertext) Size

func (m *Ciphertext) Size() (n int)

func (*Ciphertext) String

func (m *Ciphertext) String() string

func (*Ciphertext) Unmarshal

func (m *Ciphertext) Unmarshal(dAtA []byte) error

func (*Ciphertext) XXX_DiscardUnknown

func (m *Ciphertext) XXX_DiscardUnknown()

func (*Ciphertext) XXX_Marshal

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

func (*Ciphertext) XXX_Merge

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

func (*Ciphertext) XXX_Size

func (m *Ciphertext) XXX_Size() int

func (*Ciphertext) XXX_Unmarshal

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

type EncKeyPair

type EncKeyPair struct {
	PublicKey  []int32 `protobuf:"varint,1,rep,packed,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
	PrivateKey []int32 `protobuf:"varint,2,rep,packed,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"`
}

EncKeyPair is a public and private key for encrytion.

func EncKeyGen

func EncKeyGen(seed [64]byte) *EncKeyPair

EncKeyGen returns a public / private key pair for encryption.

func NewPopulatedEncKeyPair

func NewPopulatedEncKeyPair(r randyBliss, easy bool) *EncKeyPair

func (*EncKeyPair) Descriptor

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

func (*EncKeyPair) Equal

func (this *EncKeyPair) Equal(that interface{}) bool

func (*EncKeyPair) Marshal

func (m *EncKeyPair) Marshal() (dAtA []byte, err error)

func (*EncKeyPair) MarshalTo

func (m *EncKeyPair) MarshalTo(dAtA []byte) (int, error)

func (*EncKeyPair) ProtoMessage

func (*EncKeyPair) ProtoMessage()

func (*EncKeyPair) Reset

func (m *EncKeyPair) Reset()

func (*EncKeyPair) Size

func (m *EncKeyPair) Size() (n int)

func (*EncKeyPair) String

func (m *EncKeyPair) String() string

func (*EncKeyPair) Unmarshal

func (m *EncKeyPair) Unmarshal(dAtA []byte) error

func (*EncKeyPair) XXX_DiscardUnknown

func (m *EncKeyPair) XXX_DiscardUnknown()

func (*EncKeyPair) XXX_Marshal

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

func (*EncKeyPair) XXX_Merge

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

func (*EncKeyPair) XXX_Size

func (m *EncKeyPair) XXX_Size() int

func (*EncKeyPair) XXX_Unmarshal

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

type Kind

type Kind byte

Kind is Names for the five varieties of bliss-b

const (
	// B0 Kind = iota //since cannot seirialize B0 sig.
	B1 Kind = iota + 1
	B2
	B3
	B4
)

Names for the five varieties of bliss-b

type ParamT

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

ParamT is a param for each BlissB0~B4

func GetParam

func GetParam(kind Kind) (*ParamT, error)

GetParam get a param of kind.

func (*ParamT) PKSize

func (p *ParamT) PKSize() int

PKSize returns the size of publickey.

func (*ParamT) SigSize

func (p *ParamT) SigSize() int

SigSize returns the size of signature..

type PrivateKeyT

type PrivateKeyT struct {
	Kind Kind    `protobuf:"varint,1,opt,name=kind,proto3,casttype=Kind" json:"kind,omitempty"`
	S1   []int32 `protobuf:"varint,2,rep,packed,name=s1,proto3" json:"s1,omitempty"`
	S2   []int32 `protobuf:"varint,3,rep,packed,name=s2,proto3" json:"s2,omitempty"`
	A    []int32 `protobuf:"varint,4,rep,packed,name=a,proto3" json:"a,omitempty"`
}

func NewPopulatedPrivateKeyT

func NewPopulatedPrivateKeyT(r randyBliss, easy bool) *PrivateKeyT

func NewPrivateKey

func NewPrivateKey(kind Kind, seed [64]byte) *PrivateKeyT

NewPrivateKey return a private key for BLISS_B.

func (*PrivateKeyT) Descriptor

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

func (*PrivateKeyT) Equal

func (this *PrivateKeyT) Equal(that interface{}) bool

func (*PrivateKeyT) Marshal

func (m *PrivateKeyT) Marshal() (dAtA []byte, err error)

func (*PrivateKeyT) MarshalTo

func (m *PrivateKeyT) MarshalTo(dAtA []byte) (int, error)

func (*PrivateKeyT) ProtoMessage

func (*PrivateKeyT) ProtoMessage()

func (*PrivateKeyT) PublicKey

func (pk *PrivateKeyT) PublicKey() *PublicKeyT

PublicKey extracs a public key from pk.

func (*PrivateKeyT) Reset

func (m *PrivateKeyT) Reset()

func (*PrivateKeyT) Sign

func (pk *PrivateKeyT) Sign(msg []byte) *SignatureT

Sign signs msg by pk.

func (*PrivateKeyT) Size

func (m *PrivateKeyT) Size() (n int)

func (*PrivateKeyT) String

func (m *PrivateKeyT) String() string

func (*PrivateKeyT) Unmarshal

func (m *PrivateKeyT) Unmarshal(dAtA []byte) error

func (*PrivateKeyT) XXX_DiscardUnknown

func (m *PrivateKeyT) XXX_DiscardUnknown()

func (*PrivateKeyT) XXX_Marshal

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

func (*PrivateKeyT) XXX_Merge

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

func (*PrivateKeyT) XXX_Size

func (m *PrivateKeyT) XXX_Size() int

func (*PrivateKeyT) XXX_Unmarshal

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

type PublicKeyT

type PublicKeyT struct {
	Kind Kind    `protobuf:"varint,1,opt,name=kind,proto3,casttype=Kind" json:"kind,omitempty"`
	A    []int32 `protobuf:"varint,2,rep,packed,name=a,proto3" json:"a,omitempty"`
}

func NewPopulatedPublicKeyT

func NewPopulatedPublicKeyT(r randyBliss, easy bool) *PublicKeyT

func NewPublicKey

func NewPublicKey(b []byte) (*PublicKeyT, error)

NewPublicKey creates an Publickey from serialized bytes.

func (*PublicKeyT) Bytes

func (p *PublicKeyT) Bytes() []byte

Bytes serialize Publickey.

func (*PublicKeyT) Descriptor

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

func (*PublicKeyT) Equal

func (this *PublicKeyT) Equal(that interface{}) bool

func (*PublicKeyT) Marshal

func (m *PublicKeyT) Marshal() (dAtA []byte, err error)

func (*PublicKeyT) MarshalTo

func (m *PublicKeyT) MarshalTo(dAtA []byte) (int, error)

func (*PublicKeyT) ProtoMessage

func (*PublicKeyT) ProtoMessage()

func (*PublicKeyT) Reset

func (m *PublicKeyT) Reset()

func (*PublicKeyT) Size

func (m *PublicKeyT) Size() (n int)

func (*PublicKeyT) String

func (m *PublicKeyT) String() string

func (*PublicKeyT) Unmarshal

func (m *PublicKeyT) Unmarshal(dAtA []byte) error

func (*PublicKeyT) Verify

func (pub *PublicKeyT) Verify(signature *SignatureT, msg []byte) error

Verify verifies signature with pub.

func (*PublicKeyT) XXX_DiscardUnknown

func (m *PublicKeyT) XXX_DiscardUnknown()

func (*PublicKeyT) XXX_Marshal

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

func (*PublicKeyT) XXX_Merge

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

func (*PublicKeyT) XXX_Size

func (m *PublicKeyT) XXX_Size() int

func (*PublicKeyT) XXX_Unmarshal

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

type SignatureT

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

SignatureT is a signature of BLISS-B.

func NewSignature

func NewSignature(b []byte) (*SignatureT, error)

NewSignature creates an SiningKey from serialized bytes.

func (*SignatureT) Bytes

func (s *SignatureT) Bytes() []byte

Bytes serialize SigningKey.

Directories

Path Synopsis
Package bit provides bit-wise IO to an io.Writer and from an io.Reader.
Package bit provides bit-wise IO to an io.Writer and from an io.Reader.

Jump to

Keyboard shortcuts

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