claimsrv

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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("value not found")
)

Functions

func CheckKSignBabyJubInIddb added in v0.0.5

func CheckKSignBabyJubInIddb(mt *merkletree.MerkleTree, kSignPk *babyjub.PublicKey) bool

CheckKSignBabyJubInIddb checks that a given KSign is in an AuthorizeKSignClaim in the Identity Merkle Tree (in this version, as the Merkle Tree don't allows to delete data, the verification only needs to check if the AuthorizeKSignClaim is in the key-value)

func CheckKSignInIddb

func CheckKSignInIddb(mt *merkletree.MerkleTree, kSignPk *ecdsa.PublicKey) bool

CheckKSignInIddb checks that a given KSign is in an AuthorizeKSignClaim in the Identity Merkle Tree (in this version, as the Merkle Tree don't allows to delete data, the verification only needs to check if the AuthorizeKSignClaim is in the key-value)

func GetNextVersion

func GetNextVersion(mt *merkletree.MerkleTree, hi *merkletree.Hash) (uint32, error)

GetNextVersion returns the next version of a claim, given a Hash(index)

func NewMerkleTreeUser added in v0.0.4

func NewMerkleTreeUser(id core.ID, storage db.Storage, levels int) (*merkletree.MerkleTree, error)

NewMerkleTreeUser creates a new user merkle tree by using an storage with the user addres prefix.

Types

type BytesSignedMsg

type BytesSignedMsg struct {
	ValueHex  string                 `json:"valueHex" binding:"required"` // claim.Bytes() in a hex format
	Signature *utils.SignatureEthMsg `json:"signatureHex" binding:"required"`
	KSignPk   *utils.PublicKey       `json:"kSignPK" binding:"required"`
}

BytesSignedMsg contains the value and its signature in Hex representation

type ClaimAssignNameMsg

type ClaimAssignNameMsg struct {
	ClaimAssignName core.ClaimAssignName   `binding:"required"`
	Signature       *utils.SignatureEthMsg `binding:"required"`
}

ClaimAssignNameMsg contains a core.ClaimAssignName with its signature in Hex

type ClaimAuthorizeKSignSecp256k1Msg

type ClaimAuthorizeKSignSecp256k1Msg struct {
	ClaimAuthorizeKSignSecp256k1 core.ClaimAuthorizeKSignSecp256k1 `binding:"required"`
	Signature                    *utils.SignatureEthMsg            `binding:"required"`
	KSignP256                    *ecdsa.PublicKey                  `binding:"required"`
}

ClaimAuthorizeKSignSecp256k1Msg contains a core.ClaimAuthorizeKSignP256 with its signature in Hex

type ClaimBasicMsg

type ClaimBasicMsg struct {
	ClaimBasic core.ClaimBasic        `binding:"required"`
	Signature  *utils.SignatureEthMsg `binding:"required"`
}

ClaimBasicMsg contains a core.ClaimBasic with its signature in Hex

type ClaimValueMsg

type ClaimValueMsg struct {
	ClaimValue merkletree.Entry       `binding:"required"`
	Signature  *utils.SignatureEthMsg `binding:"required"`
	KSignPk    *utils.PublicKey       `binding:"required"`
}

ClaimValueMsg contains a core.ClaimValue with its signature in Hex

type ProofClaimUser added in v0.0.3

type ProofClaimUser struct {
	ClaimProof                     ProofTreeLeaf
	SetRootClaimProof              ProofTreeLeaf
	ClaimNonRevocationProof        ProofTreeLeaf
	SetRootClaimNonRevocationProof ProofTreeLeaf
	Date                           int64
	Signature                      []byte // signature of the Root of the Relay
}

TODO: Remove in next refactor ProofClaimUser is the proof of a claim in the Identity MerkleTree, and the SetRootClaim of that MerkleTree inside the Relay's MerkleTree. Also with the proofs of non revocation of both claims

func (*ProofClaimUser) Hex added in v0.0.3

TODO: Remove in next refactor

type ProofClaimUserHex added in v0.0.3

type ProofClaimUserHex struct {
	ClaimProof                     ProofTreeLeafHex
	SetRootClaimProof              ProofTreeLeafHex
	ClaimNonRevocationProof        ProofTreeLeafHex
	SetRootClaimNonRevocationProof ProofTreeLeafHex
	Date                           int64
	Signature                      string // signature of the Root of the Relay
}

TODO: Remove in next refactor

func (*ProofClaimUserHex) Unhex added in v0.0.3

func (pch *ProofClaimUserHex) Unhex() (ProofClaimUser, error)

TODO: Remove in next refactor

type ProofTreeLeaf added in v0.0.3

type ProofTreeLeaf struct {
	Leaf  []byte
	Proof []byte
	Root  merkletree.Hash
}

TODO: Remove in next refactor ProofTreeLeaf contains all the parameters needed to proof that a Leaf is in a merkletree with a given Root

func (*ProofTreeLeaf) Hex added in v0.0.3

func (pl *ProofTreeLeaf) Hex() ProofTreeLeafHex

TODO: Remove in next refactor Hex returns a ProofTreeLeafHex data structure

type ProofTreeLeafHex added in v0.0.3

type ProofTreeLeafHex struct {
	Leaf  string
	Proof string
	Root  string
}

TODO: Remove in next refactor ProofTreeLeafHex is the same data structure than ProofTreeLeaf but in Hexadecimal string representation

func (*ProofTreeLeafHex) Unhex added in v0.0.3

func (plh *ProofTreeLeafHex) Unhex() ProofTreeLeaf

TODO: Remove in next refactor

type Service

type Service interface {
	CommitNewIdRoot(id core.ID, kSignPk *ecdsa.PublicKey, root merkletree.Hash, timestamp int64, signature *utils.SignatureEthMsg) (*core.ClaimSetRootKey, error)
	AddClaimAuthorizeKSignSecp256k1First(id core.ID,
		claimAuthorizeKSignSecp256k1 core.ClaimAuthorizeKSignSecp256k1) error
	AddUserIdClaim(id core.ID, claimValueMsg ClaimValueMsg) error
	AddClaim(claim merkletree.Entrier) error
	GetIdRoot(id core.ID) (merkletree.Hash, []byte, error)
	GetClaimProofUserByHi(id core.ID, hi *merkletree.Hash) (*core.ProofClaim, error)
	GetClaimProofUserByHiOld(id core.ID, hi merkletree.Hash) (*ProofClaimUser, error)
	GetClaimProofByHi(hi *merkletree.Hash) (*core.ProofClaim, error)
	MT() *merkletree.MerkleTree
	RootSrv() rootsrv.Service
}

type ServiceImpl

type ServiceImpl struct {
	// contains filtered or unexported fields
}

func New

func New(id core.ID, mt *merkletree.MerkleTree, rootsrv rootsrv.Service,
	signer signsrv.Service) *ServiceImpl

func (*ServiceImpl) AddClaim added in v0.0.3

func (cs *ServiceImpl) AddClaim(claim merkletree.Entrier) error

AddClaim adds a claim directly to the Relay merkletree

func (*ServiceImpl) AddClaimAuthorizeKSignSecp256k1First

func (cs *ServiceImpl) AddClaimAuthorizeKSignSecp256k1First(id core.ID,
	claimAuthorizeKSignSecp256k1 core.ClaimAuthorizeKSignSecp256k1) error

AddClaimAuthorizeKSignSecp256k1First adds ClaimAuthorizeKSignSecp256k1 into the Id's merkletree, and adds the Id's merkle root into the Relay's merkletree inside a ClaimSetRootKey. Returns the merkle proof of both Claims

func (*ServiceImpl) AddUserIdClaim

func (cs *ServiceImpl) AddUserIdClaim(id core.ID, claimValueMsg ClaimValueMsg) error

AddUserIdClaim adds a claim into the Id's merkle tree, and with the Id's root, creates a new ClaimSetRootKey and adds it to the Relay's merkletree

func (*ServiceImpl) CommitNewIdRoot

func (cs *ServiceImpl) CommitNewIdRoot(id core.ID, kSignPk *ecdsa.PublicKey, root merkletree.Hash, timestamp int64, signature *utils.SignatureEthMsg) (*core.ClaimSetRootKey, error)

SetNewIdRoot checks that the data is valid and performs a claim in the Relay merkletree setting the new Root of the emiting Id

func (*ServiceImpl) GetClaimProofByHi

func (cs *ServiceImpl) GetClaimProofByHi(hi *merkletree.Hash) (*core.ProofClaim, error)

GetClaimProofByHi given a Hash(index) (Hi), returns the Claim in that Hi position inside the Relay merkletree, and it's proof of existence and of non-revocated, all in the form of a ProofClaim. The result is signed (with a timestamp) by the service.

func (*ServiceImpl) GetClaimProofUserByHi

func (cs *ServiceImpl) GetClaimProofUserByHi(id core.ID,
	hi *merkletree.Hash) (*core.ProofClaim, error)

GetClaimProofUserByHi 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.

func (*ServiceImpl) GetClaimProofUserByHiOld

func (cs *ServiceImpl) GetClaimProofUserByHiOld(id core.ID, hi merkletree.Hash) (*ProofClaimUser, error)

TODO: Remove this GetClaimProofUserByHiOld given a Hash(index) (Hi) and an Id, returns the Claim in that Hi position inside the Id's merkletree, and the ClaimSetRootKey with the Id's root in the Relay's merkletree

func (*ServiceImpl) GetIdRoot

func (cs *ServiceImpl) GetIdRoot(id core.ID) (merkletree.Hash, []byte, error)

GetIdRoot returns the root of an Id tree, and the proof of that Root Id tree in the Relay Merkle Tree

func (*ServiceImpl) MT

func (cs *ServiceImpl) MT() *merkletree.MerkleTree

MT returns the merkle tree.

func (*ServiceImpl) RootSrv added in v0.0.3

func (cs *ServiceImpl) RootSrv() rootsrv.Service

RootSrv returns the RootService

type SetRootMsg

type SetRootMsg struct {
	Root      string                 `binding:"required"`
	Id        string                 `binding:"required"`
	KSignPk   *utils.PublicKey       `binding:"required"`
	Timestamp int64                  `binding:"required"`
	Signature *utils.SignatureEthMsg `binding:"required"`
}

SetRootMsg contains the data to set the SetRootClaim with its signature in Hex

Jump to

Keyboard shortcuts

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