Documentation ¶
Overview ¶
Package ecid is a generated protocol buffer package.
It is generated from these files:
libri/common/ecid/storage.proto
It has these top-level messages:
ECDSAPrivateKey
Index ¶
- Constants
- Variables
- func FromPublicKeyBytes(buf []byte) (*ecdsa.PublicKey, error)
- func ToPublicKeyBytes(pub *ecdsa.PublicKey) []byte
- type ECDSAPrivateKey
- func (*ECDSAPrivateKey) Descriptor() ([]byte, []int)
- func (m *ECDSAPrivateKey) GetCurve() string
- func (m *ECDSAPrivateKey) GetD() []byte
- func (m *ECDSAPrivateKey) GetX() []byte
- func (m *ECDSAPrivateKey) GetY() []byte
- func (*ECDSAPrivateKey) ProtoMessage()
- func (m *ECDSAPrivateKey) Reset()
- func (m *ECDSAPrivateKey) String() string
- type ID
Constants ¶
const CurveName = "secp256k1"
CurveName gives the name of the elliptic curve used for the private key.
Variables ¶
var ( // ErrKeyPointOffCurve indicates when a public key does not lay on the expected elliptic // curve. ErrKeyPointOffCurve = errors.New("key point is off the expected curve") // ErrPrivKeyUnexpectedCurve indicates when a private key has an unexpected elliptic curve. ErrPrivKeyUnexpectedCurve = errors.New("private key has wrong curve") )
var Curve = secp256k1.S256()
Curve defines the elliptic curve public & private keys use. Curve S256 implies 32-byte private and 33-byte (compressed) public keys. The X value of the public key point is 32 bytes.
Functions ¶
func FromPublicKeyBytes ¶
FromPublicKeyBytes creates a new ecdsa.PublicKey from the marshaled compressed byte representation.
func ToPublicKeyBytes ¶
ToPublicKeyBytes marshals the public key of the ID to the compressed byte representation.
Types ¶
type ECDSAPrivateKey ¶
type ECDSAPrivateKey struct { // name of the curve used Curve string `protobuf:"bytes,1,opt,name=curve" json:"curve,omitempty"` // private key D []byte `protobuf:"bytes,2,opt,name=D,proto3" json:"D,omitempty"` // x-value of public key X []byte `protobuf:"bytes,3,opt,name=X,proto3" json:"X,omitempty"` // y-value of public key Y []byte `protobuf:"bytes,4,opt,name=Y,proto3" json:"Y,omitempty"` }
ECDSAPrivateKey represents an ECDSA key-pair, whose public key x-value is used as the peer ID to outside world.
func ToStored ¶
func ToStored(ecid ID) *ECDSAPrivateKey
ToStored creates a new ECID instance from an ID instance.
func (*ECDSAPrivateKey) Descriptor ¶
func (*ECDSAPrivateKey) Descriptor() ([]byte, []int)
func (*ECDSAPrivateKey) GetCurve ¶
func (m *ECDSAPrivateKey) GetCurve() string
func (*ECDSAPrivateKey) GetD ¶
func (m *ECDSAPrivateKey) GetD() []byte
func (*ECDSAPrivateKey) GetX ¶
func (m *ECDSAPrivateKey) GetX() []byte
func (*ECDSAPrivateKey) GetY ¶
func (m *ECDSAPrivateKey) GetY() []byte
func (*ECDSAPrivateKey) ProtoMessage ¶
func (*ECDSAPrivateKey) ProtoMessage()
func (*ECDSAPrivateKey) Reset ¶
func (m *ECDSAPrivateKey) Reset()
func (*ECDSAPrivateKey) String ¶
func (m *ECDSAPrivateKey) String() string
type ID ¶
type ID interface { fmt.Stringer // Bytes returns the byte representation Bytes() []byte // Int returns the big.Int representation Int() *big.Int // Cmp compares the ID to another Cmp(ID) int // Distance computes the XOR distance between two IDs Distance(ID) *big.Int // Key returns the ECDSA private key (which includes public key as well) Key() *ecdsa.PrivateKey // ID returns the underlying ID object ID() id.ID // PublicKeyBytes returns a byte slice of the encoded public key PublicKeyBytes() []byte // Save writes the ID's private key hex representation to the given filepath. Save(filepath string) error }
ID is an elliptic curve identifier, where the ID is the x-value of the (x, y) public key point on the curve. When coupled with the private key, this allows something (e.g., a libri peer) to sign messages that a receiver can verify.
func FromPrivateKey ¶
func FromPrivateKey(priv *ecdsa.PrivateKey) (ID, error)
FromPrivateKey creates a new ID from an ECDSA private key.
func FromPrivateKeyFile ¶ added in v0.3.0
FromPrivateKeyFile creates a new ID from plaintext file containing the private key.
func FromStored ¶
func FromStored(stored *ECDSAPrivateKey) (ID, error)
FromStored creates a new ID instance from a ECID instance.
func NewPseudoRandom ¶
NewPseudoRandom creates a new ID instance using a math.Rand source of entropy.