tkn

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Andgate = iota
	Orgate
)

Variables

This section is empty.

Functions

func CouldDecrypt

func CouldDecrypt(ciphertext []byte, a *Attributes) bool

func DecryptCCA

func DecryptCCA(ciphertext []byte, key *AttributesKey) ([]byte, error)

func EncryptCCA

func EncryptCCA(rand io.Reader, public *PublicParams, policy *Policy, msg []byte) ([]byte, error)

func GenerateParams

func GenerateParams(rand io.Reader) (*PublicParams, *SecretParams, error)

func HashStringToScalar

func HashStringToScalar(key []byte, value string) *pairing.Scalar

func ToScalar

func ToScalar(n int) *pairing.Scalar

Types

type Attribute

type Attribute struct {
	Value *pairing.Scalar
	// contains filtered or unexported fields
}

func (*Attribute) Equal

func (a *Attribute) Equal(b *Attribute) bool

type Attributes

type Attributes map[string]Attribute

func (*Attributes) Equal

func (a *Attributes) Equal(b *Attributes) bool

type AttributesKey

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

func DeriveAttributeKeysCCA

func DeriveAttributeKeysCCA(rand io.Reader, sp *SecretParams, attrs *Attributes) (*AttributesKey, error)

func (*AttributesKey) Equal

func (a *AttributesKey) Equal(b *AttributesKey) bool

func (*AttributesKey) MarshalBinary

func (a *AttributesKey) MarshalBinary() ([]byte, error)

func (*AttributesKey) UnmarshalBinary

func (a *AttributesKey) UnmarshalBinary(data []byte) error

type Formula

type Formula struct {
	Gates []Gate
}

Formula represents a monotone boolean circuit with Inputs not repeated. The representation is as follows: for n Gates there n+1 input wires, 1 output Wire, and n-1 intermediate wires. That's because there are 2n Inputs to all Gates and n outputs since every Gate is 2:1.

The wires are conceptually in an array. Wires 0 through n are the input wires, and Wire 2n is the output Wire. If there are wires between n and 2n they are intermediate wires.

All intermediate and input wires must be used exactly once as Inputs.

func (*Formula) Equal

func (f *Formula) Equal(g Formula) bool

func (*Formula) MarshalBinary

func (f *Formula) MarshalBinary() ([]byte, error)

func (*Formula) UnmarshalBinary

func (f *Formula) UnmarshalBinary(data []byte) error

type Gate

type Gate struct {
	Class int // either Andgate or Orgate
	In0   int // numbering of wires
	In1   int
	Out   int
}

Gate is a Gate in a monotone boolean formula.

func (Gate) Equal

func (g Gate) Equal(g2 Gate) bool

type Policy

type Policy struct {
	Inputs []Wire
	F      Formula // monotonic boolean formula
}

func (*Policy) Equal

func (p *Policy) Equal(p2 *Policy) bool

func (*Policy) ExtractFromCiphertext

func (p *Policy) ExtractFromCiphertext(ct []byte) error

func (*Policy) MarshalBinary

func (p *Policy) MarshalBinary() ([]byte, error)

func (*Policy) Satisfaction

func (p *Policy) Satisfaction(attr *Attributes) (*Satisfaction, error)

func (*Policy) String

func (p *Policy) String() string

func (*Policy) UnmarshalBinary

func (p *Policy) UnmarshalBinary(data []byte) error

type PublicParams

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

func (*PublicParams) Equal

func (p *PublicParams) Equal(p2 *PublicParams) bool

func (*PublicParams) MarshalBinary

func (p *PublicParams) MarshalBinary() ([]byte, error)

func (*PublicParams) UnmarshalBinary

func (p *PublicParams) UnmarshalBinary(data []byte) error

type Satisfaction

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

type SecretParams

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

func (*SecretParams) Equal

func (s *SecretParams) Equal(s2 *SecretParams) bool

func (*SecretParams) MarshalBinary

func (s *SecretParams) MarshalBinary() ([]byte, error)

func (*SecretParams) UnmarshalBinary

func (s *SecretParams) UnmarshalBinary(data []byte) error

type Wire

type Wire struct {
	Label    string
	RawValue string
	Value    *pairing.Scalar
	Positive bool
}

func (*Wire) Equal

func (w *Wire) Equal(w2 *Wire) bool

func (*Wire) MarshalBinary

func (w *Wire) MarshalBinary() ([]byte, error)

func (*Wire) String

func (w *Wire) String() string

func (*Wire) UnmarshalBinary

func (w *Wire) UnmarshalBinary(data []byte) error

Jump to

Keyboard shortcuts

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