core

package module
v2.1.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: 15 Imported by: 20

README

go-iden3-core

Go Reference Go Report Card Test Lint

Low level API to create and manipulate iden3 claims and identifiers.

Protocol specification

The protocol specification is available in the protocol

Tutorials

Tutorials are available in the tutorials

Testing

go test ./...

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as below, without any additional terms or conditions.

License

go-iden3-core is part of the iden3 project copyright 2018 0kims Association

This project is licensed under either of

at your option.

Documentation

Overview

Package core contains a low level API to create and manipulate claims.

Claims are created using the constructor function core.NewClaim. It accepts core.SchemaHash and a number of core.Option functions.

Index

Examples

Constants

View Source
const (
	SlotNameIndexA = SlotName("IndexA")
	SlotNameIndexB = SlotName("IndexB")
	SlotNameValueA = SlotName("ValueA")
	SlotNameValueB = SlotName("ValueB")
)

Variables

View Source
var (
	// ErrUnsupportedID ID with unsupported type.
	ErrUnsupportedID = errors.New("unsupported ID")
	// ErrIncorrectDID return if DID method is known, but format of DID is incorrect.
	ErrIncorrectDID = errors.New("incorrect DID")
	// ErrMethodUnknown return if DID method is unknown.
	ErrMethodUnknown = errors.New("unknown DID method")
	// ErrDIDMethodNotSupported unsupported did method.
	ErrDIDMethodNotSupported = errors.New("not supported did method")
	// ErrBlockchainNotSupportedForDID unsupported network for did.
	ErrBlockchainNotSupportedForDID = errors.New("not supported blockchain")
	// ErrNetworkNotSupportedForDID unsupported network for did.
	ErrNetworkNotSupportedForDID = errors.New("not supported network")
)
View Source
var AuthSchemaHash = SchemaHash{204, 163, 55, 26, 108, 177, 183, 21, 0, 68, 7, 227, 37, 189, 153, 60}

AuthSchemaHash predefined value of auth schema, used for auth claim during identity creation. This schema is hardcoded in the identity circuits and used to verify user's auth claim. Keccak256(https://schema.iden3.io/core/jsonld/auth.jsonld#AuthBJJCredential) last 16 bytes Hex: cca3371a6cb1b715004407e325bd993c BigInt: 80551937543569765027552589160822318028

View Source
var DIDMethodByte = map[DIDMethod]byte{
	DIDMethodIden3:     0b00000001,
	DIDMethodPolygonID: 0b00000010,
	DIDMethodOther:     0b11111111,
}

DIDMethodByte did method flag representation

View Source
var DIDMethodNetwork = map[DIDMethod]map[DIDNetworkFlag]byte{
	DIDMethodIden3:     blockchainNetworkMap,
	DIDMethodPolygonID: blockchainNetworkMap,
	DIDMethodOther: {
		{Blockchain: UnknownChain, NetworkID: UnknownNetwork}: 0b1111_1111,
	},
}

DIDMethodNetwork is map for did methods and their blockchain networks

View Source
var ErrChainIDNotRegistered = errors.New("chainID is not registered")
View Source
var ErrDataOverflow = errors.New("data does not fits SNARK size")

ErrDataOverflow means that given *big.Int value does not fit in Field Q e.g. greater than Q constant:

Q constant: 21888242871839275222246405745257275088548364400416034343698204186575808495617
View Source
var ErrIncorrectIDPosition = errors.New("incorrect ID position")

ErrIncorrectIDPosition means that passed position is not one of predefined: IDPositionIndex or IDPositionValue

View Source
var ErrIncorrectMerklizedPosition = errors.New("incorrect Merklized position")

ErrIncorrectMerklizedPosition means that passed position is not one of predefined: MerklizedRootPositionIndex or MerklizedRootPositionValue

View Source
var ErrInvalidSubjectPosition = errors.New("invalid subject position")

ErrInvalidSubjectPosition returns when subject position flags sets in invalid value.

