crypto

package
v0.6.17 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthCredential        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowCredential          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupCredential = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthPubkey        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowPubkey          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupPubkey = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthVc        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowVc          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupVc = fmt.Errorf("proto: unexpected end of group")
)
View Source
var CoinType_name = map[int32]string{
	0:  "CoinType_BITCOIN",
	1:  "CoinType_TESTNET",
	2:  "CoinType_LITECOIN",
	3:  "CoinType_DOGE",
	4:  "CoinType_ETHEREUM",
	5:  "CoinType_SONR",
	6:  "CoinType_COSMOS",
	7:  "CoinType_FILECOIN",
	8:  "CoinType_HNS",
	9:  "CoinType_SOLANA",
	10: "CoinType_XRP",
}
View Source
var CoinType_value = map[string]int32{
	"CoinType_BITCOIN":  0,
	"CoinType_TESTNET":  1,
	"CoinType_LITECOIN": 2,
	"CoinType_DOGE":     3,
	"CoinType_ETHEREUM": 4,
	"CoinType_SONR":     5,
	"CoinType_COSMOS":   6,
	"CoinType_FILECOIN": 7,
	"CoinType_HNS":      8,
	"CoinType_SOLANA":   9,
	"CoinType_XRP":      10,
}
View Source
var KeyType_name = map[int32]string{
	0: "KeyType_UNSPECIFIED",
	1: "KeyType_JSON_WEB_KEY_2020",
	2: "KeyType_ED25519_VERIFICATION_KEY_2018",
	3: "KeyType_ECDSA_SECP256K1_VERIFICATION_KEY_2019",
	4: "KeyType_RSA_VERIFICATION_KEY_2018",
	5: "KeyType_WEB_AUTHN_AUTHENTICATION_2018",
}
View Source
var KeyType_value = map[string]int32{
	"KeyType_UNSPECIFIED":                           0,
	"KeyType_JSON_WEB_KEY_2020":                     1,
	"KeyType_ED25519_VERIFICATION_KEY_2018":         2,
	"KeyType_ECDSA_SECP256K1_VERIFICATION_KEY_2019": 3,
	"KeyType_RSA_VERIFICATION_KEY_2018":             4,
	"KeyType_WEB_AUTHN_AUTHENTICATION_2018":         5,
}
View Source
var ProofType_name = map[int32]string{
	0: "ProofType_UNSPECIFIED",
	1: "ProofType_JSON_WEB_SIGNATURE_2020",
	2: "ProofType_ED25519_SIGNATURE_2018",
	3: "ProofType_ECDSA_SECP256K1_SIGNATURE_2019",
	4: "ProofType_RSA_SIGNATURE_2018",
}
View Source
var ProofType_value = map[string]int32{
	"ProofType_UNSPECIFIED":                    0,
	"ProofType_JSON_WEB_SIGNATURE_2020":        1,
	"ProofType_ED25519_SIGNATURE_2018":         2,
	"ProofType_ECDSA_SECP256K1_SIGNATURE_2019": 3,
	"ProofType_RSA_SIGNATURE_2018":             4,
}
View Source
var ServiceType_name = map[int32]string{
	0: "ServiceType_UNSPECIFIED",
	1: "ServiceType_DID_COMM_MESSAGING",
	2: "ServiceType_ENCRYPTED_DATA_VAULT",
	3: "ServiceType_LINKED_DOMAINS",
}
View Source
var ServiceType_value = map[string]int32{
	"ServiceType_UNSPECIFIED":          0,
	"ServiceType_DID_COMM_MESSAGING":   1,
	"ServiceType_ENCRYPTED_DATA_VAULT": 2,
	"ServiceType_LINKED_DOMAINS":       3,
}

Functions

func Base64UrlToBytes added in v0.6.5

func Base64UrlToBytes(base64Url string) ([]byte, error)

func BitcoinAddress added in v0.5.0

func BitcoinAddress(pk *PubKey) string

func ConvertBoolToString

func ConvertBoolToString(v bool) string

func ConvertStringToBool

func ConvertStringToBool(v string) bool

func EthereumAddress added in v0.5.0

func EthereumAddress(pk *PubKey) string

func ParseCredentialPublicKey added in v0.6.5

func ParseCredentialPublicKey(pubStr string) (interface{}, error)

Types

type Address

type Address = tmcrypto.Address

type CoinType

type CoinType int32

CoinType is the BIP-0044 coin type for each supported coin.

