pkh

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BitcoinNetworkPrefix  = "bip122:000000000019d6689c085ae165831e93"
	EthereumNetworkPrefix = "eip155:1"
	PolygonNetworkPrefix  = "eip155:137"

	ECDSASECP256k1RecoveryMethod2020 = "EcdsaSecp256k1RecoveryMethod2020"
)
View Source
const (
	// DIDPKHPrefix did:pkh prefix
	DIDPKHPrefix = "did:pkh"
)

Variables

This section is empty.

Functions

func GetDIDPKHContext

func GetDIDPKHContext() (string, error)

GetDIDPKHContext returns a context which should be manually inserted into each did:pkh document. This will likely change over time as new verification methods are supported, and general-purpose methods are specified.

func GetDIDPKHNetworkPrefixes

func GetDIDPKHNetworkPrefixes() []string

func GetDIDPKHPrefixForNetwork

func GetDIDPKHPrefixForNetwork(n Network) (string, error)

GetDIDPKHPrefixForNetwork returns the did:pkh prefix for a given network

func GetVerificationTypeForNetwork

func GetVerificationTypeForNetwork(n Network) (string, error)

GetVerificationTypeForNetwork returns the verification key type for a given network

func IsValidPKH

func IsValidPKH(id PKH) bool

IsValidPKH checks if a pkh did is valid based on the following parameters: pkh-did = "did:pkh:" address address = account_id according to [CAIP-10] account_id: chain_id + ":" + account_address chain_id: [-a-z0-9]{3,8}:[-a-zA-Z0-9]{1,32} account_address: [a-zA-Z0-9]{1,64} chain_id: namespace + ":" + reference namespace: [-a-z0-9]{3,8} reference: [-a-zA-Z0-9]{1,32}

Types

type Network

type Network string
const (
	Bitcoin  Network = "Bitcoin"
	Ethereum Network = "Ethereum"
	Polygon  Network = "Polygon"
)

func GetDIDPKHNetworkForDID

func GetDIDPKHNetworkForDID(id string) (Network, error)

GetDIDPKHNetworkForDID returns the network for a given did:pkh

func GetDIDPKHNetworkForPrefix

func GetDIDPKHNetworkForPrefix(p string) (Network, error)

GetDIDPKHNetworkForPrefix returns the did:pkh network for a given prefix

func GetSupportedPKHNetworks

func GetSupportedPKHNetworks() []Network

type PKH

type PKH string

func CreateDIDPKH

func CreateDIDPKH(namespace, reference, address string) (*PKH, error)

CreateDIDPKH constructs a did:pkh from a namespace, reference, and account address. Reference: did:pkh:namespace:reference:account_address

func CreateDIDPKHFromNetwork

func CreateDIDPKHFromNetwork(network Network, address string) (*PKH, error)

CreateDIDPKHFromNetwork constructs a did:pkh from a network and the networks native address.

func (PKH) Expand

func (d PKH) Expand() (*did.Document, error)

Expand turns the DID key into a complaint DID Document

func (PKH) IsValid

func (d PKH) IsValid() bool

func (PKH) Method

func (PKH) Method() did.Method

func (PKH) String

func (d PKH) String() string

func (PKH) Suffix

func (d PKH) Suffix() (string, error)

Suffix Parse returns the value without the `did:pkh` prefix

type Resolver

type Resolver struct{}

func (Resolver) Methods

func (Resolver) Methods() []did.Method

func (Resolver) Resolve

Jump to

Keyboard shortcuts

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