View Source
var ErrNoID = errors.New("ID is not set")

ErrNoID returns when ID not found in the Claim.

View Source
var ErrNoMerklizedRoot = errors.New("Merklized root is not set")

ErrNoMerklizedRoot returns when Merklized Root is not found in the Claim.

View Source
var (
	// TypeDefault specifies the regular identity
	// - first 2 bytes: `00000000 00000000`
	TypeDefault = [2]byte{0x00, 0x00}
)

Functions

func BuildDIDType

func BuildDIDType(method DIDMethod, blockchain Blockchain,
	network NetworkID) ([2]byte, error)

BuildDIDType builds bytes type from chain and network

func CalculateChecksum

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

CalculateChecksum returns the checksum for a given type and genesis_root, where checksum:

hash( [type | root_genesis ] )

func CheckChecksum

func CheckChecksum(id ID) bool

CheckChecksum returns a bool indicating if the ID.Checksum is consistent with the rest of the ID data

func CheckGenesisStateID

func CheckGenesisStateID(id, state *big.Int) (bool, error)

CheckGenesisStateID check if the state is genesis for the id.

func DecomposeID

func DecomposeID(id ID) (typ [2]byte, genesis [genesisLn]byte, checksum [2]byte,
	err error)

DecomposeID returns type, genesis and checksum from an ID

func ElemBytesToInts

func ElemBytesToInts(elements []ElemBytes) []*big.Int

ElemBytesToInts converts slice of ElemBytes to slice of *big.Int

func EthAddressFromID

func EthAddressFromID(id ID) ([20]byte, error)

func GenesisFromEthAddress

func GenesisFromEthAddress(addr [20]byte) [genesisLn]byte

func IdenState

func IdenState(clr, rer, ror *big.Int) (*big.Int, error)

IdenState calculates the Identity State from the Claims Tree Root, Revocation Tree Root and Roots Tree Root.

func NetworkByChainID added in v2.0.4

func NetworkByChainID(chainID ChainID) (Blockchain, NetworkID, error)

NetworkByChainID returns blockchain and networkID for registered chain ID. Or ErrChainIDNotRegistered error if chainID is not registered.

func NewDID

func NewDID(typ [2]byte, genesis [genesisLn]byte) (*w3c.DID, error)

NewDID creates a new *w3c.DID from the type and the genesis

func NewDIDFromIdenState

func NewDIDFromIdenState(typ [2]byte, state *big.Int) (*w3c.DID, error)

NewDIDFromIdenState calculates the genesis ID from an Identity State and returns it as a DID

func ParseDIDFromID

func ParseDIDFromID(id ID) (*w3c.DID, error)

ParseDIDFromID returns DID from ID

func RegisterBlockchain added in v2.0.1

func RegisterBlockchain(b Blockchain) error

RegisterBlockchain registers new blockchain

func RegisterChainID added in v2.0.1

func RegisterChainID(blockchain Blockchain, network NetworkID, chainID int) error

RegisterChainID registers chainID for blockchain and network

func RegisterDIDMethod added in v2.0.1

func RegisterDIDMethod(m DIDMethod, b byte) error

RegisterDIDMethod registers new DID method with byte flag

func RegisterDIDMethodNetwork added in v2.0.1

func RegisterDIDMethodNetwork(params DIDMethodNetworkParams, opts ...RegistrationOptions) error

RegisterDIDMethodNetwork registers new DID method network

func RegisterNetwork added in v2.0.1

func RegisterNetwork(n NetworkID) error

RegisterNetwork registers new network

Types

type Blockchain

type Blockchain string

Blockchain id of the network "eth", "polygon", etc.