const (
	// Bitcoins coin type is 0
	CoinType_CoinType_BITCOIN CoinType = 0
	// Testnet coin type is 1
	CoinType_CoinType_TESTNET CoinType = 1
	// Litecoin coin type is 2
	CoinType_CoinType_LITECOIN CoinType = 2
	// Dogecoin coin type is 3
	CoinType_CoinType_DOGE CoinType = 3
	// Ethereum coin type is 60
	CoinType_CoinType_ETHEREUM CoinType = 4
	// Sonr coin type is 703
	CoinType_CoinType_SONR CoinType = 5
	// Cosmos coin type is 118
	CoinType_CoinType_COSMOS CoinType = 6
	// Filecoin coin type is 461
	CoinType_CoinType_FILECOIN CoinType = 7
	// Handshake coin type is 5353
	CoinType_CoinType_HNS CoinType = 8
	// Solana coin type is 501
	CoinType_CoinType_SOLANA CoinType = 9
	// Ripple coin type is 144
	CoinType_CoinType_XRP CoinType = 10
)

func AllCoinTypes

func AllCoinTypes() []CoinType

AllCoinTypes returns all the coin types.

func CoinTypeFromAddrPrefix

func CoinTypeFromAddrPrefix(str string) CoinType

CoinTypeFromAddrPrefix returns the CoinType from the string.

func CoinTypeFromBipPath

func CoinTypeFromBipPath(i int32) CoinType

CoinTypeFromBipPath returns the CoinType from the index.

func CoinTypeFromDidMethod

func CoinTypeFromDidMethod(str string) CoinType

CoinTypeFromDIDMethod returns the CoinType from the DID method.

func CoinTypeFromName

func CoinTypeFromName(str string) CoinType

CoinTypeFromName returns the CoinType from the name.

func CoinTypeFromTicker

func CoinTypeFromTicker(str string) CoinType

CoinTypeFromTicker returns the CoinType from the symbol.

func (CoinType) AddrPrefix

func (ct CoinType) AddrPrefix() string

AddrPrefix returns the address prefix for the given coin type.

func (CoinType) BipPath

func (ct CoinType) BipPath() int32

BipPath returns the index for the given coin type.

func (CoinType) DidMethod

func (c CoinType) DidMethod() string

DidMethod returns the DID method for the given coin type.

func (CoinType) EnumDescriptor

func (CoinType) EnumDescriptor() ([]byte, []int)

func (CoinType) FormatAddress added in v0.5.0

func (c CoinType) FormatAddress(pk *PubKey) string

FormatAddress returns the address for the given public key for the spec of the coin type.

func (CoinType) FormatDID added in v0.6.0

func (c CoinType) FormatDID(pk *PubKey) (string, string)

FormatDID returns the DID for the given public key for the spec of the coin type, along with the address.

func (CoinType) IsBitcoin

func (c CoinType) IsBitcoin() bool

IsBitcoin returns true if the coin type is bitcoin.

func (CoinType) IsCosmos

func (c CoinType) IsCosmos() bool

IsCosmos returns true if the coin type is cosmos.

func (CoinType) IsDogecoin

func (c CoinType) IsDogecoin() bool

IsDogecoin returns true if the coin type is dogecoin.

func (CoinType) IsEthereum

func (c CoinType) IsEthereum() bool

IsEthereum returns true if the coin type is ethereum.

func (CoinType) IsFilecoin

func (c CoinType) IsFilecoin() bool

IsFilecoin returns true if the coin type is filecoin.

func (CoinType) IsHandshake

func (c CoinType) IsHandshake() bool

IsHandshake returns true if the coin type is handshake.

func (CoinType) IsLitecoin

func (c CoinType) IsLitecoin() bool

IsLitecoin returns true if the coin type is litecoin.

func (CoinType) IsRipple

func (c CoinType) IsRipple() bool

IsRipple returns true if the coin type is ripple.

func (CoinType) IsSolana

func (c CoinType) IsSolana() bool

IsSolana returns true if the coin type is solana.

func (CoinType) IsSonr

func (c CoinType) IsSonr() bool

IsSonr returns true if the coin type is sonr.

func (CoinType) IsTestnet

func (c CoinType) IsTestnet() bool

IsTestnet returns true if the coin type is testnet.

func (CoinType) Name

func (ct CoinType) Name() string

Name returns the name for the given coin type.

func (CoinType) String

