sonr/crypto/dkg/frost/participant.go
Prad Nukala 807b2e86ec
feature/1220 origin handle exists method (#1241)
* feat: add docs and CI workflow for publishing to onsonr.dev

* (refactor): Move hway,motr executables to their own repos

* feat: simplify devnet and testnet configurations

* refactor: update import path for didcrypto package

* docs(networks): Add README with project overview, architecture, and community links

* refactor: Move network configurations to deploy directory

* build: update golang version to 1.23

* refactor: move logger interface to appropriate package

* refactor: Move devnet configuration to networks/devnet

* chore: improve release process with date variable

* (chore): Move Crypto Library

* refactor: improve code structure and readability in DID module

* feat: integrate Trunk CI checks

* ci: optimize CI workflow by removing redundant build jobs

---------

Co-authored-by: Darp Alakun <i@prad.nu>
2025-01-06 17:06:10 +00:00

66 lines
1.8 KiB
Go
Executable File

//
// Copyright Coinbase, Inc. All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
// Package frost is an implementation of the DKG part of https://eprint.iacr.org/2020/852.pdf
package frost
import (
"strconv"
"github.com/onsonr/sonr/crypto/core/curves"
"github.com/onsonr/sonr/crypto/internal"
"github.com/onsonr/sonr/crypto/sharing"
)
type DkgParticipant struct {
round int
Curve *curves.Curve
otherParticipantShares map[uint32]*dkgParticipantData
Id uint32
SkShare curves.Scalar
VerificationKey curves.Point
VkShare curves.Point
feldman *sharing.Feldman
verifiers *sharing.FeldmanVerifier
secretShares []*sharing.ShamirShare
ctx byte
}
type dkgParticipantData struct {
Id uint32
Share *sharing.ShamirShare
Verifiers *sharing.FeldmanVerifier
}
func NewDkgParticipant(id, threshold uint32, ctx string, curve *curves.Curve, otherParticipants ...uint32) (*DkgParticipant, error) {
if curve == nil || len(otherParticipants) == 0 {
return nil, internal.ErrNilArguments
}
limit := uint32(len(otherParticipants)) + 1
feldman, err := sharing.NewFeldman(threshold, limit, curve)
if err != nil {
return nil, err
}
otherParticipantShares := make(map[uint32]*dkgParticipantData, len(otherParticipants))
for _, id := range otherParticipants {
otherParticipantShares[id] = &dkgParticipantData{
Id: id,
}
}
// SetBigInt the common fixed string
ctxV, _ := strconv.Atoi(ctx)
return &DkgParticipant{
Id: id,
round: 1,
Curve: curve,
feldman: feldman,
otherParticipantShares: otherParticipantShares,
ctx: byte(ctxV),
}, nil
}