const (
	// Ethereum is ethereum blockchain network
	Ethereum Blockchain = "eth"
	// Polygon is polygon blockchain network
	Polygon Blockchain = "polygon"
	// ZkEVM is zkEVM blockchain network
	ZkEVM Blockchain = "zkevm"
	// UnknownChain is used when it's not possible to retrieve blockchain type from identifier
	UnknownChain Blockchain = "unknown"
	// ReadOnly should be used for readonly identity to build readonly flag
	ReadOnly Blockchain = "readonly"
	// NoChain can be used for identity to build readonly flag
	NoChain Blockchain = ""
)

func BlockchainFromID

func BlockchainFromID(id ID) (Blockchain, error)

func FindBlockchainForDIDMethodByValue

func FindBlockchainForDIDMethodByValue(method DIDMethod, _v byte) (Blockchain, error)

FindBlockchainForDIDMethodByValue finds blockchain type by byte value

func GetBlockchain added in v2.0.1

func GetBlockchain(name string) (Blockchain, error)

GetBlockchain returns blockchain by name

type ChainID added in v2.0.1

type ChainID int32

ChainID is alias for int32 that represents ChainID

func ChainIDfromDID added in v2.0.1

func ChainIDfromDID(did w3c.DID) (ChainID, error)

ChainIDfromDID returns chain name from w3c.DID

func GetChainID added in v2.0.1

func GetChainID(blockchain Blockchain, network NetworkID) (ChainID, error)

GetChainID returns chainID for blockchain and network

type Claim

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

func NewClaim

func NewClaim(sh SchemaHash, options ...Option) (*Claim, error)

NewClaim creates new Claim with specified SchemaHash and any number of options. Using options you can specify any field in claim.

Example
var schemaHash SchemaHash
expDate := time.Date(2021, 1, 10, 20, 30, 0, 0, time.UTC)
claim, err := NewClaim(schemaHash,
	WithExpirationDate(expDate),
	WithVersion(42))
if err != nil {
	panic(err)
}
expDateRes, ok := claim.GetExpirationDate()
fmt.Println(ok)
fmt.Println(expDateRes.In(time.UTC).Format(time.RFC3339))

fmt.Println(claim.GetVersion())

indexEntry, valueEntry := claim.RawSlots()
indexHash, err := poseidon.Hash(ElemBytesToInts(indexEntry[:]))
if err != nil {
	panic(err)
}
valueHash, err := poseidon.Hash(ElemBytesToInts(valueEntry[:]))
if err != nil {
	panic(err)
}

indexSlot, err := NewElemBytesFromInt(indexHash)
if err != nil {
	panic(err)
}
valueSlot, err := NewElemBytesFromInt(valueHash)
if err != nil {
	panic(err)
}

fmt.Println(hex.EncodeToString(indexSlot[:]))
fmt.Println(hex.EncodeToString(valueSlot[:]))
Output:

true
2021-01-10T20:30:00Z
42
a07b32a81b631544f9199f4bf429ad2026baec31ba5e5e707a49cc2c9d243f18
8e6bca4b559d758eca7b6125faea23ed0765cdcb6f85b3fe9477ca4293a6fd05

func NewClaimFromBigInts added in v2.0.2

func NewClaimFromBigInts(raw [8]*big.Int) (*Claim, error)

NewClaimFromBigInts creates new Claim from bigInts.

func (*Claim) Clone

func (c *Claim) Clone() *Claim

Clone returns full deep copy of claim

func (*Claim) FromHex

func (c *Claim) FromHex(hexStr string) error

func (*Claim) GetExpirationDate

func (c *Claim) GetExpirationDate() (time.Time, bool)

GetExpirationDate returns expiration date and flag. Flag is true if expiration date is present, false if null.

func (*Claim) GetFlagUpdatable

func (c *Claim) GetFlagUpdatable() bool

GetFlagUpdatable returns claim's flag `updatable`

func (*Claim) GetID

func (c *Claim) GetID() (ID, error)

GetID returns ID from claim's index of value. Returns error ErrNoID if ID is not set.

func (*Claim) GetIDPosition

func (c *Claim) GetIDPosition() (IDPosition, error)

GetIDPosition returns the position at which the ID is stored.

