testing

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0, MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthClaimFromPubKey

func AuthClaimFromPubKey(X, Y *big.Int) (*core.Claim, error)

func AuthClaimFullInfo

func AuthClaimFullInfo(ctx context.Context, privKeyHex string,
	challenge *big.Int) (*core.ID, *core.Claim, *merkletree.Hash,
	*merkletree.MerkleTree,
	*merkletree.MerkleTree, *merkletree.MerkleTree, *merkletree.Proof,
	*merkletree.Proof, *babyjub.Signature, error)

This method is to generate auth claim, identity, all its trees, state and sign a challenge with the claim private key.

func AuthV2ClaimFromPubKey

func AuthV2ClaimFromPubKey(X, Y *big.Int) (*core.Claim, error)

func CalcStateFromRoots

func CalcStateFromRoots(claimsTree *merkletree.MerkleTree,
	optTrees ...*merkletree.MerkleTree) (*merkletree.Hash, error)

func CoreSchemaFromStr

func CoreSchemaFromStr(t testing.TB, schemaIntStr string) core.SchemaHash

func DefaultUserClaim

func DefaultUserClaim(t testing.TB, subject core.ID) *core.Claim

func ExtractPubXY

func ExtractPubXY(privKHex string) (key *babyjub.PrivateKey, x, y *big.Int)

func GISTTree

func GISTTree(ctx context.Context) *merkletree.MerkleTree

func Generate

func Generate(ctx context.Context, privKHex string) (*core.ID,
	*merkletree.MerkleTree, *merkletree.MerkleTree, *merkletree.MerkleTree,
	error, *core.Claim, *babyjub.PrivateKey)

func HashToStr

func HashToStr(siblings []*merkletree.Hash) []string

func IDFromState

func IDFromState(state *big.Int) (*core.ID, error)

func IDFromStr

func IDFromStr(t testing.TB, idStr string) *core.ID

func MTHashFromStr

func MTHashFromStr(t testing.TB, hashStr string) *merkletree.Hash

func PrepareIntArray

func PrepareIntArray(arr []*big.Int, length int) []*big.Int

func PrepareSiblingsStr

func PrepareSiblingsStr(siblings []*merkletree.Hash, levels int) []string

func PrepareStrArray

func PrepareStrArray(siblings []string, levels int) []string

func SignBBJJ

func SignBBJJ(key *babyjub.PrivateKey, sigInput []byte) (*babyjub.Signature, error)

func SignPoseidon

func SignPoseidon(pk *babyjub.PrivateKey, data []byte) ([]byte, error)

SignPoseidon signs prepared data ( value in field Q)

func TestData

func TestData(t *testing.T, fileName string, data string, generate bool) string

func UserStateCommitmentClaim

func UserStateCommitmentClaim(t testing.TB, secret *big.Int) *core.Claim

Types

type IdentityTest

type IdentityTest struct {
	ID        core.ID
	Clt       *merkletree.MerkleTree
	Ret       *merkletree.MerkleTree
	Rot       *merkletree.MerkleTree
	AuthClaim *core.Claim
	PK        *babyjub.PrivateKey
}

func NewIdentity

func NewIdentity(t testing.TB, privKHex string) *IdentityTest

func (*IdentityTest) AddClaim

func (it *IdentityTest) AddClaim(t testing.TB, claim *core.Claim)

func (*IdentityTest) ClaimMTPRaw

func (it *IdentityTest) ClaimMTPRaw(t testing.TB, claim *core.Claim) (proof *merkletree.Proof, value *big.Int)

ClaimMTPRaw returns the merkle proof of a claim

func (*IdentityTest) ClaimRevMTP

func (it *IdentityTest) ClaimRevMTP(claim *core.Claim) (sibling []string, nodeAux *NodeAuxValue, err error)

func (*IdentityTest) ClaimRevMTPRaw

func (it *IdentityTest) ClaimRevMTPRaw(t testing.TB, claim *core.Claim) (proof *merkletree.Proof, value *big.Int)

func (*IdentityTest) SignBBJJ

func (it *IdentityTest) SignBBJJ(challenge []byte) (*babyjub.Signature, error)

func (*IdentityTest) SignClaim

func (it *IdentityTest) SignClaim(t testing.TB, claim *core.Claim) *babyjub.Signature

func (*IdentityTest) SignClaimBBJJ

func (it *IdentityTest) SignClaimBBJJ(claim *core.Claim) (*babyjub.Signature, error)

func (*IdentityTest) State

func (it *IdentityTest) State(t testing.TB) *merkletree.Hash

type NodeAuxValue

type NodeAuxValue struct {
	Key   *merkletree.Hash
	Value *merkletree.Hash
	NoAux string
}

func PrepareProof

func PrepareProof(proof *merkletree.Proof) ([]string, NodeAuxValue)

Jump to

Keyboard shortcuts

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