abe

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2020 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPolicy

func CheckPolicy(policy string, userattrsJson string) string

checks satisfiability of a policy

func Decode

func Decode(x string) []byte

func Decrypt

func Decrypt(ctJson string, userattrsJson string) string

decrypt a ciphertext the function requires the list of user attributes to use and the corresponding collection of userkey

func Encode

func Encode(x []byte) string

func Encrypt

func Encrypt(secret string, policy string, authpubsJson string) string

encrypt a secret according to a given policy the function requires the public keys of the authorities mentioned in the policy

func ExtractAttrsFromPolicy

func ExtractAttrsFromPolicy(policy string) string

extracts attributes from policy string

func ExtractAuthsFromPolicy

func ExtractAuthsFromPolicy(policy string) string

extracts authorities from a policy string

func ExtractPolicyFromCiphertext

func ExtractPolicyFromCiphertext(ctJson string) string

extracts policy embedded in a ciphertext

func ExtractVarsFromUserAttrs

func ExtractVarsFromUserAttrs(userattrsJson string) map[string]int

func GetCurve

func GetCurve(curveStr string) string

func JsonObj2Str

func JsonObj2Str(x interface{}) string

func NewRandomAuth

func NewRandomAuth(orgJson string) string

new random authority

func NewRandomOrg

func NewRandomOrg(lib string, curveJson string) string

new random organization

func NewRandomSecret

func NewRandomSecret(orgJson string, seed string) string

new random secret

func NewRandomUserkey

func NewRandomUserkey(user string, attr string, authprvJson string) string

new random userkey

func RewritePolicy

func RewritePolicy(policy string) string

rewrites a policy in a simplified form

func SelectUserAttrs

func SelectUserAttrs(user string, policy string, userattrsJson string) string

select user attrs relevant for a given policy string

func SolvePolicy

func SolvePolicy(policy string, userattrsJson string) map[string]int

solves a policy

Types

type AuthKeys

type AuthKeys struct {
	AuthPub string `json:"authpub"` // public key of the authority
	AuthPrv string `json:"authprv"` // private key of the authority
}

authority public and private keys

type AuthPrv

type AuthPrv struct {
	Org string `json:"org"`

	Alpha string `json:"alpha"`

	Y string `json:"y"`
	// contains filtered or unexported fields
}

authority private params

func (*AuthPrv) Decode

func (authprv *AuthPrv) Decode() *AuthPrv

AuthPrv type from its json representation

func (*AuthPrv) Encode

func (authprv *AuthPrv) Encode() *AuthPrv

AuthPrv type to its json representation

type AuthPub

type AuthPub struct {
	Org string `json:"org"`

	Ealpha string `json:"ealpha"`

	G1y string `json:"g1y"`
	// contains filtered or unexported fields
}

authority public params

func (*AuthPub) Decode

func (authpub *AuthPub) Decode() *AuthPub

AuthPub type from its json representation

func (*AuthPub) Encode

func (authpub *AuthPub) Encode() *AuthPub

AuthPub type to its json representation

type AuthPubs

type AuthPubs struct {
	AuthPub map[string]string `json:"authpub"` // authority -> corresponding public key
}

map of authorities public keys

type Ciphertext

type Ciphertext struct {
	Org string `json:"org"`

	Policy string `json:"policy"`

	C0 string `json:"C0"`

	C map[string][][]string `json:"C"`
	// contains filtered or unexported fields
}

ciphertext encrypting the msg

func (*Ciphertext) Decode

func (ct *Ciphertext) Decode() *Ciphertext

Ciphertext type from its json representation

func (*Ciphertext) Encode

func (ct *Ciphertext) Encode() *Ciphertext

Ciphertext type to its json representation

type Curve

type Curve interface {
	Encode() Curve
	Decode() Curve
	NewPointOn(group string) Point
	NewRandomExp() *big.Int
	NewRandomSecret(n int, zerosecret bool) []*big.Int
	NewRandomPointOn(group string) Point
	UnitOnGroup(group string) Point
	HashToGroup(x string, group string) Point
	HashToPow(x string, g Point) Point
	Inv(g1 Point) Point
	Mul(g1 Point, g2 Point) Point
	Div(g1 Point, g2 Point) Point
	Pow(g1 Point, e1 *big.Int) Point
	Pow2(g1 Point, e1 *big.Int, g2 Point, e2 *big.Int) Point
	Pow3(g1 Point, e1 *big.Int, g2 Point, e2 *big.Int, g3 Point, e3 *big.Int) Point
	Pair(g1 Point, g2 Point) Point
	ProdPair(g1 []Point, g2 []Point) Point
	// contains filtered or unexported methods
}

curve interface

type Org