func (*Claim) GetMerklizedPosition

func (c *Claim) GetMerklizedPosition() (MerklizedRootPosition, error)

GetMerklizedPosition returns the position at which the Merklize flag is stored.

func (*Claim) GetMerklizedRoot

func (c *Claim) GetMerklizedRoot() (*big.Int, error)

GetMerklizedRoot returns merklized root from claim's index of value. Returns error ErrNoMerklizedRoot if MerklizedRoot is not set.

func (*Claim) GetRevocationNonce

func (c *Claim) GetRevocationNonce() uint64

GetRevocationNonce returns revocation nonce

func (*Claim) GetSchemaHash

func (c *Claim) GetSchemaHash() SchemaHash

GetSchemaHash return copy of claim's schema hash.

func (*Claim) GetVersion

func (c *Claim) GetVersion() uint32

GetVersion returns claim's version

func (*Claim) HIndex

func (c *Claim) HIndex() (*big.Int, error)

HIndex calculates the hash of the Index of the Claim

func (*Claim) HValue

func (c *Claim) HValue() (*big.Int, error)

HValue calculates the hash of the Value of the Claim

func (Claim) Hex

func (c Claim) Hex() (string, error)

Hex returns hex representation of binary claim

func (*Claim) HiHv

func (c *Claim) HiHv() (*big.Int, *big.Int, error)

HiHv returns the HIndex and HValue of the Claim

func (Claim) MarshalBinary

func (c Claim) MarshalBinary() ([]byte, error)

func (Claim) MarshalJSON

func (c Claim) MarshalJSON() ([]byte, error)

func (*Claim) RawSlots

func (c *Claim) RawSlots() (index [4]ElemBytes, value [4]ElemBytes)

RawSlots returns raw bytes of claim's index and value

func (*Claim) RawSlotsAsInts

func (c *Claim) RawSlotsAsInts() []*big.Int

RawSlotsAsInts returns slots as []*big.Int

func (*Claim) ResetExpirationDate

func (c *Claim) ResetExpirationDate()

ResetExpirationDate removes expiration date from claim

func (*Claim) ResetID

func (c *Claim) ResetID()

ResetID deletes ID from index and from value.

func (*Claim) SetExpirationDate

func (c *Claim) SetExpirationDate(dt time.Time)

SetExpirationDate sets expiration date to dt

func (*Claim) SetFlagUpdatable

func (c *Claim) SetFlagUpdatable(val bool)

SetFlagUpdatable sets claim's flag `updatable`

func (*Claim) SetIndexData

func (c *Claim) SetIndexData(slotA, slotB ElemBytes) error

SetIndexData sets data to index slots A & B. Returns ErrSlotOverflow if slotA or slotB value are too big.

func (*Claim) SetIndexDataBytes

func (c *Claim) SetIndexDataBytes(slotA, slotB []byte) error

SetIndexDataBytes sets data to index slots A & B. Returns ErrSlotOverflow if slotA or slotB value are too big.

func (*Claim) SetIndexDataInts

func (c *Claim) SetIndexDataInts(slotA, slotB *big.Int) error

SetIndexDataInts sets data to index slots A & B. Returns ErrSlotOverflow if slotA or slotB value are too big.

func (*Claim) SetIndexID

func (c *Claim) SetIndexID(id ID)

SetIndexID sets id to index. Removes id from value if any.

func (*Claim) SetIndexMerklizedRoot

func (c *Claim) SetIndexMerklizedRoot(r *big.Int) error

SetIndexMerklizedRoot sets merklized root to index. Removes root from value[2] if any.

func (*Claim) SetRevocationNonce

func (c *Claim) SetRevocationNonce(nonce uint64)

SetRevocationNonce sets claim's revocation nonce

func (*Claim) SetSchemaHash

func (c *Claim) SetSchemaHash(sh SchemaHash)

SetSchemaHash updates claim's schema hash.

func (*Claim) SetValueData

