glyph

package module
v0.0.0-...-568a83f Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2018 License: MIT Imports: 15 Imported by: 0

README

Build Status GoDoc GitHub license Coverage Status

GLYPH

Overview

This is an implementation of GLYPH, which is a signature scheme based on Ring-LWE.

This software is mostly a rewrite of a GLYPH implementation in Golang except that:

  • The implementation uses different q and B from the papaer for smaller sizes. (Note that these pramemetrs should also make the crypto more secure)
This implementation In the Paper
Q 12289 59393
B 4095 16383
Bytes of a Public key 1792 bytes 2048 bytes
Bytes of a Signature 1942 bytes 2198 bytes
Total 3734 bytes 4246 bytes

The drawback is that we need some time to sign a message (at most a few seconds).

  • The implementation uses the NTT algorithm applied in NewHope for faster FFT.

Requirements

  • git
  • go 1.9+

are required to compile.

Install

$ go get github.com/AidosKuneen/glyph

Usage

	message := []byte("some message")

	sk, err := glyph.NewSK()
	sig, err := sk.Sign(message)
	pk := sk.PK()
	err:=pk.Verify(sig, message)

Performance

Using the following test environment...

* Compiler: go version go1.10.3 linux/amd64
* Kernel: Linux WS777 4.13.5-1-ARCH #1 SMP PREEMPT Fri Oct 6 09:58:47 CEST 2017 x86_64 GNU/Linux
* CPU:  Celeron(R) CPU G1840 @ 2.80GHz 
* Memory: 8 GB

For signing, it takes about 400 mS.

For verification, it takes about 240 uS.

BenchmarkSign-2        	      10	 401147645 ns/op
BenchmarkVeri-2        	   10000	    237446 ns/op

Dependencies and Licenses

This software includes a rewrite (from C++ to go) of https://github.com/quantumsafelattices/glyph, which is covered by "Unlicense".

This software includes codes from https://github.com/Yawning/newhope, which is covered by "CC0 1.0 Universal" license.

github.com/AidosKuneen/numcpu  MIT License
Golang Standard Library                       BSD 3-clause License

Documentation

Index

Constants

View Source
const (
	PKSize  = qBits * constN / 8                  //512 bytes
	SKSize  = 2 * 2 * constN / 8                  //1792 bytes
	SigSize = ((bBits+1+2)*constN + 11*omega) / 8 //1942 bytes
)

Global Constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Publickey

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

Publickey of glyph signature.

func NewPublickey

func NewPublickey(b []byte) (*Publickey, error)

NewPublickey creates an Publickey from serialized bytes.

func (*Publickey) Bytes

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

Bytes serialize Publickey.

func (*Publickey) DecodeMsgpack

func (p *Publickey) DecodeMsgpack(dec *msgpack.Decoder) error

DecodeMsgpack unmarshals JSON to Publickey.

func (*Publickey) EncodeMsgpack

func (p *Publickey) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack marshals Publickey into valid JSON.

func (*Publickey) MarshalJSON

func (p *Publickey) MarshalJSON() ([]byte, error)

MarshalJSON marshals Publickey into valid JSON.

func (*Publickey) UnmarshalJSON

func (p *Publickey) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals JSON to Publickey.

func (*Publickey) Verify

func (pk *Publickey) Verify(sig *Signature, message []byte) error

Verify veriris the signature.

type Signature

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

Signature of glyph signature.

func NewSignature

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

NewSignature creates an sparsePolyST from serialized bytes.

func (*Signature) Bytes

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

Bytes serialize Signature.

type SigningKey

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

SigningKey of glyph signature.

func NewSK

func NewSK(key []byte) *SigningKey

NewSK generates signing key (s1,s2) from the key, stored in physical form. The key must be 32 bytes.

func NewSigningKey

func NewSigningKey(b []byte) (*SigningKey, error)

NewSigningKey creates an SiningKey from serialized bytes.

func (*SigningKey) Bytes

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

Bytes serialize SigningKey.

func (*SigningKey) DecodeMsgpack

func (s *SigningKey) DecodeMsgpack(dec *msgpack.Decoder) error

DecodeMsgpack unmarshals JSON to SigningKey.

func (*SigningKey) EncodeMsgpack

func (s *SigningKey) EncodeMsgpack(enc *msgpack.Encoder) error

EncodeMsgpack marshals SigningKey into valid JSON.

func (*SigningKey) MarshalJSON

func (s *SigningKey) MarshalJSON() ([]byte, error)

MarshalJSON marshals SiningKey into valid JSON.

func (*SigningKey) PK

func (sk *SigningKey) PK() *Publickey

PK takes a signing key stored in physical space and computes the public key in physical space points a1, a2 are stored in FFT space

func (*SigningKey) Sign

func (sk *SigningKey) Sign(message []byte) (*Signature, error)

Sign signs a message as (z,c) where z is a ring elt in physical form, and c is a hash output encoded as a sparse poly

func (*SigningKey) UnmarshalJSON

func (s *SigningKey) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals JSON to SiningKey.

Jump to

Keyboard shortcuts

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