Documentation ¶
Index ¶
- Variables
- func GenerateKeys(prg *amcl.RAND, L int) (SK, PK)
- func GenerateNymKeys(prg *amcl.RAND, sk SK, h interface{}) (skNym SK, pkNym PK)
- func GenerateYs(first bool, n int, prg *amcl.RAND) (ys []interface{})
- func PkEqual(first PK, second PK) bool
- func PointFromBytes(bytes []byte) (g interface{}, e error)
- func PointToBytes(g interface{}) (result []byte)
- func ProduceAttributes(L int, inputs ...string) (attributes []interface{})
- func StringToECPb(message string, first bool) interface{}
- func VerifyKeyPair(sk SK, pk PK) bool
- type AuditingEncryption
- type AuditingProof
- type CredRequest
- type Credentials
- func (creds *Credentials) Delegate(sk SK, publicKey PK, attributes []interface{}, prg *amcl.RAND, ...) (e error)
- func (creds *Credentials) Equals(other *Credentials) (result bool)
- func (creds *Credentials) Prove(prg *amcl.RAND, sk SK, pk PK, D Indices, m []byte, grothYs [][]interface{}, ...) (proof Proof, e error)
- func (creds *Credentials) ToBytes() (result []byte)
- func (creds *Credentials) Verify(sk SK, authorityPK PK, grothYs [][]interface{}) (e error)
- type Groth
- func (groth *Groth) Generate() (sk SK, pk PK)
- func (groth *Groth) Randomize(signature GrothSignature, rPrime *FP256BN.BIG) (signaturePrime GrothSignature)
- func (groth *Groth) Sign(sk SK, m []interface{}) (signature GrothSignature)
- func (groth *Groth) Verify(pk PK, signature GrothSignature, m []interface{}) (e error)
- type GrothSignature
- type Index
- type Indices
- type NymSignature
- type PK
- type Proof
- type RevocationProof
- type SK
- type Schnorr
- type SchnorrSignature
- type Siblings
- func (siblings *Siblings) Generate() (SK, PK)
- func (siblings *Siblings) RandomizeGroth(sigma GrothSignature, rPrime *FP256BN.BIG) GrothSignature
- func (siblings *Siblings) SignGroth(sk SK, m []interface{}) GrothSignature
- func (siblings *Siblings) SignSchnorr(sk SK, m []byte) SchnorrSignature
- func (siblings *Siblings) VerifyGroth(pk PK, sigma GrothSignature, m []interface{}) error
- func (siblings *Siblings) VerifySchnorr(pk PK, sigma SchnorrSignature, m []byte) error
Constants ¶
This section is empty.
Variables ¶
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 ¶
GenerateKeys generates a key pair for the authority (Level-0 issuer)
func GenerateNymKeys ¶
GenerateNymKeys generates a fresh pair of pseudonym keys Nym object is needed to commit to a secret key without revealing it
func GenerateYs ¶
GenerateYs is a helper that generates n y-values first need to correspond to Groth.first
func PointFromBytes ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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
type Groth ¶
type Groth struct {
// contains filtered or unexported fields
}
Groth holds internal values such as y-values and PRG
func MakeGroth ¶
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) 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)
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 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
type Proof ¶
type Proof struct {
// contains filtered or unexported fields
}
Proof is a NIZK proof object that can be verified
func ProofFromBytes ¶
ProofFromBytes un-marshals 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
type Schnorr ¶
type Schnorr struct {
// contains filtered or unexported fields
}
Schnorr holds internal values such as PRG
func MakeSchnorr ¶
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.
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 ¶
MakeSiblings creates a siblings signatures instance using y-values for Groth
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