core

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const ClaimTypeLen = 64 / 8

ClaimTypeLen is the length in bytes of the type in a claim.

View Source
const ClaimTypeVersionLen = ClaimTypeLen + ClaimVersionLen

ClaimTypeVersionLen is the length in bytes of the version and length in a claim.

View Source
const ClaimVersionLen = 32 / 8

ClaimVersionLen is the length in bytes of the version in a claim.

View Source
const EthKeyTypeLen = 32 / 8

EthKeyTypeLen is the length in bytes of the type in a claim

View Source
const ServiceTypeLen = 64 / 8

ServiceTypeLen is the length in bytes of the type of the Services

Variables

View Source
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)
)
View Source
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)
)
View Source
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

View Source
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}
)
View Source
var ErrInvalidClaimType = errors.New("invalid claim type")

ErrInvalidClaimType indicates a type error when parsing an Entry into a claim.

View Source
var (
	ErrRevokedClaim = errors.New("the claim is revoked: the next version exists")
)

Functions

func CalculateChecksum added in v0.0.4

func CalculateChecksum(typ [2]byte, genesis [27]byte) [2]byte

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

func CheckChecksum(id ID) bool

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

func DecomposeID(id ID) ([2]byte, [27]byte, [2]byte, error)

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

func HashString(s string) (stringHashed [248 / 8]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.

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

Entry serializes the claim into an Entry.

func (*ClaimAuthorizeKSignBabyJub) Type added in v0.0.5

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

Entry serializes the claim into an Entry.

func (*ClaimAuthorizeKSignSecp256k1) Type

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

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

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

func NewClaimType(name string) *ClaimType

NewClaimType creates a ClaimType from a type name.

func NewClaimTypeNum

func NewClaimTypeNum(num uint64) *ClaimType

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.

const (
	// HashTypeKeccak256 indicates that hash keccak256 is used.
	HashTypeKeccak256 HashType = 0
	// HashTypeSha256 indicates that hash sha256 is used.
	HashTypeSha256 HashType = 1
)

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

func IDFromBytes(b []byte) (ID, error)

IDFromBytes returns the ID from a given byte array

func IDFromString added in v0.0.4

func IDFromString(s string) (ID, error)

IDFromString returns the ID from a given string

func NewID added in v0.0.4

func NewID(typ [2]byte, genesis [27]byte) ID

NewID creates a new ID from a type and genesis

func (*ID) Bytes added in v0.0.4

func (id *ID) Bytes() []byte

Bytes returns the bytes from the ID

func (ID) MarshalText added in v0.0.4

func (id ID) MarshalText() ([]byte, error)

func (*ID) String added in v0.0.4

func (id *ID) String() string

String returns a base58 from the ID.Bytes()

func (*ID) UnmarshalText added in v0.0.4

func (id *ID) UnmarshalText(b []byte) error

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 NewNonceDb added in v0.0.3

func NewNonceDb() *NonceDb

NewNonceDb creates an empty NonceDb.

func (*NonceDb) Add added in v0.0.3

func (ndb *NonceDb) Add(nonce string, delta int64, aux interface{}) *NonceObj

Add adds a nonce with aux data that expires after delta seconds

func (*NonceDb) AddAux added in v0.0.3

func (ndb *NonceDb) AddAux(nonce string, aux interface{}) bool

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

func (ndb *NonceDb) New(delta int64, aux interface{}) *NonceObj

New adds a new nonce to the db that expires after delta seconds, and returns the added NonceObj

func (*NonceDb) Search added in v0.0.3

func (ndb *NonceDb) Search(nonce string) (*NonceObj, bool)

Search searches a nonce object by nonce. Returns false if the nonce is not found or expired.

func (*NonceDb) SearchAndDelete added in v0.0.3

func (ndb *NonceDb) SearchAndDelete(nonce string) (*NonceObj, bool)

SearchAndDelete searches a nonce object by nonce, and if found, deletes it from the NonceDb. Returns false if the nonce is not found or expired.

type NonceObj added in v0.0.3

type NonceObj struct {
	Nonce      string
	Expiration int64
	Aux        interface{}
}

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.

Jump to

Keyboard shortcuts

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