abe

package
v0.0.0-...-3a38687 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: AGPL-3.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthPubsOfPolicyJson

func AuthPubsOfPolicyJson(policy string) string

Json API for AuthPubsOfPolicy

func Decode

func Decode(x string) string

func DecryptJson

func DecryptJson(ctJson string, userattrsJson string) string

Json API for Decrypt

func Encode

func Encode(x string) string

func EncryptJson

func EncryptJson(secretJson string, policy string, authpubsJson string) string

Json API for Encrypt

func JsonObjToEncStr

func JsonObjToEncStr(x interface{}) string

func JsonObjToStr

func JsonObjToStr(x interface{}) string

func NewRandomAuthJson

func NewRandomAuthJson(orgJson string) string

Json API for NewRandomAuth

func NewRandomOrgJson

func NewRandomOrgJson(curveJson string) string

Json API for NewRandomOrg

func NewRandomSecretJson

func NewRandomSecretJson(orgJson string) string

Json API for NewRandomSecret

func NewRandomUserkeyJson

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

Json API for NewRandomUserkey

func PolicyOfCiphertext

func PolicyOfCiphertext(ct *Ciphertext) string

func PolicyOfCiphertextJson

func PolicyOfCiphertextJson(ctJson string) string

Json API extracting policy from ciphertexts

func SecretHash

func SecretHash(secret Point) string

func SelectUserAttrsJson

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

Json API for SelectUserAttrs

Types

type AccessPolicy

type AccessPolicy struct {
	M    [][]int          // access policy matrix
	Vars []string         // attribute list
	Row  map[string][]int // attribute -> access policy matrix rows index
}

attributes in a given policy

type AuthKeys

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

authority public and private keys

func NewAuthKeysOfJsonStr

func NewAuthKeysOfJsonStr(xJson string) (x *AuthKeys)

func NewRandomAuth

func NewRandomAuth(org *Org) (authkeys *AuthKeys)

new random authority

func (*AuthKeys) OfJsonObj

func (authkeys *AuthKeys) OfJsonObj() *AuthKeys

AuthKeys type from its json representation

func (*AuthKeys) ToJsonObj

func (authkeys *AuthKeys) ToJsonObj() *AuthKeys

AuthKeys type to its json representation

type AuthPrv

type AuthPrv struct {
	Org    *Org     `json:"-"`
	Org_   string   `json:"org"`
	Alpha  *big.Int `json:"-"`
	Alpha_ string   `json:"alpha"`
	Y      *big.Int `json:"-"`
	Y_     string   `json:"y"`
}

authority private params

func NewAuthPrvOfJsonStr

func NewAuthPrvOfJsonStr(xJson string) (x *AuthPrv)

func (*AuthPrv) OfJsonObj

func (authprv *AuthPrv) OfJsonObj() *AuthPrv

AuthPrv type from its json representation

func (*AuthPrv) ToJsonObj

func (authprv *AuthPrv) ToJsonObj() *AuthPrv

AuthPrv type to its json representation

type AuthPub

type AuthPub struct {
	Org     *Org   `json:"-"`
	Org_    string `json:"org"`
	Ealpha  Point  `json:"-"`
	Ealpha_ string `json:"ealpha"`
	G1y     Point  `json:"-"`
	G1y_    string `json:"g1y"`
}

authority public params

func NewAuthPubOfJsonStr

func NewAuthPubOfJsonStr(xJson string) (x *AuthPub)

func (*AuthPub) OfJsonObj

func (authpub *AuthPub) OfJsonObj() *AuthPub

AuthPub type from its json representation

func (*AuthPub) ToJsonObj

func (authpub *AuthPub) ToJsonObj() *AuthPub

AuthPub type to its json representation

type AuthPubs

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

map of authorities public keys

func AuthPubsOfPolicy

func AuthPubsOfPolicy(policy string) *AuthPubs

extracts authorities from a policy string

func NewAuthPubsOfJsonStr

func NewAuthPubsOfJsonStr(xJson string) (x *AuthPubs)

func (*AuthPubs) OfJsonObj

func (authpubs *AuthPubs) OfJsonObj() *AuthPubs

AuthPubs type from its json representation

func (*AuthPubs) ToJsonObj