func (c *Claim) SetValueData(slotA, slotB ElemBytes) error

SetValueData sets data to value slots A & B. Returns ErrSlotOverflow if slotA or slotB value are too big.

func (*Claim) SetValueDataBytes

func (c *Claim) SetValueDataBytes(slotA, slotB []byte) error

SetValueDataBytes sets data to value slots A & B. Returns ErrSlotOverflow if slotA or slotB value are too big.

func (*Claim) SetValueDataInts

func (c *Claim) SetValueDataInts(slotA, slotB *big.Int) error

SetValueDataInts sets data to value slots A & B. Returns ErrSlotOverflow if slotA or slotB value are too big.

func (*Claim) SetValueID

func (c *Claim) SetValueID(id ID)

SetValueID sets id to value. Removes id from index if any.

func (*Claim) SetValueMerklizedRoot

func (c *Claim) SetValueMerklizedRoot(r *big.Int) error

SetValueMerklizedRoot sets merklized root to value. Removes root from index[2] if any.

func (*Claim) SetVersion

func (c *Claim) SetVersion(ver uint32)

SetVersion sets claim's version

func (*Claim) UnmarshalBinary

func (c *Claim) UnmarshalBinary(data []byte) error

func (*Claim) UnmarshalJSON

func (c *Claim) UnmarshalJSON(in []byte) error

type DIDMethod

type DIDMethod string

DIDMethod represents did methods

const (
	// DIDMethodIden3
	DIDMethodIden3 DIDMethod = "iden3"
	// DIDMethodPolygonID
	DIDMethodPolygonID DIDMethod = "polygonid"
	// DIDMethodOther any other method not listed before
	DIDMethodOther DIDMethod = ""
)

func FindDIDMethodByValue

func FindDIDMethodByValue(b byte) (DIDMethod, error)

FindDIDMethodByValue finds did method by its byte value

func GetDIDMethod added in v2.0.1

func GetDIDMethod(name string) (DIDMethod, error)

GetDIDMethod returns DID method by name

func MethodFromID

func MethodFromID(id ID) (DIDMethod, error)

type DIDMethodNetworkParams added in v2.0.1

type DIDMethodNetworkParams struct {
	Method      DIDMethod
	Blockchain  Blockchain
	Network     NetworkID
	NetworkFlag byte
}

DIDMethodNetworkParams is a structure to represent DID method network options

type DIDNetworkFlag

type DIDNetworkFlag struct {
	Blockchain Blockchain
	NetworkID  NetworkID
}

DIDNetworkFlag is a structure to represent DID blockchain and network id

type ElemBytes

type ElemBytes [32]byte

ElemBytes length is 32 bytes. But not all 32-byte values are valid. The value should be not greater than Q constant 21888242871839275222246405745257275088548364400416034343698204186575808495617

func NewElemBytesFromInt

func NewElemBytesFromInt(i *big.Int) (ElemBytes, error)

NewElemBytesFromInt creates new ElemBytes from *big.Int. Returns error ErrDataOverflow if value is too large to fill the Field Q.

func (ElemBytes) Hex

func (el ElemBytes) Hex() string

Hex returns HEX representation of ElemBytes

func (*ElemBytes) SetInt

func (el *ElemBytes) SetInt(value *big.Int) error

SetInt sets element's data to serialized value of *big.Int in little-endian. And checks that the value is valid (fits in Field Q). Returns ErrDataOverflow if the value is too large

func (ElemBytes) ToInt

func (el ElemBytes) ToInt() *big.Int

ToInt returns *big.Int representation of ElemBytes.

type ErrSlotOverflow

type ErrSlotOverflow struct {
	Field SlotName
}

ErrSlotOverflow means some ElemBytes overflows Q Field. And wraps the name of overflowed slot.

func (ErrSlotOverflow) Error

func (e ErrSlotOverflow) Error() string

type ID

type ID [idLength]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

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

IDFromBytes returns the ID from a given byte array

