Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateChecksum(typ [2]byte, genesis [27]byte) [2]byte
- func CheckChecksum(id ID) bool
- func DecomposeID(id ID) ([2]byte, [27]byte, [2]byte, error)
- func IdenState(clr *merkletree.Hash, rer *merkletree.Hash, ror *merkletree.Hash) *merkletree.Hash
- type Claim
- func (c *Claim) Clone() *Claim
- func (c *Claim) GetExpirationDate() (time.Time, bool)
- func (c *Claim) GetFlagUpdatable() bool
- func (c *Claim) GetID() (ID, error)
- func (c *Claim) GetRevocationNonce() uint64
- func (c *Claim) GetSchemaHash() SchemaHash
- func (c *Claim) GetVersion() uint32
- func (c *Claim) ResetExpirationDate()
- func (c *Claim) ResetID()
- func (c *Claim) SetExpirationDate(dt time.Time)
- func (c *Claim) SetFlagUpdatable(val bool)
- func (c *Claim) SetIndexData(slotA, slotB DataSlot) error
- func (c *Claim) SetIndexDataBytes(slotA, slotB []byte) error
- func (c *Claim) SetIndexDataInts(slotA, slotB *big.Int) error
- func (c *Claim) SetIndexID(id ID)
- func (c *Claim) SetRevocationNonce(nonce uint64)
- func (c *Claim) SetSchemaHash(schema SchemaHash)
- func (c *Claim) SetValueData(slotA, slotB DataSlot) error
- func (c *Claim) SetValueDataBytes(slotA, slotB []byte) error
- func (c *Claim) SetValueDataInts(slotA, slotB *big.Int) error
- func (c *Claim) SetValueID(id ID)
- func (c *Claim) SetVersion(ver uint32)
- func (c *Claim) TreeEntry() merkletree.Entry
- type DataSlot
- type ErrSlotOverflow
- type ID
- type IDPosition
- type Option
- func WithExpirationDate(dt time.Time) Option
- func WithFlagUpdatable(val bool) Option
- func WithID(id ID, pos IDPosition) Option
- func WithIndexData(slotA, slotB DataSlot) Option
- func WithIndexDataBytes(slotA, slotB []byte) Option
- func WithIndexDataInts(slotA, slotB *big.Int) Option
- func WithIndexID(id ID) Option
- func WithRevocationNonce(nonce uint64) Option
- func WithValueData(slotA, slotB DataSlot) Option
- func WithValueDataBytes(slotA, slotB []byte) Option
- func WithValueDataInts(slotA, slotB *big.Int) Option
- func WithValueID(id ID) Option
- func WithVersion(ver uint32) Option
- type SchemaHash
- type SlotName
- type Subject
Constants ¶
const ( SlotNameIndexA = SlotName("IndexA") SlotNameIndexB = SlotName("IndexB") SlotNameValueA = SlotName("ValueA") SlotNameValueB = SlotName("ValueB") )
Variables ¶
var ErrDataOverflow = errors.New("data does not fits SNARK size")
var ErrIncorrectIDPosition = errors.New("incorrect ID position")
var ErrNoID = errors.New("ID is not set")
var ( // TypeBJP0 specifies the BJ-P0 // - first 2 bytes: `00000000 00000000` // - curve of k_op: babyjubjub // - hash function: `Poseidon` with 4+4 elements TypeBJP0 = [2]byte{0x00, 0x00} )
Functions ¶
func CalculateChecksum ¶
CalculateChecksum, returns the checksum for a given type and genesis_root, where checksum: hash( [type | root_genesis ] )
func CheckChecksum ¶
CheckChecksum returns a bool indicating if the ID.Checksum is consistent with the rest of the ID data
func DecomposeID ¶
DecomposeID returns type, genesis and checksum from an ID
Types ¶
type Claim ¶
type Claim struct {
// contains filtered or unexported fields
}
func (*Claim) GetExpirationDate ¶
GetExpirationDate returns expiration date and flag. Flag is true if expiration date is present, false if null.
func (*Claim) GetFlagUpdatable ¶
func (*Claim) GetRevocationNonce ¶
func (*Claim) GetSchemaHash ¶
func (c *Claim) GetSchemaHash() SchemaHash
func (*Claim) GetVersion ¶
func (*Claim) ResetExpirationDate ¶
func (c *Claim) ResetExpirationDate()
func (*Claim) SetExpirationDate ¶
func (*Claim) SetFlagUpdatable ¶
func (*Claim) SetIndexData ¶
func (*Claim) SetIndexDataBytes ¶
func (*Claim) SetIndexID ¶
func (*Claim) SetRevocationNonce ¶
func (*Claim) SetSchemaHash ¶
func (c *Claim) SetSchemaHash(schema SchemaHash)
func (*Claim) SetValueData ¶
func (*Claim) SetValueDataBytes ¶
func (*Claim) SetValueID ¶
func (*Claim) SetVersion ¶
type ErrSlotOverflow ¶
type ErrSlotOverflow struct {
Field SlotName
}
func (ErrSlotOverflow) Error ¶
func (e ErrSlotOverflow) Error() string
type ID ¶
type ID [31]byte
ID is a byte array with [ type | root_genesis | checksum ] [2 bytes | 27 bytes | 2 bytes ] where the root_genesis are the first 28 bytes from the hash root_genesis
func CalculateGenesisID ¶
CalculateGenesisID calculate genesis id based on provided claims tree root
func IDFromBytes ¶
IDFromBytes returns the ID from a given byte array
func IDFromString ¶
IDFromString returns the ID from a given string
func IdGenesisFromIdenState ¶
func IdGenesisFromIdenState(hash *merkletree.Hash) *ID
IdGenesisFromIdenState calculates the genesis Id from an Identity State.
func (ID) MarshalText ¶
func (*ID) UnmarshalText ¶
type IDPosition ¶
type IDPosition uint8
const ( // IDPositionIndex means ID value is in index slots IDPositionIndex IDPosition = iota + 1 // value 0 is position undefined // IDPositionValue means ID value is in value slots IDPositionValue )
type Option ¶
func WithExpirationDate ¶
func WithFlagUpdatable ¶
func WithID ¶
func WithID(id ID, pos IDPosition) Option
func WithIndexData ¶
func WithIndexDataBytes ¶
func WithIndexDataInts ¶
func WithIndexID ¶
func WithRevocationNonce ¶
func WithValueData ¶
func WithValueDataBytes ¶
func WithValueDataInts ¶
func WithValueID ¶
func WithVersion ¶
type SchemaHash ¶
type SchemaHash [schemaHashLn]byte
func (SchemaHash) MarshalText ¶
func (sc SchemaHash) MarshalText() ([]byte, error)