func (x CoinType) String() string

func (CoinType) Ticker

func (ct CoinType) Ticker() string

Ticker returns the symbol for the given coin type for exchanges.

type JSONWebSignature2020Proof

type JSONWebSignature2020Proof struct {
	Proof *Proof `protobuf:"bytes,1,opt,name=proof,proto3" json:"proof,omitempty"`
	Jws   string `protobuf:"bytes,2,opt,name=jws,proto3" json:"jws,omitempty"`
}

JSONWebSignature2020Proof is a VC proof with a signature according to JsonWebSignature2020

func (*JSONWebSignature2020Proof) Descriptor

func (*JSONWebSignature2020Proof) Descriptor() ([]byte, []int)

func (*JSONWebSignature2020Proof) GetJws

func (m *JSONWebSignature2020Proof) GetJws() string

func (*JSONWebSignature2020Proof) GetProof

func (m *JSONWebSignature2020Proof) GetProof() *Proof

func (*JSONWebSignature2020Proof) Marshal

func (m *JSONWebSignature2020Proof) Marshal() (dAtA []byte, err error)

func (*JSONWebSignature2020Proof) MarshalTo

func (m *JSONWebSignature2020Proof) MarshalTo(dAtA []byte) (int, error)

func (*JSONWebSignature2020Proof) MarshalToSizedBuffer

func (m *JSONWebSignature2020Proof) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*JSONWebSignature2020Proof) ProtoMessage

func (*JSONWebSignature2020Proof) ProtoMessage()

func (*JSONWebSignature2020Proof) Reset

func (m *JSONWebSignature2020Proof) Reset()

func (*JSONWebSignature2020Proof) Size

func (m *JSONWebSignature2020Proof) Size() (n int)

func (*JSONWebSignature2020Proof) String

func (m *JSONWebSignature2020Proof) String() string

func (*JSONWebSignature2020Proof) Unmarshal

func (m *JSONWebSignature2020Proof) Unmarshal(dAtA []byte) error

func (*JSONWebSignature2020Proof) XXX_DiscardUnknown

func (m *JSONWebSignature2020Proof) XXX_DiscardUnknown()

func (*JSONWebSignature2020Proof) XXX_Marshal

func (m *JSONWebSignature2020Proof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*JSONWebSignature2020Proof) XXX_Merge

func (m *JSONWebSignature2020Proof) XXX_Merge(src proto.Message)

func (*JSONWebSignature2020Proof) XXX_Size

func (m *JSONWebSignature2020Proof) XXX_Size() int

func (*JSONWebSignature2020Proof) XXX_Unmarshal

func (m *JSONWebSignature2020Proof) XXX_Unmarshal(b []byte) error

type KeyType

type KeyType int32

KeyType is the type of key used to sign a DID document.

const (
	// No key type specified
	KeyType_KeyType_UNSPECIFIED KeyType = 0
	// JsonWebKey2020 is a VerificationMethod type. https://w3c-ccg.github.io/lds-jws2020/
	KeyType_KeyType_JSON_WEB_KEY_2020 KeyType = 1
	// ED25519VerificationKey2018 is the Ed25519VerificationKey2018 verification key type as specified here: https://w3c-ccg.github.io/lds-ed25519-2018/
	KeyType_KeyType_ED25519_VERIFICATION_KEY_2018 KeyType = 2
	// ECDSASECP256K1VerificationKey2019 is the EcdsaSecp256k1VerificationKey2019 verification key type as specified here: https://w3c-ccg.github.io/lds-ecdsa-secp256k1-2019/
	KeyType_KeyType_ECDSA_SECP256K1_VERIFICATION_KEY_2019 KeyType = 3
	// RSAVerificationKey2018 is the RsaVerificationKey2018 verification key type as specified here: https://w3c-ccg.github.io/lds-rsa2018/
	KeyType_KeyType_RSA_VERIFICATION_KEY_2018 KeyType = 4
	// WebAuthnAuthentication2018 is the WebAuthnAuthentication2018 verification key type as specified here: https://w3c-ccg.github.io/lds-webauthn/
	KeyType_KeyType_WEB_AUTHN_AUTHENTICATION_2018 KeyType = 5
)

func KeyTypeFromMulticodec

func KeyTypeFromMulticodec(code uint64) (KeyType, error)

KeyTypeFromMulticodec returns the key type

func KeyTypeFromPrettyString

func KeyTypeFromPrettyString(s string) (KeyType, error)