func (authpubs *AuthPubs) ToJsonObj() *AuthPubs

AuthPubs type to its json representation

type Ciphertext

type Ciphertext struct {
	Org     *Org                  `json:"-"`
	Org_    string                `json:"org"`
	Policy  string                `json:"-"`
	Policy_ string                `json:"policy"`
	C0      Point                 `json:"-"`
	C0_     string                `json:"c0"`
	C       map[string][][]Point  `json:"-"`
	C_      map[string][][]string `json:"c"`
}

ciphertext encrypting the msg

func Encrypt

func Encrypt(secret Point, policy string, authpubs *AuthPubs) (ct *Ciphertext)

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

func NewCiphertextOfJsonStr

func NewCiphertextOfJsonStr(xJson string) (x *Ciphertext)

func (*Ciphertext) OfJsonObj

func (ct *Ciphertext) OfJsonObj() *Ciphertext

Ciphertext type from its json representation

func (*Ciphertext) ToJsonObj

func (ct *Ciphertext) ToJsonObj() *Ciphertext

Ciphertext type to its json representation

type Curve

type Curve interface {
	ToJsonObj() Curve
	OfJsonObj() Curve
	SetSeed(seed string) Curve
	InitRng() 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

func NewCurveOfJsonStr

func NewCurveOfJsonStr(xJson string) (x Curve)

type Org

type Org struct {
	Crv  Curve  `json:"-"`
	Crv_ string `json:"crv"`
	G1   Point  `json:"-"`
	G1_  string `json:"g1"`
	G2   Point  `json:"-"`
	G2_  string `json:"g2"`
	E    Point  `json:"-"`
	E_   string `json:"e"`
}

organization

func GetOrgFromAuthPubs

func GetOrgFromAuthPubs(authpubs *AuthPubs) *Org

func NewOrgOfJsonStr

func NewOrgOfJsonStr(xJson string) (x *Org)

func NewRandomOrg

func NewRandomOrg(curve Curve) (org *Org)

new random organization

func (*Org) OfJsonObj

func (org *Org) OfJsonObj() *Org

Org type from its json representation

func (*Org) ToJsonObj

func (org *Org) ToJsonObj() *Org

Org type to its json representation

type Point

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

point interface

func Decrypt

func Decrypt(ct *Ciphertext, userattrs *UserAttrs) (secret Point)

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

func NewPointOfJsonStr

func NewPointOfJsonStr(xJson string) (x Point)

func NewRandomSecret

func NewRandomSecret(org *Org) (secret Point)

new random secret

type UserAttrs

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

map of user attributes

func NewRandomUserkey

func NewRandomUserkey(user string, attr string, authprv *AuthPrv) (userattrs *UserAttrs)

new random userkey

func NewUserAttrsOfJsonStr

func NewUserAttrsOfJsonStr(xJson string) (x *UserAttrs)

func (*UserAttrs) Add

func (userattrs0 *UserAttrs) Add(userattrs1 *UserAttrs) *UserAttrs

merge 2 UserAttrs

func (*UserAttrs) OfJsonObj

func (userattrs *UserAttrs) OfJsonObj() *UserAttrs

UserAttrs type from its json representation

func (*UserAttrs) SelectUserAttrs

func (userattrs *UserAttrs) SelectUserAttrs(user string, policy string) *UserAttrs

select user attrs relevant for a given policy string

func (*UserAttrs) ToJsonObj

func (userattrs *UserAttrs) ToJsonObj() *UserAttrs

UserAttrs type to its json representation

type Userkey

type Userkey struct {
	Org  *Org   `json:"-"`
	Org_ string `json:"org"`
	K    Point  `json:"-"`
	K_   string `json:"k"`
	KP   Point  `json:"-"`
	KP_  string `json:"kp"`
}

user key

func NewUserkeyOfJsonStr

func NewUserkeyOfJsonStr(xJson string) (x *Userkey)

func (*Userkey) OfJsonObj

func (userkey *Userkey) OfJsonObj() *Userkey

Userkey type from its json representation

func (*Userkey) ToJsonObj

func (userkey *Userkey) ToJsonObj() *Userkey

Userkey type to its json representation

Directories

Path Synopsis
miracl

Jump to

Keyboard shortcuts

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