feature/migrate models (#16)

* feat: add new supported attestation formats to genesis

* feat: refactor keyType to keytype enum

* refactor: remove unused imports and code

* refactor: update main.go to use src package

* refactor: move web-related structs from  to

* refactor: move client middleware package to root

* refactor: remove unused IndexedDB dependency

* feat: update worker implementation to use

* feat: add Caddyfile and Caddy configuration for vault service

* refactor(config): move keyshare and address to Motr config

* fix: validate service origin in AllocateVault

* chore: remove IndexedDB configuration

* feat: add support for IPNS-based vault access
This commit is contained in:
Prad Nukala
2024-09-19 02:04:22 -04:00
committed by GitHub
parent 6d8bd8fc85
commit 96e6486c43
151 changed files with 10997 additions and 21705 deletions
-226
View File
@@ -1,226 +0,0 @@
package builder
import (
"encoding/base64"
"fmt"
"github.com/go-webauthn/webauthn/protocol"
"github.com/go-webauthn/webauthn/protocol/webauthncose"
didv1 "github.com/onsonr/sonr/api/did/v1"
"github.com/onsonr/sonr/x/did/types"
)
func APIFormatDIDNamespace(namespace types.DIDNamespace) didv1.DIDNamespace {
return didv1.DIDNamespace(namespace)
}
func APIFormatDIDNamespaces(namespaces []types.DIDNamespace) []didv1.DIDNamespace {
var s []didv1.DIDNamespace
for _, namespace := range namespaces {
s = append(s, APIFormatDIDNamespace(namespace))
}
return s
}
func APIFormatKeyRole(role types.KeyRole) didv1.KeyRole {
return didv1.KeyRole(role)
}
func APIFormatKeyAlgorithm(algorithm types.KeyAlgorithm) didv1.KeyAlgorithm {
return didv1.KeyAlgorithm(algorithm)
}
func APIFormatKeyEncoding(encoding types.KeyEncoding) didv1.KeyEncoding {
return didv1.KeyEncoding(encoding)
}
func APIFormatKeyCurve(curve types.KeyCurve) didv1.KeyCurve {
return didv1.KeyCurve(curve)
}
func APIFormatKeyType(keyType types.KeyType) didv1.KeyType {
return didv1.KeyType(keyType)
}
func APIFormatPermissions(permissions *types.Permissions) *didv1.Permissions {
if permissions == nil {
return nil
}
p := didv1.Permissions{
Grants: APIFormatDIDNamespaces(permissions.Grants),
Scopes: APIFormatPermissionScopes(permissions.Scopes),
}
return &p
}
func APIFormatPermissionScope(scope types.PermissionScope) didv1.PermissionScope {
return didv1.PermissionScope(scope)
}
func APIFormatPermissionScopes(scopes []types.PermissionScope) []didv1.PermissionScope {
var s []didv1.PermissionScope
for _, scope := range scopes {
s = append(s, APIFormatPermissionScope(scope))
}
return s
}
func APIFormatPubKeyJWK(jwk *types.PubKey_JWK) *didv1.PubKey_JWK {
return &didv1.PubKey_JWK{
Kty: jwk.Kty,
Crv: jwk.Crv,
X: jwk.X,
Y: jwk.Y,
N: jwk.N,
E: jwk.E,
}
}
func APIFormatPubKey(key *types.PubKey) *didv1.PubKey {
return &didv1.PubKey{
Role: APIFormatKeyRole(key.GetRole()),
Algorithm: APIFormatKeyAlgorithm(key.GetAlgorithm()),
Encoding: APIFormatKeyEncoding(key.GetEncoding()),
Curve: APIFormatKeyCurve(key.GetCurve()),
KeyType: APIFormatKeyType(key.GetKeyType()),
Raw: key.GetRaw(),
}
}
func FormatEC2PublicKey(key *webauthncose.EC2PublicKeyData) (*types.PubKey_JWK, error) {
curve, err := GetCOSECurveName(key.Curve)
if err != nil {
return nil, err
}
jwkMap := map[string]interface{}{
"kty": "EC",
"crv": curve,
"x": base64.RawURLEncoding.EncodeToString(key.XCoord),
"y": base64.RawURLEncoding.EncodeToString(key.YCoord),
}
return MapToJWK(jwkMap)
}
func FormatRSAPublicKey(key *webauthncose.RSAPublicKeyData) (*types.PubKey_JWK, error) {
jwkMap := map[string]interface{}{
"kty": "RSA",
"n": base64.RawURLEncoding.EncodeToString(key.Modulus),
"e": base64.RawURLEncoding.EncodeToString(key.Exponent),
}
return MapToJWK(jwkMap)
}
func FormatOKPPublicKey(key *webauthncose.OKPPublicKeyData) (*types.PubKey_JWK, error) {
curve, err := GetOKPCurveName(key.Curve)
if err != nil {
return nil, err
}
jwkMap := map[string]interface{}{
"kty": "OKP",
"crv": curve,
"x": base64.RawURLEncoding.EncodeToString(key.XCoord),
}
return MapToJWK(jwkMap)
}
func MapToJWK(m map[string]interface{}) (*types.PubKey_JWK, error) {
jwk := &types.PubKey_JWK{}
for k, v := range m {
switch k {
case "kty":
jwk.Kty = v.(string)
case "crv":
jwk.Crv = v.(string)
case "x":
jwk.X = v.(string)
case "y":
jwk.Y = v.(string)
case "n":
jwk.N = v.(string)
case "e":
jwk.E = v.(string)
}
}
return jwk, nil
}
func GetCOSECurveName(curveID int64) (string, error) {
switch curveID {
case int64(webauthncose.P256):
return "P-256", nil
case int64(webauthncose.P384):
return "P-384", nil
case int64(webauthncose.P521):
return "P-521", nil
default:
return "", fmt.Errorf("unknown curve ID: %d", curveID)
}
}
func GetOKPCurveName(curveID int64) (string, error) {
switch curveID {
case int64(webauthncose.Ed25519):
return "Ed25519", nil
default:
return "", fmt.Errorf("unknown OKP curve ID: %d", curveID)
}
}
// NormalizeTransports returns the transports as strings
func NormalizeTransports(transports []protocol.AuthenticatorTransport) []string {
tss := make([]string, len(transports))
for i, t := range transports {
tss[i] = string(t)
}
return tss
}
// GetTransports returns the protocol.AuthenticatorTransport
func ModuleTransportsToProtocol(transport []string) []protocol.AuthenticatorTransport {
tss := make([]protocol.AuthenticatorTransport, len(transport))
for i, t := range transport {
tss[i] = protocol.AuthenticatorTransport(t)
}
return tss
}
func ModuleFormatAPIPermissions(permissions *didv1.Permissions) *types.Permissions {
if permissions == nil {
return nil
}
p := types.Permissions{
Grants: ModuleFormatAPIDIDNamespaces(permissions.Grants),
Scopes: ModuleFormatAPIPermissionScopes(permissions.Scopes),
}
return &p
}
func ModuleFormatAPIPermissionScope(scope didv1.PermissionScope) types.PermissionScope {
return types.PermissionScope(scope)
}
func ModuleFormatAPIPermissionScopes(scopes []didv1.PermissionScope) []types.PermissionScope {
var s []types.PermissionScope
for _, scope := range scopes {
s = append(s, ModuleFormatAPIPermissionScope(scope))
}
return s
}
func ModuleFormatAPIDIDNamespace(namespace didv1.DIDNamespace) types.DIDNamespace {
return types.DIDNamespace(namespace)
}
func ModuleFormatAPIDIDNamespaces(namespaces []didv1.DIDNamespace) []types.DIDNamespace {
var s []types.DIDNamespace
for _, namespace := range namespaces {
s = append(s, ModuleFormatAPIDIDNamespace(namespace))
}
return s
}
-70
View File
@@ -1,70 +0,0 @@
package builder
import (
"crypto/hmac"
"crypto/sha512"
"encoding/binary"
"errors"
"math/big"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/onsonr/sonr/x/did/types"
)
// ComputeAccountPublicKey computes the public key of a child key given the extended public key, chain code, and index.
func computeBip32AccountPublicKey(extPubKey PublicKey, chainCode types.ChainCode, index int) (*types.PubKey, error) {
// Check if the index is a hardened child key
if chainCode&0x80000000 != 0 && index < 0 {
return nil, errors.New("invalid index")
}
// Serialize the public key
pubKey, err := btcec.ParsePubKey(extPubKey.GetRaw())
if err != nil {
return nil, err
}
pubKeyBytes := pubKey.SerializeCompressed()
// Serialize the index
indexBytes := make([]byte, 4)
binary.BigEndian.PutUint32(indexBytes, uint32(index))
// Compute the HMAC-SHA512
mac := hmac.New(sha512.New, []byte{byte(chainCode)})
mac.Write(pubKeyBytes)
mac.Write(indexBytes)
I := mac.Sum(nil)
// Split I into two 32-byte sequences
IL := I[:32]
// Convert IL to a big integer
ilNum := new(big.Int).SetBytes(IL)
// Check if parse256(IL) >= n
curve := btcec.S256()
if ilNum.Cmp(curve.N) >= 0 {
return nil, errors.New("invalid child key")
}
// Compute the child public key
ilx, ily := curve.ScalarBaseMult(IL)
childX, childY := curve.Add(ilx, ily, pubKey.X(), pubKey.Y())
lx := newBigIntFieldVal(childX)
ly := newBigIntFieldVal(childY)
// Create the child public key
childPubKey := btcec.NewPublicKey(lx, ly)
pk, err := types.NewPublicKey(childPubKey.SerializeCompressed(), types.ChainCodeKeyInfos[chainCode])
if err != nil {
return nil, err
}
return pk, nil
}
// newBigIntFieldVal creates a new field value from a big integer.
func newBigIntFieldVal(val *big.Int) *btcec.FieldVal {
lx := new(btcec.FieldVal)
lx.SetByteSlice(val.Bytes())
return lx
}
-334
View File
@@ -1,334 +0,0 @@
package builder
import (
"github.com/onsonr/sonr/x/did/types"
)
type (
AuthenticatorAttachment string
AuthenticatorTransport string
)
const (
// Platform represents a platform authenticator is attached using a client device-specific transport, called
// platform attachment, and is usually not removable from the client device. A public key credential bound to a
// platform authenticator is called a platform credential.
Platform AuthenticatorAttachment = "platform"
// CrossPlatform represents a roaming authenticator is attached using cross-platform transports, called
// cross-platform attachment. Authenticators of this class are removable from, and can "roam" among, client devices.
// A public key credential bound to a roaming authenticator is called a roaming credential.
CrossPlatform AuthenticatorAttachment = "cross-platform"
)
func ParseAuthenticatorAttachment(s string) AuthenticatorAttachment {
switch s {
case "platform":
return Platform
default:
return CrossPlatform
}
}
const (
// USB indicates the respective authenticator can be contacted over removable USB.
USB AuthenticatorTransport = "usb"
// NFC indicates the respective authenticator can be contacted over Near Field Communication (NFC).
NFC AuthenticatorTransport = "nfc"
// BLE indicates the respective authenticator can be contacted over Bluetooth Smart (Bluetooth Low Energy / BLE).
BLE AuthenticatorTransport = "ble"
// SmartCard indicates the respective authenticator can be contacted over ISO/IEC 7816 smart card with contacts.
//
// WebAuthn Level 3.
SmartCard AuthenticatorTransport = "smart-card"
// Hybrid indicates the respective authenticator can be contacted using a combination of (often separate)
// data-transport and proximity mechanisms. This supports, for example, authentication on a desktop computer using
// a smartphone.
//
// WebAuthn Level 3.
Hybrid AuthenticatorTransport = "hybrid"
// Internal indicates the respective authenticator is contacted using a client device-specific transport, i.e., it
// is a platform authenticator. These authenticators are not removable from the client device.
Internal AuthenticatorTransport = "internal"
)
func ParseAuthenticatorTransport(s string) AuthenticatorTransport {
switch s {
case "usb":
return USB
case "nfc":
return NFC
case "ble":
return BLE
case "smart-card":
return SmartCard
case "hybrid":
return Hybrid
default:
return Internal
}
}
type AuthenticatorFlags byte
const (
// FlagUserPresent Bit 00000001 in the byte sequence. Tells us if user is present. Also referred to as the UP flag.
FlagUserPresent AuthenticatorFlags = 1 << iota // Referred to as UP
// FlagRFU1 is a reserved for future use flag.
FlagRFU1
// FlagUserVerified Bit 00000100 in the byte sequence. Tells us if user is verified
// by the authenticator using a biometric or PIN. Also referred to as the UV flag.
FlagUserVerified
// FlagBackupEligible Bit 00001000 in the byte sequence. Tells us if a backup is eligible for device. Also referred
// to as the BE flag.
FlagBackupEligible // Referred to as BE
// FlagBackupState Bit 00010000 in the byte sequence. Tells us if a backup state for device. Also referred to as the
// BS flag.
FlagBackupState
// FlagRFU2 is a reserved for future use flag.
FlagRFU2
// FlagAttestedCredentialData Bit 01000000 in the byte sequence. Indicates whether
// the authenticator added attested credential data. Also referred to as the AT flag.
FlagAttestedCredentialData
// FlagHasExtensions Bit 10000000 in the byte sequence. Indicates if the authenticator data has extensions. Also
// referred to as the ED flag.
FlagHasExtensions
)
type AttestationFormat string
const (
// AttestationFormatPacked is the "packed" attestation statement format is a WebAuthn-optimized format for
// attestation. It uses a very compact but still extensible encoding method. This format is implementable by
// authenticators with limited resources (e.g., secure elements).
AttestationFormatPacked AttestationFormat = "packed"
// AttestationFormatTPM is the TPM attestation statement format returns an attestation statement in the same format
// as the packed attestation statement format, although the rawData and signature fields are computed differently.
AttestationFormatTPM AttestationFormat = "tpm"
// AttestationFormatAndroidKey is the attestation statement format for platform authenticators on versions "N", and
// later, which may provide this proprietary "hardware attestation" statement.
AttestationFormatAndroidKey AttestationFormat = "android-key"
// AttestationFormatAndroidSafetyNet is the attestation statement format that Android-based platform authenticators
// MAY produce an attestation statement based on the Android SafetyNet API.
AttestationFormatAndroidSafetyNet AttestationFormat = "android-safetynet"
// AttestationFormatFIDOUniversalSecondFactor is the attestation statement format that is used with FIDO U2F
// authenticators.
AttestationFormatFIDOUniversalSecondFactor AttestationFormat = "fido-u2f"
// AttestationFormatApple is the attestation statement format that is used with Apple devices' platform
// authenticators.
AttestationFormatApple AttestationFormat = "apple"
// AttestationFormatNone is the attestation statement format that is used to replace any authenticator-provided
// attestation statement when a WebAuthn Relying Party indicates it does not wish to receive attestation information.
AttestationFormatNone AttestationFormat = "none"
)
func ExtractAttestationFormats(p *types.Params) []AttestationFormat {
var formats []AttestationFormat
for _, v := range p.AttestationFormats {
formats = append(formats, parseAttestationFormat(v))
}
return formats
}
func parseAttestationFormat(s string) AttestationFormat {
switch s {
case "packed":
return AttestationFormatPacked
case "tpm":
return AttestationFormatTPM
case "android-key":
return AttestationFormatAndroidKey
case "android-safetynet":
return AttestationFormatAndroidSafetyNet
case "fido-u2f":
return AttestationFormatFIDOUniversalSecondFactor
case "apple":
return AttestationFormatApple
case "none":
return AttestationFormatNone
default:
return AttestationFormatPacked
}
}
type CredentialType string
const (
CredentialTypePublicKeyCredential CredentialType = "public-key"
)
type ConveyancePreference string
const (
// PreferNoAttestation is a ConveyancePreference value.
//
// This value indicates that the Relying Party is not interested in authenticator attestation. For example, in order
// to potentially avoid having to obtain user consent to relay identifying information to the Relying Party, or to
// save a round trip to an Attestation CA or Anonymization CA.
//
// This is the default value.
//
// Specification: §5.4.7. Attestation Conveyance Preference Enumeration (https://www.w3.org/TR/webauthn/#dom-attestationconveyancepreference-none)
PreferNoAttestation ConveyancePreference = "none"
// PreferIndirectAttestation is a ConveyancePreference value.
//
// This value indicates that the Relying Party prefers an attestation conveyance yielding verifiable attestation
// statements, but allows the client to decide how to obtain such attestation statements. The client MAY replace the
// authenticator-generated attestation statements with attestation statements generated by an Anonymization CA, in
// order to protect the users privacy, or to assist Relying Parties with attestation verification in a
// heterogeneous ecosystem.
//
// Note: There is no guarantee that the Relying Party will obtain a verifiable attestation statement in this case.
// For example, in the case that the authenticator employs self attestation.
//
// Specification: §5.4.7. Attestation Conveyance Preference Enumeration (https://www.w3.org/TR/webauthn/#dom-attestationconveyancepreference-indirect)
PreferIndirectAttestation ConveyancePreference = "indirect"
// PreferDirectAttestation is a ConveyancePreference value.
//
// This value indicates that the Relying Party wants to receive the attestation statement as generated by the
// authenticator.
//
// Specification: §5.4.7. Attestation Conveyance Preference Enumeration (https://www.w3.org/TR/webauthn/#dom-attestationconveyancepreference-direct)
PreferDirectAttestation ConveyancePreference = "direct"
// PreferEnterpriseAttestation is a ConveyancePreference value.
//
// This value indicates that the Relying Party wants to receive an attestation statement that may include uniquely
// identifying information. This is intended for controlled deployments within an enterprise where the organization
// wishes to tie registrations to specific authenticators. User agents MUST NOT provide such an attestation unless
// the user agent or authenticator configuration permits it for the requested RP ID.
//
// If permitted, the user agent SHOULD signal to the authenticator (at invocation time) that enterprise
// attestation is requested, and convey the resulting AAGUID and attestation statement, unaltered, to the Relying
// Party.
//
// Specification: §5.4.7. Attestation Conveyance Preference Enumeration (https://www.w3.org/TR/webauthn/#dom-attestationconveyancepreference-enterprise)
PreferEnterpriseAttestation ConveyancePreference = "enterprise"
)
func ExtractConveyancePreference(p *types.Params) ConveyancePreference {
switch p.ConveyancePreference {
case "none":
return PreferNoAttestation
case "indirect":
return PreferIndirectAttestation
case "direct":
return PreferDirectAttestation
case "enterprise":
return PreferEnterpriseAttestation
default:
return PreferNoAttestation
}
}
type PublicKeyCredentialHints string
const (
// PublicKeyCredentialHintSecurityKey is a PublicKeyCredentialHint that indicates that the Relying Party believes
// that users will satisfy this request with a physical security key. For example, an enterprise Relying Party may
// set this hint if they have issued security keys to their employees and will only accept those authenticators for
// registration and authentication.
//
// For compatibility with older user agents, when this hint is used in PublicKeyCredentialCreationOptions, the
// authenticatorAttachment SHOULD be set to cross-platform.
PublicKeyCredentialHintSecurityKey PublicKeyCredentialHints = "security-key"
// PublicKeyCredentialHintClientDevice is a PublicKeyCredentialHint that indicates that the Relying Party believes
// that users will satisfy this request with a platform authenticator attached to the client device.
//
// For compatibility with older user agents, when this hint is used in PublicKeyCredentialCreationOptions, the
// authenticatorAttachment SHOULD be set to platform.
PublicKeyCredentialHintClientDevice PublicKeyCredentialHints = "client-device"
// PublicKeyCredentialHintHybrid is a PublicKeyCredentialHint that indicates that the Relying Party believes that
// users will satisfy this request with general-purpose authenticators such as smartphones. For example, a consumer
// Relying Party may believe that only a small fraction of their customers possesses dedicated security keys. This
// option also implies that the local platform authenticator should not be promoted in the UI.
//
// For compatibility with older user agents, when this hint is used in PublicKeyCredentialCreationOptions, the
// authenticatorAttachment SHOULD be set to cross-platform.
PublicKeyCredentialHintHybrid PublicKeyCredentialHints = "hybrid"
)
func ParsePublicKeyCredentialHints(s string) PublicKeyCredentialHints {
switch s {
case "security-key":
return PublicKeyCredentialHintSecurityKey
case "client-device":
return PublicKeyCredentialHintClientDevice
case "hybrid":
return PublicKeyCredentialHintHybrid
default:
return ""
}
}
type AttestedCredentialData struct {
AAGUID []byte `json:"aaguid"`
CredentialID []byte `json:"credential_id"`
// The raw credential public key bytes received from the attestation data.
CredentialPublicKey []byte `json:"public_key"`
}
type ResidentKeyRequirement string
const (
// ResidentKeyRequirementDiscouraged indicates the Relying Party prefers creating a server-side credential, but will
// accept a client-side discoverable credential. This is the default.
ResidentKeyRequirementDiscouraged ResidentKeyRequirement = "discouraged"
// ResidentKeyRequirementPreferred indicates to the client we would prefer a discoverable credential.
ResidentKeyRequirementPreferred ResidentKeyRequirement = "preferred"
// ResidentKeyRequirementRequired indicates the Relying Party requires a client-side discoverable credential, and is
// prepared to receive an error if a client-side discoverable credential cannot be created.
ResidentKeyRequirementRequired ResidentKeyRequirement = "required"
)
func ParseResidentKeyRequirement(s string) ResidentKeyRequirement {
switch s {
case "discouraged":
return ResidentKeyRequirementDiscouraged
case "preferred":
return ResidentKeyRequirementPreferred
default:
return ResidentKeyRequirementRequired
}
}
type (
AuthenticationExtensions map[string]any
UserVerificationRequirement string
)
const (
// VerificationRequired User verification is required to create/release a credential
VerificationRequired UserVerificationRequirement = "required"
// VerificationPreferred User verification is preferred to create/release a credential
VerificationPreferred UserVerificationRequirement = "preferred" // This is the default
// VerificationDiscouraged The authenticator should not verify the user for the credential
VerificationDiscouraged UserVerificationRequirement = "discouraged"
)
-48
View File
@@ -1,48 +0,0 @@
package builder
import (
"net/http"
"github.com/labstack/echo/v4"
"gopkg.in/macaroon.v2"
"gopkg.in/macaroon-bakery.v2/bakery/checkers"
)
var PermissionNamespace *checkers.Namespace
func ValidateMacaroonMiddleware(secretKey []byte, location string) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
// Extract the macaroon from the Authorization header
auth := c.Request().Header.Get("Authorization")
if auth == "" {
return c.JSON(http.StatusUnauthorized, map[string]string{"error": "Missing Authorization header"})
}
// Decode the macaroon
mac, err := macaroon.Base64Decode([]byte(auth))
if err != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "Invalid macaroon encoding"})
}
token, err := macaroon.New(secretKey, mac, location, macaroon.LatestVersion)
if err != nil {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "Invalid macaroon"})
}
// Verify the macaroon
err = token.Verify(secretKey, func(caveat string) error {
// Implement your caveat verification logic here
// For example, you might check if the caveat is still valid (e.g., not expired)
return nil // Return nil if the caveat is valid
}, nil)
if err != nil {
return c.JSON(http.StatusUnauthorized, map[string]string{"error": "Invalid macaroon"})
}
// Macaroon is valid, proceed to the next handler
return next(c)
}
}
}
-22
View File
@@ -1,22 +0,0 @@
package builder
//
// func GetDiscovery(origin string) *types.DiscoveryDocument {
// baseURL := "https://" + origin // Ensure this is the correct base URL for your service
// discoveryDoc := &types.DiscoveryDocument{
// Issuer: baseURL,
// AuthorizationEndpoint: fmt.Sprintf("%s/auth", baseURL),
// TokenEndpoint: fmt.Sprintf("%s/token", baseURL),
// UserinfoEndpoint: fmt.Sprintf("%s/userinfo", baseURL),
// JwksUri: fmt.Sprintf("%s/jwks", baseURL),
// RegistrationEndpoint: fmt.Sprintf("%s/register", baseURL),
// ScopesSupported: []string{"openid", "profile", "email", "web3", "sonr"},
// ResponseTypesSupported: []string{"code"},
// ResponseModesSupported: []string{"query", "form_post"},
// GrantTypesSupported: []string{"authorization_code", "refresh_token"},
// AcrValuesSupported: []string{"passkey"},
// SubjectTypesSupported: []string{"public"},
// ClaimsSupported: []string{"sub", "iss", "name", "email"},
// }
// return discoveryDoc
// }
-82
View File
@@ -1,82 +0,0 @@
package builder
import (
"encoding/json"
"github.com/onsonr/sonr/x/did/types"
)
type AuthenticatorResponse struct {
// From the spec https://www.w3.org/TR/webauthn/#dom-authenticatorresponse-clientdatajson
// This attribute contains a JSON serialization of the client data passed to the authenticator
// by the client in its call to either create() or get().
ClientDataJSON URLEncodedBase64 `json:"clientDataJSON"`
}
type AuthenticatorAttestationResponse struct {
// The byte slice of clientDataJSON, which becomes CollectedClientData
AuthenticatorResponse
Transports []string `json:"transports,omitempty"`
AuthenticatorData URLEncodedBase64 `json:"authenticatorData"`
PublicKey URLEncodedBase64 `json:"publicKey"`
PublicKeyAlgorithm int64 `json:"publicKeyAlgorithm"`
// AttestationObject is the byte slice version of attestationObject.
// This attribute contains an attestation object, which is opaque to, and
// cryptographically protected against tampering by, the client. The
// attestation object contains both authenticator data and an attestation
// statement. The former contains the AAGUID, a unique credential ID, and
// the credential public key. The contents of the attestation statement are
// determined by the attestation statement format used by the authenticator.
// It also contains any additional information that the Relying Party's server
// requires to validate the attestation statement, as well as to decode and
// validate the authenticator data along with the JSON-serialized client data.
AttestationObject URLEncodedBase64 `json:"attestationObject"`
}
type PublicKeyCredentialCreationOptions struct {
RelyingParty RelyingPartyEntity `json:"rp"`
User UserEntity `json:"user"`
Challenge URLEncodedBase64 `json:"challenge"`
Parameters []CredentialParameter `json:"pubKeyCredParams,omitempty"`
Timeout int `json:"timeout,omitempty"`
CredentialExcludeList []CredentialDescriptor `json:"excludeCredentials,omitempty"`
AuthenticatorSelection AuthenticatorSelection `json:"authenticatorSelection,omitempty"`
Hints []PublicKeyCredentialHints `json:"hints,omitempty"`
Attestation ConveyancePreference `json:"attestation,omitempty"`
AttestationFormats []AttestationFormat `json:"attestationFormats,omitempty"`
Extensions AuthenticationExtensions `json:"extensions,omitempty"`
}
func GetPublicKeyCredentialCreationOptions(origin string, subject string, vaultCID string, params *types.Params) (*PublicKeyCredentialCreationOptions, error) {
chal, err := CreateChallenge()
if err != nil {
return nil, err
}
return &PublicKeyCredentialCreationOptions{
RelyingParty: NewRelayingParty(origin, subject),
User: NewUserEntity(subject, subject, vaultCID),
Parameters: ExtractCredentialParameters(params),
Timeout: 20,
CredentialExcludeList: nil,
Challenge: chal,
AuthenticatorSelection: AuthenticatorSelection{},
Hints: nil,
Attestation: ExtractConveyancePreference(params),
AttestationFormats: ExtractAttestationFormats(params),
Extensions: nil,
}, nil
}
func UnmarshalAuthenticatorResponse(data []byte) (*AuthenticatorResponse, error) {
var ar AuthenticatorResponse
err := json.Unmarshal(data, &ar)
if err != nil {
return nil, err
}
return &ar, nil
}
-81
View File
@@ -1,81 +0,0 @@
package builder
import (
"fmt"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
didv1 "github.com/onsonr/sonr/api/did/v1"
"github.com/onsonr/sonr/x/did/types"
"github.com/go-webauthn/webauthn/protocol/webauthncose"
)
// PublicKey is an interface for a public key
type PublicKey interface {
cryptotypes.PubKey
Clone() cryptotypes.PubKey
GetRaw() []byte
GetRole() types.KeyRole
GetAlgorithm() types.KeyAlgorithm
GetEncoding() types.KeyEncoding
GetCurve() types.KeyCurve
GetKeyType() types.KeyType
}
// CreateAuthnVerification creates a new verification method for an authn method
func CreateAuthnVerification(namespace types.DIDNamespace, issuer string, controller string, pubkey *types.PubKey, identifier string) *types.Verification {
return &types.Verification{
Method: namespace,
Controller: controller,
PublicKey: pubkey,
Id: identifier,
Issuer: issuer,
}
}
// CreateWalletVerification creates a new verification method for a wallet
func CreateWalletVerification(namespace types.DIDNamespace, controller string, pubkey *types.PubKey, identifier string) *didv1.Verification {
return &didv1.Verification{
Method: APIFormatDIDNamespace(namespace),
Controller: controller,
PublicKey: APIFormatPubKey(pubkey),
Id: identifier,
}
}
// ExtractWebAuthnPublicKey parses the raw public key bytes and returns a JWK representation
func ExtractWebAuthnPublicKey(keyBytes []byte) (*types.PubKey_JWK, error) {
key, err := webauthncose.ParsePublicKey(keyBytes)
if err != nil {
return nil, fmt.Errorf("failed to parse public key: %w", err)
}
switch k := key.(type) {
case *webauthncose.EC2PublicKeyData:
return FormatEC2PublicKey(k)
case *webauthncose.RSAPublicKeyData:
return FormatRSAPublicKey(k)
case *webauthncose.OKPPublicKeyData:
return FormatOKPPublicKey(k)
default:
return nil, fmt.Errorf("unsupported key type")
}
}
// NewInitialWalletAccounts creates a new set of verification methods for a wallet
func NewInitialWalletAccounts(controller string, pubkey *types.PubKey) ([]*didv1.Verification, error) {
var verificationMethods []*didv1.Verification
for method, chain := range types.InitialChainCodes {
nk, err := computeBip32AccountPublicKey(pubkey, chain, 0)
if err != nil {
return nil, err
}
addr, err := chain.FormatAddress(nk)
if err != nil {
return nil, nil
}
verificationMethods = append(verificationMethods, CreateWalletVerification(method, controller, nk, method.FormatDID(addr)))
}
return verificationMethods, nil
}
-56
View File
@@ -1,56 +0,0 @@
package builder
import (
"github.com/onsonr/sonr/x/did/types"
"gopkg.in/macaroon-bakery.v2/bakery/checkers"
)
var (
GenericPermissionScopeStrings = [...]string{
"profile.name",
"identifiers.email",
"identifiers.phone",
"transactions.read",
"transactions.write",
"wallets.read",
"wallets.create",
"wallets.subscribe",
"wallets.update",
"transactions.verify",
"transactions.broadcast",
"admin.user",
"admin.validator",
}
StringToModulePermissionScope = map[string]types.PermissionScope{
"PERMISSION_SCOPE_UNSPECIFIED": types.PermissionScope_PERMISSION_SCOPE_UNSPECIFIED,
"PERMISSION_SCOPE_BASIC_INFO": types.PermissionScope_PERMISSION_SCOPE_BASIC_INFO,
"PERMISSION_SCOPE_IDENTIFIERS_EMAIL": types.PermissionScope_PERMISSION_SCOPE_PERMISSIONS_READ,
"PERMISSION_SCOPE_IDENTIFIERS_PHONE": types.PermissionScope_PERMISSION_SCOPE_PERMISSIONS_WRITE,
"PERMISSION_SCOPE_TRANSACTIONS_READ": types.PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_READ,
"PERMISSION_SCOPE_TRANSACTIONS_WRITE": types.PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_WRITE,
"PERMISSION_SCOPE_WALLETS_READ": types.PermissionScope_PERMISSION_SCOPE_WALLETS_READ,
"PERMISSION_SCOPE_WALLETS_CREATE": types.PermissionScope_PERMISSION_SCOPE_WALLETS_CREATE,
"PERMISSION_SCOPE_WALLETS_SUBSCRIBE": types.PermissionScope_PERMISSION_SCOPE_WALLETS_SUBSCRIBE,
"PERMISSION_SCOPE_WALLETS_UPDATE": types.PermissionScope_PERMISSION_SCOPE_WALLETS_UPDATE,
"PERMISSION_SCOPE_TRANSACTIONS_VERIFY": types.PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_VERIFY,
"PERMISSION_SCOPE_TRANSACTIONS_BROADCAST": types.PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_BROADCAST,
"PERMISSION_SCOPE_ADMIN_USER": types.PermissionScope_PERMISSION_SCOPE_ADMIN_USER,
"PERMISSION_SCOPE_ADMIN_VALIDATOR": types.PermissionScope_PERMISSION_SCOPE_ADMIN_VALIDATOR,
}
)
func ResolvePermissionScope(scope string) (types.PermissionScope, bool) {
uriToPrefix := make(map[string]string)
for _, scope := range GenericPermissionScopeStrings {
uriToPrefix["https://example.com/auth/"+scope] = scope
}
PermissionNamespace := checkers.NewNamespace(uriToPrefix)
prefix, ok := PermissionNamespace.Resolve("https://example.com/auth/" + scope)
if !ok {
return 0, false
}
permScope, ok := StringToModulePermissionScope[prefix]
return permScope, ok
}
-103
View File
@@ -1,103 +0,0 @@
package builder
import (
"crypto/rand"
"strings"
"github.com/onsonr/sonr/x/did/types"
)
// ChallengeLength - Length of bytes to generate for a challenge.
const ChallengeLength = 32
// CreateChallenge creates a new challenge that should be signed and returned by the authenticator. The spec recommends
// using at least 16 bytes with 100 bits of entropy. We use 32 bytes.
func CreateChallenge() (challenge URLEncodedBase64, err error) {
challenge = make([]byte, ChallengeLength)
if _, err = rand.Read(challenge); err != nil {
return nil, err
}
return challenge, nil
}
type CredentialEntity struct {
// A human-palatable name for the entity. Its function depends on what the PublicKeyCredentialEntity represents:
//
// When inherited by PublicKeyCredentialRpEntity it is a human-palatable identifier for the Relying Party,
// intended only for display. For example, "ACME Corporation", "Wonderful Widgets, Inc." or "ОАО Примертех".
//
// When inherited by PublicKeyCredentialUserEntity, it is a human-palatable identifier for a user account. It is
// intended only for display, i.e., aiding the user in determining the difference between user accounts with similar
// displayNames. For example, "alexm", "alex.p.mueller@example.com" or "+14255551234".
Name string `json:"name"`
}
func NewCredentialEntity(name string) CredentialEntity {
return CredentialEntity{
Name: name,
}
}
type CredentialParameter struct {
Type CredentialType `json:"type"`
Algorithm types.COSEAlgorithmIdentifier `json:"alg"`
}
func NewCredentialParameter(ki *types.KeyInfo) CredentialParameter {
return CredentialParameter{
Type: CredentialTypePublicKeyCredential,
Algorithm: ki.Algorithm.CoseIdentifier(),
}
}
func ExtractCredentialParameters(p *types.Params) []CredentialParameter {
var keys []*types.KeyInfo
for k, v := range p.AllowedPublicKeys {
if strings.Contains(k, "webauthn") {
keys = append(keys, v)
}
}
var cparams []CredentialParameter
for _, ki := range keys {
cparams = append(cparams, NewCredentialParameter(ki))
}
return cparams
}
type RelyingPartyEntity struct {
CredentialEntity
// A unique identifier for the Relying Party entity, which sets the RP ID.
ID string `json:"id"`
}
func NewRelayingParty(name string, origin string) RelyingPartyEntity {
return RelyingPartyEntity{
CredentialEntity: NewCredentialEntity(origin),
ID: origin,
}
}
type UserEntity struct {
CredentialEntity
// A human-palatable name for the user account, intended only for display.
// For example, "Alex P. Müller" or "田中 倫". The Relying Party SHOULD let
// the user choose this, and SHOULD NOT restrict the choice more than necessary.
DisplayName string `json:"displayName"`
// ID is the user handle of the user account entity. To ensure secure operation,
// authentication and authorization decisions MUST be made on the basis of this id
// member, not the displayName nor name members. See Section 6.1 of
// [RFC8266](https://www.w3.org/TR/webauthn/#biblio-rfc8266).
ID any `json:"id"`
}
func NewUserEntity(name string, subject string, cid string) UserEntity {
return UserEntity{
CredentialEntity: NewCredentialEntity(name),
DisplayName: subject,
ID: cid,
}
}
-1
View File
@@ -1 +0,0 @@
package builder
-169
View File
@@ -1,169 +0,0 @@
package builder
import (
"bytes"
"encoding/base64"
"reflect"
"github.com/go-webauthn/webauthn/protocol"
)
// Credential contains all needed information about a WebAuthn credential for storage.
type Credential struct {
Subject string `json:"handle"`
AttestationType string `json:"attestationType"`
Origin string `json:"origin"`
CredentialID []byte `json:"id"`
PublicKey []byte `json:"publicKey"`
Transport []string `json:"transport"`
SignCount uint32 `json:"signCount"`
UserPresent bool `json:"userPresent"`
UserVerified bool `json:"userVerified"`
BackupEligible bool `json:"backupEligible"`
BackupState bool `json:"backupState"`
CloneWarning bool `json:"cloneWarning"`
}
// NewCredential will return a credential pointer on successful validation of a registration response.
func NewCredential(c *protocol.ParsedCredentialCreationData, origin, handle string) *Credential {
return &Credential{
Subject: handle,
Origin: origin,
AttestationType: c.Response.AttestationObject.Format,
CredentialID: c.Response.AttestationObject.AuthData.AttData.CredentialID,
PublicKey: c.Response.AttestationObject.AuthData.AttData.CredentialPublicKey,
Transport: NormalizeTransports(c.Response.Transports),
SignCount: c.Response.AttestationObject.AuthData.Counter,
UserPresent: c.Response.AttestationObject.AuthData.Flags.HasUserPresent(),
UserVerified: c.Response.AttestationObject.AuthData.Flags.HasUserVerified(),
BackupEligible: c.Response.AttestationObject.AuthData.Flags.HasBackupEligible(),
BackupState: c.Response.AttestationObject.AuthData.Flags.HasAttestedCredentialData(),
}
}
// Descriptor converts a Credential into a protocol.CredentialDescriptor.
func (c *Credential) Descriptor() protocol.CredentialDescriptor {
return protocol.CredentialDescriptor{
Type: protocol.PublicKeyCredentialType,
CredentialID: c.CredentialID,
Transport: ModuleTransportsToProtocol(c.Transport),
AttestationType: c.AttestationType,
}
}
// This is a signal that the authenticator may be cloned, see CloneWarning above for more information.
func (a *Credential) UpdateCounter(authDataCount uint32) {
if authDataCount <= a.SignCount && (authDataCount != 0 || a.SignCount != 0) {
a.CloneWarning = true
return
}
a.SignCount = authDataCount
}
type CredentialDescriptor struct {
// The valid credential types.
Type CredentialType `json:"type"`
// CredentialID The ID of a credential to allow/disallow.
CredentialID URLEncodedBase64 `json:"id"`
// The authenticator transports that can be used.
Transport []AuthenticatorTransport `json:"transports,omitempty"`
// The AttestationType from the Credential. Used internally only.
AttestationType string `json:"-"`
}
func NewCredentialDescriptor(credentialID string, transports []AuthenticatorTransport, attestationType string) *CredentialDescriptor {
return &CredentialDescriptor{
CredentialID: URLEncodedBase64(credentialID),
Transport: transports,
AttestationType: attestationType,
Type: CredentialTypePublicKeyCredential,
}
}
type AuthenticatorSelection struct {
// AuthenticatorAttachment If this member is present, eligible authenticators are filtered to only
// authenticators attached with the specified AuthenticatorAttachment enum.
AuthenticatorAttachment AuthenticatorAttachment `json:"authenticatorAttachment,omitempty"`
// RequireResidentKey this member describes the Relying Party's requirements regarding resident
// credentials. If the parameter is set to true, the authenticator MUST create a client-side-resident
// public key credential source when creating a public key credential.
RequireResidentKey *bool `json:"requireResidentKey,omitempty"`
// ResidentKey this member describes the Relying Party's requirements regarding resident
// credentials per Webauthn Level 2.
ResidentKey ResidentKeyRequirement `json:"residentKey,omitempty"`
// UserVerification This member describes the Relying Party's requirements regarding user verification for
// the create() operation. Eligible authenticators are filtered to only those capable of satisfying this
// requirement.
UserVerification UserVerificationRequirement `json:"userVerification,omitempty"`
}
type AuthenticatorData struct {
RPIDHash []byte `json:"rpid"`
Flags AuthenticatorFlags `json:"flags"`
Counter uint32 `json:"sign_count"`
AttData AttestedCredentialData `json:"att_data"`
ExtData []byte `json:"ext_data"`
}
type AttestationObject struct {
// The authenticator data, including the newly created public key. See AuthenticatorData for more info
AuthData AuthenticatorData
// The byteform version of the authenticator data, used in part for signature validation
RawAuthData []byte `json:"authData"`
// The format of the Attestation data.
Format string `json:"fmt"`
// The attestation statement data sent back if attestation is requested.
AttStatement map[string]any `json:"attStmt,omitempty"`
}
type URLEncodedBase64 []byte
func (e URLEncodedBase64) String() string {
return base64.RawURLEncoding.EncodeToString(e)
}
// UnmarshalJSON base64 decodes a URL-encoded value, storing the result in the
// provided byte slice.
func (e *URLEncodedBase64) UnmarshalJSON(data []byte) error {
if bytes.Equal(data, []byte("null")) {
return nil
}
// Trim the leading spaces.
data = bytes.Trim(data, "\"")
// Trim the trailing equal characters.
data = bytes.TrimRight(data, "=")
out := make([]byte, base64.RawURLEncoding.DecodedLen(len(data)))
n, err := base64.RawURLEncoding.Decode(out, data)
if err != nil {
return err
}
v := reflect.ValueOf(e).Elem()
v.SetBytes(out[:n])
return nil
}
// MarshalJSON base64 encodes a non URL-encoded value, storing the result in the
// provided byte slice.
func (e URLEncodedBase64) MarshalJSON() ([]byte, error) {
if e == nil {
return []byte("null"), nil
}
return []byte(`"` + base64.RawURLEncoding.EncodeToString(e) + `"`), nil
}
+60 -9
View File
@@ -1,7 +1,9 @@
package keeper
import (
"context"
"time"
"github.com/ipfs/kubo/client/rpc"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/onsonr/sonr/x/did/types"
@@ -14,18 +16,26 @@ type Context struct {
Peer *peer.Peer
}
func (k Keeper) CurrentCtx(goCtx context.Context) Context {
ctx := sdk.UnwrapSDKContext(goCtx)
peer, _ := peer.FromContext(goCtx)
return Context{SDKCtx: ctx, Peer: peer, Keeper: k}
// AverageBlockTime returns the average block time in seconds
func (c Context) AverageBlockTime() float64 {
return float64(c.SDK().BlockTime().Sub(c.SDK().BlockTime()).Seconds())
}
func (c Context) Params() *types.Params {
return c.Keeper.GetParams(c.SDK())
// GetExpirationBlockHeight returns the block height at which the given duration will have passed
func (c Context) CalculateExpiration(duration time.Duration) int64 {
return c.SDKCtx.BlockHeight() + int64(duration.Seconds()/c.AverageBlockTime())
}
func (c Context) SDK() sdk.Context {
return c.SDKCtx
// IPFSConnected returns true if the IPFS client is initialized
func (c Context) IPFSConnected() bool {
if c.Keeper.ipfsClient == nil {
ipfsClient, err := rpc.NewLocalApi()
if err != nil {
return false
}
c.Keeper.ipfsClient = ipfsClient
}
return c.Keeper.ipfsClient != nil
}
func (c Context) IsAnonymous() bool {
@@ -35,9 +45,50 @@ func (c Context) IsAnonymous() bool {
return c.Peer.Addr == nil
}
func (c Context) Params() *types.Params {
p, err := c.Keeper.Params.Get(c.SDK())
if err != nil {
p = types.DefaultParams()
}
params := p.ActiveParams(c.IPFSConnected())
return &params
}
func (c Context) PeerID() string {
if c.Peer == nil {
return ""
}
return c.Peer.Addr.String()
}
func (c Context) SDK() sdk.Context {
return c.SDKCtx
}
// ValidateOrigin checks if a service origin is valid
func (c Context) ValidateOrigin(origin string) error {
if origin == "localhost" {
return nil
}
return types.ErrInvalidServiceOrigin
}
// VerifyMinimumStake checks if a validator has a minimum stake
func (c Context) VerifyMinimumStake(addr string) bool {
address, err := sdk.AccAddressFromBech32(addr)
if err != nil {
return false
}
addval, err := sdk.ValAddressFromBech32(addr)
if err != nil {
return false
}
del, err := c.Keeper.StakingKeeper.GetDelegation(c.SDK(), address, addval)
if err != nil {
return false
}
if del.Shares.IsZero() {
return false
}
return del.Shares.IsPositive()
}
+19 -15
View File
@@ -2,10 +2,11 @@ package keeper
import (
"context"
"time"
"cosmossdk.io/log"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ipfs/boxo/path"
"google.golang.org/grpc/peer"
"github.com/onsonr/sonr/x/did/types"
)
@@ -54,22 +55,25 @@ func (k Keeper) CheckValidatorExists(ctx sdk.Context, addr string) bool {
return false
}
// GetAverageBlockTime returns the average block time in seconds
func (k Keeper) GetAverageBlockTime(ctx sdk.Context) float64 {
return float64(ctx.BlockTime().Sub(ctx.BlockTime()).Seconds())
}
// GetParams returns the module parameters.
func (k Keeper) GetParams(ctx sdk.Context) *types.Params {
p, err := k.Params.Get(ctx)
// HasPathInIPFS checks if a file is in the local IPFS node
func (k Keeper) HasPathInIPFS(ctx sdk.Context, cid string) (bool, error) {
path, err := path.NewPath(cid)
if err != nil {
p = types.DefaultParams()
return false, err
}
params := p.ActiveParams(k.HasIPFSConnection())
return &params
v, err := k.ipfsClient.Unixfs().Get(ctx, path)
if err != nil {
return false, err
}
if v == nil {
return false, nil
}
return true, nil
}
// GetExpirationBlockHeight returns the block height at which the given duration will have passed
func (k Keeper) GetExpirationBlockHeight(ctx sdk.Context, duration time.Duration) int64 {
return ctx.BlockHeight() + int64(duration.Seconds()/k.GetAverageBlockTime(ctx))
func (k Keeper) UnwrapCtx(goCtx context.Context) Context {
ctx := sdk.UnwrapSDKContext(goCtx)
peer, _ := peer.FromContext(goCtx)
return Context{SDKCtx: ctx, Peer: peer, Keeper: k}
}
-117
View File
@@ -1,117 +0,0 @@
package keeper
import (
"context"
"fmt"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ipfs/boxo/files"
"github.com/ipfs/boxo/path"
"github.com/ipfs/kubo/client/rpc"
"github.com/ipfs/kubo/core/coreiface/options"
"github.com/onsonr/sonr/internal/vfs"
)
// assembleInitialVault assembles the initial vault
func (k Keeper) assembleInitialVault(ctx sdk.Context) (string, int64, error) {
cnfg, err := vfs.NewDWNConfigFile("test", "test")
if err != nil {
return "", 0, err
}
fileMap := map[string]files.Node{
"config.pkl": cnfg,
"sw.js": vfs.SWJSFile(),
"app.wasm": vfs.DWNWasmFile(),
"index.html": vfs.IndexFile(),
}
cid, err := k.ipfsClient.Unixfs().Add(context.Background(), files.NewMapDirectory(fileMap))
if err != nil {
return "", 0, err
}
return cid.String(), k.GetExpirationBlockHeight(ctx, time.Second*15), nil
}
// pinInitialVault pins the initial vault to the local IPFS node
func (k Keeper) pinInitialVault(_ sdk.Context, cid string, address string) (bool, error) {
// Resolve the path
path, err := path.NewPath(cid)
if err != nil {
return false, err
}
// 1. Initialize vault.db sqlite database in local IPFS with Mount
// 2. Insert the InitialWalletAccounts
// 3. Publish the path to the IPNS
_, err = k.ipfsClient.Name().Publish(context.Background(), path, options.Name.Key(address))
if err != nil {
return false, err
}
// 4. Insert the accounts into x/auth
// 5. Insert the controller into state
return true, nil
}
// GetFromIPFS gets a file from the local IPFS node
func (k Keeper) GetFromIPFS(ctx sdk.Context, cid string) (files.Directory, error) {
path, err := path.NewPath(cid)
if err != nil {
return nil, err
}
node, err := k.ipfsClient.Unixfs().Get(ctx, path)
if err != nil {
return nil, err
}
dir, ok := node.(files.Directory)
if !ok {
return nil, fmt.Errorf("retrieved node is not a directory")
}
return dir, nil
}
// HasIPFSConnection returns true if the IPFS client is initialized
func (k *Keeper) HasIPFSConnection() bool {
if k.ipfsClient == nil {
ipfsClient, err := rpc.NewLocalApi()
if err != nil {
return false
}
k.ipfsClient = ipfsClient
}
return k.ipfsClient != nil
}
// HasPathInIPFS checks if a file is in the local IPFS node
func (k Keeper) HasPathInIPFS(ctx sdk.Context, cid string) (bool, error) {
path, err := path.NewPath(cid)
if err != nil {
return false, err
}
v, err := k.ipfsClient.Unixfs().Get(ctx, path)
if err != nil {
return false, err
}
if v == nil {
return false, nil
}
return true, nil
}
// PinToIPFS pins a file to the local IPFS node
func (k Keeper) PinToIPFS(ctx sdk.Context, cid string, name string) error {
path, err := path.NewPath(cid)
if err != nil {
return err
}
err = k.ipfsClient.Pin().Add(ctx, path, options.Pin.Name(name))
if err != nil {
return err
}
return nil
}
-20
View File
@@ -92,26 +92,6 @@ func NewKeeper(
return k
}
// VerifyMinimumStake checks if a validator has a minimum stake
func (k Keeper) VerifyMinimumStake(ctx sdk.Context, addr string) bool {
address, err := sdk.AccAddressFromBech32(addr)
if err != nil {
return false
}
addval, err := sdk.ValAddressFromBech32(addr)
if err != nil {
return false
}
del, err := k.StakingKeeper.GetDelegation(ctx, address, addval)
if err != nil {
return false
}
if del.Shares.IsZero() {
return false
}
return del.Shares.IsPositive()
}
// VerifyServicePermissions checks if a service has permission
func (k Keeper) VerifyServicePermissions(
ctx sdk.Context,
+3 -13
View File
@@ -21,8 +21,8 @@ func (k Querier) Params(
goCtx context.Context,
req *types.QueryRequest,
) (*types.QueryParamsResponse, error) {
ctx := k.CurrentCtx(goCtx)
return &types.QueryParamsResponse{Params: k.GetParams(ctx.SDK())}, nil
ctx := k.UnwrapCtx(goCtx)
return &types.QueryParamsResponse{Params: ctx.Params()}, nil
}
// Resolve implements types.QueryServer.
@@ -30,22 +30,12 @@ func (k Querier) Resolve(
goCtx context.Context,
req *types.QueryRequest,
) (*types.QueryResolveResponse, error) {
_ = k.CurrentCtx(goCtx)
_ = k.UnwrapCtx(goCtx)
return &types.QueryResolveResponse{}, nil
}
// Service implements types.QueryServer.
func (k Querier) Service(
goCtx context.Context,
req *types.QueryRequest,
) (*types.QueryServiceResponse, error) {
// ctx := k.CurrentCtx(goCtx)
return &types.QueryServiceResponse{}, nil
}
// Sync implements types.QueryServer.
func (k Querier) Sync(goCtx context.Context, req *types.SyncRequest) (*types.SyncResponse, error) {
// ctx := sdk.UnwrapSDKContext(goCtx)
panic("Sync is unimplemented")
return &types.SyncResponse{}, nil
}
+24 -36
View File
@@ -2,13 +2,11 @@ package keeper
import (
"context"
"encoding/json"
"cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/onsonr/sonr/x/did/builder"
"github.com/onsonr/sonr/x/did/types"
)
@@ -23,21 +21,6 @@ func NewMsgServerImpl(keeper Keeper) types.MsgServer {
return &msgServer{k: keeper}
}
// # AuthorizeService
//
// AuthorizeService implements types.MsgServer.
func (ms msgServer) AuthorizeService(goCtx context.Context, msg *types.MsgAuthorizeService) (*types.MsgAuthorizeServiceResponse, error) {
if ms.k.authority != msg.Controller {
return nil, errors.Wrapf(
govtypes.ErrInvalidSigner,
"invalid authority; expected %s, got %s",
ms.k.authority,
msg.Controller,
)
}
return &types.MsgAuthorizeServiceResponse{}, nil
}
// # AllocateVault
//
// AllocateVault implements types.MsgServer.
@@ -45,32 +28,22 @@ func (ms msgServer) AllocateVault(
goCtx context.Context,
msg *types.MsgAllocateVault,
) (*types.MsgAllocateVaultResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
// 1.Check if the service origin is valid
// if ms.k.IsValidServiceOrigin(ctx, msg.Origin) {
// return nil, types.ErrInvalidServiceOrigin
// }
ctx := ms.k.UnwrapCtx(goCtx)
if err := ctx.ValidateOrigin(msg.Origin); err != nil {
return nil, err
}
cid, expiryBlock, err := ms.k.assembleInitialVault(ctx)
if err != nil {
return nil, err
}
regOpts, err := builder.GetPublicKeyCredentialCreationOptions(msg.Origin, msg.Subject, cid, ms.k.GetParams(ctx))
if err != nil {
return nil, err
}
// Convert to string
regOptsJSON, err := json.Marshal(regOpts)
// 2.Allocate the vault
cid, expiryBlock, err := ms.k.AssembleVault(ctx, msg.GetSubject(), msg.GetOrigin())
if err != nil {
return nil, err
}
// 3.Return the response
return &types.MsgAllocateVaultResponse{
ExpiryBlock: expiryBlock,
Cid: cid,
RegistrationOptions: string(regOptsJSON),
ExpiryBlock: expiryBlock,
Cid: cid,
}, nil
}
@@ -101,6 +74,21 @@ func (ms msgServer) RegisterService(
return nil, errors.Wrapf(types.ErrInvalidServiceOrigin, "invalid service origin")
}
// # AuthorizeService
//
// AuthorizeService implements types.MsgServer.
func (ms msgServer) AuthorizeService(goCtx context.Context, msg *types.MsgAuthorizeService) (*types.MsgAuthorizeServiceResponse, error) {
if ms.k.authority != msg.Controller {
return nil, errors.Wrapf(
govtypes.ErrInvalidSigner,
"invalid authority; expected %s, got %s",
ms.k.authority,
msg.Controller,
)
}
return &types.MsgAuthorizeServiceResponse{}, nil
}
// # UpdateParams
//
// UpdateParams updates the x/did module parameters.
+86
View File
@@ -0,0 +1,86 @@
package keeper
import (
"context"
"time"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/bech32"
"github.com/ipfs/boxo/files"
"github.com/ipfs/boxo/path"
"github.com/ipfs/kubo/core/coreiface/options"
"github.com/onsonr/crypto/mpc"
"github.com/onsonr/sonr/internal/vfs"
)
type Vault struct {
FS files.Node
ValKs mpc.Share
}
func NewVault(subject string, origin string, chainID string) (*Vault, error) {
shares, err := mpc.GenerateKeyshares()
var (
valKs = shares[0]
usrKs = shares[1]
)
usrKsJSON, err := usrKs.Marshal()
if err != nil {
return nil, err
}
sonrAddr, err := bech32.ConvertAndEncode("idx", valKs.GetPublicKey())
if err != nil {
return nil, err
}
cnfg, err := vfs.NewDWNConfigFile(usrKsJSON, sonrAddr, chainID)
if err != nil {
return nil, err
}
fileMap := map[string]files.Node{
"config.json": cnfg,
"sw.js": vfs.SWJSFile(),
"app.wasm": vfs.DWNWasmFile(),
"index.html": vfs.IndexFile(),
}
return &Vault{
FS: files.NewMapDirectory(fileMap),
ValKs: valKs,
}, nil
}
// AssembleVault assembles the initial vault
func (k Keeper) AssembleVault(ctx Context, subject string, origin string) (string, int64, error) {
v, err := NewVault(subject, origin, "sonr-testnet")
if err != nil {
return "", 0, err
}
cid, err := k.ipfsClient.Unixfs().Add(context.Background(), v.FS)
if err != nil {
return "", 0, err
}
return cid.String(), ctx.CalculateExpiration(time.Second * 15), nil
}
// PinVaultController pins the initial vault to the local IPFS node
func (k Keeper) PinVaultController(_ sdk.Context, cid string, address string) (bool, error) {
// Resolve the path
path, err := path.NewPath(cid)
if err != nil {
return false, err
}
// 1. Initialize vault.db sqlite database in local IPFS with Mount
// 2. Insert the InitialWalletAccounts
// 3. Publish the path to the IPNS
_, err = k.ipfsClient.Name().Publish(context.Background(), path, options.Name.Key(address))
if err != nil {
return false, err
}
// 4. Insert the accounts into x/auth
// 5. Insert the controller into state
return true, nil
}
+2 -8
View File
@@ -10,7 +10,6 @@ import (
"cosmossdk.io/client/v2/autocli"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/x/nft"
nftkeeper "cosmossdk.io/x/nft/keeper"
"github.com/cosmos/cosmos-sdk/client"
@@ -68,8 +67,7 @@ func (a AppModuleBasic) Name() string {
func (a AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
return cdc.MustMarshalJSON(&types.GenesisState{
GlobalIntegrity: types.DefaultGlobalIntegrity(),
Params: types.DefaultParams(),
Params: types.DefaultParams(),
})
}
@@ -105,11 +103,7 @@ func (a AppModule) InitGenesis(ctx sdk.Context, marshaler codec.JSONCodec, messa
if err := a.keeper.Params.Set(ctx, didGenesisState.Params); err != nil {
panic(err)
}
nftGenesisState := nft.DefaultGenesisState()
if err := types.DefaultNFTClasses(nftGenesisState); err != nil {
panic(err)
}
a.nftKeeper.InitGenesis(ctx, nftGenesisState)
return nil
}
+1
View File
@@ -0,0 +1 @@
package types
+1 -162
View File
@@ -2,24 +2,17 @@ package types
import (
"crypto/ecdsa"
"crypto/sha256"
"encoding/hex"
"strings"
fmt "fmt"
ethcrypto "github.com/ethereum/go-ethereum/crypto"
"golang.org/x/crypto/sha3"
"github.com/cosmos/btcutil/bech32"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
"github.com/mr-tron/base58/base58"
"github.com/onsonr/crypto"
// this line is used by starport scaffolding # 1
)
@@ -42,7 +35,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
func RegisterInterfaces(registry types.InterfaceRegistry) {
registry.RegisterImplementations(
(*cryptotypes.PubKey)(nil),
&PubKey{},
// &PubKey{},
)
registry.RegisterImplementations(
@@ -55,160 +48,6 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
}
type ChainCode uint32
const (
ChainCodeBTC ChainCode = 0
ChainCodeETH ChainCode = 60
ChainCodeIBC ChainCode = 118
ChainCodeSNR ChainCode = 703
)
var InitialChainCodes = map[DIDNamespace]ChainCode{
DIDNamespace_DID_NAMESPACE_BITCOIN: ChainCodeBTC,
DIDNamespace_DID_NAMESPACE_IBC: ChainCodeIBC,
DIDNamespace_DID_NAMESPACE_ETHEREUM: ChainCodeETH,
DIDNamespace_DID_NAMESPACE_SONR: ChainCodeSNR,
}
func (c ChainCode) FormatAddress(pubKey *PubKey) (string, error) {
switch c {
case ChainCodeBTC:
return bech32.Encode("bc", pubKey.Bytes())
case ChainCodeETH:
epk, err := pubKey.ECDSA()
if err != nil {
return "", err
}
return ComputeEthAddress(*epk), nil
case ChainCodeSNR:
return bech32.Encode("idx", pubKey.Bytes())
case ChainCodeIBC:
return bech32.Encode("cosmos", pubKey.Bytes())
}
return "", ErrUnsopportedChainCode
}
func (n DIDNamespace) ChainCode() (uint32, error) {
switch n {
case DIDNamespace_DID_NAMESPACE_BITCOIN:
return 0, nil
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
return 64, nil
case DIDNamespace_DID_NAMESPACE_IBC:
return 118, nil
case DIDNamespace_DID_NAMESPACE_SONR:
return 703, nil
default:
return 0, fmt.Errorf("unsupported chain")
}
}
func (n DIDNamespace) DIDMethod() string {
switch n {
case DIDNamespace_DID_NAMESPACE_IPFS:
return "ipfs"
case DIDNamespace_DID_NAMESPACE_SONR:
return "sonr"
case DIDNamespace_DID_NAMESPACE_BITCOIN:
return "btcr"
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
return "ethr"
case DIDNamespace_DID_NAMESPACE_IBC:
return "ibcr"
case DIDNamespace_DID_NAMESPACE_WEBAUTHN:
return "webauthn"
case DIDNamespace_DID_NAMESPACE_DWN:
return "motr"
case DIDNamespace_DID_NAMESPACE_SERVICE:
return "web"
default:
return "n/a"
}
}
func (n DIDNamespace) FormatDID(subject string) string {
return fmt.Sprintf("%s:%s", n.DIDMethod(), subject)
}
type EncodedKey []byte
func (e KeyEncoding) EncodeRaw(data []byte) (EncodedKey, error) {
switch e {
case KeyEncoding_KEY_ENCODING_RAW:
return data, nil
case KeyEncoding_KEY_ENCODING_HEX:
return []byte(hex.EncodeToString(data)), nil
case KeyEncoding_KEY_ENCODING_MULTIBASE:
return []byte(base58.Encode(data)), nil
default:
return nil, nil
}
}
func (e KeyEncoding) DecodeRaw(data EncodedKey) ([]byte, error) {
switch e {
case KeyEncoding_KEY_ENCODING_RAW:
return data, nil
case KeyEncoding_KEY_ENCODING_HEX:
return hex.DecodeString(string(data))
case KeyEncoding_KEY_ENCODING_MULTIBASE:
return base58.Decode(string(data))
default:
return nil, nil
}
}
type COSEAlgorithmIdentifier int
func (k KeyAlgorithm) CoseIdentifier() COSEAlgorithmIdentifier {
switch k {
case KeyAlgorithm_KEY_ALGORITHM_ES256:
return COSEAlgorithmIdentifier(-7)
case KeyAlgorithm_KEY_ALGORITHM_ES384:
return COSEAlgorithmIdentifier(-35)
case KeyAlgorithm_KEY_ALGORITHM_ES512:
return COSEAlgorithmIdentifier(-36)
case KeyAlgorithm_KEY_ALGORITHM_EDDSA:
return COSEAlgorithmIdentifier(-8)
case KeyAlgorithm_KEY_ALGORITHM_ES256K:
return COSEAlgorithmIdentifier(-10)
default:
return COSEAlgorithmIdentifier(0)
}
}
func (k KeyCurve) ComputePublicKey(data []byte) (*PubKey, error) {
return nil, ErrUnsupportedKeyCurve
}
func (k *Keyshare) Equals(o crypto.MPCShare) bool {
opk := o.GetPublicKey()
if opk != nil && k.PublicKey == nil {
return false
}
return k.GetRole() == o.GetRole()
}
func (k *Keyshare) IsUser() bool {
return k.Role == 2
}
func (k *Keyshare) IsValidator() bool {
return k.Role == 1
}
// ComputeOriginTXTRecord generates a fingerprint for a given origin
func ComputeOriginTXTRecord(origin string) string {
h := sha256.New()
h.Write([]byte(origin))
return fmt.Sprintf("v=sonr,o=%s,p=%x", origin, h.Sum(nil))
}
func ComputeEthAddress(pk ecdsa.PublicKey) string {
// Generate Ethereum address
address := ethcrypto.PubkeyToAddress(pk)
-31
View File
@@ -1,31 +0,0 @@
package types
// Coin represents a cryptocurrency
type Coin interface {
// FormatAddress formats a public key into an address
FormatAddress(pubKey []byte) (string, error)
// GetIndex returns the coin type index
GetIndex() int64
// GetPath returns the coin component path
GetPath() uint32
// GetSymbol returns the coin symbol
GetSymbol() string
// GetMethod returns the coin DID method
GetMethod() string
// GetName returns the coin name
GetName() string
}
// CoinBTCType is the coin type for BTC
const CoinBTCType = int64(0)
// CoinETHType is the coin type for ETH
const CoinETHType = int64(60)
// CoinSNRType is the coin type for SNR
const CoinSNRType = int64(703)
+55 -63
View File
@@ -6,7 +6,12 @@ import (
ormv1alpha1 "cosmossdk.io/api/cosmos/orm/v1alpha1"
"cosmossdk.io/collections"
"cosmossdk.io/x/nft"
"github.com/onsonr/sonr/internal/orm/assettype"
"github.com/onsonr/sonr/internal/orm/keyalgorithm"
"github.com/onsonr/sonr/internal/orm/keycurve"
"github.com/onsonr/sonr/internal/orm/keyencoding"
"github.com/onsonr/sonr/internal/orm/keyrole"
"github.com/onsonr/sonr/internal/orm/keytype"
)
// ParamsKey saves the current module params.
@@ -36,8 +41,7 @@ const DefaultIndex uint64 = 1
func DefaultGenesis() *GenesisState {
return &GenesisState{
// this line is used by starport scaffolding # genesis/types/default
GlobalIntegrity: DefaultGlobalIntegrity(),
Params: DefaultParams(),
Params: DefaultParams(),
}
}
@@ -45,20 +49,19 @@ func DefaultGenesis() *GenesisState {
// failure.
func (gs GenesisState) Validate() error {
// this line is used by starport scaffolding # genesis/types/validate
if gs.GlobalIntegrity == nil {
return fmt.Errorf("global integrity proof is nil")
}
return gs.Params.Validate()
}
// DefaultNFTClasses configures the Initial DIDNamespace NFT classes
func DefaultNFTClasses(nftGenesis *nft.GenesisState) error {
for _, n := range DIDNamespace_value {
nftGenesis.Classes = append(nftGenesis.Classes, DIDNamespace(n).GetNFTClass())
}
return nil
}
// // DefaultNFTClasses configures the Initial DIDNamespace NFT classes
//
// func DefaultNFTClasses(nftGenesis *nft.GenesisState) error {
// for _, n := range DIDNamespace_value {
// nftGenesis.Classes = append(nftGenesis.Classes, DIDNamespace(n).GetNFTClass())
// }
// return nil
// }
//
// DefaultParams returns default module parameters.
func DefaultParams() Params {
return Params{
@@ -70,16 +73,6 @@ func DefaultParams() Params {
}
}
// DefaultGlobalIntegrity returns the default global integrity proof
func DefaultGlobalIntegrity() *GlobalIntegrity {
return &GlobalIntegrity{
Controller: "did:sonr:0x0",
Seed: DefaultSeedMessage(),
Accumulator: []byte{},
Count: 0,
}
}
// DefaultSeedMessage returns the default seed message
func DefaultSeedMessage() string {
l1 := "The Sonr Network shall make no protocol that respects the establishment of centralized authority,"
@@ -97,7 +90,7 @@ func DefaultAssets() []*AssetInfo {
Symbol: "BTC",
Hrp: "bc",
Index: 0,
AssetType: AssetType_ASSET_TYPE_NATIVE,
AssetType: assettype.Native.String(),
IconUrl: "https://cdn.sonr.land/BTC.svg",
},
{
@@ -105,7 +98,7 @@ func DefaultAssets() []*AssetInfo {
Symbol: "ETH",
Hrp: "eth",
Index: 64,
AssetType: AssetType_ASSET_TYPE_NATIVE,
AssetType: assettype.Native.String(),
IconUrl: "https://cdn.sonr.land/ETH.svg",
},
{
@@ -113,76 +106,75 @@ func DefaultAssets() []*AssetInfo {
Symbol: "SNR",
Hrp: "idx",
Index: 703,
AssetType: AssetType_ASSET_TYPE_NATIVE,
AssetType: assettype.Native.String(),
IconUrl: "https://cdn.sonr.land/SNR.svg",
},
}
}
// DefaultKeyInfos returns the default key infos: secp256k1, ed25519, keccak256, and bls12381.
func DefaultKeyInfos() map[string]*KeyInfo {
return map[string]*KeyInfo{
// Identity Key Info
// Sonr Controller Key Info - From MPC
"auth.dwn": {
Role: KeyRole_KEY_ROLE_INVOCATION,
Curve: KeyCurve_KEY_CURVE_P256,
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
Encoding: KeyEncoding_KEY_ENCODING_HEX,
Type: KeyType_KEY_TYPE_MPC,
Role: keyrole.Invocation.String(),
Curve: keycurve.P256.String(),
Algorithm: keyalgorithm.Ecdsa.String(),
Encoding: keyencoding.Hex.String(),
Type: keytype.Mpc.String(),
},
// Sonr Vault Shared Key Info - From Registration
"auth.zk": {
Role: KeyRole_KEY_ROLE_ASSERTION,
Curve: KeyCurve_KEY_CURVE_BLS12381,
Algorithm: KeyAlgorithm_KEY_ALGORITHM_UNSPECIFIED,
Encoding: KeyEncoding_KEY_ENCODING_MULTIBASE,
Type: KeyType_KEY_TYPE_ZK,
Role: keyrole.Assertion.String(),
Curve: keycurve.Bls12381.String(),
Algorithm: keyalgorithm.Es256k.String(),
Encoding: keyencoding.Multibase.String(),
Type: keytype.Zk.String(),
},
// Blockchain Key Info
// Ethereum Key Info
"auth.ethereum": {
Role: KeyRole_KEY_ROLE_DELEGATION,
Curve: KeyCurve_KEY_CURVE_KECCAK256,
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
Encoding: KeyEncoding_KEY_ENCODING_HEX,
Type: KeyType_KEY_TYPE_BIP32,
Role: keyrole.Delegation.String(),
Curve: keycurve.Keccak256.String(),
Algorithm: keyalgorithm.Ecdsa.String(),
Encoding: keyencoding.Hex.String(),
Type: keytype.Bip32.String(),
},
// Bitcoin/IBC Key Info
"auth.bitcoin": {
Role: KeyRole_KEY_ROLE_DELEGATION,
Curve: KeyCurve_KEY_CURVE_SECP256K1,
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
Encoding: KeyEncoding_KEY_ENCODING_HEX,
Type: KeyType_KEY_TYPE_BIP32,
Role: keyrole.Delegation.String(),
Curve: keycurve.Secp256k1.String(),
Algorithm: keyalgorithm.Ecdsa.String(),
Encoding: keyencoding.Hex.String(),
Type: keytype.Bip32.String(),
},
// Authentication Key Info
// Browser based WebAuthn
"webauthn.browser": {
Role: KeyRole_KEY_ROLE_AUTHENTICATION,
Curve: KeyCurve_KEY_CURVE_P256,
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ES256,
Encoding: KeyEncoding_KEY_ENCODING_RAW,
Type: KeyType_KEY_TYPE_WEBAUTHN,
Role: keyrole.Authentication.String(),
Curve: keycurve.P256.String(),
Algorithm: keyalgorithm.Es256.String(),
Encoding: keyencoding.Raw.String(),
Type: keytype.Webauthn.String(),
},
// FIDO U2F
"webauthn.fido": {
Role: KeyRole_KEY_ROLE_AUTHENTICATION,
Curve: KeyCurve_KEY_CURVE_P256,
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ES256,
Encoding: KeyEncoding_KEY_ENCODING_RAW,
Type: KeyType_KEY_TYPE_WEBAUTHN,
Role: keyrole.Authentication.String(),
Curve: keycurve.P256.String(),
Algorithm: keyalgorithm.Es256.String(),
Encoding: keyencoding.Raw.String(),
Type: keytype.Webauthn.String(),
},
// Cross-Platform Passkeys
"webauthn.passkey": {
Role: KeyRole_KEY_ROLE_AUTHENTICATION,
Curve: KeyCurve_KEY_CURVE_ED25519,
Algorithm: KeyAlgorithm_KEY_ALGORITHM_EDDSA,
Encoding: KeyEncoding_KEY_ENCODING_RAW,
Type: KeyType_KEY_TYPE_WEBAUTHN,
Role: keyrole.Authentication.String(),
Curve: keycurve.Ed25519.String(),
Algorithm: keyalgorithm.Eddsa.String(),
Encoding: keyencoding.Raw.String(),
Type: keytype.Webauthn.String(),
},
}
}
+2339 -935
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-102
View File
@@ -1,102 +0,0 @@
package types
import (
"cosmossdk.io/x/nft"
)
func (n DIDNamespace) ID() string {
switch n {
case DIDNamespace_DID_NAMESPACE_DWN:
return "did:dwn:0"
case DIDNamespace_DID_NAMESPACE_SONR:
return "did:sonr:0"
case DIDNamespace_DID_NAMESPACE_BITCOIN:
return "did:btc:0"
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
return "did:eth:0"
case DIDNamespace_DID_NAMESPACE_IBC:
return "did:ibc:0"
case DIDNamespace_DID_NAMESPACE_WEBAUTHN:
return "did:authn:0"
case DIDNamespace_DID_NAMESPACE_SERVICE:
return "did:web:0"
case DIDNamespace_DID_NAMESPACE_IPFS:
return "did:ipfs:0"
}
return ""
}
func (n DIDNamespace) Name() string {
switch n {
case DIDNamespace_DID_NAMESPACE_DWN:
return "DecentralizedWebNode"
case DIDNamespace_DID_NAMESPACE_SONR:
return "SonrNetwork"
case DIDNamespace_DID_NAMESPACE_BITCOIN:
return "BitcoinNetwork"
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
return "EthereumNetwork"
case DIDNamespace_DID_NAMESPACE_IBC:
return "IBCNetwork"
case DIDNamespace_DID_NAMESPACE_WEBAUTHN:
return "WebAuthentication"
case DIDNamespace_DID_NAMESPACE_SERVICE:
return "DecentrlizedService"
case DIDNamespace_DID_NAMESPACE_IPFS:
return "IPFSStorage"
}
return ""
}
func (n DIDNamespace) Symbol() string {
switch n {
case DIDNamespace_DID_NAMESPACE_DWN:
return "DWN"
case DIDNamespace_DID_NAMESPACE_SONR:
return "SONR"
case DIDNamespace_DID_NAMESPACE_BITCOIN:
return "BTC"
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
return "ETH"
case DIDNamespace_DID_NAMESPACE_IBC:
return "IBC"
case DIDNamespace_DID_NAMESPACE_WEBAUTHN:
return "WEBAUTHN"
case DIDNamespace_DID_NAMESPACE_SERVICE:
return "SERVICE"
case DIDNamespace_DID_NAMESPACE_IPFS:
return "IPFS"
}
return ""
}
func (n DIDNamespace) Description() string {
switch n {
case DIDNamespace_DID_NAMESPACE_DWN:
return "DWN Service Provider"
case DIDNamespace_DID_NAMESPACE_SONR:
return "Sonr Network Gateway"
case DIDNamespace_DID_NAMESPACE_BITCOIN:
return "Bitcoin Network Gateway"
case DIDNamespace_DID_NAMESPACE_ETHEREUM:
return "Ethereum Network Gateway"
case DIDNamespace_DID_NAMESPACE_IBC:
return "IBC Network Gateway"
case DIDNamespace_DID_NAMESPACE_WEBAUTHN:
return "Web Authentication Key"
case DIDNamespace_DID_NAMESPACE_SERVICE:
return "Decentrlized Service"
case DIDNamespace_DID_NAMESPACE_IPFS:
return "Data Storage on IPFS"
}
return ""
}
func (n DIDNamespace) GetNFTClass() *nft.Class {
return &nft.Class{
Id: n.ID(),
Name: n.Name(),
Symbol: n.Symbol(),
Description: n.Description(),
}
}
-36
View File
@@ -1,36 +0,0 @@
package types
var (
PermissionScopeStrings = [...]string{
"profile",
"permissions.read",
"permissions.write",
"transactions.read",
"transactions.write",
"wallets.read",
"wallets.create",
"wallets.subscribe",
"wallets.update",
"transactions.verify",
"transactions.broadcast",
"admin.user",
"admin.validator",
}
StringToPermissionScope = map[string]PermissionScope{
"PERMISSION_SCOPE_UNSPECIFIED": PermissionScope_PERMISSION_SCOPE_UNSPECIFIED,
"PERMISSION_SCOPE_PROFILE_NAME": PermissionScope_PERMISSION_SCOPE_BASIC_INFO,
"PERMISSION_SCOPE_IDENTIFIERS_EMAIL": PermissionScope_PERMISSION_SCOPE_PERMISSIONS_READ,
"PERMISSION_SCOPE_IDENTIFIERS_PHONE": PermissionScope_PERMISSION_SCOPE_PERMISSIONS_WRITE,
"PERMISSION_SCOPE_TRANSACTIONS_READ": PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_READ,
"PERMISSION_SCOPE_TRANSACTIONS_WRITE": PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_WRITE,
"PERMISSION_SCOPE_WALLETS_READ": PermissionScope_PERMISSION_SCOPE_WALLETS_READ,
"PERMISSION_SCOPE_WALLETS_CREATE": PermissionScope_PERMISSION_SCOPE_WALLETS_CREATE,
"PERMISSION_SCOPE_WALLETS_SUBSCRIBE": PermissionScope_PERMISSION_SCOPE_WALLETS_SUBSCRIBE,
"PERMISSION_SCOPE_WALLETS_UPDATE": PermissionScope_PERMISSION_SCOPE_WALLETS_UPDATE,
"PERMISSION_SCOPE_TRANSACTIONS_VERIFY": PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_VERIFY,
"PERMISSION_SCOPE_TRANSACTIONS_BROADCAST": PermissionScope_PERMISSION_SCOPE_TRANSACTIONS_BROADCAST,
"PERMISSION_SCOPE_ADMIN_USER": PermissionScope_PERMISSION_SCOPE_ADMIN_USER,
"PERMISSION_SCOPE_ADMIN_VALIDATOR": PermissionScope_PERMISSION_SCOPE_ADMIN_VALIDATOR,
}
)
-153
View File
@@ -1,153 +0,0 @@
package types
import (
"crypto/ecdsa"
"encoding/hex"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/mr-tron/base58/base58"
"github.com/onsonr/crypto"
"github.com/onsonr/crypto/macaroon"
)
var WalletKeyInfo = &KeyInfo{
Role: KeyRole_KEY_ROLE_DELEGATION,
Curve: KeyCurve_KEY_CURVE_SECP256K1,
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
Encoding: KeyEncoding_KEY_ENCODING_HEX,
Type: KeyType_KEY_TYPE_BIP32,
}
var EthKeyInfo = &KeyInfo{
Role: KeyRole_KEY_ROLE_DELEGATION,
Curve: KeyCurve_KEY_CURVE_KECCAK256,
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
Encoding: KeyEncoding_KEY_ENCODING_HEX,
Type: KeyType_KEY_TYPE_BIP32,
}
var SonrKeyInfo = &KeyInfo{
Role: KeyRole_KEY_ROLE_INVOCATION,
Curve: KeyCurve_KEY_CURVE_P256,
Algorithm: KeyAlgorithm_KEY_ALGORITHM_ECDSA,
Encoding: KeyEncoding_KEY_ENCODING_HEX,
Type: KeyType_KEY_TYPE_MPC,
}
var ChainCodeKeyInfos = map[ChainCode]*KeyInfo{
ChainCodeBTC: WalletKeyInfo,
ChainCodeETH: EthKeyInfo,
ChainCodeSNR: SonrKeyInfo,
ChainCodeIBC: WalletKeyInfo,
}
// NewEthPublicKey returns a new ethereum public key
func NewPublicKey(data []byte, keyInfo *KeyInfo) (*PubKey, error) {
encKey, err := keyInfo.Encoding.EncodeRaw(data)
if err != nil {
return nil, err
}
return &PubKey{
Raw: encKey,
Role: keyInfo.Role,
Encoding: keyInfo.Encoding,
Algorithm: keyInfo.Algorithm,
Curve: keyInfo.Curve,
KeyType: keyInfo.Type,
}, nil
}
// Address returns the address of the public key
func (k *PubKey) Address() cryptotypes.Address {
return nil
}
// Bytes returns the raw bytes of the public key
func (k *PubKey) Bytes() []byte {
bz, _ := k.GetEncoding().DecodeRaw(k.GetRaw())
return bz
}
// Clone returns a copy of the public key
func (k *PubKey) Clone() cryptotypes.PubKey {
return &PubKey{
Raw: k.GetRaw(),
Role: k.GetRole(),
Encoding: k.GetEncoding(),
Algorithm: k.GetAlgorithm(),
Curve: k.GetCurve(),
KeyType: k.GetKeyType(),
}
}
// IssueMacaroon returns a macaroon for the public key with the given id and location
func (pk *PubKey) IssueMacaroon(subject string, origin string) (*macaroon.Macaroon, error) {
return macaroon.New(pk.Bytes(), []byte(subject), origin, macaroon.LatestVersion)
}
// ECDSA returns the ECDSA public key
func (k *PubKey) ECDSA() (*ecdsa.PublicKey, error) {
return crypto.ComputeEcdsaPublicKey(k.Bytes())
}
// VerifySignature verifies a signature over the given message
func (k *PubKey) VerifySignature(msg []byte, sig []byte) bool {
pk, err := crypto.ComputeEcdsaPublicKey(k.Bytes())
sigMpc, err := crypto.DeserializeMPCSignature(sig)
if err != nil {
return false
}
return crypto.VerifyMPCSignature(sigMpc, msg, pk)
}
// Equals returns true if two public keys are equal
func (k *PubKey) Equals(k2 cryptotypes.PubKey) bool {
if k == nil && k2 == nil {
return true
}
return false
}
// Type returns the type of the public key
func (k *PubKey) Type() string {
return k.KeyType.String()
}
// DecodePublicKey extracts the public key from the given data
func (k *KeyInfo) DecodePublicKey(data interface{}) ([]byte, error) {
var bz []byte
switch v := data.(type) {
case string:
bz = []byte(v)
case []byte:
bz = v
default:
return nil, ErrUnsupportedKeyEncoding
}
if k.Encoding == KeyEncoding_KEY_ENCODING_RAW {
return bz, nil
}
if k.Encoding == KeyEncoding_KEY_ENCODING_HEX {
return hex.DecodeString(string(bz))
}
if k.Encoding == KeyEncoding_KEY_ENCODING_MULTIBASE {
return base58.Decode(string(bz))
}
return nil, ErrUnsupportedKeyEncoding
}
// EncodePublicKey encodes the public key according to the KeyInfo's encoding
func (k *KeyInfo) EncodePublicKey(data []byte) (string, error) {
if k.Encoding == KeyEncoding_KEY_ENCODING_RAW {
return string(data), nil
}
if k.Encoding == KeyEncoding_KEY_ENCODING_HEX {
return hex.EncodeToString(data), nil
}
if k.Encoding == KeyEncoding_KEY_ENCODING_MULTIBASE {
return base58.Encode(data), nil
}
return "", ErrUnsupportedKeyEncoding
}
+31 -352
View File
@@ -258,68 +258,6 @@ func (m *QueryResolveResponse) GetDocument() *Document {
return nil
}
// QueryLoginOptionsResponse is the response type for the Query/LoginOptions RPC method.
type QueryServiceResponse struct {
// options is the PublicKeyCredentialAttestationOptions
Existing bool `protobuf:"varint,1,opt,name=existing,proto3" json:"existing,omitempty"`
Service *ServiceInfo `protobuf:"bytes,2,opt,name=service,proto3" json:"service,omitempty"`
TxtRecord string `protobuf:"bytes,3,opt,name=txt_record,json=txtRecord,proto3" json:"txt_record,omitempty"`
}
func (m *QueryServiceResponse) Reset() { *m = QueryServiceResponse{} }
func (m *QueryServiceResponse) String() string { return proto.CompactTextString(m) }
func (*QueryServiceResponse) ProtoMessage() {}
func (*QueryServiceResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_ae1fa9bb626e2869, []int{4}
}
func (m *QueryServiceResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *QueryServiceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_QueryServiceResponse.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *QueryServiceResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryServiceResponse.Merge(m, src)
}
func (m *QueryServiceResponse) XXX_Size() int {
return m.Size()
}
func (m *QueryServiceResponse) XXX_DiscardUnknown() {
xxx_messageInfo_QueryServiceResponse.DiscardUnknown(m)
}
var xxx_messageInfo_QueryServiceResponse proto.InternalMessageInfo
func (m *QueryServiceResponse) GetExisting() bool {
if m != nil {
return m.Existing
}
return false
}
func (m *QueryServiceResponse) GetService() *ServiceInfo {
if m != nil {
return m.Service
}
return nil
}
func (m *QueryServiceResponse) GetTxtRecord() string {
if m != nil {
return m.TxtRecord
}
return ""
}
// SyncRequest is the request type for the Sync RPC method.
type SyncRequest struct {
Did string `protobuf:"bytes,1,opt,name=did,proto3" json:"did,omitempty"`
@@ -329,7 +267,7 @@ func (m *SyncRequest) Reset() { *m = SyncRequest{} }
func (m *SyncRequest) String() string { return proto.CompactTextString(m) }
func (*SyncRequest) ProtoMessage() {}
func (*SyncRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_ae1fa9bb626e2869, []int{5}
return fileDescriptor_ae1fa9bb626e2869, []int{4}
}
func (m *SyncRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@@ -374,7 +312,7 @@ func (m *SyncResponse) Reset() { *m = SyncResponse{} }
func (m *SyncResponse) String() string { return proto.CompactTextString(m) }
func (*SyncResponse) ProtoMessage() {}
func (*SyncResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_ae1fa9bb626e2869, []int{6}
return fileDescriptor_ae1fa9bb626e2869, []int{5}
}
func (m *SyncResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@@ -415,7 +353,6 @@ func init() {
proto.RegisterType((*QueryResponse)(nil), "did.v1.QueryResponse")
proto.RegisterType((*QueryParamsResponse)(nil), "did.v1.QueryParamsResponse")
proto.RegisterType((*QueryResolveResponse)(nil), "did.v1.QueryResolveResponse")
proto.RegisterType((*QueryServiceResponse)(nil), "did.v1.QueryServiceResponse")
proto.RegisterType((*SyncRequest)(nil), "did.v1.SyncRequest")
proto.RegisterType((*SyncResponse)(nil), "did.v1.SyncResponse")
}
@@ -423,41 +360,35 @@ func init() {
func init() { proto.RegisterFile("did/v1/query.proto", fileDescriptor_ae1fa9bb626e2869) }
var fileDescriptor_ae1fa9bb626e2869 = []byte{
// 543 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0x41, 0x6f, 0xd3, 0x30,
0x14, 0x6e, 0xba, 0xb5, 0x69, 0x5f, 0x3b, 0x18, 0x6e, 0x85, 0x42, 0x19, 0x01, 0xf9, 0x80, 0x76,
0x80, 0x5a, 0x2b, 0x57, 0x90, 0x10, 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 0xe0, 0x3b, 0x9b, 0xaf, 0x90, 0xdb, 0xb9, 0x84,
0xae, 0xad, 0x04, 0x23, 0xa3, 0xd7, 0x46, 0x40, 0x8a, 0xf7, 0x71, 0x4a, 0x39, 0x3d, 0x43, 0x6f,
0xc0, 0x77, 0x66, 0xfd, 0x97, 0xe4, 0xa5, 0xf5, 0xe0, 0x3b, 0x46, 0xb2, 0x83, 0x6e, 0x11, 0xe7,
0x32, 0x39, 0xb5, 0xcf, 0xe2, 0x0c, 0x3d, 0x87, 0xcd, 0xc2, 0x2e, 0xb4, 0x5a, 0xca, 0xca, 0xdd,
0x5e, 0x77, 0x1d, 0x74, 0x6a, 0x5b, 0x46, 0xcd, 0xc7, 0x35, 0xa2, 0x72, 0x91, 0xbc, 0x78, 0xfa,
0x63, 0x1e, 0x7a, 0xe7, 0xf3, 0xd0, 0xfb, 0x3d, 0x0f, 0xbd, 0x2f, 0x8b, 0xb0, 0x72, 0xbe, 0x08,
0x2b, 0xbf, 0x16, 0x61, 0xe5, 0x2d, 0x4e, 0xb9, 0xfe, 0x38, 0x39, 0xea, 0x27, 0x72, 0x44, 0xa4,
0x50, 0x52, 0x64, 0xc4, 0x7c, 0x66, 0x66, 0x32, 0x9d, 0x8f, 0x99, 0x3a, 0xaa, 0x9b, 0x87, 0xfd,
0xe4, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfc, 0x65, 0xe3, 0x8b, 0x3f, 0x04, 0x00, 0x00,
// 446 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0x4f, 0x6b, 0xd4, 0x40,
0x14, 0xdf, 0x69, 0xbb, 0xd9, 0xf6, 0x75, 0xab, 0xe5, 0x35, 0x48, 0x58, 0x4b, 0x94, 0x39, 0x48,
0x0f, 0x92, 0xa1, 0xf5, 0xaa, 0x20, 0xd2, 0xa3, 0x07, 0x1b, 0x6f, 0x9e, 0x4c, 0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 0x2b,
0xa3, 0x55, 0xc5, 0xec, 0xcf, 0x7b, 0xab, 0x5f, 0xb7, 0xa5, 0x30, 0xe7, 0x81, 0x7d, 0xfb, 0x4f,
0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0x31, 0x4b, 0x75, 0xe8, 0x4d, 0x03, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@@ -476,10 +407,6 @@ type QueryClient interface {
Params(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
// Resolve queries the DID document by its id.
Resolve(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResolveResponse, error)
// Service returns associated ServiceInfo for a given Origin
// if the servie is not found, a fingerprint is generated to be used
// as a TXT record in DNS. v=sonr, o=origin, p=protocol
Service(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryServiceResponse, error)
// Sync queries the DID document by its id. And returns the required PKL information
Sync(ctx context.Context, in *SyncRequest, opts ...grpc.CallOption) (*SyncResponse, error)
}
@@ -510,15 +437,6 @@ func (c *queryClient) Resolve(ctx context.Context, in *QueryRequest, opts ...grp
return out, nil
}
func (c *queryClient) Service(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryServiceResponse, error) {
out := new(QueryServiceResponse)
err := c.cc.Invoke(ctx, "/did.v1.Query/Service", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *queryClient) Sync(ctx context.Context, in *SyncRequest, opts ...grpc.CallOption) (*SyncResponse, error) {
out := new(SyncResponse)
err := c.cc.Invoke(ctx, "/did.v1.Query/Sync", in, out, opts...)
@@ -534,10 +452,6 @@ type QueryServer interface {
Params(context.Context, *QueryRequest) (*QueryParamsResponse, error)
// Resolve queries the DID document by its id.
Resolve(context.Context, *QueryRequest) (*QueryResolveResponse, error)
// Service returns associated ServiceInfo for a given Origin
// if the servie is not found, a fingerprint is generated to be used
// as a TXT record in DNS. v=sonr, o=origin, p=protocol
Service(context.Context, *QueryRequest) (*QueryServiceResponse, error)
// Sync queries the DID document by its id. And returns the required PKL information
Sync(context.Context, *SyncRequest) (*SyncResponse, error)
}
@@ -552,9 +466,6 @@ func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryRequest)
func (*UnimplementedQueryServer) Resolve(ctx context.Context, req *QueryRequest) (*QueryResolveResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Resolve not implemented")
}
func (*UnimplementedQueryServer) Service(ctx context.Context, req *QueryRequest) (*QueryServiceResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Service not implemented")
}
func (*UnimplementedQueryServer) Sync(ctx context.Context, req *SyncRequest) (*SyncResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Sync not implemented")
}
@@ -599,24 +510,6 @@ func _Query_Resolve_Handler(srv interface{}, ctx context.Context, dec func(inter
return interceptor(ctx, in, info, handler)
}
func _Query_Service_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QueryRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(QueryServer).Service(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/did.v1.Query/Service",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(QueryServer).Service(ctx, req.(*QueryRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Query_Sync_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SyncRequest)
if err := dec(in); err != nil {
@@ -647,10 +540,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{
MethodName: "Resolve",
Handler: _Query_Resolve_Handler,
},
{
MethodName: "Service",
Handler: _Query_Service_Handler,
},
{
MethodName: "Sync",
Handler: _Query_Sync_Handler,
@@ -845,58 +734,6 @@ func (m *QueryResolveResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *QueryServiceResponse) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *QueryServiceResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *QueryServiceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.TxtRecord) > 0 {
i -= len(m.TxtRecord)
copy(dAtA[i:], m.TxtRecord)
i = encodeVarintQuery(dAtA, i, uint64(len(m.TxtRecord)))
i--
dAtA[i] = 0x1a
}
if m.Service != nil {
{
size, err := m.Service.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintQuery(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
}
if m.Existing {
i--
if m.Existing {
dAtA[i] = 1
} else {
dAtA[i] = 0
}
i--
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
func (m *SyncRequest) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@@ -1046,26 +883,6 @@ func (m *QueryResolveResponse) Size() (n int) {
return n
}
func (m *QueryServiceResponse) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Existing {
n += 2
}
if m.Service != nil {
l = m.Service.Size()
n += 1 + l + sovQuery(uint64(l))
}
l = len(m.TxtRecord)
if l > 0 {
n += 1 + l + sovQuery(uint64(l))
}
return n
}
func (m *SyncRequest) Size() (n int) {
if m == nil {
return 0
@@ -1621,144 +1438,6 @@ func (m *QueryResolveResponse) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *QueryServiceResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: QueryServiceResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: QueryServiceResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Existing", wireType)
}
var v int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
v |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
m.Existing = bool(v != 0)
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Service", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthQuery
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthQuery
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Service == nil {
m.Service = &ServiceInfo{}
}
if err := m.Service.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field TxtRecord", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthQuery
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthQuery
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.TxtRecord = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipQuery(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthQuery
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *SyncRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
-119
View File
@@ -141,78 +141,6 @@ func local_request_Query_Resolve_0(ctx context.Context, marshaler runtime.Marsha
}
var (
filter_Query_Service_0 = &utilities.DoubleArray{Encoding: map[string]int{"origin": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
)
func request_Query_Service_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["origin"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "origin")
}
protoReq.Origin, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "origin", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Service_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.Service(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Query_Service_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq QueryRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["origin"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "origin")
}
protoReq.Origin, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "origin", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Service_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Service(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_Query_Sync_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
@@ -301,29 +229,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
})
mux.Handle("GET", pattern_Query_Service_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_Query_Service_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Service_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_Query_Sync_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -428,26 +333,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
})
mux.Handle("GET", pattern_Query_Service_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_Query_Service_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_Query_Service_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_Query_Sync_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@@ -476,8 +361,6 @@ var (
pattern_Query_Resolve_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 0}, []string{"did"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_Service_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"service", "origin"}, "", runtime.AssumeColonVerbOpt(false)))
pattern_Query_Sync_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"sync"}, "", runtime.AssumeColonVerbOpt(false)))
)
@@ -486,7 +369,5 @@ var (
forward_Query_Resolve_0 = runtime.ForwardResponseMessage
forward_Query_Service_0 = runtime.ForwardResponseMessage
forward_Query_Sync_0 = runtime.ForwardResponseMessage
)
+239 -278
View File
@@ -27,16 +27,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
type Alias struct {
// The unique identifier of the alias
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
// The DID of the alias
Did string `protobuf:"bytes,2,opt,name=did,proto3" json:"did,omitempty"`
// The alias of the DID
Alias string `protobuf:"bytes,3,opt,name=alias,proto3" json:"alias,omitempty"`
Subject string `protobuf:"bytes,2,opt,name=subject,proto3" json:"subject,omitempty"`
// Origin of the alias
Origin string `protobuf:"bytes,4,opt,name=origin,proto3" json:"origin,omitempty"`
// Permissions of the alias
Scopes []string `protobuf:"bytes,5,rep,name=scopes,proto3" json:"scopes,omitempty"`
// Expiration of the alias
Expiration int64 `protobuf:"varint,6,opt,name=expiration,proto3" json:"expiration,omitempty"`
Origin string `protobuf:"bytes,3,opt,name=origin,proto3" json:"origin,omitempty"`
}
func (m *Alias) Reset() { *m = Alias{} }
@@ -79,16 +73,9 @@ func (m *Alias) GetId() string {
return ""
}
func (m *Alias) GetDid() string {
func (m *Alias) GetSubject() string {
if m != nil {
return m.Did
}
return ""
}
func (m *Alias) GetAlias() string {
if m != nil {
return m.Alias
return m.Subject
}
return ""
}
@@ -100,36 +87,26 @@ func (m *Alias) GetOrigin() string {
return ""
}
func (m *Alias) GetScopes() []string {
if m != nil {
return m.Scopes
}
return nil
}
func (m *Alias) GetExpiration() int64 {
if m != nil {
return m.Expiration
}
return 0
}
// Controller represents a Sonr DWN Vault
type Controller struct {
// The unique identifier of the controller
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
// The DID of the controller
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
SonrAddress string `protobuf:"bytes,2,opt,name=sonr_address,json=sonrAddress,proto3" json:"sonr_address,omitempty"`
// The DID of the controller
EthAddress string `protobuf:"bytes,3,opt,name=eth_address,json=ethAddress,proto3" json:"eth_address,omitempty"`
// The DID of the controller
BtcAddress string `protobuf:"bytes,4,opt,name=btc_address,json=btcAddress,proto3" json:"btc_address,omitempty"`
// Aliases of the controller
Aliases []*Alias `protobuf:"bytes,3,rep,name=aliases,proto3" json:"aliases,omitempty"`
Aliases []string `protobuf:"bytes,5,rep,name=aliases,proto3" json:"aliases,omitempty"`
// PubKey is the verification method
PublicKey *PubKey `protobuf:"bytes,4,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
PublicKey *PubKey `protobuf:"bytes,6,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
// The vault address or identifier
VaultCid string `protobuf:"bytes,5,opt,name=vault_cid,json=vaultCid,proto3" json:"vault_cid,omitempty"`
VaultCid string `protobuf:"bytes,7,opt,name=vault_cid,json=vaultCid,proto3" json:"vault_cid,omitempty"`
// The Authentications of the controller
Authentication []*Credential `protobuf:"bytes,6,rep,name=authentication,proto3" json:"authentication,omitempty"`
Authentication []string `protobuf:"bytes,8,rep,name=authentication,proto3" json:"authentication,omitempty"`
// The Status of the claims for the controller
Status string `protobuf:"bytes,7,opt,name=status,proto3" json:"status,omitempty"`
Status string `protobuf:"bytes,9,opt,name=status,proto3" json:"status,omitempty"`
}
func (m *Controller) Reset() { *m = Controller{} }
@@ -172,14 +149,28 @@ func (m *Controller) GetId() string {
return ""
}
func (m *Controller) GetAddress() string {
func (m *Controller) GetSonrAddress() string {
if m != nil {
return m.Address
return m.SonrAddress
}
return ""
}
func (m *Controller) GetAliases() []*Alias {
func (m *Controller) GetEthAddress() string {
if m != nil {
return m.EthAddress
}
return ""
}
func (m *Controller) GetBtcAddress() string {
if m != nil {
return m.BtcAddress
}
return ""
}
func (m *Controller) GetAliases() []string {
if m != nil {
return m.Aliases
}
@@ -200,7 +191,7 @@ func (m *Controller) GetVaultCid() string {
return ""
}
func (m *Controller) GetAuthentication() []*Credential {
func (m *Controller) GetAuthentication() []string {
if m != nil {
return m.Authentication
}
@@ -221,15 +212,15 @@ type Verification struct {
// The controller of the verification
Controller string `protobuf:"bytes,2,opt,name=controller,proto3" json:"controller,omitempty"`
// The DIDNamespace of the verification
Method DIDNamespace `protobuf:"varint,3,opt,name=method,proto3,enum=did.v1.DIDNamespace" json:"method,omitempty"`
DidMethod string `protobuf:"bytes,3,opt,name=did_method,json=didMethod,proto3" json:"did_method,omitempty"`
// The value of the linked identifier
Issuer string `protobuf:"bytes,4,opt,name=issuer,proto3" json:"issuer,omitempty"`
// The subject of the verification
Subject string `protobuf:"bytes,5,opt,name=subject,proto3" json:"subject,omitempty"`
// The public key of the verification
PublicKey *PubKey `protobuf:"bytes,6,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
// The Verification Kind (Authentication, Assertion, CapabilityDelegation, CapabilityInvocation)
Kind string `protobuf:"bytes,7,opt,name=kind,proto3" json:"kind,omitempty"`
// The Verification Type (Authentication, Assertion, CapabilityDelegation, CapabilityInvocation)
VerificationType string `protobuf:"bytes,7,opt,name=verification_type,json=verificationType,proto3" json:"verification_type,omitempty"`
}
func (m *Verification) Reset() { *m = Verification{} }
@@ -279,11 +270,11 @@ func (m *Verification) GetController() string {
return ""
}
func (m *Verification) GetMethod() DIDNamespace {
func (m *Verification) GetDidMethod() string {
if m != nil {
return m.Method
return m.DidMethod
}
return DIDNamespace_DID_NAMESPACE_UNSPECIFIED
return ""
}
func (m *Verification) GetIssuer() string {
@@ -307,9 +298,9 @@ func (m *Verification) GetPublicKey() *PubKey {
return nil
}
func (m *Verification) GetKind() string {
func (m *Verification) GetVerificationType() string {
if m != nil {
return m.Kind
return m.VerificationType
}
return ""
}
@@ -323,43 +314,42 @@ func init() {
func init() { proto.RegisterFile("did/v1/state.proto", fileDescriptor_f44bb702879c34b4) }
var fileDescriptor_f44bb702879c34b4 = []byte{
// 561 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0x31, 0x8f, 0xd3, 0x3e,
0x18, 0xc6, 0x2f, 0x49, 0x9b, 0xfe, 0xfb, 0xde, 0xff, 0x4a, 0x65, 0x2a, 0x30, 0x87, 0x14, 0xaa,
0x0e, 0xd0, 0xa1, 0x34, 0x5c, 0x41, 0x0c, 0x15, 0x0b, 0xf4, 0x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x1a, 0x81, 0x9f, 0x51,
0xb5, 0xe4, 0xc4, 0x5c, 0x83, 0xce, 0xa4, 0x57, 0x0f, 0x72, 0xfa, 0xf2, 0xf4, 0x55, 0x9c, 0x51,
0x59, 0xc4, 0x09, 0x8d, 0xac, 0x47, 0x8f, 0xc0, 0xa4, 0x2c, 0xa9, 0xa8, 0x6f, 0x47, 0x55, 0xe9,
0xaf, 0x24, 0xcb, 0xf9, 0x7b, 0x9a, 0x28, 0x4b, 0xac, 0x2e, 0xf7, 0xe0, 0xfb, 0xff, 0x82, 0x8f,
0xa0, 0x71, 0xc1, 0x72, 0x62, 0x09, 0x99, 0xf5, 0xf4, 0xa9, 0xe1, 0xf3, 0xc8, 0xf2, 0xb9, 0x0f,
0xfd, 0x3f, 0xf1, 0x47, 0x55, 0xae, 0x51, 0x15, 0x63, 0x64, 0x9b, 0x9a, 0x9b, 0xd5, 0x7c, 0xf1,
0xec, 0xdb, 0x26, 0x70, 0xae, 0x36, 0x81, 0xf3, 0x73, 0x13, 0x38, 0x1f, 0xb7, 0xc1, 0xc1, 0xd5,
0x36, 0x38, 0xf8, 0xb1, 0x0d, 0x0e, 0xde, 0x0e, 0x16, 0x4c, 0x2d, 0xcb, 0xf9, 0x38, 0xe1, 0x59,
0xc8, 0x73, 0xc9, 0x73, 0x11, 0x9a, 0x9f, 0xcb, 0x50, 0x3f, 0x2a, 0xb5, 0x2e, 0xa8, 0x9c, 0xfb,
0xe6, 0x45, 0x3d, 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x70, 0x7b, 0x75, 0x51, 0xb3, 0x03, 0x00,
0x00,
// 557 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xcb, 0x6e, 0xd3, 0x40,
0x14, 0xed, 0xd8, 0x79, 0x34, 0x37, 0x55, 0x70, 0x47, 0x55, 0x19, 0x15, 0x30, 0x21, 0x42, 0x55,
0x25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x80, 0x72, 0x3a, 0x98, 0x30, 0x35, 0x12, 0xd4, 0x45, 0xd3, 0xa0,
0x9c, 0xbe, 0x31, 0x80, 0x1e, 0x95, 0x4b, 0x59, 0xb0, 0xdc, 0x85, 0xe2, 0xaa, 0xf2, 0xb2, 0x55,
0xb7, 0x97, 0xed, 0x3f, 0x03, 0x79, 0x06, 0xfb, 0xb3, 0x52, 0xff, 0x03, 0x35, 0x9f, 0x32, 0x17,
0x4c, 0x50, 0x3e, 0x78, 0x37, 0x9f, 0xb2, 0xfe, 0xd4, 0x18, 0x7c, 0xb5, 0x59, 0x58, 0xdb, 0x4d,
0xd7, 0x69, 0x1b, 0x8b, 0x3b, 0xf0, 0x70, 0x33, 0x5e, 0x77, 0x33, 0x5b, 0xd7, 0x72, 0x8d, 0xe7,
0xc7, 0xd0, 0xbe, 0x23, 0xba, 0xba, 0x64, 0xc5, 0xf3, 0x09, 0x22, 0xd5, 0xd7, 0xaf, 0x7e, 0x2c,
0x42, 0x74, 0xb3, 0x08, 0xd1, 0x9f, 0x45, 0x88, 0xbe, 0x2e, 0xc3, 0x9d, 0x9b, 0x65, 0xb8, 0xf3,
0x6b, 0x19, 0xee, 0x7c, 0xe8, 0x0c, 0xb9, 0x1a, 0x15, 0x49, 0x2f, 0x15, 0x93, 0x48, 0x64, 0x3a,
0xe9, 0xc8, 0x7c, 0x3e, 0x47, 0xfa, 0xd9, 0xea, 0x1b, 0x65, 0x52, 0x33, 0x4f, 0xf6, 0xe5, 0xbf,
0x00, 0x00, 0x00, 0xff, 0xff, 0x58, 0x8d, 0xb9, 0xaa, 0xff, 0x03, 0x00, 0x00,
}
func (m *Alias) Marshal() (dAtA []byte, err error) {
@@ -382,38 +372,17 @@ func (m *Alias) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.Expiration != 0 {
i = encodeVarintState(dAtA, i, uint64(m.Expiration))
i--
dAtA[i] = 0x30
}
if len(m.Scopes) > 0 {
for iNdEx := len(m.Scopes) - 1; iNdEx >= 0; iNdEx-- {
i -= len(m.Scopes[iNdEx])
copy(dAtA[i:], m.Scopes[iNdEx])
i = encodeVarintState(dAtA, i, uint64(len(m.Scopes[iNdEx])))
i--
dAtA[i] = 0x2a
}
}
if len(m.Origin) > 0 {
i -= len(m.Origin)
copy(dAtA[i:], m.Origin)
i = encodeVarintState(dAtA, i, uint64(len(m.Origin)))
i--
dAtA[i] = 0x22
}
if len(m.Alias) > 0 {
i -= len(m.Alias)
copy(dAtA[i:], m.Alias)
i = encodeVarintState(dAtA, i, uint64(len(m.Alias)))
i--
dAtA[i] = 0x1a
}
if len(m.Did) > 0 {
i -= len(m.Did)
copy(dAtA[i:], m.Did)
i = encodeVarintState(dAtA, i, uint64(len(m.Did)))
if len(m.Subject) > 0 {
i -= len(m.Subject)
copy(dAtA[i:], m.Subject)
i = encodeVarintState(dAtA, i, uint64(len(m.Subject)))
i--
dAtA[i] = 0x12
}
@@ -452,20 +421,15 @@ func (m *Controller) MarshalToSizedBuffer(dAtA []byte) (int, error) {
copy(dAtA[i:], m.Status)
i = encodeVarintState(dAtA, i, uint64(len(m.Status)))
i--
dAtA[i] = 0x3a
dAtA[i] = 0x4a
}
if len(m.Authentication) > 0 {
for iNdEx := len(m.Authentication) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Authentication[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintState(dAtA, i, uint64(size))
}
i -= len(m.Authentication[iNdEx])
copy(dAtA[i:], m.Authentication[iNdEx])
i = encodeVarintState(dAtA, i, uint64(len(m.Authentication[iNdEx])))
i--
dAtA[i] = 0x32
dAtA[i] = 0x42
}
}
if len(m.VaultCid) > 0 {
@@ -473,7 +437,7 @@ func (m *Controller) MarshalToSizedBuffer(dAtA []byte) (int, error) {
copy(dAtA[i:], m.VaultCid)
i = encodeVarintState(dAtA, i, uint64(len(m.VaultCid)))
i--
dAtA[i] = 0x2a
dAtA[i] = 0x3a
}
if m.PublicKey != nil {
{
@@ -485,26 +449,35 @@ func (m *Controller) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i = encodeVarintState(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x22
dAtA[i] = 0x32
}
if len(m.Aliases) > 0 {
for iNdEx := len(m.Aliases) - 1; iNdEx >= 0; iNdEx-- {
{
size, err := m.Aliases[iNdEx].MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintState(dAtA, i, uint64(size))
}
i -= len(m.Aliases[iNdEx])
copy(dAtA[i:], m.Aliases[iNdEx])
i = encodeVarintState(dAtA, i, uint64(len(m.Aliases[iNdEx])))
i--
dAtA[i] = 0x1a
dAtA[i] = 0x2a
}
}
if len(m.Address) > 0 {
i -= len(m.Address)
copy(dAtA[i:], m.Address)
i = encodeVarintState(dAtA, i, uint64(len(m.Address)))
if len(m.BtcAddress) > 0 {
i -= len(m.BtcAddress)
copy(dAtA[i:], m.BtcAddress)
i = encodeVarintState(dAtA, i, uint64(len(m.BtcAddress)))
i--
dAtA[i] = 0x22
}
if len(m.EthAddress) > 0 {
i -= len(m.EthAddress)
copy(dAtA[i:], m.EthAddress)
i = encodeVarintState(dAtA, i, uint64(len(m.EthAddress)))
i--
dAtA[i] = 0x1a
}
if len(m.SonrAddress) > 0 {
i -= len(m.SonrAddress)
copy(dAtA[i:], m.SonrAddress)
i = encodeVarintState(dAtA, i, uint64(len(m.SonrAddress)))
i--
dAtA[i] = 0x12
}
@@ -538,10 +511,10 @@ func (m *Verification) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.Kind) > 0 {
i -= len(m.Kind)
copy(dAtA[i:], m.Kind)
i = encodeVarintState(dAtA, i, uint64(len(m.Kind)))
if len(m.VerificationType) > 0 {
i -= len(m.VerificationType)
copy(dAtA[i:], m.VerificationType)
i = encodeVarintState(dAtA, i, uint64(len(m.VerificationType)))
i--
dAtA[i] = 0x3a
}
@@ -571,10 +544,12 @@ func (m *Verification) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i--
dAtA[i] = 0x22
}
if m.Method != 0 {
i = encodeVarintState(dAtA, i, uint64(m.Method))
if len(m.DidMethod) > 0 {
i -= len(m.DidMethod)
copy(dAtA[i:], m.DidMethod)
i = encodeVarintState(dAtA, i, uint64(len(m.DidMethod)))
i--
dAtA[i] = 0x18
dAtA[i] = 0x1a
}
if len(m.Controller) > 0 {
i -= len(m.Controller)
@@ -614,11 +589,7 @@ func (m *Alias) Size() (n int) {
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
l = len(m.Did)
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
l = len(m.Alias)
l = len(m.Subject)
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
@@ -626,15 +597,6 @@ func (m *Alias) Size() (n int) {
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
if len(m.Scopes) > 0 {
for _, s := range m.Scopes {
l = len(s)
n += 1 + l + sovState(uint64(l))
}
}
if m.Expiration != 0 {
n += 1 + sovState(uint64(m.Expiration))
}
return n
}
@@ -648,13 +610,21 @@ func (m *Controller) Size() (n int) {
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
l = len(m.Address)
l = len(m.SonrAddress)
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
l = len(m.EthAddress)
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
l = len(m.BtcAddress)
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
if len(m.Aliases) > 0 {
for _, e := range m.Aliases {
l = e.Size()
for _, s := range m.Aliases {
l = len(s)
n += 1 + l + sovState(uint64(l))
}
}
@@ -667,8 +637,8 @@ func (m *Controller) Size() (n int) {
n += 1 + l + sovState(uint64(l))
}
if len(m.Authentication) > 0 {
for _, e := range m.Authentication {
l = e.Size()
for _, s := range m.Authentication {
l = len(s)
n += 1 + l + sovState(uint64(l))
}
}
@@ -693,8 +663,9 @@ func (m *Verification) Size() (n int) {
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
if m.Method != 0 {
n += 1 + sovState(uint64(m.Method))
l = len(m.DidMethod)
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
l = len(m.Issuer)
if l > 0 {
@@ -708,7 +679,7 @@ func (m *Verification) Size() (n int) {
l = m.PublicKey.Size()
n += 1 + l + sovState(uint64(l))
}
l = len(m.Kind)
l = len(m.VerificationType)
if l > 0 {
n += 1 + l + sovState(uint64(l))
}
@@ -784,7 +755,7 @@ func (m *Alias) Unmarshal(dAtA []byte) error {
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Did", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field Subject", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
@@ -812,41 +783,9 @@ func (m *Alias) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Did = string(dAtA[iNdEx:postIndex])
m.Subject = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Alias", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthState
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthState
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Alias = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Origin", wireType)
}
@@ -878,57 +817,6 @@ func (m *Alias) Unmarshal(dAtA []byte) error {
}
m.Origin = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Scopes", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthState
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthState
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Scopes = append(m.Scopes, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
case 6:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType)
}
m.Expiration = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Expiration |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipState(dAtA[iNdEx:])
@@ -1013,7 +901,7 @@ func (m *Controller) Unmarshal(dAtA []byte) error {
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field SonrAddress", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
@@ -1041,13 +929,13 @@ func (m *Controller) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Address = string(dAtA[iNdEx:postIndex])
m.SonrAddress = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Aliases", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field EthAddress", wireType)
}
var msglen int
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
@@ -1057,27 +945,89 @@ func (m *Controller) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthState
}
postIndex := iNdEx + msglen
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthState
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Aliases = append(m.Aliases, &Alias{})
if err := m.Aliases[len(m.Aliases)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
m.EthAddress = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field BtcAddress", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthState
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthState
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.BtcAddress = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Aliases", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthState
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthState
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Aliases = append(m.Aliases, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
case 6:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType)
}
@@ -1113,7 +1063,7 @@ func (m *Controller) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 5:
case 7:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field VaultCid", wireType)
}
@@ -1145,11 +1095,11 @@ func (m *Controller) Unmarshal(dAtA []byte) error {
}
m.VaultCid = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 6:
case 8:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Authentication", wireType)
}
var msglen int
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
@@ -1159,27 +1109,25 @@ func (m *Controller) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthState
}
postIndex := iNdEx + msglen
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthState
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Authentication = append(m.Authentication, &Credential{})
if err := m.Authentication[len(m.Authentication)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
m.Authentication = append(m.Authentication, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
case 7:
case 9:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType)
}
@@ -1326,10 +1274,10 @@ func (m *Verification) Unmarshal(dAtA []byte) error {
m.Controller = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Method", wireType)
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field DidMethod", wireType)
}
m.Method = 0
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowState
@@ -1339,11 +1287,24 @@ func (m *Verification) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
m.Method |= DIDNamespace(b&0x7F) << shift
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthState
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthState
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.DidMethod = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Issuer", wireType)
@@ -1446,7 +1407,7 @@ func (m *Verification) Unmarshal(dAtA []byte) error {
iNdEx = postIndex
case 7:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field VerificationType", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
@@ -1474,7 +1435,7 @@ func (m *Verification) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Kind = string(dAtA[iNdEx:postIndex])
m.VerificationType = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
+186 -84
View File
@@ -207,7 +207,7 @@ type MsgAllocateVaultResponse struct {
// ExpiryBlock is the block number at which the vault will expire.
ExpiryBlock int64 `protobuf:"varint,2,opt,name=expiry_block,json=expiryBlock,proto3" json:"expiry_block,omitempty"`
// RegistrationOptions is a json string of the PublicKeyCredentialCreationOptions for WebAuthn
RegistrationOptions string `protobuf:"bytes,3,opt,name=registration_options,json=registrationOptions,proto3" json:"registration_options,omitempty"`
Token string `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"`
// IsLocalhost is a flag to indicate if the vault is localhost
Localhost bool `protobuf:"varint,4,opt,name=localhost,proto3" json:"localhost,omitempty"`
}
@@ -259,9 +259,9 @@ func (m *MsgAllocateVaultResponse) GetExpiryBlock() int64 {
return 0
}
func (m *MsgAllocateVaultResponse) GetRegistrationOptions() string {
func (m *MsgAllocateVaultResponse) GetToken() string {
if m != nil {
return m.RegistrationOptions
return m.Token
}
return ""
}
@@ -417,7 +417,7 @@ type MsgAuthorizeService struct {
// Origin is the origin of the request in wildcard form.
Origin string `protobuf:"bytes,2,opt,name=origin,proto3" json:"origin,omitempty"`
// Permissions is the scope of the service.
Scopes *Permissions `protobuf:"bytes,3,opt,name=scopes,proto3" json:"scopes,omitempty"`
Permissions map[string]string `protobuf:"bytes,3,rep,name=permissions,proto3" json:"permissions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
// token is the macron token to authenticate the operation.
Token string `protobuf:"bytes,4,opt,name=token,proto3" json:"token,omitempty"`
}
@@ -469,9 +469,9 @@ func (m *MsgAuthorizeService) GetOrigin() string {
return ""
}
func (m *MsgAuthorizeService) GetScopes() *Permissions {
func (m *MsgAuthorizeService) GetPermissions() map[string]string {
if m != nil {
return m.Scopes
return m.Permissions
}
return nil
}
@@ -653,6 +653,7 @@ func init() {
proto.RegisterType((*MsgRegisterControllerResponse)(nil), "did.v1.MsgRegisterControllerResponse")
proto.RegisterMapType((map[string]string)(nil), "did.v1.MsgRegisterControllerResponse.AccountsEntry")
proto.RegisterType((*MsgAuthorizeService)(nil), "did.v1.MsgAuthorizeService")
proto.RegisterMapType((map[string]string)(nil), "did.v1.MsgAuthorizeService.PermissionsEntry")
proto.RegisterType((*MsgAuthorizeServiceResponse)(nil), "did.v1.MsgAuthorizeServiceResponse")
proto.RegisterType((*MsgRegisterService)(nil), "did.v1.MsgRegisterService")
proto.RegisterType((*MsgRegisterServiceResponse)(nil), "did.v1.MsgRegisterServiceResponse")
@@ -661,59 +662,58 @@ func init() {
func init() { proto.RegisterFile("did/v1/tx.proto", fileDescriptor_d73284df019ff211) }
var fileDescriptor_d73284df019ff211 = []byte{
// 824 bytes of a gzipped FileDescri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1e, 0x31, 0xb7, 0xcc, 0x4c, 0xcd, 0x5b, 0x97, 0x63, 0x29, 0xa5, 0x79, 0xed, 0xdb, 0x17, 0x4f,
0xef, 0xa2, 0xc1, 0x87, 0xcf, 0xce, 0x5b, 0xe8, 0xf9, 0x79, 0x0b, 0xfd, 0x73, 0xde, 0x42, 0x3f,
0x5d, 0xb4, 0xf6, 0x9e, 0x5f, 0xb4, 0xf6, 0xfe, 0xba, 0x68, 0xed, 0x3d, 0xb1, 0x7c, 0x2a, 0xc7,
0xb3, 0x51, 0xd7, 0x65, 0xd3, 0x1e, 0x0b, 0x05, 0x0b, 0x79, 0x2f, 0xfe, 0x39, 0xeb, 0xa9, 0x6f,
0xb4, 0x5c, 0x44, 0x44, 0x8c, 0xca, 0xf1, 0xa7, 0xf8, 0xde, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff,
0xf9, 0xc0, 0x77, 0x8b, 0x1a, 0x08, 0x00, 0x00,
// 806 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x6f, 0xfb, 0x44,
0x10, 0x8d, 0xe3, 0xfc, 0xf2, 0x6b, 0x26, 0x6d, 0x13, 0x2d, 0x85, 0xba, 0x2e, 0x4d, 0x83, 0x01,
0x29, 0x54, 0x25, 0x51, 0x5b, 0x09, 0x55, 0x05, 0x21, 0x35, 0x08, 0xa9, 0x12, 0x0a, 0x14, 0x17,
0x38, 0xf4, 0x52, 0x39, 0xf6, 0xe2, 0x2c, 0x71, 0xbc, 0xd1, 0xee, 0x26, 0x6a, 0x38, 0xf1, 0xe7,
0x86, 0x38, 0xf0, 0x05, 0xe0, 0xcc, 0xb1, 0x07, 0xbe, 0x01, 0x97, 0x1e, 0x2b, 0x4e, 0x9c, 0x10,
0x6a, 0x0f, 0xfd, 0x1a, 0xc8, 0x5e, 0xdb, 0x71, 0xfe, 0x34, 0x6a, 0xcb, 0x25,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, 0x78, 0xdc, 0xff, 0x5d, 0x05, 0xb5, 0xc5, 0x5d, 0x74, 0x02,
0xcb, 0x13, 0x97, 0xfc, 0x7a, 0x6a, 0xbf, 0x69, 0x40, 0xdf, 0x7e, 0x00, 0x48, 0x4e, 0xff, 0x02,
0xca, 0x33, 0xa6, 0xdc, 0x5c, 0xe0, 0x16, 0xfd, 0xcd, 0x05, 0x60, 0xd2, 0xf5, 0x13, 0x58, 0x99,
0xbc, 0xc9, 0xb5, 0xf4, 0x5b, 0x69, 0x44, 0xaf, 0x3e, 0x84, 0x24, 0xcd, 0xce, 0x01, 0xcd, 0xb9,
0x01, 0xb7, 0x16, 0xfe, 0x9b, 0xf5, 0xb7, 0x1f, 0xf5, 0x67, 0x47, 0x9f, 0x43, 0x69, 0xda, 0x23,
0xfa, 0x9c, 0x37, 0x63, 0xf1, 0xc6, 0xc3, 0x58, 0xdc, 0x52, 0x7f, 0xf1, 0xdd, 0xfd, 0xd5, 0x8e,
0xd2, 0xfc, 0xe0, 0xfa, 0xb6, 0xa2, 0xdc, 0xdc, 0x56, 0x94, 0x7f, 0x6f, 0x2b, 0xca, 0x2f, 0x77,
0x95, 0xcc, 0xcd, 0x5d, 0x25, 0xf3, 0xf7, 0x5d, 0x25, 0x73, 0x6e, 0xb8, 0x44, 0x74, 0x06, 0xed,
0xba, 0x4d, 0x7b, 0x0d, 0xea, 0x73, 0xea, 0xb3, 0x46, 0xf8, 0x73, 0xd9, 0x08, 0x3e, 0xf5, 0x62,
0xd4, 0xc7, 0xbc, 0x9d, 0x0f, 0x3f, 0xe8, 0x07, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x20, 0x91,
0xda, 0xb5, 0x4b, 0x08, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@@ -1100,10 +1100,10 @@ func (m *MsgAllocateVaultResponse) MarshalToSizedBuffer(dAtA []byte) (int, error
i--
dAtA[i] = 0x20
}
if len(m.RegistrationOptions) > 0 {
i -= len(m.RegistrationOptions)
copy(dAtA[i:], m.RegistrationOptions)
i = encodeVarintTx(dAtA, i, uint64(len(m.RegistrationOptions)))
if len(m.Token) > 0 {
i -= len(m.Token)
copy(dAtA[i:], m.Token)
i = encodeVarintTx(dAtA, i, uint64(len(m.Token)))
i--
dAtA[i] = 0x1a
}
@@ -1265,17 +1265,24 @@ func (m *MsgAuthorizeService) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i--
dAtA[i] = 0x22
}
if m.Scopes != nil {
{
size, err := m.Scopes.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintTx(dAtA, i, uint64(size))
if len(m.Permissions) > 0 {
for k := range m.Permissions {
v := m.Permissions[k]
baseI := i
i -= len(v)
copy(dAtA[i:], v)
i = encodeVarintTx(dAtA, i, uint64(len(v)))
i--
dAtA[i] = 0x12
i -= len(k)
copy(dAtA[i:], k)
i = encodeVarintTx(dAtA, i, uint64(len(k)))
i--
dAtA[i] = 0xa
i = encodeVarintTx(dAtA, i, uint64(baseI-i))
i--
dAtA[i] = 0x1a
}
i--
dAtA[i] = 0x1a
}
if len(m.Origin) > 0 {
i -= len(m.Origin)
@@ -1489,7 +1496,7 @@ func (m *MsgAllocateVaultResponse) Size() (n int) {
if m.ExpiryBlock != 0 {
n += 1 + sovTx(uint64(m.ExpiryBlock))
}
l = len(m.RegistrationOptions)
l = len(m.Token)
if l > 0 {
n += 1 + l + sovTx(uint64(l))
}
@@ -1568,9 +1575,13 @@ func (m *MsgAuthorizeService) Size() (n int) {
if l > 0 {
n += 1 + l + sovTx(uint64(l))
}
if m.Scopes != nil {
l = m.Scopes.Size()
n += 1 + l + sovTx(uint64(l))
if len(m.Permissions) > 0 {
for k, v := range m.Permissions {
_ = k
_ = v
mapEntrySize := 1 + len(k) + sovTx(uint64(len(k))) + 1 + len(v) + sovTx(uint64(len(v)))
n += mapEntrySize + 1 + sovTx(uint64(mapEntrySize))
}
}
l = len(m.Token)
if l > 0 {
@@ -2059,7 +2070,7 @@ func (m *MsgAllocateVaultResponse) Unmarshal(dAtA []byte) error {
}
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field RegistrationOptions", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
@@ -2087,7 +2098,7 @@ func (m *MsgAllocateVaultResponse) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.RegistrationOptions = string(dAtA[iNdEx:postIndex])
m.Token = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 4:
if wireType != 0 {
@@ -2632,7 +2643,7 @@ func (m *MsgAuthorizeService) Unmarshal(dAtA []byte) error {
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Scopes", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
@@ -2659,12 +2670,103 @@ func (m *MsgAuthorizeService) Unmarshal(dAtA []byte) error {
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Scopes == nil {
m.Scopes = &Permissions{}
if m.Permissions == nil {
m.Permissions = make(map[string]string)
}
if err := m.Scopes.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
var mapkey string
var mapvalue string
for iNdEx < postIndex {
entryPreIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
if fieldNum == 1 {
var stringLenmapkey uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLenmapkey |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLenmapkey := int(stringLenmapkey)
if intStringLenmapkey < 0 {
return ErrInvalidLengthTx
}
postStringIndexmapkey := iNdEx + intStringLenmapkey
if postStringIndexmapkey < 0 {
return ErrInvalidLengthTx
}
if postStringIndexmapkey > l {
return io.ErrUnexpectedEOF
}
mapkey = string(dAtA[iNdEx:postStringIndexmapkey])
iNdEx = postStringIndexmapkey
} else if fieldNum == 2 {
var stringLenmapvalue uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLenmapvalue |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLenmapvalue := int(stringLenmapvalue)
if intStringLenmapvalue < 0 {
return ErrInvalidLengthTx
}
postStringIndexmapvalue := iNdEx + intStringLenmapvalue
if postStringIndexmapvalue < 0 {
return ErrInvalidLengthTx
}
if postStringIndexmapvalue > l {
return io.ErrUnexpectedEOF
}
mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue])
iNdEx = postStringIndexmapvalue
} else {
iNdEx = entryPreIndex
skippy, err := skipTx(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTx
}
if (iNdEx + skippy) > postIndex {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
m.Permissions[mapkey] = mapvalue
iNdEx = postIndex
case 4:
if wireType != 2 {