dac

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Workers uint = 0

Workers specify the number of worker threads to use for parallel computations 0 will spawn as many workers as there are tasks 1 is equivalent to sequential execution 2+ workers will distribute the work among specified number of threads

Functions

func GenerateKeys

func GenerateKeys(prg *amcl.RAND, L int) (SK, PK)

GenerateKeys generates a key pair for the authority (Level-0 issuer)

func GenerateNymKeys

func GenerateNymKeys(prg *amcl.RAND, sk SK, h interface{}) (skNym SK, pkNym PK)

GenerateNymKeys generates a fresh pair of pseudonym keys Nym object is needed to commit to a secret key without revealing it

func GenerateYs

func GenerateYs(first bool, n int, prg *amcl.RAND) (ys []interface{})

GenerateYs is a helper that generates n y-values first need to correspond to Groth.first

func PkEqual

func PkEqual(first PK, second PK) bool

PkEqual checks if two public keys are equal

func PointFromBytes

func PointFromBytes(bytes []byte) (g interface{}, e error)

PointFromBytes converts a byte array to ECP or ECP2

func PointToBytes

func PointToBytes(g interface{}) (result []byte)

PointToBytes converts ECP or ECP2 to byte array

func ProduceAttributes

func ProduceAttributes(L int, inputs ...string) (attributes []interface{})

ProduceAttributes is a helper that converts a set of strings to a set of attributes. An attribute is a point on elliptic curve, L control whether ECP or ECP2. An attribute is generated as a generator to the power of hash of string.

func StringToECPb

func StringToECPb(message string, first bool) interface{}

StringToECPb converts a string to a point on the curve. It does so by hashing the string and using it as an exponent to generator.

func VerifyKeyPair

func VerifyKeyPair(sk SK, pk PK) bool

VerifyKeyPair is a helper that checks if the given secret key corresponds to the given public key

Types

type AuditingEncryption

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

AuditingEncryption is the ElGamal encryption of user's public key under auditor's public key

func AuditingEncrypt

func AuditingEncrypt(prg *amcl.RAND, audPk PK, userPk PK) (encryption AuditingEncryption, r *FP256BN.BIG)

AuditingEncrypt produces the auditing encryption. It requires auditor's public key and user's public key. It produces the encryption itself and the randomness used (thus, randomized encryption). Randomness is safe to disclose and it is used to verify the proof.

func AuditingEncryptionFromBytes

func AuditingEncryptionFromBytes(input []byte) (encryption *AuditingEncryption)

AuditingEncryptionFromBytes un-marshals the NIZK object using ASN1 encoding

func (*AuditingEncryption) AuditingDecrypt

func (encryption *AuditingEncryption) AuditingDecrypt(audSk SK) (plaintext interface{})

AuditingDecrypt decrypts the auditing encryption. Auditor uses her private key and gets user's public key.

func (*AuditingEncryption) ToBytes

func (encryption *AuditingEncryption) ToBytes() (result []byte)

ToBytes marshals the NIZK object using ASN1 encoding

type AuditingProof

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

AuditingProof is a NIZK that certifies that the auditing encryption is "honest". Honest encryption encrypts user's public key under auditor's public key.

func AuditingProofFromBytes

func AuditingProofFromBytes(input []byte) (proof *AuditingProof)

AuditingProofFromBytes un-marshals the NIZK object using ASN1 encoding

func AuditingProve

func AuditingProve(prg *amcl.RAND, encryption AuditingEncryption, pk PK, sk SK, pkNym PK, skNym SK, audPk PK, r *FP256BN.BIG, h interface{}) (proof AuditingProof)

AuditingProve generate a NIZK proof of "honest" encryption. It needs the auditing encryption, user's key pair, pseudonym pair and auditor's public key.

func (*AuditingProof) ToBytes

func (proof *AuditingProof) ToBytes() (result []byte)

ToBytes marshals the NIZK object using ASN1 encoding

