2024-11-18 19:04:10 -05:00
|
|
|
package controller
|
2024-09-25 19:45:28 -04:00
|
|
|
|
|
|
|
import (
|
2024-11-23 01:28:58 -05:00
|
|
|
"github.com/onsonr/sonr/pkg/crypto/mpc"
|
2024-09-25 19:45:28 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type ControllerI interface {
|
|
|
|
ChainID() string
|
2024-11-23 01:28:58 -05:00
|
|
|
// GetPubKey() *commonv1.PubKey
|
2024-09-25 19:45:28 -04:00
|
|
|
SonrAddress() string
|
2024-10-18 14:09:16 -04:00
|
|
|
RawPublicKey() []byte
|
2024-09-25 19:45:28 -04:00
|
|
|
}
|
|
|
|
|
2024-11-23 01:28:58 -05:00
|
|
|
func New(src mpc.KeyshareSource) (ControllerI, error) {
|
2024-09-25 19:45:28 -04:00
|
|
|
return &controller{
|
2024-11-23 01:28:58 -05:00
|
|
|
src: src,
|
|
|
|
address: src.Address(),
|
|
|
|
publicKey: src.PublicKey(),
|
|
|
|
did: src.Issuer(),
|
|
|
|
chainID: "sonr-testnet-1",
|
2024-09-25 19:45:28 -04:00
|
|
|
}, nil
|
|
|
|
}
|
2024-09-25 20:11:30 -04:00
|
|
|
|
|
|
|
type controller struct {
|
2024-11-23 01:28:58 -05:00
|
|
|
src mpc.KeyshareSource
|
2024-09-25 20:11:30 -04:00
|
|
|
address string
|
|
|
|
chainID string
|
|
|
|
publicKey []byte
|
2024-10-15 14:31:19 -04:00
|
|
|
did string
|
2024-09-25 20:11:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *controller) ChainID() string {
|
|
|
|
return c.chainID
|
|
|
|
}
|
|
|
|
|
2024-11-23 01:28:58 -05:00
|
|
|
//
|
|
|
|
// func (c *controller) GetPubKey() *commonv1.PubKey {
|
|
|
|
// return &commonv1.PubKey{
|
|
|
|
// KeyType: "ecdsa",
|
|
|
|
// RawKey: &commonv1.RawKey{
|
|
|
|
// Algorithm: "secp256k1",
|
|
|
|
// Key: c.publicKey,
|
|
|
|
// },
|
|
|
|
// Role: "authentication",
|
|
|
|
// }
|
|
|
|
// }
|
2024-09-27 20:58:05 -04:00
|
|
|
|
2024-10-18 13:45:57 -04:00
|
|
|
func (c *controller) RawPublicKey() []byte {
|
2024-09-25 20:11:30 -04:00
|
|
|
return c.publicKey
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *controller) SonrAddress() string {
|
|
|
|
return c.address
|
|
|
|
}
|