func IDFromDID

func IDFromDID(did w3c.DID) (ID, error)

func IDFromInt

func IDFromInt(i *big.Int) (ID, error)

IDFromInt returns the ID from a given big.Int

func IDFromString

func IDFromString(s string) (ID, error)

IDFromString returns the ID from a given string

func NewID

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

NewID creates a new ID from a type and genesis

func NewIDFromIdenState

func NewIDFromIdenState(typ [2]byte, state *big.Int) (*ID, error)

NewIDFromIdenState calculates the genesis ID from an Identity State.

func ProfileID

func ProfileID(id ID, nonce *big.Int) (ID, error)

ProfileID calculates the Profile ID from the Identity and profile nonce. If nonce is empty or zero ID is returned

func (*ID) BigInt

func (id *ID) BigInt() *big.Int

func (*ID) Bytes

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

Bytes returns the bytes from the ID

func (*ID) Equal

func (id *ID) Equal(id2 *ID) bool

func (*ID) Equals

func (id *ID) Equals(id2 *ID) bool

func (ID) MarshalText

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

func (*ID) String

func (id *ID) String() string

String returns a base58 from the ID

func (*ID) Type

func (id *ID) Type() [2]byte

func (*ID) UnmarshalText

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

type IDPosition

type IDPosition uint8
const (
	// IDPositionNone means ID value not located in claim.
	IDPositionNone IDPosition = iota
	// IDPositionIndex means ID value is in index slots.
	IDPositionIndex
	// IDPositionValue means ID value is in value slots.
	IDPositionValue
)

type MerklizedRootPosition

type MerklizedRootPosition uint8
const (
	// MerklizedRootPositionNone means root data value not located in claim.
	MerklizedRootPositionNone MerklizedRootPosition = iota
	// MerklizedRootPositionIndex means root data value is in index slots.
	MerklizedRootPositionIndex
	// MerklizedRootPositionValue means root data value is in value slots.
	MerklizedRootPositionValue
)

type NetworkID

type NetworkID string

NetworkID is method specific network identifier

const (
	// Main is main network
	Main NetworkID = "main"
	// Mumbai is polygon mumbai test network
	Mumbai NetworkID = "mumbai"
	// Amoy is polygon amoy test network
	Amoy NetworkID = "amoy"
	// Goerli is ethereum goerli test network
	Goerli NetworkID = "goerli" // goerli
	// Sepolia is ethereum Sepolia test network
	Sepolia NetworkID = "sepolia"
	// Test is test network
	Test NetworkID = "test"
	// UnknownNetwork is used when it's not possible to retrieve network from identifier
	UnknownNetwork NetworkID = "unknown"
	// NoNetwork should be used for readonly identity to build readonly flag
	NoNetwork NetworkID = ""
)

func FindNetworkIDForDIDMethodByValue

func FindNetworkIDForDIDMethodByValue(method DIDMethod, _v byte) (NetworkID, error)

FindNetworkIDForDIDMethodByValue finds network by byte value

func GetNetwork added in v2.0.1

func GetNetwork(name string) (NetworkID, error)

GetNetwork returns network by name

func NetworkIDFromID

func NetworkIDFromID(id ID) (NetworkID, error)

type Option

type Option func(*Claim) error

Option provides the ability to set different Claim's fields on construction

func WithExpirationDate

func WithExpirationDate(dt time.Time) Option

WithExpirationDate sets claim's expiration date to `dt`.

func WithFlagMerklized

func WithFlagMerklized(p MerklizedRootPosition) Option

WithFlagMerklized sets claim's flag `merklize`

func WithFlagUpdatable

func WithFlagUpdatable(val bool) Option

WithFlagUpdatable sets claim's flag `updatable`

func WithID

func WithID(id ID, pos IDPosition) Option

WithID sets ID to claim's index or value depending on `pos`.

func WithIndexData

func WithIndexData(slotA, slotB ElemBytes) Option