KeyTypeFromPrettyString returns the key type

func (KeyType) EnumDescriptor

func (KeyType) EnumDescriptor() ([]byte, []int)

func (KeyType) FormatString

func (kt KeyType) FormatString() string

func (KeyType) IsBlockchainKey added in v0.5.0

func (kt KeyType) IsBlockchainKey() bool

IsBlockchainKey returns true if the key is a edsa or secp256k1 key

func (KeyType) IsWebAuthnKey added in v0.5.0

func (kt KeyType) IsWebAuthnKey() bool

IsWebAuthnKey returns true if the key is a webauthn key

func (KeyType) MulticodecType

func (kt KeyType) MulticodecType() uint64

-- We represent those as raw public key bytes prefixed with public key -- multiformat code. | secp256k1 "0xe7" | Ed25519 "0xed" | P256 "0x1200" | P384 "0x1201" | P512 "0x1202" | RSA "0x1205"

MulticodecType returns the multicodec code for the key type

func (KeyType) PrettyString

func (kt KeyType) PrettyString() string

PrettyString returns the string representation of the key type

func (KeyType) String

func (x KeyType) String() string

type Proof

type Proof struct {
	// Type defines the specific proof type used. For example, an Ed25519Signature2018 type indicates that the proof includes a digital signature produced by an ed25519 cryptographic key.
	Type ProofType `protobuf:"varint,1,opt,name=type,proto3,enum=sonrhq.sonr.crypto.ProofType" json:"type,omitempty"`
	// ProofPurpose defines the intent for the proof, the reason why an entity created it. Acts as a safeguard to prevent the proof from being misused for a purpose other than the one it was intended for.
	ProofPurpose string `protobuf:"bytes,2,opt,name=proof_purpose,json=proofPurpose,proto3" json:"proof_purpose,omitempty"`
	// VerificationMethod points to the ID that can be used to verify the proof, eg: a public key.
	VerificationMethod string `protobuf:"bytes,3,opt,name=verification_method,json=verificationMethod,proto3" json:"verification_method,omitempty"`
	// Created notes when the proof was created using a iso8601 string
	Created string `protobuf:"bytes,4,opt,name=created,proto3" json:"created,omitempty"`
	// Domain specifies the restricted domain of the proof
	Domain string `protobuf:"bytes,5,opt,name=domain,proto3" json:"domain,omitempty"`
}

Proof represents a credential/presentation proof as defined by the Linked Data Proofs 1.0 specification (https://w3c-ccg.github.io/ld-proofs/).

func (*Proof) Descriptor

func (*Proof) Descriptor() ([]byte, []int)

func (*Proof) GetCreated

func (m *Proof) GetCreated() string

func (*Proof) GetDomain

func (m *Proof) GetDomain() string

func (*Proof) GetProofPurpose

func (m *Proof) GetProofPurpose() string

func (*Proof) GetType

func (m *Proof) GetType() ProofType

func (*Proof) GetVerificationMethod

func (m *Proof) GetVerificationMethod() string

func (*Proof) Marshal

func (m *Proof) Marshal() (dAtA []byte, err error)

func (*Proof) MarshalTo

func (m *Proof) MarshalTo(dAtA []byte) (int, error)

func (*Proof) MarshalToSizedBuffer

func (m *Proof) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Proof) ProtoMessage

func (*Proof) ProtoMessage()

func (*Proof) Reset

func (m *Proof) Reset()

func (*Proof) Size

func (m *Proof) Size() (n int)

func (*Proof) String

func (m *Proof) String() string

func (*Proof) Unmarshal

func (m *Proof) Unmarshal(dAtA []byte) error

func (*Proof) XXX_DiscardUnknown

func (m *Proof) XXX_DiscardUnknown()

func (*Proof) XXX_Marshal

func (m *Proof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Proof) XXX_Merge

func (m *Proof) XXX_Merge(src proto.Message)

func (*Proof) XXX_Size

func (m *Proof) XXX_Size() int

func (*Proof) XXX_Unmarshal

func (m *Proof) XXX_Unmarshal(b []byte) error

type ProofType

type ProofType int32

ProofType is the type of proof used to present claims over a DID document.

