compat

package
v0.0.0-...-2c216b4 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package compatibility implements wrapper types, constants and functions around github.com/emmyzkp/emmy/client, making relevant functionality compatible with go language binding tools. All the constructs defined in this package are compatible with gobind tool that generates language bindings for Java or Objective C in order to expose Go code to Android or iOS mobile applications.

The gobind tool imposes several restrictions on the types of exported fields, function parameters and their return values. Read more about them here: https://godoc.org/golang.org/x/mobile/cmd/gobind.

Only Java bindings generated from this package were tested.

Generating language bindings

To generate Java bindings for use in an Android application, read the overview of gomobile tool (https://godoc.org/golang.org/x/mobile/cmd/gomobile). When you are all set, run:

gomobile bind -v -o emmy.aar github.com/emmyzkp/emmy/client/compatibility

This command will produce an Android archive (. AAR) named emmy.aar from compatibility package. You can add generated AAR as a dependency to your Android application. Then, you can import Go types, functions and constants as regular Java types from the Java package compatibility. For instance, see Java code snippet below:

import compatibility.Connetion;
import compatibility.ConnectionConfig;
...
ConnectionConfig cfg = new ConnectionConfig("localhost:7007", "", cert.getBytes());
Connection conn = new Connection(cfg)

Go types exposed to Java code

Generic types:

ConnectionConfig
Connection
Logger
ServiceInfo

Clients that allow us to execute various interactive cryptographic protocols with the server:

PseudonymsysCAClient
PseudonymsysClient
PseudonymsysCAECClient
PseudonymsysECClient

Cryptographic types:

CACertificate
CACertificateEC
Credential
CredentialEC
ECGroupElement
CLPubKey
PubKeyEC
Transcript
TranscriptEC
Pseudonym
PseudonymEC

Index

Constants

View Source
const (
	DEBUG    = log.DEBUG
	INFO     = log.INFO
	NOTICE   = log.NOTICE
	WARNING  = log.WARNING
	ERROR    = log.ERROR
	CRITICAL = log.CRITICAL
)

Supported log levels.

View Source
const (
	P256 = int(ec.P256)
	P224 = int(ec.P224)
	P384 = int(ec.P384)
	P521 = int(ec.P521)
)

Representations of specific elliptic curves to be used in elliptic cryptography based schemes.

Variables

View Source
var ArgsConversionError = errors.New("failed to convert string argument to big integer")

ArgsConversionError indicates an error due to a failed conversion of string argument to *big.Int type from package https://golang.org/pkg/math/big/.

Functions

func SetLogger

func SetLogger(logger *Logger)

SetLogger propagates the given *Logger to client package, around which this package wraps.

Types

type CACertificate

type CACertificate struct {
	BlindedA string
	BlindedB string
	R        string
	S        string
}

CACertificate represents an equivalent of pseudsys.CACert, but has string field types to overcome type restrictions of Go language binding tools.

func NewCACertificate

func NewCACertificate(blindedA, blindedB, r, s string) *CACertificate

type CACertificateEC

type CACertificateEC struct {
	BlindedA *ECGroupElement
	BlindedB *ECGroupElement
	R        string
	S        string
}

CACertificateEC represents an equivalent of pseudonymsys.CACertificateEC, but has field types compatible with Go language binding tools.

func NewCACertificateEC

func NewCACertificateEC(bA, bB *ECGroupElement, r, s string) *CACertificateEC

type CLClient

type CLClient struct {
	*cl.Client
}

func NewCLClient

func NewCLClient(conn *Connection) *CLClient

func (*CLClient) GetPublicParams

func (c *CLClient) GetPublicParams() (*CLPublicParams, error)

func (*CLClient) IssueCred

func (c *CLClient) IssueCred(cm *CLCredManager, regKey string) (*CLCred,
	error)

func (*CLClient) ProveCred

func (c *CLClient) ProveCred(cm *CLCredManager, cred *CLCred,
	revealed *CLRevealedAttrs) (string, error)

type CLCred

type CLCred struct {
	*cl.Cred
}

func NewCLCred

func NewCLCred(bytes []byte) (*CLCred, error)

func (*CLCred) Bytes

func (c *CLCred) Bytes() ([]byte, error)

type CLCredManager

type CLCredManager struct {
	*cl.CredManager
}

func NewCLCredManager

func NewCLCredManager(params *CLParams, pk *CLPubKey,
	secret []byte, cred *CLRawCred) (*CLCredManager,
	error)

NewCLCredManager generates credential manager for the CL scheme. It accepts parameters for the CL scheme (these must match server-side configuration), server's public key, user's secret and attributes to manage.

func RestoreCLCredManager

func RestoreCLCredManager(ctx *CLCredManagerContext, secret []byte,
	cred *CLRawCred) (*CLCredManager, error)

RestoreCLCredManager establishes credential manager for the CL scheme. It is meant to be used to re-establish the credential manager after it has been previously created with NewCLCredManager.

func (*CLCredManager) GetContext

func (cm *CLCredManager) GetContext() *CLCredManagerContext

GetContext returns a CLCredManagerContext filled with current state of the CLCredManager. It can be used to restore a CLCredManager.

type CLCredManagerContext

type CLCredManagerContext struct {
	*cl.CredManagerCtx
}

func NewCLCredManagerContext

func NewCLCredManagerContext(bytes []byte) (*CLCredManagerContext, error)

func (*CLCredManagerContext) Bytes

func (c *CLCredManagerContext) Bytes() ([]byte, error)

type CLLongAttribute

type CLLongAttribute struct {
	*cl.Int64Attr
}

type CLParams

type CLParams struct {
	*clpb.Params
}

type CLPubKey

type CLPubKey struct {
	*cl.PubKey
}

func (*CLPubKey) GenerateMasterSecret

func (k *CLPubKey) GenerateMasterSecret() []byte

type CLPublicParams

type CLPublicParams struct {
	PubKey  *CLPubKey
	Config  *CLParams
	RawCred *CLRawCred
}

type CLRawCred

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

func NewCLRawCred

func NewCLRawCred(bytes []byte) (*CLRawCred, error)

func (*CLRawCred) Bytes

func (c *CLRawCred) Bytes() ([]byte, error)

func (*CLRawCred) GetAttributeNames

func (c *CLRawCred) GetAttributeNames() []string

func (*CLRawCred) SetLongAttribute

func (c *CLRawCred) SetLongAttribute(name string, val int64) error

func (*CLRawCred) SetStringAttribute

func (c *CLRawCred) SetStringAttribute(name, val string) error

type CLRevealedAttrs

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

func NewCLRevealedAttrs

func NewCLRevealedAttrs() *CLRevealedAttrs

func (*CLRevealedAttrs) Add

func (a *CLRevealedAttrs) Add(attr string)

type CLStringAttribute

type CLStringAttribute struct {
	*cl.StrAttr
}

type Commitment

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

type Connection

type Connection struct {
	*grpc.ClientConn
}

Connection wraps *grpc.ClientConn. A Connection should be constructed independently and then passed as an argument to protocol clients. Same Connection can be re-used for many clients.

func NewConnection

func NewConnection(cfg *ConnectionConfig) (*Connection, error)

NewConnection accepts *ConnectionConfig and uses the provided configuration information to establish connection to the server.

func (*Connection) Close

func (c *Connection) Close() error

Close attempts to close connection to the server.

type ConnectionConfig

type ConnectionConfig struct {
	Endpoint           string // Server's Endpoint
	ServerNameOverride string
	CACertificate      []byte
	TimeoutMillis      int
}

ConnectionConfig wraps client.ConnectionConfig that holds connection information. Clients need to provide these information in order to establish connection to the server. For more details see documentation for the github.com/emmyzkp/emmy/client package.

func NewConnectionConfig

func NewConnectionConfig(endpoint, serverNameOverride string,
	certificate []byte, timeout int) *ConnectionConfig

NewConnectionConfig constructs an instance of ConnectionConfig based on the provided server endpoint, serverNameOverride and CA certificate.

type Credential

type Credential struct {
	SmallAToGamma string
	SmallBToGamma string
	AToGamma      string
	BToGamma      string
	T1            *Transcript
	T2            *Transcript
}

Credential represents an equivalent of pseudsys.CLCred, but has field types compatible with Go language binding tools.

func NewCredential

func NewCredential(aToGamma, bToGamma, AToGamma, BToGamma string,
	t1, t2 *Transcript) *Credential

type CredentialEC

type CredentialEC struct {
	SmallAToGamma *ECGroupElement
	SmallBToGamma *ECGroupElement
	AToGamma      *ECGroupElement
	BToGamma      *ECGroupElement
	T1            *TranscriptEC
	T2            *TranscriptEC
}

CredentialEC represents an equivalent of ecpseudsys.CLCred, but has field types compatible with Go language binding tools.

func NewCredentialEC

func NewCredentialEC(aToGamma, bToGamma, AToGamma, BToGamma *ECGroupElement,
	t1, t2 *TranscriptEC) *CredentialEC

type ECGroupElement

type ECGroupElement struct {
	X string
	Y string
}

ECGroupElement represents an equivalent of ec.GroupElement, but has string field types to overcome type restrictions of Go language binding tools.

func NewECGroupElement

func NewECGroupElement(x, y string) *ECGroupElement

type Logger

type Logger struct {
	*log.StdoutLogger
}

Logger wraps a concrete *log.StdoutLogger implementation. It can be constructed by the client application in order to override default logger provided by the client package.

func NewLogger

func NewLogger(logLevel string) (*Logger, error)

NewLogger constructs a *Logger with a fixed format and configurable log level.

type PedersenParams

type PedersenParams struct {
	Group SchnorrGroup
	H     []byte
	// contains filtered or unexported fields
}

type Pseudonym

type Pseudonym struct {
	A string
	B string
}

Pseudonym represents an equivalent of pseudsys.Nym, but has string field types to overcome type restrictions of Go language binding tools.

func NewPseudonym

func NewPseudonym(a, b string) *Pseudonym

type PseudonymEC

type PseudonymEC struct {
	A *ECGroupElement
	B *ECGroupElement
}

PseudonymEC represents an equivalent of pseudonymsys.PseudonymEC, but has field types compatible with Go language binding tools.

func NewPseudonymEC

func NewPseudonymEC(a, b *ECGroupElement) *PseudonymEC

type PseudonymsysCAClient

type PseudonymsysCAClient struct {
	*psys.CAClient
}

CAClient wraps around client.CAClient to conform to type restrictions of Go language binding tools. It exposes the same set of methods as client.CAClient.

func NewPseudonymsysCAClient

func NewPseudonymsysCAClient(g *SchnorrGroup) (*PseudonymsysCAClient, error)

func (*PseudonymsysCAClient) Connect

func (c *PseudonymsysCAClient) Connect(conn *Connection)

func (*PseudonymsysCAClient) GenerateCertificate

func (c *PseudonymsysCAClient) GenerateCertificate(userSecret string,
	nym *Pseudonym) (*CACertificate, error)

func (*PseudonymsysCAClient) GenerateMasterNym

func (c *PseudonymsysCAClient) GenerateMasterNym(secret string) (*Pseudonym, error)

type PseudonymsysCAClientEC

type PseudonymsysCAClientEC struct {
	*ecpsys.CAClient
}

PseudonymsysCAECClient wraps around client.CAClient to conform to type restrictions of Go language binding tools. It exposes the same set of methods as client.CAClient.

func NewPseudonymsysCAClientEC

func NewPseudonymsysCAClientEC(curve int) *PseudonymsysCAClientEC

func (*PseudonymsysCAClientEC) Connect

func (c *PseudonymsysCAClientEC) Connect(conn *Connection)

func (*PseudonymsysCAClientEC) GenerateCertificate

func (c *PseudonymsysCAClientEC) GenerateCertificate(userSecret string,
	nym *PseudonymEC) (*CACertificateEC, error)

func (*PseudonymsysCAClientEC) GenerateMasterNym

func (c *PseudonymsysCAClientEC) GenerateMasterNym(secret string, curve int) (*PseudonymEC,
	error)

type PseudonymsysClient

type PseudonymsysClient struct {
	*psys.Client
}

CLClient wraps around client.CLClient to conform to type restrictions of Go language binding tools. It exposes the same set of methods as client.CLClient.

func NewPseudonymsysClient

func NewPseudonymsysClient(conn *Connection, g *SchnorrGroup) (*PseudonymsysClient, error)

func (*PseudonymsysClient) GenerateMasterKey

func (c *PseudonymsysClient) GenerateMasterKey() string

GenerateMasterKey returns a string representation of the master secret key to be used with the pseudonym system scheme.

func (*PseudonymsysClient) GenerateNym

func (c *PseudonymsysClient) GenerateNym(userSecret string,
	cert *CACertificate, regKey string) (*Pseudonym, error)

func (*PseudonymsysClient) ObtainCredential

func (c *PseudonymsysClient) ObtainCredential(userSecret string,
	nym *Pseudonym, publicKey *PubKey) (*Credential, error)

func (*PseudonymsysClient) TransferCredential

func (c *PseudonymsysClient) TransferCredential(orgName, userSecret string,
	nym *Pseudonym, cred *Credential) (string, error)

type PseudonymsysClientEC

type PseudonymsysClientEC struct {
	*ecpsys.Client
}

CLClient wraps around client.CLClient to conform to type restrictions of Go language binding tools. It exposes the same set of methods as client.CLClient.

func NewPseudonymsysClientEC

func NewPseudonymsysClientEC(conn *Connection, curve int) (*PseudonymsysClientEC, error)

func (*PseudonymsysClientEC) GenerateMasterKey

func (c *PseudonymsysClientEC) GenerateMasterKey() string

GenerateMasterKey returns a string representation of the master secret key to be used with the pseudonym system scheme in the EC arithmetic.

func (*PseudonymsysClientEC) GenerateNym

func (c *PseudonymsysClientEC) GenerateNym(userSecret string,
	cert *CACertificateEC, regKey string) (*PseudonymEC, error)

func (*PseudonymsysClientEC) ObtainCredential

func (c *PseudonymsysClientEC) ObtainCredential(userSecret string,
	nym *PseudonymEC, publicKey *PubKeyEC) (*CredentialEC, error)

func (*PseudonymsysClientEC) TransferCredential

func (c *PseudonymsysClientEC) TransferCredential(orgName, userSecret string,
	nym *PseudonymEC, cred *CredentialEC) (string, error)

type PubKey

type PubKey struct {
	H1 string
	H2 string
}

CLPubKey represents an equivalent of pseudsys.CLPubKey, but has string field types to overcome type restrictions of Go language binding tools.

func NewPubKey

func NewPubKey(h1, h2 string) *PubKey

type PubKeyEC

type PubKeyEC struct {
	H1 *ECGroupElement
	H2 *ECGroupElement
}

PubKeyEC represents an equivalent of ecpseudsys.PubKeyEC, but has field types compatible with Go language binding tools.

func NewPubKeyEC

func NewPubKeyEC(h1, h2 *ECGroupElement) *PubKeyEC

type SchnorrGroup

type SchnorrGroup struct {
	P string
	G string
	Q string
}

SchnorrGroup represents an equivalent of schnorr.Group, but has string field types to overcome type restrictions of Go language binding tools.

func NewSchnorrGroup

func NewSchnorrGroup(p, g, q string) *SchnorrGroup

type ServiceInfo

type ServiceInfo struct {
	Name        string
	Description string
	Provider    string
}

ServiceInfo holds information about the secure service provider and its service offering.

type Transcript

type Transcript struct {
	A      string
	B      string
	Hash   string
	ZAlpha string
}

Transcript represents an equivalent of schnorr.BlindedTrans, but has string field types to overcome type restrictions of Go language binding tools.

func NewTranscript

func NewTranscript(a, b, hash, zAlpha string) *Transcript

type TranscriptEC

type TranscriptEC struct {
	Alpha_1 string
	Alpha_2 string
	Beta_1  string
	Beta_2  string
	Hash    string
	ZAlpha  string
}

TranscriptEC represents an equivalent of ecschnorr.BlindedTrans, but has string field types to overcome type restrictions of Go language binding tools.

func NewTranscriptEC

func NewTranscriptEC(alpha_1, alpha_2, beta_1, beta_2, hash, zAlpha string) *TranscriptEC

Jump to

Keyboard shortcuts

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