Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateChecksum(typ [2]byte, genesis [27]byte) [2]byte
- func CalculateIdGenesis(kop *babyjub.PublicKey, kdis, kreen, kupdateRoot common.Address) (*ID, *GenesisProofClaims, error)
- func CheckChecksum(id ID) bool
- func ClearMostSigByte(e [256 / 8]byte) merkletree.ElemBytes
- func DecomposeID(id ID) ([2]byte, [27]byte, [2]byte, error)
- func GetNextVersionEntry(entry *merkletree.Entry) *merkletree.Entry
- func GetNonRevocationMTProof(mt *merkletree.MerkleTree, leafData *merkletree.Data, hi *merkletree.Hash) (*merkletree.Proof, error)
- func GetPreviousVersionEntry(entry *merkletree.Entry) (*merkletree.Entry, error)
- func HashString(s string) (stringHashed [248 / 8]byte)
- func NewClaimFromEntry(e *merkletree.Entry) (merkletree.Entrier, error)
- func SetClaimTypeVersionInData(d *merkletree.Data, claimType ClaimType, version uint32)
- func VerifyPredicateProof(p *PredicateProof) bool
- func VerifyProofClaim(operationalPk *babyjub.PublicKey, pc *ProofClaim) (bool, error)
- type ClaimAssignName
- type ClaimAuthEthKey
- type ClaimAuthorizeKSignBabyJub
- type ClaimAuthorizeKSignSecp256k1
- type ClaimAuthorizeService
- type ClaimBasic
- type ClaimEthId
- type ClaimLinkObjectIdentity
- type ClaimSetRootKey
- type ClaimType
- type EthKeyType
- type GenesisProofClaims
- type HashType
- type ID
- type NonceDb
- func (ndb *NonceDb) Add(nonce string, delta int64, aux interface{}) *NonceObj
- func (ndb *NonceDb) AddAux(nonce string, aux interface{}) bool
- func (ndb *NonceDb) DeleteOld()
- func (ndb *NonceDb) DeleteOldOportunistic()
- func (ndb *NonceDb) New(delta int64, aux interface{}) *NonceObj
- func (ndb *NonceDb) Search(nonce string) (*NonceObj, bool)
- func (ndb *NonceDb) SearchAndDelete(nonce string) (*NonceObj, bool)
- type NonceObj
- type ObjectType
- type PredicateProof
- type ProofClaim
- type ProofClaimPartial
- type ServiceType
- type SetRootAux
Constants ¶
const ClaimTypeLen = 64 / 8
ClaimTypeLen is the length in bytes of the type in a claim.
const ClaimTypeVersionLen = ClaimTypeLen + ClaimVersionLen
ClaimTypeVersionLen is the length in bytes of the version and length in a claim.
const ClaimVersionLen = 32 / 8
ClaimVersionLen is the length in bytes of the version in a claim.
const EthKeyTypeLen = 32 / 8
EthKeyTypeLen is the length in bytes of the type in a claim
const ServiceTypeLen = 64 / 8
ServiceTypeLen is the length in bytes of the type of the Services
Variables ¶
var ( // ClaimTypeBasic is a simple claim type that can be used for anything. ClaimTypeBasic = NewClaimTypeNum(0) // ClaimTypeAuthorizeKSignBabyJub is a claim type to autorize a babyjub public key for signing. ClaimTypeAuthorizeKSignBabyJub = NewClaimTypeNum(1) // ClaimTypeSetRootKey is a claim type of the root key of a merkle tree that goes into the relay. ClaimTypeSetRootKey = NewClaimTypeNum(2) // ClaimTypeAssignName is a claim type to assign a name to an ID ClaimTypeAssignName = NewClaimTypeNum(3) // ClaimTypeAuthorizeKSignSecp256k1 is a claim type to autorize a secp256k1 public key for signing. ClaimTypeAuthorizeKSignSecp256k1 = NewClaimTypeNum(4) // ClaimTypeLinkObjectIdentity is a claim type to link an object (represented by a hash) to an identity. ClaimTypeLinkObjectIdentity = NewClaimTypeNum(5) // ClaimTypeAuthorizeService is a claim type to authorize a Service for the identity that performs the claim ClaimTypeAuthorizeService = NewClaimTypeNum(6) // ClaimTypeNonce is a claim used to increment the tree nonce to modify the root hash ClaimTypeNonce = NewClaimTypeNum(7) // ClaimTypeEthId is a claim type to autorize an Eth Address to be used as Id inside Ethereum ClaimTypeEthId = NewClaimTypeNum(8) // ClaimTypeAuthEthKey is a claim type to authorize an Eth Address directly from a private key, allowing to specify if is used as KDisable (revoke), KReenable (recover), etc ClaimTypeAuthEthKey = NewClaimTypeNum(9) )
var ( // EthKeyTypeDisable specifies a Ethereum Key (Addr) that is allowed to Disable the ID EthKeyTypeDisable = NewEthKeyType(0) // EthKeyTypeReenable specifies a Ethereum Key (Addr) that is allowed to Reenable the ID EthKeyTypeReenable = NewEthKeyType(1) // EthKeyTypeUpgrade specifies a Ethereum Key (Addr) that is allowed to Upgrade the ID EthKeyTypeUpgrade = NewEthKeyType(2) // EthKeyTypeUpdateRoot specifies a Ethereum Key (Addr) that is allowed to Update the Root in roots smart contract in name of the ID EthKeyTypeUpdateRoot = NewEthKeyType(3) )
var ( // ServiceTypeRelay is the type for authorize Relays ServiceTypeRelay = NewServiceType(0) // ServiceTypeNotificationsServer is the type for authorize Notification Server ServiceTypeNotificationsServer = NewServiceType(1) // ServiceTypeDiscoveryNode is the type for authorize DiscoveryNode ServiceTypeDiscoveryNode = NewServiceType(2) )
ServiceType
var ( // TypeBJM7 specifies the BJ-M7 // - first 2 bytes: `00000000 00000000` // - curve of k_op: babyjub // - hash function: `MIMC7` TypeBJM7 = [2]byte{0x00, 0x00} // TypeS2M7 specifies the S2-M7 // - first 2 bytes: `00000000 00000100` // - curve of k_op: secp256k1 // - hash function: `MIMC7` TypeS2M7 = [2]byte{0x00, 0x04} )
var ErrInvalidClaimType = errors.New("invalid claim type")
ErrInvalidClaimType indicates a type error when parsing an Entry into a claim.
var (
ErrRevokedClaim = errors.New("the claim is revoked: the next version exists")
)
Functions ¶
func CalculateChecksum ¶ added in v0.0.4
CalculateChecksum, returns the checksum for a given type and genesis_root, where checksum: hash( [type | root_genesis ] )
func CalculateIdGenesis ¶ added in v0.0.4
func CalculateIdGenesis(kop *babyjub.PublicKey, kdis, kreen, kupdateRoot common.Address) (*ID, *GenesisProofClaims, error)
CalculateIdGenesis calculates the ID given the input parameters. Adds the given parameters into an ephemeral MerkleTree to calculate the MerkleRoot. ID: base58 ( [ type | root_genesis | checksum ] ) where checksum: hash( [type | root_genesis ] ) where the hash function is MIMC7
func CheckChecksum ¶ added in v0.0.4
CheckChecksum returns a bool indicating if the ID.Checksum is consistent with the rest of the ID data
func ClearMostSigByte ¶ added in v0.0.6
func ClearMostSigByte(e [256 / 8]byte) merkletree.ElemBytes
ClearMostSigByte sets the most significant byte of the element to 0 to make sure it fits inside a merkletree.RElement.
func DecomposeID ¶ added in v0.0.4
DecomposeID returns type, genesis and checksum from an ID
func GetNextVersionEntry ¶ added in v0.0.5
func GetNextVersionEntry(entry *merkletree.Entry) *merkletree.Entry
func GetNonRevocationMTProof ¶ added in v0.0.3
func GetNonRevocationMTProof(mt *merkletree.MerkleTree, leafData *merkletree.Data, hi *merkletree.Hash) (*merkletree.Proof, error)
GetNonRevocationMTProof is a helper function to return a proof of non existence of the following version of a given claim (leafData). If the following version exists, an error is returned.
func GetPreviousVersionEntry ¶ added in v0.0.5
func GetPreviousVersionEntry(entry *merkletree.Entry) (*merkletree.Entry, error)
func HashString ¶ added in v0.0.3
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.
func SetClaimTypeVersionInData ¶
func SetClaimTypeVersionInData(d *merkletree.Data, claimType ClaimType, version uint32)
SetClaimTypeVersionInData is a helper function to set the type and version of a claim.
func VerifyPredicateProof ¶ added in v0.0.5
func VerifyPredicateProof(p *PredicateProof) bool
VerifyPredicateProof, ϕ_min checks that: - 0: tree is updated incrementally
- claim position was empty in oldRoot
- 1: claim is added correctly
- claim position contains the claim in currentRoot
- 2: claim is not revocated
- claim (version+1) is empty in currentRoot
in case that the claim version != 0: - 3: claim is at the expected version
- claim (version-1) exist in oldRoot
- 4: current version is incremental from the last one
- siblings of check_0 are inside of check_1
*TODO The input format will depend on the zkSnark inputs format (not specified yet)
func VerifyProofClaim ¶ added in v0.0.3
func VerifyProofClaim(operationalPk *babyjub.PublicKey, pc *ProofClaim) (bool, error)
CheckProofClaim checks the claim proofs from the bottom to the top are valid and not revoked, and that the top root is signed by relayAddr. WARNING TODO currently the Root signature verification is disabled, see comment in line 82
Types ¶
type ClaimAssignName ¶
type ClaimAssignName struct { // Version is the claim version. Version uint32 // NameHash is the hash of the name. NameHash [248 / 8]byte // Id is the assigned ID Id ID }
ClaimAssignName is a claim to assign a name to an id.
func NewClaimAssignName ¶
func NewClaimAssignName(name string, id ID) *ClaimAssignName
NewClaimAssignName returns a ClaimAssignName with the name and Id.
func NewClaimAssignNameFromEntry ¶
func NewClaimAssignNameFromEntry(e *merkletree.Entry) *ClaimAssignName
NewClaimAssignNameFromEntry deserializes a ClaimAssignName from an Entry.
func (*ClaimAssignName) Entry ¶
func (c *ClaimAssignName) Entry() *merkletree.Entry
Entry serializes the claim into an Entry.
func (*ClaimAssignName) Type ¶
func (c *ClaimAssignName) Type() ClaimType
Type returns the ClaimType of the claim.
type ClaimAuthEthKey ¶ added in v0.0.6
type ClaimAuthEthKey struct { // Version is the claim version Version uint32 // EthKey is the ethereum address of the Key that is being authorized EthKey common.Address // EthKeyType specifies the type of the EthKey, for which use is authorized EthKeyType uint32 }
ClaimAuthEthKey is a claim type to authorize an Eth Address directly from a private key, allowing to specify if is used as KDisable (revoke), KReenable (recover), etc
func NewClaimAuthEthKey ¶ added in v0.0.6
func NewClaimAuthEthKey(ethKey common.Address, typ EthKeyType) *ClaimAuthEthKey
NewClaimAuthEthKey returns a ClaimAuthEthKey
func NewClaimAuthEthKeyFromEntry ¶ added in v0.0.6
func NewClaimAuthEthKeyFromEntry(e *merkletree.Entry) *ClaimAuthEthKey
NewClaimAuthEthKey deserializes a ClaimAuthEthKey from an Entry
func (*ClaimAuthEthKey) Entry ¶ added in v0.0.6
func (c *ClaimAuthEthKey) Entry() *merkletree.Entry
Entry serializes the claim into an Entry
func (*ClaimAuthEthKey) Type ¶ added in v0.0.6
func (c *ClaimAuthEthKey) Type() ClaimType
Type returns the ClaimType of the claim
type ClaimAuthorizeKSignBabyJub ¶ added in v0.0.5
type ClaimAuthorizeKSignBabyJub struct { // Version is the claim version. Version uint32 // Sign means positive if false, negative if true. Sign bool // Ay is the y coordinate of the baby jub curve point which corresponds // to the public key. Ay *big.Int }
ClaimAuthorizeKSignBabyJub is a claim to authorize a baby jub public key for signing.
func NewClaimAuthorizeKSignBabyJub ¶ added in v0.0.5
func NewClaimAuthorizeKSignBabyJub(pk *babyjub.PublicKey) *ClaimAuthorizeKSignBabyJub
NewClaimAuthorizeKSignBabyJub returns a ClaimAuthorizeKSignBabyJub with the given elliptic public key parameters.
func NewClaimAuthorizeKSignBabyJubFromEntry ¶ added in v0.0.5
func NewClaimAuthorizeKSignBabyJubFromEntry(e *merkletree.Entry) *ClaimAuthorizeKSignBabyJub
NewClaimAuthorizeKSignBabyJubFromEntry deserializes a ClaimAuthorizeKSignBabyJubFrom from an Entry.
func (*ClaimAuthorizeKSignBabyJub) Entry ¶ added in v0.0.5
func (c *ClaimAuthorizeKSignBabyJub) Entry() *merkletree.Entry
Entry serializes the claim into an Entry.
func (*ClaimAuthorizeKSignBabyJub) Type ¶ added in v0.0.5
func (c *ClaimAuthorizeKSignBabyJub) Type() ClaimType
Type returns the ClaimType of the claim.
type ClaimAuthorizeKSignSecp256k1 ¶
type ClaimAuthorizeKSignSecp256k1 struct { // Version is the claim version. Version uint32 // PubKey is the ECDSA public key. PubKey *ecdsa.PublicKey }
ClaimAuthorizeKSignSecp256k1 is a claim to autorize a public key for signing.
func NewClaimAuthorizeKSignSecp256k1 ¶
func NewClaimAuthorizeKSignSecp256k1(pk *ecdsa.PublicKey) *ClaimAuthorizeKSignSecp256k1
NewClaimAuthorizeKSignSecp256k1 returns a ClaimAuthorizeKSignSecp256k1 with the given elliptic public key parameters.
func NewClaimAuthorizeKSignSecp256k1FromEntry ¶
func NewClaimAuthorizeKSignSecp256k1FromEntry(e *merkletree.Entry) (*ClaimAuthorizeKSignSecp256k1, error)
NewClaimAuthorizeKSignSecp256k1FromEntry deserializes a ClaimAuthorizeKSignSecp256k1 from an Entry.
func (*ClaimAuthorizeKSignSecp256k1) Entry ¶
func (c *ClaimAuthorizeKSignSecp256k1) Entry() *merkletree.Entry
Entry serializes the claim into an Entry.
func (*ClaimAuthorizeKSignSecp256k1) Type ¶
func (c *ClaimAuthorizeKSignSecp256k1) Type() ClaimType
Type returns the ClaimType of the claim.
type ClaimAuthorizeService ¶ added in v0.0.3
type ClaimAuthorizeService struct { // Version is the claim version. Version uint32 // ServiceType is the type of the authorized service ServiceType *ServiceType // ServiceAddr is the hash of the addr ServiceAddr [248 / 8]byte // ServicePubK is the hash of the pubK ServicePubK [248 / 8]byte // ServiceUrl is the hash of the domain ServiceUrl [248 / 8]byte }
ClaimAuthorizeService is a claim to authorize a Service for the identity that performs the claim
func NewClaimAuthorizeService ¶ added in v0.0.3
func NewClaimAuthorizeService(serviceType *ServiceType, serviceAddr, servicePubK, serviceUrl string) *ClaimAuthorizeService
NewClaimAuthorizeService returns a ClaimAuthorizeService with the provided data.
func NewClaimAuthorizeServiceFromEntry ¶ added in v0.0.3
func NewClaimAuthorizeServiceFromEntry(e *merkletree.Entry) *ClaimAuthorizeService
NewClaimAuthorizeServiceFromEntry deserializes a ClaimAuthorizeService from an Entry.
func (*ClaimAuthorizeService) Entry ¶ added in v0.0.3
func (c *ClaimAuthorizeService) Entry() *merkletree.Entry
Entry serializes the claim into an Entry.
func (*ClaimAuthorizeService) Type ¶ added in v0.0.3
func (c *ClaimAuthorizeService) Type() ClaimType
Type returns the ClaimType of the claim.
type ClaimBasic ¶
type ClaimBasic struct { // Version is the claim version. Version uint32 // IndexSlot is data that goes into the remaining space used for the index. IndexSlot [400 / 8]byte // DataSlot is the data that goes into the remaining space not used for the index. DataSlot [496 / 8]byte }
ClaimBasic is a simple claim that can be used for anything.
func NewClaimBasic ¶
func NewClaimBasic(indexSlot [400 / 8]byte, dataSlot [496 / 8]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) Type ¶
func (c *ClaimBasic) Type() ClaimType
Type returns the ClaimType of the claim.
type ClaimEthId ¶ added in v0.0.3
type ClaimEthId struct { // Version is the claim version Version uint32 // Addr is the EthId that will use this identity in the ethereum blockchain Address common.Address // IdentityFactory specifies that the ClaimEthId.Address is an smartcontract, and how this identity is created. It can be just an identitied of the method, or an smartcontract that creates the identity. // IDEN3 specifies the contract address 0x9827348723984729834234 as the factory for its contrafactual identities // If 0x000.0000, means that is not using an identity creator, and the identity is always available. IdentityFactory common.Address }
ClaimEthId is a claim to authorize an ethereum address for the identity. The address can be of a counterfactual smart contract, or a direct address from a private key
func NewClaimEthId ¶ added in v0.0.3
func NewClaimEthId(addr, identityFactory common.Address) *ClaimEthId
NewClaimEthId returns a ClaimEthId
func NewClaimEthIdFromEntry ¶ added in v0.0.3
func NewClaimEthIdFromEntry(e *merkletree.Entry) *ClaimEthId
NewClaimEthId deserializes a ClaimEthId from an Entry.
func (*ClaimEthId) Entry ¶ added in v0.0.3
func (c *ClaimEthId) Entry() *merkletree.Entry
Entry serializes the claim into an Entry.
func (*ClaimEthId) Type ¶ added in v0.0.3
func (c *ClaimEthId) Type() ClaimType
Type returns the ClaimType of the claim.
type ClaimLinkObjectIdentity ¶ added in v0.0.3
type ClaimLinkObjectIdentity struct { // Version is the claim version. Version uint32 // ObjectType is the representation of the objectHash. ObjectType ObjectType // ObjectIndex is the index of this object which the identity has. ObjectIndex uint16 // Id is the ID. Id ID // ObjectHash is the hash of the object. ObjectHash [256 / 8]byte // Auxiliary data to complement claim information. AuxData [256 / 8]byte }
ClaimLinkObjectIdentity aims to link a hash of an object to an identity.
func NewClaimLinkObjectIdentity ¶ added in v0.0.3
func NewClaimLinkObjectIdentity(objectType ObjectType, objectIndex uint16, id ID, objectHash [256 / 8]byte, auxData [256 / 8]byte) (*ClaimLinkObjectIdentity, error)
NewClaimLinkObjectIdentity returns a ClaimLinkObjectIdentity.
func NewClaimLinkObjectIdentityFromEntry ¶ added in v0.0.3
func NewClaimLinkObjectIdentityFromEntry(entry *merkletree.Entry) *ClaimLinkObjectIdentity
NewClaimLinkObjectIdentityFromEntry deserializes a ClaimLinkObjectIdentity from an Entry.
func (*ClaimLinkObjectIdentity) Entry ¶ added in v0.0.3
func (claim *ClaimLinkObjectIdentity) Entry() *merkletree.Entry
Entry serializes the claim into an Entry.
func (*ClaimLinkObjectIdentity) Type ¶ added in v0.0.3
func (c *ClaimLinkObjectIdentity) Type() ClaimType
Type returns the ClaimType of the claim.
type ClaimSetRootKey ¶
type ClaimSetRootKey struct { // Version is the claim version. Version uint32 // Era is used for labeling epochs. Era uint32 // Id is the ID related to the root key. Id ID // RootKey is the root of the mekrlee tree. RootKey merkletree.Hash }
ClaimSetRootKey is a claim of the root key of a merkle tree that goes into the relay.
func NewClaimSetRootKey ¶
func NewClaimSetRootKey(id ID, rootKey merkletree.Hash) (*ClaimSetRootKey, error)
NewClaimSetRootKey returns a ClaimSetRootKey with the given Eth ID and merklee tree root key.
func NewClaimSetRootKeyFromEntry ¶
func NewClaimSetRootKeyFromEntry(e *merkletree.Entry) *ClaimSetRootKey
NewClaimSetRootKeyFromEntry deserializes a ClaimSetRootKey from an Entry.
func (*ClaimSetRootKey) Entry ¶
func (c *ClaimSetRootKey) Entry() *merkletree.Entry
Entry serializes the claim into an Entry.
func (*ClaimSetRootKey) Type ¶
func (c *ClaimSetRootKey) Type() ClaimType
Type returns the ClaimType of the claim.
type ClaimType ¶
type ClaimType [ClaimTypeLen]byte
ClaimType is the type used to store a claim type.
func GetClaimTypeVersionFromData ¶
func GetClaimTypeVersionFromData(d *merkletree.Data) (c ClaimType, v uint32)
GetClaimTypeVersionFromData gets claims fields data and version from a given claim.
func NewClaimType ¶
NewClaimType creates a ClaimType from a type name.
func NewClaimTypeNum ¶
NewClaimTypeNum to set type to a claim.
type EthKeyType ¶ added in v0.0.6
type EthKeyType [EthKeyTypeLen]byte
ClaimType is the type used to store a claim type
func NewEthKeyType ¶ added in v0.0.6
func NewEthKeyType(num uint32) EthKeyType
NewClaimTypeNum to set type to a claim.
type GenesisProofClaims ¶ added in v0.0.6
type GenesisProofClaims struct { KOp ProofClaim KDis ProofClaim KReen ProofClaim KUpdateRoot ProofClaim }
type HashType ¶ added in v0.0.3
type HashType uint32
HashType defines the type of hash used in objectHash.
type ID ¶ added in v0.0.4
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 IDFromBytes ¶ added in v0.0.4
IDFromBytes returns the ID from a given byte array
func IDFromString ¶ added in v0.0.4
IDFromString returns the ID from a given string
func (ID) MarshalText ¶ added in v0.0.4
func (*ID) UnmarshalText ¶ added in v0.0.4
type NonceDb ¶ added in v0.0.3
type NonceDb struct {
// contains filtered or unexported fields
}
NonceDb is a collection of nonces with expiration dates.
func (*NonceDb) Add ¶ added in v0.0.3
Add adds a nonce with aux data that expires after delta seconds
func (*NonceDb) AddAux ¶ added in v0.0.3
AddAux adds aux data to a nonceObj only if it doesn't have an Aux already. Returns true on success.
func (*NonceDb) DeleteOld ¶ added in v0.0.3
func (ndb *NonceDb) DeleteOld()
DeleteOld deletes all the expired nonces.
func (*NonceDb) DeleteOldOportunistic ¶ added in v0.0.3
func (ndb *NonceDb) DeleteOldOportunistic()
DeleteOldOportunistic deletes expired nonces once every N calls (where N is 128 for now).
func (*NonceDb) New ¶ added in v0.0.3
New adds a new nonce to the db that expires after delta seconds, and returns the added NonceObj
type NonceObj ¶ added in v0.0.3
NonceObj represents a nonce with an expiration date and auxiliary data
type ObjectType ¶ added in v0.0.3
type ObjectType uint32
ObjectType defines the type of object that objectHash is representing.
const ( // ObjectTypePassport indicates that hash represents a passport. ObjectTypePassport ObjectType = 0 // ObjectTypeAddress indicates that hash represents an address. ObjectTypeAddress ObjectType = 1 // ObjectTypePhone indicates that hash represents a phone number. ObjectTypePhone ObjectType = 2 // ObjectTypeDob indicates that hash represents date of birth. ObjectTypeDob ObjectType = 3 // ObjectTypeGivenName indicates that hash represents a given name. ObjectTypeGivenName ObjectType = 4 // ObjectTypeFamilyName indicates that hash represents a family name. ObjectTypeFamilyName ObjectType = 5 // ObjectTypeCertificate indicates that hash represents a certificate. ObjectTypeCertificate ObjectType = 6 // ObjectTypeStorage indicates that hash represents a stored file. ObjectTypeStorage ObjectType = 7 )
type PredicateProof ¶ added in v0.0.5
type PredicateProof struct { LeafEntry *merkletree.Entry MtpNonExistInOldRoot *merkletree.Proof MtpExist *merkletree.Proof MtpNonExistNextVersion *merkletree.Proof MtpExistPreviousVersion *merkletree.Proof OldRoot *merkletree.Hash Root *merkletree.Hash }
func GetPredicateProof ¶ added in v0.0.5
func GetPredicateProof(mt *merkletree.MerkleTree, oldRoot, hi *merkletree.Hash) (*PredicateProof, error)
GetPredicateProof, ϕ_min checks that: - 0: tree is updated incrementally
- claim position was empty in oldRoot
- 1: claim is added correctly
- claim position contains the claim in currentRoot
- 2: claim is not revocated
- claim (version+1) is empty in currentRoot
in case that the claim version != 0: - 3: claim is at the expected version
- claim (version-1) exist in oldRoot
- 4: current version is incremental from the last one
- siblings of check_0 are inside siblings of check_1
*TODO The output format will depend on the zkSnark inputs format (not specified yet)
type ProofClaim ¶ added in v0.0.3
type ProofClaim struct { Proofs []ProofClaimPartial `json:"proofs" binding:"required"` Leaf *merkletree.Data `json:"leaf" binding:"required"` Date int64 `json:"date" binding:"required"` Signature *babyjub.SignatureComp `json:"signature" binding:"required"` // signature of the Root of the Relay Signer ID `json:"signer" binding:"required"` }
ProofClaim is a complete proof of a claim that includes all the proofs of existence and non-existence for mutliple levels from the leaf of a tree to the signed root of possibly another tree whose root binding:"required".
func GetClaimProofByHi ¶ added in v0.0.3
func GetClaimProofByHi(mt *merkletree.MerkleTree, hi *merkletree.Hash) (*ProofClaim, error)
GetClaimProofByHi given a Hash(index) (Hi) and an id, returns the Claim in that Hi position inside the User merkletree, it's proof of existence and of non-revocation, and the proof of existence and of non-revocation for the set root claim in the relay tree, all in the form of a ProofClaim. The result is not yet signed and has no timestamp.
func (*ProofClaim) String ¶ added in v0.0.3
func (pc *ProofClaim) String() string
type ProofClaimPartial ¶ added in v0.0.3
type ProofClaimPartial struct { Mtp0 *merkletree.Proof `json:"mtp0" binding:"required"` Mtp1 *merkletree.Proof `json:"mtp1" binding:"required"` Root *merkletree.Hash `json:"root" binding:"required"` Aux *SetRootAux `json:"aux" binding:"required"` }
ProofClaimPartial is a proof of existence and non-existence of a claim in a single tree (only one level).
func (*ProofClaimPartial) String ¶ added in v0.0.3
func (pcp *ProofClaimPartial) String() string
type ServiceType ¶ added in v0.0.3
type ServiceType [ServiceTypeLen]byte
ServiceType is the type used to store a claim type.
func NewServiceType ¶ added in v0.0.3
func NewServiceType(num uint64) *ServiceType
NewServiceType to set type of authorized services
type SetRootAux ¶
type SetRootAux struct { Version uint32 `json:"version" binding:"required"` Era uint32 `json:"era" binding:"required"` Id ID `json:"id" binding:"required"` }
SetRootAux is the auxiliary data to build the set root claim from a root in a partial proof of claim.