func (*AuditingProof) Verify

func (proof *AuditingProof) Verify(encryption AuditingEncryption, pkNym PK, audPk PK, h interface{}) (e error)

Verify validates the auditing NIZK. Successfull validation means that the encryption is "honest".

type CredRequest

type CredRequest struct {
	Nonce []byte
	Pk    PK
	ResT  interface{}
	ResR  *FP256BN.BIG
}

CredRequest encapsulates a public key with given nonce along with a NIZK of corresponding secret key All algorithm work for both ECP and ECP2 (depending on L)

func CredRequestFromBytes

func CredRequestFromBytes(input []byte) (credReq *CredRequest)

CredRequestFromBytes un-marshals the credential request object using ASN1 encoding

func MakeCredRequest

func MakeCredRequest(prg *amcl.RAND, sk SK, nonce []byte, L int) (credReq *CredRequest)

MakeCredRequest composes a credential request including a public key with given nonce along with a NIZK of corresponding secret key L is a level of credentials for which the request is generated (should match public key type)

func (*CredRequest) ToBytes

func (credReq *CredRequest) ToBytes() (result []byte)

ToBytes marshals the credential request object using ASN1 encoding

func (*CredRequest) Validate

func (credReq *CredRequest) Validate() (e error)

Validate verifies the NIZK Note that cheking the nonce is not included (needs to be done separately)

type Credentials

type Credentials struct {
	Attributes [][]interface{}
	// contains filtered or unexported fields
}

Credentials holds all credential links. Each link includes a signature, a set of attributes and a public key

func CredentialsFromBytes

func CredentialsFromBytes(input []byte) (creds *Credentials)

CredentialsFromBytes un-marshals the credentials object using ASN1 encoding

func MakeCredentials

func MakeCredentials(pk PK) (creds *Credentials)

MakeCredentials creates empty (default) credentials (0th link) Needs authority's public key

func (*Credentials) Delegate

func (creds *Credentials) Delegate(sk SK, publicKey PK, attributes []interface{}, prg *amcl.RAND, grothYs [][]interface{}) (e error)

Delegate extends credentials by a single link. Needs secret key of the delegator, public key and attributes of the delegatee. Returns error if exception / panic occurred (perhaps due to wrong type of curve)

func (*Credentials) Equals

func (creds *Credentials) Equals(other *Credentials) (result bool)

Equals checks the equality of two credentials objects

func (*Credentials) Prove

func (creds *Credentials) Prove(prg *amcl.RAND, sk SK, pk PK, D Indices, m []byte, grothYs [][]interface{}, h interface{}, skNym SK) (proof Proof, e error)

Prove generates a NIZK proof. This function is implemented following the pseudocode on page 11, with some bug fixes. As optimization, the odd and even branches are combined. Secret key is that of the last level, public key is that of the authority (top level). Proof will also sign a message m. D is a set of disclosed attributes (with their 'coordinates' and values). D can be empty, then no attributes will be disclosed. h and skNym should be received with GenerateNymKeys.

func (*Credentials) ToBytes

func (creds *Credentials) ToBytes() (result []byte)

ToBytes marshals the credentials object using ASN1 encoding

func (*Credentials) Verify

func (creds *Credentials) Verify(sk SK, authorityPK PK, grothYs [][]interface{}) (e error)

Verify checks the validity of the credentils. Note, this has nothing to do with the NIZK proof. If verification fails, returns error describing the failed stage.

type Groth

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

Groth holds internal values such as y-values and PRG

func MakeGroth

func MakeGroth(prg *amcl.RAND, first bool, ys []interface{}) (groth *Groth)

MakeGroth creates a new Groth object. PRG is stored and used in randomized operations. first parameter defines if it is Groth-1 or Groth-2 from the original paper. ys need to be precomputed externally (should use GenerateYs method)

func (*Groth) Generate

func (groth *Groth) Generate() (sk SK, pk PK)

Generate generates a key pair

