mpc

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDecodeAttestedCredentialData = Error{/* contains filtered or unexported fields */}
	ErrDecodeAuthenticatorData      = Error{/* contains filtered or unexported fields */}
	ErrDecodeCOSEKey                = Error{/* contains filtered or unexported fields */}
	ErrECDAANotSupported            = Error{/* contains filtered or unexported fields */}
	ErrEncodeAttestedCredentialData = Error{/* contains filtered or unexported fields */}
	ErrEncodeAuthenticatorData      = Error{/* contains filtered or unexported fields */}
	ErrGenerateChallenge            = Error{/* contains filtered or unexported fields */}
	ErrMarshalAttestationObject     = Error{/* contains filtered or unexported fields */}
	ErrOption                       = Error{/* contains filtered or unexported fields */}
	ErrNotImplemented               = Error{/* contains filtered or unexported fields */}
	ErrUnmarshalAttestationObject   = Error{/* contains filtered or unexported fields */}
	ErrVerifyAttestation            = Error{/* contains filtered or unexported fields */}
	ErrVerifyAuthentication         = Error{/* contains filtered or unexported fields */}
	ErrVerifyClientExtensionOutput  = Error{/* contains filtered or unexported fields */}
	ErrVerifyRegistration           = Error{/* contains filtered or unexported fields */}
	ErrVerifySignature              = Error{/* contains filtered or unexported fields */}
)

Categorical top-level errors

Functions

func AesDecryptWithKey

func AesDecryptWithKey(aesKey, ciphertext []byte) ([]byte, error)

AesDecryptWithKey uses the give 32-bit key to decrypt plaintext.

func AesDecryptWithPassword

func AesDecryptWithPassword(password string, ciphertext []byte) ([]byte, error)

AesDecryptWithPassword uses the give password to generate an aes key and encrypt plaintext.

func AesEncryptWithKey

func AesEncryptWithKey(aesKey, plaintext []byte) ([]byte, error)

AesEncryptWithKey uses the give 32-bit key to encrypt plaintext.

func AesEncryptWithPassword

func AesEncryptWithPassword(password string, plaintext []byte) ([]byte, error)

AesEncryptWithPassword uses the give password to generate an aes key and decrypt plaintext.

func DecodePublicKey

func DecodePublicKey(coseKey *COSEKey) (crypto.PublicKey, error)

DecodePublicKey parses a crypto.PublicKey from a COSEKey

func NewAesKey

func NewAesKey() ([]byte, error)

NewAesKey generates a new 32-bit key.

func SerializeSignature

func SerializeSignature(sig *ecdsa.Signature) ([]byte, error)

SerializeSignature marshals an ECDSA signature to DER format for use with the CMP protocol

func SignatureFromBytes

func SignatureFromBytes(sigStr []byte) (*ecdsa.Signature, error)

- The R and S values must be in the valid range for secp256k1 scalars:

  • Negative values are rejected
  • Zero is rejected
  • Values greater than or equal to the secp256k1 group order are rejected

func VerifySignature

func VerifySignature(rawKey cbor.RawMessage, message, sig []byte) error

VerifySignature verifies a signature using a provided COSEKey, message, and signature

Types

type COSEAlgorithmIdentifier

type COSEAlgorithmIdentifier int

COSEAlgorithmIdentifier is a number identifying a cryptographic algorithm

const (
	AlgorithmRS1   COSEAlgorithmIdentifier = -65535
	AlgorithmRS512 COSEAlgorithmIdentifier = -259
	AlgorithmRS384 COSEAlgorithmIdentifier = -258
	AlgorithmRS256 COSEAlgorithmIdentifier = -257
	AlgorithmPS512 COSEAlgorithmIdentifier = -39
	AlgorithmPS384 COSEAlgorithmIdentifier = -38
	AlgorithmPS256 COSEAlgorithmIdentifier = -37
	AlgorithmES512 COSEAlgorithmIdentifier = -36
	AlgorithmES384 COSEAlgorithmIdentifier = -35
	AlgorithmEdDSA COSEAlgorithmIdentifier = -8
	AlgorithmES256 COSEAlgorithmIdentifier = -7
)

enum values for COSEAlgorithmIdentifier type

type COSEEllipticCurve

type COSEEllipticCurve int

COSEEllipticCurve is a number identifying an elliptic curve

const (
	CurveP256 COSEEllipticCurve = 1
	CurveP384 COSEEllipticCurve = 2
	CurveP521 COSEEllipticCurve = 3
)

enum values for COSEEllipticCurve type

type COSEKey