WithIndexData sets data to index slots A & B. Returns ErrSlotOverflow if slotA or slotB value are too big.

func WithIndexDataBytes

func WithIndexDataBytes(slotA, slotB []byte) Option

WithIndexDataBytes sets data to index slots A & B. Returns ErrSlotOverflow if slotA or slotB value are too big.

func WithIndexDataInts

func WithIndexDataInts(slotA, slotB *big.Int) Option

WithIndexDataInts sets data to index slots A & B. Returns ErrSlotOverflow if slotA or slotB value are too big.

func WithIndexID

func WithIndexID(id ID) Option

WithIndexID sets ID to claim's index

func WithIndexMerklizedRoot

func WithIndexMerklizedRoot(r *big.Int) Option

WithIndexMerklizedRoot sets root to index i_2 Returns ErrSlotOverflow if root value are too big.

func WithMerklizedRoot

func WithMerklizedRoot(r *big.Int, pos MerklizedRootPosition) Option

WithMerklizedRoot sets root to value v_2 or index i_2 Returns ErrSlotOverflow if root value are too big.

func WithRevocationNonce

func WithRevocationNonce(nonce uint64) Option

WithRevocationNonce sets claim's revocation nonce.

func WithValueData

func WithValueData(slotA, slotB ElemBytes) Option

WithValueData sets data to value slots A & B. Returns ErrSlotOverflow if slotA or slotB value are too big.

func WithValueDataBytes

func WithValueDataBytes(slotA, slotB []byte) Option

WithValueDataBytes sets data to value slots A & B. Returns ErrSlotOverflow if slotA or slotB value are too big.

func WithValueDataInts

func WithValueDataInts(slotA, slotB *big.Int) Option

WithValueDataInts sets data to value slots A & B. Returns ErrSlotOverflow if slotA or slotB value are too big.

func WithValueID

func WithValueID(id ID) Option

WithValueID sets ID to claim's value

func WithValueMerklizedRoot

func WithValueMerklizedRoot(r *big.Int) Option

WithValueMerklizedRoot sets root to value v_2 Returns ErrSlotOverflow if root value are too big.

func WithVersion

func WithVersion(ver uint32) Option

WithVersion sets claim's version

type RegistrationOptions added in v2.0.1

type RegistrationOptions func(params *registrationOptions)

RegistrationOptions is a type for DID method network options

func WithChainID added in v2.0.1

func WithChainID(chainID int) RegistrationOptions

WithChainID registers new chain ID method with byte flag

func WithDIDMethodByte added in v2.0.1

func WithDIDMethodByte(methodByte byte) RegistrationOptions

WithDIDMethodByte registers new DID method with byte flag

type SchemaHash

type SchemaHash [schemaHashLn]byte

SchemaHash is a 16-bytes hash of file's content, that describes claim structure.

func NewSchemaHashFromHex

func NewSchemaHashFromHex(s string) (SchemaHash, error)

NewSchemaHashFromHex creates new SchemaHash from hex string

func NewSchemaHashFromInt

func NewSchemaHashFromInt(i *big.Int) SchemaHash

NewSchemaHashFromInt creates new SchemaHash from big.Int

func (SchemaHash) BigInt

func (sh SchemaHash) BigInt() *big.Int

BigInt returns a bigInt presentation of SchemaHash

func (SchemaHash) MarshalText

func (sh SchemaHash) MarshalText() ([]byte, error)

MarshalText returns HEX representation of SchemaHash.

Returning error is always nil.

type SlotName

type SlotName string

Directories

Path Synopsis
Package w3c is a set of tools to work with Decentralized Identifiers (DIDs) as described in the DID spec https://w3c.github.io/did-core/ Got from https://github.com/build-trust/did
Package w3c is a set of tools to work with Decentralized Identifiers (DIDs) as described in the DID spec https://w3c.github.io/did-core/ Got from https://github.com/build-trust/did

Jump to

Keyboard shortcuts

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