func (*Groth) Randomize

func (groth *Groth) Randomize(signature GrothSignature, rPrime *FP256BN.BIG) (signaturePrime GrothSignature)

Randomize changes the signature by randomizing each of its components. Randomized signature is valid for the original message. If rPrime is provided, it will be used for randomization, otherwise it will be generated using internal PRG.

func (*Groth) Sign

func (groth *Groth) Sign(sk SK, m []interface{}) (signature GrothSignature)

Sign signs the message given by points on the curve (ECP or ECP2)

func (*Groth) Verify

func (groth *Groth) Verify(pk PK, signature GrothSignature, m []interface{}) (e error)

Verify verifies the signature. If verification fails, the error will not be nil, and will identify the part of pipeline, which failed

type GrothSignature

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

GrothSignature encapsulates the signature object - R, S, Ts values

func GrothSignatureFromBytes

func GrothSignatureFromBytes(input []byte) (signature *GrothSignature)

GrothSignatureFromBytes marshals the Groth signature object using ASN1 encoding

func SignNonRevoke

func SignNonRevoke(prg *amcl.RAND, sk SK, userPk PK, epoch *FP256BN.BIG, ys []interface{}) (signature GrothSignature)

SignNonRevoke generates a Groth signature of user's public key along with the epoch. Needs revocation authority's private key.

func (*GrothSignature) ToBytes

func (signature *GrothSignature) ToBytes() (result []byte)

ToBytes un-marshals the Groth signature object using ASN1 encoding

type Index

type Index struct {
	I, J      int
	Attribute interface{}
}

Index holds the attribute with its position in credentials

type Indices

type Indices []Index

Indices is an abstraction over the set of Index objects

func (Indices) Len

func (indices Indices) Len() int

func (Indices) Less

func (indices Indices) Less(i, j int) bool

func (Indices) Swap

func (indices Indices) Swap(i, j int)

type NymSignature

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

NymSignature is signature / NIZK proof of knowledge of pseudonym's secret key sk and randomness skNym

func NymSignatureFromBytes

func NymSignatureFromBytes(input []byte) (signature *NymSignature)

NymSignatureFromBytes un-marshals the NIZK object using ASN1 encoding

func SignNym

func SignNym(prg *amcl.RAND, pkNym PK, skNym SK, sk SK, h interface{}, m []byte) (signature NymSignature)

SignNym generates a proof of knowledge of pseudonym's secret key sk and randomness skNym

func (*NymSignature) ToBytes

func (signature *NymSignature) ToBytes() (result []byte)

ToBytes marshals the NIZK object using ASN1 encoding

func (*NymSignature) VerifyNym

func (signature *NymSignature) VerifyNym(h interface{}, pkNym PK, m []byte) (e error)

VerifyNym verifies the proof of knowledge of pseudonym's secret key sk and randomness skNym

type PK

type PK = interface{}

PK abstraction over public key

type Proof

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

Proof is a NIZK proof object that can be verified

func ProofFromBytes

func ProofFromBytes(input []byte) (proof *Proof)

ProofFromBytes un-marshals the proof

func (*Proof) Equals

func (proof *Proof) Equals(other Proof) (result bool)

Equals checks the equality of two proofs

func (*Proof) ToBytes

func (proof *Proof) ToBytes() (result []byte)

ToBytes marshlas the proof

func (*Proof) VerifyProof

func (proof *Proof) VerifyProof(pk PK, grothYs [][]interface{}, h interface{}, pkNym PK, D Indices, m []byte) (e error)

VerifyProof verifies a NIZK proof. This function is implemented following the pseudocode on page 12, with some bug fixes. As optimization, the odd and even branches are combined. Public key is that of the authority (top level), m is the message that was signed during generation. h and pkNym should be received with GenerateNymKeys. D is a set of disclosed attributes (with their 'coordinates' and values). D has to exactly correspond to the one used in generation.

type RevocationProof

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