const (
	// No proof type specified
	ProofType_ProofType_UNSPECIFIED ProofType = 0
	// JsonWebSignature2020 is a proof type. https://w3c-ccg.github.io/lds-jws2020/
	ProofType_ProofType_JSON_WEB_SIGNATURE_2020 ProofType = 1
	// ED25519Signature2018 is the Ed25519Signature2018 proof type as specified here: https://w3c-ccg.github.io/lds-ed25519-2018/
	ProofType_ProofType_ED25519_SIGNATURE_2018 ProofType = 2
	// EcdsaSecp256k1Signature2019 is the EcdsaSecp256k1Signature2019 proof type as specified here: https://w3c-ccg.github.io/lds-ecdsa-secp256k1-2019/
	ProofType_ProofType_ECDSA_SECP256K1_SIGNATURE_2019 ProofType = 3
	// RsaSignature2018 is the RsaSignature2018 proof type as specified here: https://w3c-ccg.github.io/lds-rsa2018/
	ProofType_ProofType_RSA_SIGNATURE_2018 ProofType = 4
)

func (ProofType) EnumDescriptor

func (ProofType) EnumDescriptor() ([]byte, []int)

func (ProofType) FormatString

func (kt ProofType) FormatString() string

func (ProofType) String

func (x ProofType) String() string

type PubKey

type PubKey struct {
	Key     []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	KeyType string `protobuf:"bytes,2,opt,name=key_type,json=keyType,proto3" json:"key_type,omitempty"`
}

func NewPubKey

func NewPubKey(bz []byte, kt KeyType) *PubKey

NewPubKey takes a byte array and returns a PubKey

func (*PubKey) Address

func (pk *PubKey) Address() Address

Creating a new method called Address() that returns an Address type.

func (*PubKey) Base64 added in v0.5.0

func (pk *PubKey) Base64() string

Base64 returns the base64 encoding of the key.

func (*PubKey) Blake3 added in v0.5.0

func (pk *PubKey) Blake3() string

Blake3 returns the blake3 hash of the key.

func (*PubKey) Btcec added in v0.5.0

func (pk *PubKey) Btcec() (*btcec.PublicKey, error)

Btcec returns the btcec public key.

func (*PubKey) Bytes

func (pk *PubKey) Bytes() []byte

Returning the key in bytes.

func (*PubKey) Descriptor

func (*PubKey) Descriptor() ([]byte, []int)

func (*PubKey) Equals

func (pk *PubKey) Equals(other cryptotypes.PubKey) bool

Comparing the two keys.

func (*PubKey) GetKey

func (m *PubKey) GetKey() []byte

func (*PubKey) GetKeyType

func (m *PubKey) GetKeyType() string

func (*PubKey) Marshal

func (m *PubKey) Marshal() (dAtA []byte, err error)

func (*PubKey) MarshalTo

func (m *PubKey) MarshalTo(dAtA []byte) (int, error)

func (*PubKey) MarshalToSizedBuffer

func (m *PubKey) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PubKey) Multibase

func (pk *PubKey) Multibase() string

Multibase returns the Base58 encoding the key.

func (*PubKey) ProtoMessage

func (*PubKey) ProtoMessage()

func (*PubKey) Raw

func (pk *PubKey) Raw() []byte

Raw returns the raw key without the type.

func (*PubKey) Reset

func (m *PubKey) Reset()

func (*PubKey) Secp256k1 added in v0.5.0

func (pk *PubKey) Secp256k1() (*secp256k1.PubKey, error)

Returning the secp256k1 public key.

func (*PubKey) Size

func (m *PubKey) Size() (n int)

func (*PubKey) String

func (m *PubKey) String() string

func (*PubKey) Type

func (pk *PubKey) Type() string

Returning the type of the key.

func (*PubKey) Unmarshal

func (m *PubKey) Unmarshal(dAtA []byte) error

func (*PubKey) VerifySignature

func (pk *PubKey) VerifySignature(msg []byte, sig []byte) bool

Verifying the signature of the message.

func (*PubKey) XXX_DiscardUnknown

func (m *PubKey) XXX_DiscardUnknown()

func (*PubKey) XXX_Marshal

func (m *PubKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PubKey) XXX_Merge

func (m *PubKey) XXX_Merge(src proto.Message)

func (*PubKey) XXX_Size

func (m *PubKey) XXX_Size() int

func (*PubKey) XXX_Unmarshal

func (m *PubKey) XXX_Unmarshal(b []byte) error

type ServiceType

type ServiceType int32

ServiceType is the type of service used to provide a DID document.