type COSEKey struct {
	Kty       int             `cbor:"1,keyasint,omitempty"`
	Kid       []byte          `cbor:"2,keyasint,omitempty"`
	Alg       int             `cbor:"3,keyasint,omitempty"`
	KeyOpts   int             `cbor:"4,keyasint,omitempty"`
	IV        []byte          `cbor:"5,keyasint,omitempty"`
	CrvOrNOrK cbor.RawMessage `cbor:"-1,keyasint,omitempty"` // K for symmetric keys, Crv for elliptic curve keys, N for RSA modulus
	XOrE      cbor.RawMessage `cbor:"-2,keyasint,omitempty"` // X for curve x-coordinate, E for RSA public exponent
	Y         cbor.RawMessage `cbor:"-3,keyasint,omitempty"` // Y for curve y-cooridate
	D         []byte          `cbor:"-4,keyasint,omitempty"`
}

COSEKey represents a key decoded from COSE format.

type COSEKeyType

type COSEKeyType int

COSEKeyType is a number identifying a key type

const (
	KeyTypeOKP COSEKeyType = 1
	KeyTypeEC2 COSEKeyType = 2
	KeyTypeRSA COSEKeyType = 3
)

enum values for COSEKeyType type

type Error

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

Error represents an error in a WebAuthn relying party operation

func NewError

func NewError(fmStr string, els ...interface{}) Error

NewError returns a new Error with a custom message

func (Error) Error

func (e Error) Error() string

Error implements the error interface

func (Error) Is

func (e Error) Is(target error) bool

Is establishes equality for error types

func (Error) Unwrap

func (e Error) Unwrap() error

Unwrap allows for error unwrapping

func (Error) Wrap

func (e Error) Wrap(err error) Error

Wrap returns a new error which contains the provided error wrapped with this error

type Network

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

Network simulates a point-to-point network between different parties using Go channels. The same network is used by all processes, and can be reused for different protocols. When used with test.Handler, no interaction from the user is required beyond creating the network.

func NewNetwork

func NewNetwork(parties party.IDSlice) *Network

func (*Network) Done

func (n *Network) Done(id party.ID) chan struct{}

func (*Network) Next

func (n *Network) Next(id party.ID) <-chan *protocol.Message

func (*Network) Quit

func (n *Network) Quit(id party.ID)

func (*Network) Send

func (n *Network) Send(msg *protocol.Message)

type Wallet

type Wallet struct {
	ID party.ID

	PubKey      []byte
	Configs     map[party.ID]*cmp.Config
	ConfigsLock sync.Mutex
	Network     *Network
	Threshold   int
	// contains filtered or unexported fields
}

func GenerateWallet

func GenerateWallet(cb common.MotorCallback, options ...WalletOption) (*Wallet, error)

GenerateWallet a new ECDSA private key shared among all the given participants.

func (*Wallet) Address

func (w *Wallet) Address(id ...party.ID) (string, error)

Returns the Bech32 representation of the given party.

func (*Wallet) Config

func (w *Wallet) Config() *cmp.Config

Config returns the configuration of this wallet.

func (*Wallet) CreateInitialShards

func (w *Wallet) CreateInitialShards() (dscShard, pskShard, recShard []byte, unused [][]byte, err error)

func (*Wallet) GetSigners

func (w *Wallet) GetSigners() party.IDSlice

GetSigners returns the list of signers for the given message.

func (*Wallet) Marshal

func (w *Wallet) Marshal() ([]byte, error)

Marshal returns the JSON representation of the entire wallet.

func (*Wallet) PublicKey

func (w *Wallet) PublicKey() ([]byte, error)

Returns the ECDSA public key of the given party.

func (*Wallet) PublicKeyBase58

func (w *Wallet) PublicKeyBase58() (string, error)

Returns the ECDSA public key of the given party.

func (*Wallet) PublicKeyProto

func (w *Wallet) PublicKeyProto() (*secp256k1.PubKey, error)

func (*Wallet) Refresh

func (w *Wallet) Refresh(pl *pool.Pool) (*cmp.Config, error)

Refreshes all shares of an existing ECDSA private key.

func (*Wallet) Sign

func (w *Wallet) Sign(m []byte) (*ecdsa.Signature, error)

Generates an ECDSA signature for messageHash.

func (*Wallet) Unmarshal

func (w *Wallet) Unmarshal(buf []byte) error

Unmarshal unmarshals the given JSON into the wallet.

func (*Wallet) Verify

func (w *Wallet) Verify(m []byte, sig []byte) bool

Verifies an ECDSA signature for messageHash.

type WalletOption

type WalletOption func(*walletConfig)

WalletOption is a function that applies a configuration option to a walletConfig

func WithBase58PubKey added in v0.6.0

func WithBase58PubKey(key string) WalletOption

func WithConfigs

func WithConfigs(cnfs map[party.ID]*cmp.Config) WalletOption

WithConfigs sets the configs used for the MPC wallet

func WithParticipants

func WithParticipants(participants ...party.ID) WalletOption

WithParticipants adds a list of participants to the wallet

func WithThreshold

func WithThreshold(threshold int) WalletOption

WithThreshold sets the threshold of the MPC wallet

Jump to

Keyboard shortcuts

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