RevocationProof is a NIZK that a user has been approved for an epoch. More formally, NIZK of Groth signature of user's public key with the epoch.

func RevocationProofFromBytes

func RevocationProofFromBytes(input []byte) (proof *RevocationProof)

RevocationProofFromBytes un-marshals the NIZK object using ASN1 encoding

func RevocationProve

func RevocationProve(prg *amcl.RAND, signature GrothSignature, sk SK, skNym SK, epoch *FP256BN.BIG, h interface{}, ys []interface{}) (proof RevocationProof)

RevocationProve generates a NIZK of the Groth signature of user's public key along with the epoch

func (*RevocationProof) ToBytes

func (proof *RevocationProof) ToBytes() (result []byte)

ToBytes marshals the NIZK object using ASN1 encoding

func (*RevocationProof) Verify

func (proof *RevocationProof) Verify(pkNym PK, epoch *FP256BN.BIG, h interface{}, pkRev PK, ys []interface{}) (e error)

Verify validates the NIZK of the Groth signature of user's public key along with the epoch

type SK

type SK = *FP256BN.BIG

SK abstraction over secret key

type Schnorr

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

Schnorr holds internal values such as PRG

func MakeSchnorr

func MakeSchnorr(prg *amcl.RAND, first bool) (schnorr *Schnorr)

MakeSchnorr creates a new Schnorr object. PRG is stored and used in randomized operations. first parameter defines if it is Schnorr-1 or Schnorr-2 from the original paper.

func (*Schnorr) Generate

func (schnorr *Schnorr) Generate() (sk SK, pk PK)

Generate generates a key pair

func (*Schnorr) Sign

func (schnorr *Schnorr) Sign(sk *FP256BN.BIG, m []byte) (signature SchnorrSignature)

Sign signs the message given by points on the curve (ECP or ECP2)

func (*Schnorr) Verify

func (schnorr *Schnorr) Verify(pk PK, signature SchnorrSignature, m []byte) (e error)

Verify verifies the signature. Returns nil if verification is successful.

type SchnorrSignature

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

SchnorrSignature encapsulates the signature object - s and e values

func SchnorrSignatureFromBytes

func SchnorrSignatureFromBytes(input []byte) (signature *SchnorrSignature)

SchnorrSignatureFromBytes un-marshals the NIZK object using ASN1 encoding

func (*SchnorrSignature) ToBytes

func (signature *SchnorrSignature) ToBytes() (result []byte)

ToBytes marshals the NIZK object using ASN1 encoding

type Siblings

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

Siblings holds groth, schnorr objects and PRG

func MakeSiblings

func MakeSiblings(prg *amcl.RAND, first bool, grothYs []interface{}) (siblings *Siblings)

MakeSiblings creates a siblings signatures instance using y-values for Groth

func (*Siblings) Generate

func (siblings *Siblings) Generate() (SK, PK)

Generate generates a key pair

func (*Siblings) RandomizeGroth

func (siblings *Siblings) RandomizeGroth(sigma GrothSignature, rPrime *FP256BN.BIG) GrothSignature

RandomizeGroth is wrapper around Groth.Randomize

func (*Siblings) SignGroth

func (siblings *Siblings) SignGroth(sk SK, m []interface{}) GrothSignature

SignGroth is wrapper around Groth.Sign

func (*Siblings) SignSchnorr

func (siblings *Siblings) SignSchnorr(sk SK, m []byte) SchnorrSignature

SignSchnorr is wrapper around Schnorr.Sign

func (*Siblings) VerifyGroth

func (siblings *Siblings) VerifyGroth(pk PK, sigma GrothSignature, m []interface{}) error

VerifyGroth is wrapper around Groth.Verify

func (*Siblings) VerifySchnorr

func (siblings *Siblings) VerifySchnorr(pk PK, sigma SchnorrSignature, m []byte) error

VerifySchnorr is wrapper around Schnorr.Verify

Jump to

Keyboard shortcuts

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