const (
	// No service type specified
	ServiceType_ServiceType_UNSPECIFIED ServiceType = 0
	// DIDCommMessaging is the DIDCommMessaging service type as specified here: https://identity.foundation/didcomm-messaging/spec/
	ServiceType_ServiceType_DID_COMM_MESSAGING ServiceType = 1
	// EncryptedDataVault is the EncryptedDataVault service type as specified here: https://identity.foundation/edv-spec/
	ServiceType_ServiceType_ENCRYPTED_DATA_VAULT ServiceType = 2
	// LinkedDomains is the LinkedDomains service type as specified here: https://identity.foundation/linked-domains/
	ServiceType_ServiceType_LINKED_DOMAINS ServiceType = 3
)

func (ServiceType) EnumDescriptor

func (ServiceType) EnumDescriptor() ([]byte, []int)

func (ServiceType) FormatString

func (kt ServiceType) FormatString() string

func (ServiceType) String

func (x ServiceType) String() string

type VerifiableCredential

type VerifiableCredential struct {
	// ID is the unique identifier for the credential.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// Context is a list of URIs that define the context of the credential.
	Context []string `protobuf:"bytes,2,rep,name=context,proto3" json:"context,omitempty"`
	// Type is a list of URIs that define the type of the credential.
	Type []string `protobuf:"bytes,3,rep,name=type,proto3" json:"type,omitempty"`
	// Issuer is the DID of the issuer of the credential.
	Issuer string `protobuf:"bytes,4,opt,name=issuer,proto3" json:"issuer,omitempty"`
	// IssuanceDate is the date the credential was issued.
	IssuanceDate string `protobuf:"bytes,5,opt,name=issuance_date,json=issuanceDate,proto3" json:"issuance_date,omitempty"`
	// ExpirationDate is the date the credential expires.
	ExpirationDate string `protobuf:"bytes,6,opt,name=expiration_date,json=expirationDate,proto3" json:"expiration_date,omitempty"`
	// CredentialSubject is the subject of the credential.
	CredentialSubject map[string]string `` /* 200-byte string literal not displayed */
	// Proof is the proof of the credential.
	Proof map[string]string `` /* 151-byte string literal not displayed */
}

VerifiableCredential represents a credential as defined by the Verifiable Credentials Data Model 1.0 specification (https://www.w3.org/TR/vc-data-model/).

func (*VerifiableCredential) Descriptor

func (*VerifiableCredential) Descriptor() ([]byte, []int)

func (*VerifiableCredential) GetContext

func (m *VerifiableCredential) GetContext() []string

func (*VerifiableCredential) GetCredentialSubject

func (m *VerifiableCredential) GetCredentialSubject() map[string]string

func (*VerifiableCredential) GetExpirationDate

func (m *VerifiableCredential) GetExpirationDate() string

func (*VerifiableCredential) GetId

func (m *VerifiableCredential) GetId() string

func (*VerifiableCredential) GetIssuanceDate

func (m *VerifiableCredential) GetIssuanceDate() string

func (*VerifiableCredential) GetIssuer

func (m *VerifiableCredential) GetIssuer() string

func (*VerifiableCredential) GetProof

func (m *VerifiableCredential) GetProof() map[string]string

func (*VerifiableCredential) GetType

func (m *VerifiableCredential) GetType() []string

func (*VerifiableCredential) Marshal

func (m *VerifiableCredential) Marshal() (dAtA []byte, err error)

func (*VerifiableCredential) MarshalTo

func (m *VerifiableCredential) MarshalTo(dAtA []byte) (int, error)

func (*VerifiableCredential) MarshalToSizedBuffer

func (m *VerifiableCredential) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*VerifiableCredential) ProtoMessage

func (*VerifiableCredential) ProtoMessage()

func (*VerifiableCredential) Reset

func (m *VerifiableCredential) Reset()

func (*VerifiableCredential) Size

func (m *VerifiableCredential) Size() (n int)

func (*VerifiableCredential) String

func (m *VerifiableCredential) String() string

func (*VerifiableCredential) Unmarshal

func (m *VerifiableCredential) Unmarshal(dAtA []byte) error

func (*VerifiableCredential) XXX_DiscardUnknown

func (m *VerifiableCredential) XXX_DiscardUnknown()

func (*VerifiableCredential) XXX_Marshal

func (m *VerifiableCredential) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*VerifiableCredential) XXX_Merge

func (m *VerifiableCredential) XXX_Merge(src proto.Message)

