mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
- **feat: add documentation and GitHub Actions workflow for publishing documentation** - **docs(concepts): add documentation for chain modules** - **refactor: Simplify session management with SQLite storage and remove deprecated code** - **refactor: Simplify database initialization and remove DatabaseContext** - **refactor: move connection handling logic to resolver package** - **feat: implement session management with database persistence** - **feat: Ensure config directory exists when creating database path** - **feat: Add SetUserHandle function to set user handle in session** - **feat: Add public methods to set session fields with database save** - **refactor: Remove unused session setter functions** - **feat: Add getter methods for all Session Model properties** - **feat: enhance Session model with user name details** - **feat: add Motr support and update UI elements** - **<no value>** - **feat: Add unique handle constraint and method to check handle existence** - **docs: update site URL to onsonr.dev** - **fix: correct import statement for database package** - **test: updated CI to run tests on pull requests and merge groups** - **docs: remove reference to develop branch in workflow** - **feat: add WebAuthn support for user registration** - **fix: correct smart account attenuation preset name** - **feat: add ComputeIssuerDID and ComputeSonrAddr functions to ucan package** - **test: add unit tests for MPC keyset and keyshare** - **feat: introduce new script to streamline GitHub issue creation**
72 lines
1.9 KiB
Go
72 lines
1.9 KiB
Go
package mpc
|
|
|
|
import (
|
|
"crypto/ecdsa"
|
|
|
|
"github.com/onsonr/sonr/crypto/core/protocol"
|
|
"github.com/onsonr/sonr/crypto/tecdsa/dklsv1/dkg"
|
|
)
|
|
|
|
// BaseKeyshare contains common fields and methods for both validator and user keyshares
|
|
type BaseKeyshare struct {
|
|
Message *protocol.Message `json:"message"`
|
|
Role int `json:"role"`
|
|
UncompressedPubKey []byte `json:"public_key"`
|
|
CompressedPubKey []byte `json:"compressed_public_key"`
|
|
}
|
|
|
|
func initFromAlice(aliceOut *dkg.AliceOutput, originalMsg *protocol.Message) BaseKeyshare {
|
|
return BaseKeyshare{
|
|
Message: originalMsg,
|
|
Role: 1,
|
|
UncompressedPubKey: aliceOut.PublicKey.ToAffineUncompressed(),
|
|
CompressedPubKey: aliceOut.PublicKey.ToAffineCompressed(),
|
|
}
|
|
}
|
|
|
|
func initFromBob(bobOut *dkg.BobOutput, originalMsg *protocol.Message) BaseKeyshare {
|
|
return BaseKeyshare{
|
|
Message: originalMsg,
|
|
Role: 2,
|
|
UncompressedPubKey: bobOut.PublicKey.ToAffineUncompressed(),
|
|
CompressedPubKey: bobOut.PublicKey.ToAffineCompressed(),
|
|
}
|
|
}
|
|
|
|
func (b *BaseKeyshare) GetPayloads() map[string][]byte {
|
|
return b.Message.Payloads
|
|
}
|
|
|
|
func (b *BaseKeyshare) GetMetadata() map[string]string {
|
|
return b.Message.Metadata
|
|
}
|
|
|
|
func (b *BaseKeyshare) GetPublicKey() []byte {
|
|
return b.UncompressedPubKey
|
|
}
|
|
|
|
func (b *BaseKeyshare) GetProtocol() string {
|
|
return b.Message.Protocol
|
|
}
|
|
|
|
func (b *BaseKeyshare) GetRole() int32 {
|
|
return int32(b.Role)
|
|
}
|
|
|
|
func (b *BaseKeyshare) GetVersion() uint32 {
|
|
return uint32(b.Message.Version)
|
|
}
|
|
|
|
func (b *BaseKeyshare) ECDSAPublicKey() (*ecdsa.PublicKey, error) {
|
|
return ComputeEcdsaPublicKey(b.UncompressedPubKey)
|
|
}
|
|
|
|
func (b *BaseKeyshare) ExtractMessage() *protocol.Message {
|
|
return &protocol.Message{
|
|
Payloads: b.GetPayloads(),
|
|
Metadata: b.GetMetadata(),
|
|
Protocol: b.GetProtocol(),
|
|
Version: uint(b.GetVersion()),
|
|
}
|
|
}
|