type Org struct {
	Lib string `json:"lib"`

	Curve string `json:"curve"`

	G1 string `json:"g1"`

	G2 string `json:"g2"`

	E string `json:"e"`
	// contains filtered or unexported fields
}

organization

func (*Org) Decode

func (org *Org) Decode() *Org

Org type from its json representation

func (*Org) Encode

func (org *Org) Encode() *Org

Org type to its json representation

type PbcCurve

type PbcCurve struct {
	Params    string `json:"params"`
	Maxrndexp string `json:"maxrndexp"`
	// contains filtered or unexported fields
}

curve on pbc library

func (*PbcCurve) Decode

func (curve *PbcCurve) Decode() Curve

PbcCurve type from its json representation

func (*PbcCurve) Div

func (curve *PbcCurve) Div(g1 Point, g2 Point) Point

group operation

func (*PbcCurve) Encode

func (curve *PbcCurve) Encode() Curve

PbcCurve type to its json representation

func (*PbcCurve) HashToGroup

func (curve *PbcCurve) HashToGroup(x string, group string) Point

hash to group ("G1", "G2", "GT") in the bilinear pairing

func (*PbcCurve) HashToPow

func (curve *PbcCurve) HashToPow(x string, g Point) Point

hash to group ("G1", "G2", "GT") in the bilinear pairing

func (*PbcCurve) Inv

func (curve *PbcCurve) Inv(g1 Point) Point

group operation

func (*PbcCurve) Mul

func (curve *PbcCurve) Mul(g1 Point, g2 Point) Point

group operation

func (*PbcCurve) NewPointOn

func (curve *PbcCurve) NewPointOn(group string) Point

new point instance on a curve

func (*PbcCurve) NewRandomExp

func (curve *PbcCurve) NewRandomExp() *big.Int

new random exponent

func (*PbcCurve) NewRandomPointOn

func (curve *PbcCurve) NewRandomPointOn(group string) Point

new random point on a group ("G1", "G2", "GT") in the bilinear pairing

func (*PbcCurve) NewRandomSecret

func (curve *PbcCurve) NewRandomSecret(n int, zerosecret bool) []*big.Int

new random secret vector of length n if zerosecret is true, the first component of the vector is zero

func (*PbcCurve) Pair

func (curve *PbcCurve) Pair(g1 Point, g2 Point) Point

pairing

func (*PbcCurve) Pow

func (curve *PbcCurve) Pow(g1 Point, e1 *big.Int) Point

group operation

func (*PbcCurve) Pow2

func (curve *PbcCurve) Pow2(g1 Point, e1 *big.Int, g2 Point, e2 *big.Int) Point

group operation

func (*PbcCurve) Pow3

func (curve *PbcCurve) Pow3(g1 Point, e1 *big.Int, g2 Point, e2 *big.Int, g3 Point, e3 *big.Int) Point

group operation

func (*PbcCurve) ProdPair

func (curve *PbcCurve) ProdPair(g1 []Point, g2 []Point) Point

pairing

func (*PbcCurve) UnitOnGroup

func (curve *PbcCurve) UnitOnGroup(group string) Point

unit on group ("G1", "G2", "GT") in the bilinear pairing

type PbcPoint

type PbcPoint struct {
	P     string `json:"p"`
	Group string `json:"group"`
	// contains filtered or unexported fields
}

point on pbc library

func (*PbcPoint) Decode

func (p *PbcPoint) Decode(curve Curve) Point

PbcPoint type from its json representation

func (*PbcPoint) Encode

func (p *PbcPoint) Encode() Point

PbcPoint type to its json representation

func (*PbcPoint) GetGroup

func (p *PbcPoint) GetGroup() string

func (*PbcPoint) GetP

func (p *PbcPoint) GetP() string

type Point

type Point interface {
	Encode() Point
	Decode(curve Curve) Point
	GetP() string
	GetGroup() string
	// contains filtered or unexported methods
}

point interface

type PolicyAttrs

type PolicyAttrs struct {
	Row map[string][]int `json:"row"` // attribute -> access policy matrix rows index
}

attributes in a given policy

type UserAttrs

type UserAttrs struct {
	User    string            `json:"user"`    // user
	Coeff   map[string][]int  `json:"coeff"`   // attribute -> its coefficients
	Userkey map[string]string `json:"userkey"` // attribute -> corresponding userkey
}

map of user attributes

type Userkey

type Userkey struct {
	Org string `json:"org"`

	K string `json:"K"`

	KP string `json:"KP"`
	// contains filtered or unexported fields
}

user key

func (*Userkey) Decode

func (userkey *Userkey) Decode() *Userkey

Userkey type from its json representation

func (*Userkey) Encode

func (userkey *Userkey) Encode() *Userkey

Userkey type to its json representation

Directories

Path Synopsis
+build linux
+build linux
+build cgo
+build cgo

Jump to

Keyboard shortcuts

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