func (*VerifiableCredential) XXX_Size

func (m *VerifiableCredential) XXX_Size() int

func (*VerifiableCredential) XXX_Unmarshal

func (m *VerifiableCredential) XXX_Unmarshal(b []byte) error

type WebauthnAuthenticator

type WebauthnAuthenticator struct {
	// The AAGUID of the authenticator. An AAGUID is defined as an array containing the globally unique
	// identifier of the authenticator model being sought.
	Aaguid []byte `protobuf:"bytes,1,opt,name=aaguid,proto3" json:"aaguid,omitempty"`
	// SignCount -Upon a new login operation, the Relying Party compares the stored signature counter value
	// with the new signCount value returned in the assertion’s authenticator data. If this new
	// signCount value is less than or equal to the stored value, a cloned authenticator may
	// exist, or the authenticator may be malfunctioning.
	SignCount uint32 `protobuf:"varint,2,opt,name=sign_count,json=signCount,proto3" json:"sign_count,omitempty"`
	// CloneWarning - This is a signal that the authenticator may be cloned, i.e. at least two copies of the
	// credential private key may exist and are being used in parallel. Relying Parties should incorporate
	// this information into their risk scoring. Whether the Relying Party updates the stored signature
	// counter value in this case, or not, or fails the authentication ceremony or not, is Relying Party-specific.
	CloneWarning bool `protobuf:"varint,3,opt,name=clone_warning,json=cloneWarning,proto3" json:"clone_warning,omitempty"`
}

WebauthnAuthenticator contains certificate information about a WebAuthn authenticator

func (*WebauthnAuthenticator) Descriptor

func (*WebauthnAuthenticator) Descriptor() ([]byte, []int)

func (*WebauthnAuthenticator) GetAaguid

func (m *WebauthnAuthenticator) GetAaguid() []byte

func (*WebauthnAuthenticator) GetCloneWarning

func (m *WebauthnAuthenticator) GetCloneWarning() bool

func (*WebauthnAuthenticator) GetSignCount

func (m *WebauthnAuthenticator) GetSignCount() uint32

func (*WebauthnAuthenticator) Marshal

func (m *WebauthnAuthenticator) Marshal() (dAtA []byte, err error)

func (*WebauthnAuthenticator) MarshalTo

func (m *WebauthnAuthenticator) MarshalTo(dAtA []byte) (int, error)

func (*WebauthnAuthenticator) MarshalToSizedBuffer

func (m *WebauthnAuthenticator) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*WebauthnAuthenticator) ProtoMessage

func (*WebauthnAuthenticator) ProtoMessage()

func (*WebauthnAuthenticator) Reset

func (m *WebauthnAuthenticator) Reset()

func (*WebauthnAuthenticator) Size

func (m *WebauthnAuthenticator) Size() (n int)

func (*WebauthnAuthenticator) String

func (m *WebauthnAuthenticator) String() string

func (*WebauthnAuthenticator) Unmarshal

func (m *WebauthnAuthenticator) Unmarshal(dAtA []byte) error

func (*WebauthnAuthenticator) UpdateCounter

func (a *WebauthnAuthenticator) UpdateCounter(authDataCount uint32)

VerifyCounter Step 17 of §7.2. about verifying attestation. If the signature counter value authData.signCount is nonzero or the value stored in conjunction with credential’s id attribute is nonzero, then run the following sub-step:

If the signature counter value authData.signCount is

→ Greater than the signature counter value stored in conjunction with credential’s id attribute.
Update the stored signature counter value, associated with credential’s id attribute, to be the value of
authData.signCount.

→ Less than or equal to the signature counter value stored in conjunction with credential’s id attribute.
This is a signal that the authenticator may be cloned, see CloneWarning above for more information.

func (*WebauthnAuthenticator) XXX_DiscardUnknown

func (m *WebauthnAuthenticator) XXX_DiscardUnknown()

func (*WebauthnAuthenticator) XXX_Marshal

func (m *WebauthnAuthenticator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*WebauthnAuthenticator) XXX_Merge

func (m *WebauthnAuthenticator) XXX_Merge(src proto.Message)

func (*WebauthnAuthenticator) XXX_Size

func (m *WebauthnAuthenticator) XXX_Size() int

func (*WebauthnAuthenticator) XXX_Unmarshal

func (m *WebauthnAuthenticator) XXX_Unmarshal(b []byte) error

type WebauthnCredential

