Documentation ¶
Index ¶
- Constants
- Variables
- func AddLeafRevocationsTree(mt *merkletree.MerkleTree, nonce, version uint32) error
- func AddLeafRootsTree(mt *merkletree.MerkleTree, root *merkletree.Hash) error
- func ClaimArrayToHexArray(claims []merkletree.Entrier) []string
- func ClaimToHex(c merkletree.Entrier) string
- func ClearMostSigByte(e [merkletree.ElemBytesLen]byte) merkletree.ElemBytes
- func GetRevocationNonce(e *merkletree.Entry) uint32
- func HashString(s string) (stringHashed [EntryFullBytesLen]byte)
- func NewClaimFromEntry(e *merkletree.Entry) (merkletree.Entrier, error)
- type BabyJubKeyType
- type ClaimBasic
- type ClaimGeneric
- type ClaimHeader
- type ClaimKeyBabyJub
- type ClaimOtherIden
- type ClaimSubject
- type ClaimSubjectPos
- type ClaimType
- type Claimer
- type LeafRevocationsTree
- type LeafRootsTree
- type Metadata
Constants ¶
const ( // ClaimTypeLen is the length in bytes of the type in a claim. ClaimTypeLen = 64 / 8 ClaimFlagsLen = 32 / 8 ClaimHeaderLen = ClaimTypeLen + ClaimFlagsLen ClaimVersionLen = 32 / 8 ClaimRevNonceLen = 32 / 8 ClaimExpirationLen = 64 / 8 EntryFullBytesLen = 248 / 8 )
const ( // ClaimSubjectSelf is a claim that refers to a property of the issuing // identity. ClaimSubjectSelf ClaimSubject = 0b00 ClaimSubjectStringSelf string = "Self" // ClaimSubjectOtherIden is a claim that refers to a property of // another identity. ClaimSubjectOtherIden ClaimSubject = 0b10 ClaimSubjectStringOtherIden string = "OtherIden" // ClaimSubjectObject is a claim that refers to a property of an // object. ClaimSubjectObject ClaimSubject = 0b01 ClaimSubjectStringObject string = "Object" )
const ( // ClaimSubjectPosIndex means that the subject is found in the Index of the claim ClaimSubjectPosIndex ClaimSubjectPos = 0b0 ClaimSubjectPosStringIndex string = "Index" // ClaimSubjectPosIndex means that the subject is found in the Value of the claim ClaimSubjectPosValue ClaimSubjectPos = 0b1 ClaimSubjectPosStringValue string = "Value" )
const ( IndexSlotLen = EntryFullBytesLen - ClaimTypeLen - ClaimFlagsLen + EntryFullBytesLen*3 ValueSlotLen = EntryFullBytesLen - ClaimRevNonceLen + EntryFullBytesLen*3 )
const ClaimTypeVersionLen = ClaimTypeLen + ClaimFlagsLen + ClaimVersionLen
ClaimTypeVersionLen is the length in bytes of the version and length in a claim.
const (
IndexSubjectSlotLen = EntryFullBytesLen - ClaimTypeLen - ClaimFlagsLen + EntryFullBytesLen*2
)
Variables ¶
var ( // ClaimTypeBasic is a simple claim type that can be used for anything. ClaimTypeBasic = NewClaimTypeNum(0) ClaimTypeStringBasic = "Basic" // ClaimTypeKeyBabyJub is a claim type to autorize a babyjub public key for signing. ClaimTypeKeyBabyJub = NewClaimTypeNum(1) ClaimTypeStringKeyBabyJub = "KeyBabyJub" // ClaimTypeOtherIden is a simple claim type that can be used for // anything with a recipient subject. ClaimTypeOtherIden = NewClaimTypeNum(2) ClaimTypeStringOtherIden = "OtherIden" )
var ( ClaimHeaderBasic = ClaimHeader{ Type: ClaimTypeBasic, Subject: ClaimSubjectSelf, Expiration: false, Version: false} ClaimHeaderKeyBabyJub = ClaimHeader{ Type: ClaimTypeKeyBabyJub, Subject: ClaimSubjectSelf, Expiration: false, Version: false} ClaimHeaderOtherIden = ClaimHeader{ Type: ClaimTypeOtherIden, Subject: ClaimSubjectOtherIden, SubjectPos: ClaimSubjectPosIndex, Expiration: false, Version: false} )
var ErrInvalidClaimType = errors.New("invalid claim type")
ErrInvalidClaimType indicates a type error when parsing an Entry into a claim.
Functions ¶
func AddLeafRevocationsTree ¶
func AddLeafRevocationsTree(mt *merkletree.MerkleTree, nonce, version uint32) error
AddLeafRevocationsTree adds a new leaf to the given MerkleTree, which contains the Nonce & Version
func AddLeafRootsTree ¶
func AddLeafRootsTree(mt *merkletree.MerkleTree, root *merkletree.Hash) error
AddLeafRootsTree adds a new leaf to the given MerkleTree, which contains the Root
func ClaimArrayToHexArray ¶
func ClaimArrayToHexArray(claims []merkletree.Entrier) []string
func ClaimToHex ¶
func ClaimToHex(c merkletree.Entrier) string
func ClearMostSigByte ¶
func ClearMostSigByte(e [merkletree.ElemBytesLen]byte) merkletree.ElemBytes
ClearMostSigByte sets the most significant byte of the element to 0 to make sure it fits inside the FiniteField over R.
func GetRevocationNonce ¶
func GetRevocationNonce(e *merkletree.Entry) uint32
func HashString ¶
func HashString(s string) (stringHashed [EntryFullBytesLen]byte)
HashString takes the first 31 bytes of a hash applied to string
func NewClaimFromEntry ¶
func NewClaimFromEntry(e *merkletree.Entry) (merkletree.Entrier, error)
NewClaimFromEntry deserializes a valid claim type into a Claim.
Types ¶
type BabyJubKeyType ¶ added in v0.0.8
type BabyJubKeyType uint64
const ( BabyJubKeyTypeGeneric BabyJubKeyType = 0 BabyJubKeyTypeAuthorizeKSign BabyJubKeyType = 1 )
type ClaimBasic ¶
type ClaimBasic struct { // IndexSlot is data that goes into the remaining space used for the index. IndexSlot [IndexSlotLen]byte // ValueSlot is the data that goes into the remaining space not used for the index. ValueSlot [ValueSlotLen]byte // contains filtered or unexported fields }
ClaimBasic is a simple claim that can be used for anything.
func NewClaimBasic ¶
func NewClaimBasic(indexSlot [IndexSlotLen]byte, valueSlot [ValueSlotLen]byte) *ClaimBasic
NewClaimBasic returns a ClaimBasic with the provided data.
func NewClaimBasicFromEntry ¶
func NewClaimBasicFromEntry(e *merkletree.Entry) *ClaimBasic
NewClaimBasicFromEntry deserializes a ClaimBasic from an Entry.
func (*ClaimBasic) Entry ¶
func (c *ClaimBasic) Entry() *merkletree.Entry
Entry serializes the claim into an Entry.
func (*ClaimBasic) Metadata ¶
func (c *ClaimBasic) Metadata() *Metadata
type ClaimGeneric ¶
type ClaimGeneric struct {
// contains filtered or unexported fields
}
func HexArrayToClaimGenericArray ¶
func HexArrayToClaimGenericArray(arrH []string) ([]ClaimGeneric, error)
func HexToClaimGeneric ¶
func HexToClaimGeneric(h string) (ClaimGeneric, error)
func NewClaimGeneric ¶
func NewClaimGeneric(entry *merkletree.Entry) *ClaimGeneric
func (*ClaimGeneric) Entry ¶
func (c *ClaimGeneric) Entry() *merkletree.Entry
func (*ClaimGeneric) Metadata ¶
func (c *ClaimGeneric) Metadata() *Metadata
type ClaimHeader ¶
type ClaimHeader struct { Type ClaimType Subject ClaimSubject SubjectPos ClaimSubjectPos Expiration bool Version bool }
ClaimHeader represents the first bytes of the claim index and contains its type and flags.
func (ClaimHeader) Marshal ¶
func (c ClaimHeader) Marshal(e *merkletree.Entry)
Marshal the ClaimHeader into an entry
func (*ClaimHeader) Unmarshal ¶
func (c *ClaimHeader) Unmarshal(e *merkletree.Entry)
Unmarshal the ClaimHeader from an entry
type ClaimKeyBabyJub ¶ added in v0.0.8
type ClaimKeyBabyJub struct { // KeyType is used to specify if the type of usage given to the Key // if 0 is the generic one // if 1 is to AuthorizeKSign Key KeyType BabyJubKeyType // Ax is the x coordinate of the BabyJubJub curve point which // corresponds to the public key. Ax *big.Int // Ay is the y coordinate of the BabyJubJub curve point which // corresponds to the public key. Ay *big.Int // contains filtered or unexported fields }
ClaimKeyBabyJub is a claim to authorize a baby jub public key for signing.
func NewClaimKeyBabyJub ¶ added in v0.0.8
func NewClaimKeyBabyJub(pk *babyjub.PublicKey, subType BabyJubKeyType) *ClaimKeyBabyJub
NewClaimKeyBabyJub returns a ClaimKeyBabyJub with the given elliptic public key parameters.
func NewClaimKeyBabyJubFromEntry ¶ added in v0.0.8
func NewClaimKeyBabyJubFromEntry(e *merkletree.Entry) *ClaimKeyBabyJub
NewClaimKeyBabyJubFromEntry deserializes a ClaimKeyBabyJubFrom from an Entry.
func (*ClaimKeyBabyJub) Entry ¶ added in v0.0.8
func (c *ClaimKeyBabyJub) Entry() *merkletree.Entry
Entry serializes the claim into an Entry.
func (*ClaimKeyBabyJub) Metadata ¶ added in v0.0.8
func (c *ClaimKeyBabyJub) Metadata() *Metadata
type ClaimOtherIden ¶ added in v0.0.8
type ClaimOtherIden struct { // IndexSlot is data that goes into the remaining space used for the index. IndexSlot [IndexSubjectSlotLen]byte // ValueSlot is the data that goes into the remaining space not used for the index. ValueSlot [ValueSlotLen]byte // contains filtered or unexported fields }
ClaimOtherIden is a simple claim that can be used for anything.
func NewClaimOtherIden ¶ added in v0.0.8
func NewClaimOtherIden(subject *core.ID, indexSlot [IndexSubjectSlotLen]byte, valueSlot [ValueSlotLen]byte) *ClaimOtherIden
NewClaimOtherIden returns a ClaimOtherIden with the provided data.
func NewClaimOtherIdenFromEntry ¶ added in v0.0.8
func NewClaimOtherIdenFromEntry(e *merkletree.Entry) *ClaimOtherIden
NewClaimOtherIdenFromEntry deserializes a ClaimOtherIden from an Entry.
func (*ClaimOtherIden) Entry ¶ added in v0.0.8
func (c *ClaimOtherIden) Entry() *merkletree.Entry
Entry serializes the claim into an Entry.
func (*ClaimOtherIden) Metadata ¶ added in v0.0.8
func (c *ClaimOtherIden) Metadata() *Metadata
type ClaimSubject ¶ added in v0.0.8
type ClaimSubject byte
ClaimSubject is the flag option to specify a recipient of a claim
func (ClaimSubject) MarshalText ¶ added in v0.0.8
func (cs ClaimSubject) MarshalText() ([]byte, error)
func (*ClaimSubject) UnmarshalText ¶ added in v0.0.8
func (cs *ClaimSubject) UnmarshalText(b []byte) error
type ClaimSubjectPos ¶ added in v0.0.8
type ClaimSubjectPos byte
ClaimSubjectPos is the flag option to specify the position of the subject in the claim
func (ClaimSubjectPos) MarshalText ¶ added in v0.0.8
func (csp ClaimSubjectPos) MarshalText() ([]byte, error)
func (*ClaimSubjectPos) UnmarshalText ¶ added in v0.0.8
func (csp *ClaimSubjectPos) UnmarshalText(b []byte) error
type ClaimType ¶
type ClaimType [ClaimTypeLen]byte
ClaimType is the type used to store a claim type.
func NewClaimType ¶
NewClaimType creates a ClaimType from a type name.
func NewClaimTypeNum ¶
NewClaimTypeNum to set type to a claim.
func (ClaimType) MarshalText ¶
func (*ClaimType) UnmarshalText ¶
type Claimer ¶
type Claimer interface { merkletree.Entrier Metadata() *Metadata }
Claimer is an intefrace that extends Entrier with a function that returns the claim metadata.
type LeafRevocationsTree ¶
LeafRevocationsTree contains the root to be inserted in the leaf
func NewLeafRevocationsTree ¶
func NewLeafRevocationsTree(nonce, version uint32) *LeafRevocationsTree
NewLeafRevocationsTree returns a LeafRevocationsTree with the provided root.
func NewLeafRevocationsTreeFromEntry ¶
func NewLeafRevocationsTreeFromEntry(e *merkletree.Entry) *LeafRevocationsTree
NewLeafRevocationsTreeFromEntry deserializes a LeafRevocationsTree from an Entry.
func (*LeafRevocationsTree) Entry ¶
func (l *LeafRevocationsTree) Entry() *merkletree.Entry
Entry serializes the leaf into an Entry.
type LeafRootsTree ¶
type LeafRootsTree struct {
Root merkletree.Hash
}
LeafRootsTree contains the root to be inserted in the leaf
func NewLeafRootsTree ¶
func NewLeafRootsTree(root merkletree.Hash) *LeafRootsTree
NewLeafRootsTree returns a LeafRootsTree with the provided root.
func NewLeafRootsTreeFromEntry ¶
func NewLeafRootsTreeFromEntry(e *merkletree.Entry) *LeafRootsTree
NewLeafRootsTreeFromEntry deserializes a LeafRootsTree from an Entry.
func (*LeafRootsTree) Entry ¶
func (l *LeafRootsTree) Entry() *merkletree.Entry
Entry serializes the leaf into an Entry.
type Metadata ¶
type Metadata struct { Subject *core.ID Expiration int64 Version uint32 RevNonce uint32 // contains filtered or unexported fields }
Metadata is a header and generic (some optional) values of a claim.
func NewMetadata ¶
func NewMetadata(header ClaimHeader) Metadata
NewMetadata creates a new Metadata with a specific header.
func (*Metadata) Header ¶
func (m *Metadata) Header() ClaimHeader
Header returns the header from the metadata.
func (Metadata) Marshal ¶
func (m Metadata) Marshal(e *merkletree.Entry)
Marshal the Metadata into an entry
func (Metadata) MarshalJSON ¶
func (*Metadata) Unmarshal ¶
func (m *Metadata) Unmarshal(e *merkletree.Entry)
Unmarshal the Metadata from an entry