type WebauthnCredential struct {
	// A probabilistically-unique byte sequence identifying a public key credential source and its authentication assertions.
	Id []byte `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// The public key portion of a Relying Party-specific credential key pair, generated by an authenticator and returned to
	// a Relying Party at registration time (see also public key credential). The private key portion of the credential key
	// pair is known as the credential private key. Note that in the case of self attestation, the credential key pair is also
	// used as the attestation key pair, see self attestation for details.
	PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
	// The attestation format used (if any) by the authenticator when creating the credential.
	AttestationType string `protobuf:"bytes,3,opt,name=attestation_type,json=attestationType,proto3" json:"attestation_type,omitempty"`
	// The transports used by the authenticator when creating the credential.
	Transport []string `protobuf:"bytes,4,rep,name=transport,proto3" json:"transport,omitempty"`
	// The Authenticator information for a given certificate
	Authenticator *WebauthnAuthenticator `protobuf:"bytes,5,opt,name=authenticator,proto3" json:"authenticator,omitempty"`
}

WebauthnCredential contains all needed information about a WebAuthn credential for storage

func ConvertStdCredential

func ConvertStdCredential(wa *webauthn.Credential) *WebauthnCredential

ConvertStdCredential creates a common.WebauthnCredential from a webauthn.Credential from the go-webauthn package

func CredentialFromDIDString added in v0.5.0

func CredentialFromDIDString(did string) (*WebauthnCredential, error)

CredentialFromDIDString converts a DID string into a WebauthnCredential

func (*WebauthnCredential) DID added in v0.4.4

func (c *WebauthnCredential) DID() string

Did returns the DID for a WebauthnCredential

func (*WebauthnCredential) Descriptor

func (*WebauthnCredential) Descriptor() ([]byte, []int)

func (*WebauthnCredential) FromMetadata

func (c *WebauthnCredential) FromMetadata(m map[string]string) error

FromMetadata converts a map[string]string into a common WebauthnCredential

func (*WebauthnCredential) GetAttestationType

func (m *WebauthnCredential) GetAttestationType() string

func (*WebauthnCredential) GetAuthenticator

func (m *WebauthnCredential) GetAuthenticator() *WebauthnAuthenticator

func (*WebauthnCredential) GetId

func (m *WebauthnCredential) GetId() []byte

func (*WebauthnCredential) GetPublicKey

func (m *WebauthnCredential) GetPublicKey() []byte

func (*WebauthnCredential) GetTransport

func (m *WebauthnCredential) GetTransport() []string

func (*WebauthnCredential) Marshal

func (m *WebauthnCredential) Marshal() (dAtA []byte, err error)

func (*WebauthnCredential) MarshalTo

func (m *WebauthnCredential) MarshalTo(dAtA []byte) (int, error)

func (*WebauthnCredential) MarshalToSizedBuffer

func (m *WebauthnCredential) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*WebauthnCredential) ProtoMessage

func (*WebauthnCredential) ProtoMessage()

func (*WebauthnCredential) PubKey added in v0.5.0

func (c *WebauthnCredential) PubKey() *PubKey

PublicKeyMultibase returns the public key in multibase format

func (*WebauthnCredential) Reset

func (m *WebauthnCredential) Reset()

func (*WebauthnCredential) Size

func (m *WebauthnCredential) Size() (n int)

func (*WebauthnCredential) String

func (m *WebauthnCredential) String() string

func (*WebauthnCredential) ToMetadata

func (c *WebauthnCredential) ToMetadata() map[string]string

ToMetadata converts a common WebauthnCredential into a map[string]string

func (*WebauthnCredential) ToStdCredential

func (c *WebauthnCredential) ToStdCredential() *webauthn.Credential

ToStdCredential converts a common WebauthnCredential to one that can be used for the go-webauthn package

func (*WebauthnCredential) Unmarshal

func (m *WebauthnCredential) Unmarshal(dAtA []byte) error

func (*WebauthnCredential) XXX_DiscardUnknown

func (m *WebauthnCredential) XXX_DiscardUnknown()

func (*WebauthnCredential) XXX_Marshal

func (m *WebauthnCredential) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*WebauthnCredential) XXX_Merge

func (m *WebauthnCredential) XXX_Merge(src proto.Message)

func (*WebauthnCredential) XXX_Size

func (m *WebauthnCredential) XXX_Size() int

func (*WebauthnCredential) XXX_Unmarshal

func (m *WebauthnCredential) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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